selvpcclient

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 15 Imported by: 4

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:

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

View Source
const (
	// AppVersion is a version of the application.
	AppVersion = "1.12.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
)
View Source
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 added in v1.1.0

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

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

func NewHTTPClient added in v1.5.0

func NewHTTPClient() *http.Client

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.

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

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

type JSONRFC3339NoZTimezone

type JSONRFC3339NoZTimezone time.Time

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 added in v1.10.0

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 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 provides the ability to retrieve and update quotas through the Resell v2 API.
Package quotas provides the ability to retrieve and update quotas through the Resell v2 API.
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.

Jump to

Keyboard shortcuts

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