Package go-selvpcclient provides a Go library to work with the Selectel API:
The Go library documentation is available at godoc.org.
You can use this library to work with the following objects of the Cloud Management API and Cloud Quota Management API.
Cloud Management API:
- capabilities
- floating ips
- keypairs
- licenses
- projects
- roles
- subnets
- tokens
- traffic
- users
- vrrp subnets
Cloud Quota Management API:
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/v3
To work with the Selectel VPC API you first need to:
- create a Selectel account: registration page
- create the service user: users and roles
package main
import (
"context"
"fmt"
"log"
"github.com/selectel/go-selvpcclient/v3/selvpcclient"
"github.com/selectel/go-selvpcclient/v3/selvpcclient/resell/v2/projects"
)
func main() {
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)
}
}