Skip to content

cloudsigma/cloudsigma-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CloudSigma SDK for Go

Build Status Go Report Card GoDoc

cloudsigma-sdk-go is the official CloudSigma SDK for the Go programming language.

Installation

# X.Y.Z is the version you need
go get github.com/cloudsigma/cloudsigma-sdk-go@vX.Y.Z


# for non Go modules usage or latest version
go get github.com/cloudsigma/cloudsigma-sdk-go

Usage

import "github.com/cloudsigma/cloudsigma-sdk-go"

Create a new CloudSigma client, then use the exposed services to access different parts of the CloudSigma API.

Authentication

Currently, HTTP Basic Authentication is the only method of authenticating with the API. You can then use your credentials to create a new client:

cred := cloudsigma.NewUsernamePasswordCredentialsProvider("my-user@my-domain.com", "my-secure-password")
client := cloudsigma.NewClient(cred)

If you want to specify more parameters by client initialization, use With... methods and pass via option pattern:

cred := cloudsigma.NewUsernamePasswordCredentialsProvider("my-user@my-domain.com", "my-secure-password")
client := cloudsigma.NewClient(cred,
  cloudsigma.WithLocation("fra"),
  cloudsigma.WithHTTPClient(customHTTPClient),
)

Examples

List all servers for the user.

func main() {
  cred := cloudsigma.NewUsernamePasswordCredentialsProvider("my-user@my-domain.com", "my-secure-password")
  client := cloudsigma.NewClient(cred)

  // list all servers for the authenticated user
  ctx := context.Background()
  servers, _, err := client.Servers.List(ctx)
}

Contributing

We love pull requests! Please see the contribution guidelines.

License

This SDK is distributed under the BSD 3-Clause License, see LICENSE for more information.