go-selvpcclient: github.com/selectel/go-selvpcclient/selvpcclient Index | Files | Directories

package selvpcclient

import "github.com/selectel/go-selvpcclient/selvpcclient"

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

Package Files

doc.go selvpc.go

Constants

const (
    // AppVersion is a version of the application.
    AppVersion = "1.9.0"

    // AppName is a global application name.
    AppName = "go-selvpcclient"

    // DefaultEndpoint contains basic endpoint for queries.
    DefaultEndpoint = "https://api.selectel.ru/vpc"

    // 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.

func BuildQueryParameters Uses

func BuildQueryParameters(opts interface{}) (string, error)

BuildQueryParameters converts provided options struct to the string of URL parameters.

func NewHTTPClient Uses

func NewHTTPClient() *http.Client

NewHTTPClient returns a reference to an initialized configured HTTP client.

type IPVersion Uses

type IPVersion string

IPVersion represents a type for the IP versions of the different Selectel VPC APIs.

const (
    // IPv4 represents IP version 4.
    IPv4 IPVersion = "ipv4"

    // IPv6 represents IP version 6.
    IPv6 IPVersion = "ipv6"
)

type JSONRFC3339NoZTimezone Uses

type JSONRFC3339NoZTimezone time.Time

JSONRFC3339NoZTimezone is a type for timestamps SelVPC responses with the RFC3339NoZ format.

func (*JSONRFC3339NoZTimezone) UnmarshalJSON Uses

func (jt *JSONRFC3339NoZTimezone) UnmarshalJSON(data []byte) error

UnmarshalJSON helps to unmarshal timestamps from SelVPC responses to the JSONRFC3339NoZTimezone type.

type ResponseResult Uses

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 Uses

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 Uses

func (result *ResponseResult) ExtractResult(to interface{}) error

ExtractResult allows to provide an object into which ResponseResult body will be extracted.

type ServiceClient Uses

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 Uses

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

PathSynopsis
resellPackage resell provides all needed method and structures to work with the Selectel VPC Resell API.
resell/v2Package v2 provides methods and structures to work with the Resell V2 API.
resell/v2/capabilitiesPackage capabilities provides the ability to retrieve capabilities information through the Resell v2 API.
resell/v2/capabilities/testing
resell/v2/floatingipsPackage floatingips provides the ability to retrieve and manage floating ips through the Resell v2 API.
resell/v2/floatingips/testing
resell/v2/keypairsPackage keypairs provides the ability to retrieve and manage keypairs through the Resell v2 API.
resell/v2/keypairs/testing
resell/v2/licensesPackage licenses provides the ability to retrieve and manage licenses through the Resell v2 API.
resell/v2/licenses/testing
resell/v2/projectsPackage projects provides the ability to retrieve and manage projects through the Resell v2 API.
resell/v2/projects/testing
resell/v2/quotasPackage quotas provides the ability to retrieve and update quotas through the Resell v2 API.
resell/v2/quotas/testing
resell/v2/rolesPackage roles provides the ability to retrieve and manage roles through the Resell v2 API.
resell/v2/roles/testing
resell/v2/serversPackage servers contains reusable structures for other go-selvpcclient packages.
resell/v2/subnetsPackage subnets provides the ability to retrieve and manage subnets through the Resell v2 API.
resell/v2/subnets/testing
resell/v2/tokensPackage tokens provides the ability to create tokens through the Resell v2 API.
resell/v2/tokens/testing
resell/v2/trafficPackage traffic provides the ability to retrieve traffic data through the Resell v2 API.
resell/v2/traffic/testing
resell/v2/usersPackage users provides the ability to retrieve and manage users through the Resell v2 API.
resell/v2/users/testing
resell/v2/vrrpsubnetsPackage vrrpsubnets provides the ability to retrieve and manage VRRP subnets through the Resell v2 API.
resell/v2/vrrpsubnets/testing
testutils

Package selvpcclient imports 15 packages (graph) and is imported by 18 packages. Updated 2019-10-05. Refresh now. Tools for package owners.