govh

package module
v0.0.0-...-c219fb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2017 License: MIT Imports: 8 Imported by: 1

README

GOVH

A Go package to consume OVH API.

OVH CLI have moved here : OVH-CLI

Documentation

Index

Constants

View Source
const (
	//API_HOST        = "api.ovh.com"
	API_ENDPOINT_EU     = "https://api.ovh.com"
	API_ENDPOINT_CA     = "https://ca.api.ovh.com"
	API_ENDPOINT_SYS_EU = "https://eu.api.soyoustart.com"
	API_ENDPOINT_SYS_CA = "https://ca.api.soyoustart.com"
	API_VERSION         = "1.0"
)

Variables

View Source
var (
	ErrInvalidkey        = errors.New("INVALID_KEY")
	ErrInvalidCredential = errors.New("INVALID_CREDENTIAL")
)

Functions

func AuthGetConsumerKey

func AuthGetConsumerKey(ak, region string) (ck string, link string, err error)

AuthGetConsumerKey returns the consumer key

func RegionEndpoint

func RegionEndpoint(region string) string

Types

type APIResponse

type APIResponse struct {
	StatusCode int
	Status     string
	Body       []byte
}

APIResponse represents a response from OVH API

func (*APIResponse) HandleErr

func (r *APIResponse) HandleErr(err error, expectedHTTPCode []int) error

HandleErr return error on unexpected HTTP code

type DateTime

type DateTime struct {
	time.Time
}

Datetimes DateTime represents date as returned by OVH

func (DateTime) MarshalJSON

func (dt DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(data []byte) error

type DateTime2

type DateTime2 struct {
	time.Time
}

DateTime2 represents an other date as returned by OVH don't ask me why but OVH use differents TZ for datetime...

func (DateTime2) MarshalJSON

func (dt DateTime2) MarshalJSON() ([]byte, error)

func (*DateTime2) UnmarshalJSON

func (dt *DateTime2) UnmarshalJSON(data []byte) error

type OVHClient

type OVHClient struct {
	*http.Client
	// contains filtered or unexported fields
}

OVHClient API client

func New

func New(ak string, as string, ck string, region string) (c *OVHClient)

New returns an OVH API Client

func (*OVHClient) DELETE

func (c *OVHClient) DELETE(ressource string, expectedHTTPCode ...int) (response APIResponse, err error)

DELETE do a GET query

func (*OVHClient) GET

func (c *OVHClient) GET(ressource string, expectedHTTPCode ...int) (response APIResponse, err error)

GET do a GET query

func (*OVHClient) POST

func (c *OVHClient) POST(ressource, payload string, expectedHTTPCode ...int) (APIresponse APIResponse, err error)

POST do a POST query

func (*OVHClient) PUT

func (c *OVHClient) PUT(ressource, payload string, expectedHTTPCode ...int) (response APIResponse, err error)

PUT do a PUT query

func (*OVHClient) Query

func (c *OVHClient) Query(method string, ressource string, payload string, expectedHTTPCode []int) (response APIResponse, err error)

Query process the request & return a response (or error)

Directories

Path Synopsis
dedicated

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL