Package go-selvpcclient provides a Go library to work with the Selectel VPC API.
The Go library documentation is available at godoc.org.
The API usage examples are available at knowledge base.
API documentation is also available at the VPC page (if you've created an account on the registration page).
You can use this library to work with the following objects of the Selectel VPC API:
- capabilities
- cross region subnets
- floating ips
- keypairs
- licenses
- projects
- quotas
- roles
- subnets
- tokens
- traffic
- users
- vrrp subnets
Selectel VPC Cloud is based on the OpenStack, so you don't need this library to work with actual servers, volumes, networks, etc.
You can use the Gophercloud project to work with the OpenStack objects.
You can install go-selvpcclient
as a Go package:
go get github.com/selectel/go-selvpcclient/selvpcclient
To work with the Selectel VPC API you first need to:
- create a Selectel account: registration page
- obtain an API token: api keys
package main
import (
"context"
"fmt"
"log"
resell "github.com/selectel/go-selvpcclient/selvpcclient/resell/v2"
"github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/projects"
)
// API token from the https://my.selectel.ru.
var token = "token_key"
func main() {
// Initialize the Resell V2 client.
resellClient := resell.NewV2ResellClient(token)
// Get and print all projects.
ctx := context.Background()
allProjects, _, err := projects.List(ctx, resellClient)
if err != nil {
log.Fatal(err)
}
for _, myProject := range allProjects {
fmt.Println(myProject)
}
}