Documentation ¶
Overview ¶
Package selvpcclient provides a library to work with the Selectel VPC API.
Authentication ¶
To work with the Selectel VPC API you first need to:
- create a Selectel account: https://my.selectel.ru/registration
- obtain an API token: http://my.selectel.ru/profile/apikeys
You can then provide the API token to the selvpc service client.
Service clients ¶
Service client is a special struct that implements a client for different part of the Selectel VPC API. You need to initialize the needed service client prior to do any requests:
token := "token_string" resellClient := resell.NewV2ResellClient(token)
All methods of service clients uses the Go context to provide end-user of the library with a native way to work with the cancellation signals
Index ¶
Constants ¶
const ( // AppVersion is a version of the application. AppVersion = "2.0.0" // AppName is a global application name. AppName = "go-selvpcclient" // DefaultEndpoint contains basic endpoint for queries. DefaultEndpoint = "https://api.selectel.ru/vpc" DefaultOpenstackIdentityEndpoint = "https://api.selvpc.ru/identity/v3/" // DefaultUserAgent contains basic user agent that will be used in queries. DefaultUserAgent = AppName + "/" + AppVersion )
const RFC3339NoZ = "2006-01-02T15:04:05"
RFC3339NoZ describes a timestamp format used by some SelVPC responses.
Variables ¶
This section is empty.
Functions ¶
func BuildQueryParameters ¶
BuildQueryParameters converts provided options struct to the string of URL parameters.
func NewHTTPClient ¶
NewHTTPClient returns a reference to an initialized configured HTTP client.
Types ¶
type IPVersion ¶
type IPVersion string
IPVersion represents a type for the IP versions of the different Selectel VPC APIs.
type JSONRFC3339NoZTimezone ¶
JSONRFC3339NoZTimezone is a type for timestamps SelVPC responses with the RFC3339NoZ format.
func (*JSONRFC3339NoZTimezone) UnmarshalJSON ¶
func (jt *JSONRFC3339NoZTimezone) UnmarshalJSON(data []byte) error
UnmarshalJSON helps to unmarshal timestamps from SelVPC responses to the JSONRFC3339NoZTimezone type.
type ResponseResult ¶
type ResponseResult struct { *http.Response // Err contains error that can be provided to a caller. Err error }
ResponseResult represents a result of a HTTP request. It embeddes standard http.Response and adds a custom error description.
func (*ResponseResult) ExtractErr ¶
func (result *ResponseResult) ExtractErr() (string, error)
ExtractErr build a string without whitespaces from the error body. We don't unmarshal it into some struct because there are no strict error definition in the API.
func (*ResponseResult) ExtractResult ¶
func (result *ResponseResult) ExtractResult(to interface{}) error
ExtractResult allows to provide an object into which ResponseResult body will be extracted.
type ServiceClient ¶
type ServiceClient struct { // HTTPClient represents an initialized HTTP client that will be used to do requests. HTTPClient *http.Client // Endpoint represents an endpoint that will be used in all requests. Endpoint string // TokenID is a client authentication token. TokenID string // UserAgent contains user agent that will be used in all requests. UserAgent string }
ServiceClient stores details that are needed to work with different Selectel VPC APIs.
func (*ServiceClient) DoRequest ¶
func (client *ServiceClient) DoRequest(ctx context.Context, method, path string, body io.Reader) (*ResponseResult, error)
DoRequest performs the HTTP request with the current ServiceClient's HTTPClient. Authentication and optional headers will be added automatically.
Directories ¶
Path | Synopsis |
---|---|
Package quotamanager provides methods and structures to work with the Quotas Manager API.
|
Package quotamanager provides methods and structures to work with the Quotas Manager API. |
quotas
Package quotas provides the ability to retrieve and update quotas through the Quota Manager API.
|
Package quotas provides the ability to retrieve and update quotas through the Quota Manager API. |
Package resell provides all needed method and structures to work with the Selectel VPC Resell API.
|
Package resell provides all needed method and structures to work with the Selectel VPC Resell API. |
v2
Package v2 provides methods and structures to work with the Resell V2 API.
|
Package v2 provides methods and structures to work with the Resell V2 API. |
v2/capabilities
Package capabilities provides the ability to retrieve capabilities information through the Resell v2 API.
|
Package capabilities provides the ability to retrieve capabilities information through the Resell v2 API. |
v2/floatingips
Package floatingips provides the ability to retrieve and manage floating ips through the Resell v2 API.
|
Package floatingips provides the ability to retrieve and manage floating ips through the Resell v2 API. |
v2/keypairs
Package keypairs provides the ability to retrieve and manage keypairs through the Resell v2 API.
|
Package keypairs provides the ability to retrieve and manage keypairs through the Resell v2 API. |
v2/licenses
Package licenses provides the ability to retrieve and manage licenses through the Resell v2 API.
|
Package licenses provides the ability to retrieve and manage licenses through the Resell v2 API. |
v2/projects
Package projects provides the ability to retrieve and manage projects through the Resell v2 API.
|
Package projects provides the ability to retrieve and manage projects through the Resell v2 API. |
v2/quotas
Package quotas is deprecated.
|
Package quotas is deprecated. |
v2/roles
Package roles provides the ability to retrieve and manage roles through the Resell v2 API.
|
Package roles provides the ability to retrieve and manage roles through the Resell v2 API. |
v2/servers
Package servers contains reusable structures for other go-selvpcclient packages.
|
Package servers contains reusable structures for other go-selvpcclient packages. |
v2/subnets
Package subnets provides the ability to retrieve and manage subnets through the Resell v2 API.
|
Package subnets provides the ability to retrieve and manage subnets through the Resell v2 API. |
v2/tokens
Package tokens provides the ability to create tokens through the Resell v2 API.
|
Package tokens provides the ability to create tokens through the Resell v2 API. |
v2/traffic
Package traffic provides the ability to retrieve traffic data through the Resell v2 API.
|
Package traffic provides the ability to retrieve traffic data through the Resell v2 API. |
v2/users
Package users provides the ability to retrieve and manage users through the Resell v2 API.
|
Package users provides the ability to retrieve and manage users through the Resell v2 API. |
v2/vrrpsubnets
Package vrrpsubnets provides the ability to retrieve and manage VRRP subnets through the Resell v2 API.
|
Package vrrpsubnets provides the ability to retrieve and manage VRRP subnets through the Resell v2 API. |