Skip to content

selectel/go-selvpcclient

Repository files navigation

go-selvpcclient: a Go library for the Selectel VPC API

GoDoc Go Report Card Coverage Status

Package go-selvpcclient provides a Go library to work with the Selectel API:

Documentation

The Go library documentation is available at godoc.org.

What this library is capable of

You can use this library to work with the following objects of the Cloud Management API and Cloud Quota Management API.

Cloud Management API:

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.

Getting started

Installation

You can install go-selvpcclient as a Go package:

go get github.com/selectel/go-selvpcclient/selvpcclient/v4

Authentication

To work with the Selectel VPC API you first need to:

Usage example

package main

import (
 "context"
 "fmt"
 "log"

 "github.com/selectel/go-selvpcclient/v4/selvpcclient"
 "github.com/selectel/go-selvpcclient/v4/selvpcclient/resell/v2/projects"
)

func main() {
 ctx := context.Background()

 options := &selvpcclient.ClientOptions{
  Context:    ctx,
  DomainName: "999999",
  AuthRegion: "<pool>",
  AuthURL:     "https://cloud.api.selcloud.ru/identity/v3/",
  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)
 }
}