Go SDK for Selectel Global Router resources
You can install needed globalrouter-go packages via go get command:
go get github.com/selectel/globalrouter-goTo work with the Selectel global-router Servers API you first need to:
- Create a Selectel account: registration page.
- Create a project in Selectel Cloud Platform projects.
- Retrieve a token for your account via API or go-selvpcclient.
You can find available endpoints here.
package main
import (
"context"
"fmt"
globalrouter "github.com/selectel/globalrouter-go/pkg/v1"
)
func main() {
// Auth token.
token := "gAAAAABeVNzu-..."
// Global router endpoint to work with.
endpoint := "https://api.selectel.ru/naas/v1"
// Create the client.
client := globalrouter.NewClientV1(
token,
globalrouter.WithAPIUrl("https://api.selectel.ru/naas/v1"),
)
// Get all Zones with specified name
zones, _, _ := client.ListZones(ctx, nil)
// Print all cloud zones
for _, zone := range *zones {
if zone.Service == "vpc" {
fmt.Printf("Zone name: %s\n", zone.Name)
}
}
}