Documentation
¶
Overview ¶
Package ovh provides a HTTP wrapper for the OVH API.
Index ¶
- Constants
- Variables
- type APIError
- type AccessRule
- type CkRequest
- type CkValidationState
- type Client
- func (c *Client) AuthenticateRequest(req runtime.ClientRequest, reg strfmt.Registry) error
- func (c *Client) Cloud() *cloud_ops.Client
- func (c *Client) Domain() *domain_ops.Client
- func (c *Client) IP() *ip_ops.Client
- func (c *Client) IPLoadbalancing() *iploadbalancing_ops.Client
- func (c *Client) Me() *me_ops.Client
- func (c *Client) NewCkRequest() *CkRequest
- func (c *Client) NewCkRequestWithRedirection(redirection string) *CkRequest
- func (c *Client) Ping() error
- func (c *Client) Time() (*time.Time, error)
- func (c *Client) TimeDelta() (time.Duration, error)
- func (c *Client) VIP() *vip_ops.Client
- func (c *Client) VPS() *vps_ops.Client
- func (c *Client) VRack() *vrack_ops.Client
Constants ¶
const ( OvhEU = "https://eu.api.ovh.com/1.0" OvhCA = "https://ca.api.ovh.com/1.0" KimsufiEU = "https://eu.api.kimsufi.com/1.0" KimsufiCA = "https://ca.api.kimsufi.com/1.0" SoyoustartEU = "https://eu.api.soyoustart.com/1.0" SoyoustartCA = "https://ca.api.soyoustart.com/1.0" RunaboveCA = "https://api.runabove.com/1.0" )
Endpoints
const DefaultTimeout = 180 * time.Second
DefaultTimeout api requests after 180s
Variables ¶
var ( ReadOnly = []string{"GET"} ReadWrite = []string{"GET", "POST", "PUT", "DELETE"} ReadWriteSafe = []string{"GET", "POST", "PUT"} )
Map user friendly access level names to corresponding HTTP verbs
var Endpoints = map[string]string{ "ovh-eu": OvhEU, "ovh-ca": OvhCA, "kimsufi-eu": KimsufiEU, "kimsufi-ca": KimsufiCA, "soyoustart-eu": SoyoustartEU, "soyoustart-ca": SoyoustartCA, "runabove-ca": RunaboveCA, }
Endpoints conveniently maps endpoints names to their URI for external configuration
var (
ErrAPIDown = errors.New("go-vh: the OVH API is down, it does't respond to /time anymore")
)
Errors
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { // Error message. Message string // HTTP code. Code int // ID of the request QueryID string }
APIError represents an error that can occurred while calling the API.
type AccessRule ¶
type AccessRule struct { // Allowed HTTP Method for the requested AccessRule. // Can be set to GET/POST/PUT/DELETE. Method string `json:"method"` // Allowed path. // Can be an exact string or a string with '*' char. // Example : // /me : only /me is authorized // /* : all calls are authorized Path string `json:"path"` }
AccessRule represents a method allowed for a path
type CkRequest ¶
type CkRequest struct { AccessRules []AccessRule `json:"accessRules"` Redirection string `json:"redirection,omitempty"` // contains filtered or unexported fields }
CkRequest represents the parameters to fill in order to ask a new consumerKey.
func (*CkRequest) AddRecursiveRules ¶
AddRecursiveRules adds grant requests on "path" and "path/*", for all methods "ReadOnly", "ReadWrite" and "ReadWriteSafe" should be used for "methods" unless specific access are required.
func (*CkRequest) AddRules ¶
AddRules adds grant requests on "path" for all methods. "ReadOnly", "ReadWrite" and "ReadWriteSafe" should be used for "methods" unless specific access are required.
func (*CkRequest) Do ¶
func (ck *CkRequest) Do() (*CkValidationState, error)
Do executes the request. On success, set the consumer key in the client and return the URL the user needs to visit to validate the key
type CkValidationState ¶
type CkValidationState struct { // Consumer key, which need to be validated by customer. ConsumerKey string `json:"consumerKey"` // Current status, should be always "pendingValidation". State string `json:"state"` // URL to redirect user in order to log in. ValidationURL string `json:"validationUrl"` }
CkValidationState represents the response when asking a new consumerKey.
func (*CkValidationState) String ¶
func (ck *CkValidationState) String() string
type Client ¶
type Client struct { // Self generated tokens. Create one by visiting // https://eu.api.ovh.com/createApp/ // AppKey holds the Application key AppKey string // AppSecret holds the Application secret key AppSecret string // ConsumerKey holds the user/app specific token. It must have been validated before use. ConsumerKey string // Client is the underlying HTTP client used to run the requests. It may be overloaded but a default one is instanciated in “NewClient“ by default. Client *http.Client Timeout time.Duration Transport *httptransport.Runtime // contains filtered or unexported fields }
Client represents a client to call the OVH API
func NewDefaultClient ¶
NewDefaultClient will load all it's parameter from environment or configuration files
func NewEndpointClient ¶
NewEndpointClient will create an API client for specified endpoint and load all credentials from environment or configuration files
func (*Client) AuthenticateRequest ¶
AuthenticateRequest adds authentication data to the request
func (*Client) Domain ¶
func (c *Client) Domain() *domain_ops.Client
func (*Client) IPLoadbalancing ¶
func (c *Client) IPLoadbalancing() *iploadbalancing_ops.Client
func (*Client) NewCkRequest ¶
NewCkRequest helps create a new ck request
func (*Client) NewCkRequestWithRedirection ¶
NewCkRequestWithRedirection helps create a new ck request with a redirect URL
func (*Client) Ping ¶
Ping performs a ping to OVH API. In fact, ping is just a /auth/time call, in order to check if API is up.