selvpcclient

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 1

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
  - create the service user: https://docs.selectel.ru/control-panel-actions/users-and-roles/add-user/

Usage example

ctx := context.Background()

options := &selvpcclient.ClientOptions{
	Context:    ctx,
	DomainName: "999999",
	Username:   "admin",
	Password:   "m1-sup3r-p@ssw0rd-p3w-p3w",
}

client, err := selvpcclient.NewClient(options)
if err != nil {
	log.Fatal(err)
}

result, resp, err := projects.List(client)
if err != nil {
	log.Fatal(err)
}

fmt.Printf("Response StatusCode: %d \n", resp.StatusCode)

for _, project := range result {
	fmt.Printf("Project name: %s, enabled: %t \n", project.Name, project.Enabled)
}

Index

Constants

View Source
const (
	AppName           = "go-selvpcclient"
	AppVersion        = "3.1.1"
	DefaultAuthRegion = "ru-1"
	DefaultAuthURL    = "https://cloud.api.selcloud.ru/identity/v3/"
)
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

This section is empty.

Types

type Client

type Client struct {
	// Resell - client for Cloud Management API.
	Resell *clients.ResellClient

	// QuotaManager - client for Cloud Quota Management API.
	QuotaManager *clients.QuotaManagerClient

	// Catalog - service for simplified resolve regional endpoints from Keystone catalog.
	Catalog *clientservices.CatalogService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options *ClientOptions) (*Client, error)

func (*Client) GetXAuthToken

func (selvpc *Client) GetXAuthToken() string

GetXAuthToken - returns X-Auth-Token from Service Provider. This method doesn't guarantee that the token is valid. It returns the last used token from the service provider. Usually the lifetime of the token is 24h. If you use this token, then you should handle 401 error.

type ClientOptions

type ClientOptions struct {
	Context context.Context

	// Your Account ID, for example: 234567.
	DomainName string

	// Credentials of your service user.
	// Documentation: https://docs.selectel.ru/control-panel-actions/users-and-roles/
	Username string
	Password string

	// Optional field, that is used for authentication with project scope.
	// If you created service user with admin role of project, then this field is for you.
	ProjectID string

	// Optional field to specify a non-default Identity endpoint.
	AuthURL string

	// Optional field for setting a non-default location for endpoints like ResellAPI or Keystone.
	AuthRegion string

	// Optional field to specify the domain name where the user is located.
	// Used in private clouds to issue a token not from owned domain.
	// If this field is not set, then it will be equal to the value of DomainName.
	UserDomainName string
}

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.

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 Cloud Management API (Resell) API.
Package resell provides all needed method and structures to work with the Selectel Cloud Management API (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.

Jump to

Keyboard shortcuts

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