ovh

package module
v0.0.0-...-9bb71bf Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2017 License: Apache-2.0 Imports: 27 Imported by: 0

README

GoDoc Go Report Card

go-ovh

Golang client for OVH

Motivation

The official OVH API GO client only handles credential creation and requests signing. This project generates idimatic GO client for OVH apis using go-swagger generator.

Acknowledgement

Documentation

Overview

Package ovh provides a HTTP wrapper for the OVH API.

Index

Constants

View Source
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

View Source
const DefaultTimeout = 180 * time.Second

DefaultTimeout api requests after 180s

Variables

View Source
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

View Source
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

View Source
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.

func (*APIError) Error

func (err *APIError) Error() string

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

func (ck *CkRequest) AddRecursiveRules(methods []string, path string)

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) AddRule

func (ck *CkRequest) AddRule(method, path string)

AddRule adds a new rule to the ckRequest

func (*CkRequest) AddRules

func (ck *CkRequest) AddRules(methods []string, path string)

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 NewClient

func NewClient(endpoint, appKey, appSecret, consumerKey string) (*Client, error)

NewClient represents a new client to call the API

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient will load all it's parameter from environment or configuration files

func NewEndpointClient

func NewEndpointClient(endpoint string) (*Client, error)

NewEndpointClient will create an API client for specified endpoint and load all credentials from environment or configuration files

func (*Client) AuthenticateRequest

func (c *Client) AuthenticateRequest(req runtime.ClientRequest, reg strfmt.Registry) error

AuthenticateRequest adds authentication data to the request

func (*Client) Cloud

func (c *Client) Cloud() *cloud_ops.Client

func (*Client) Domain

func (c *Client) Domain() *domain_ops.Client

func (*Client) IP

func (c *Client) IP() *ip_ops.Client

func (*Client) IPLoadbalancing

func (c *Client) IPLoadbalancing() *iploadbalancing_ops.Client

func (*Client) Me

func (c *Client) Me() *me_ops.Client

func (*Client) NewCkRequest

func (c *Client) NewCkRequest() *CkRequest

NewCkRequest helps create a new ck request

func (*Client) NewCkRequestWithRedirection

func (c *Client) NewCkRequestWithRedirection(redirection string) *CkRequest

NewCkRequestWithRedirection helps create a new ck request with a redirect URL

func (*Client) Ping

func (c *Client) Ping() error

Ping performs a ping to OVH API. In fact, ping is just a /auth/time call, in order to check if API is up.

func (*Client) Time

func (c *Client) Time() (*time.Time, error)

Time returns time from the OVH API, by asking GET /auth/time.

func (*Client) TimeDelta

func (c *Client) TimeDelta() (time.Duration, error)

TimeDelta represents the delay between the machine that runs the code and the OVH API. The delay shouldn't change, let's do it only once.

func (*Client) VIP

func (c *Client) VIP() *vip_ops.Client

func (*Client) VPS

func (c *Client) VPS() *vps_ops.Client

func (*Client) VRack

func (c *Client) VRack() *vrack_ops.Client

Jump to

Keyboard shortcuts

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