Avisi cloud logo

Golang client

Get started with Avisi Cloud's Golang SDK

Avisi Cloud Golang SDK

The Avisi Cloud SDK for Golang provides developers with a convenient way to interact with the Avisi Cloud platform via its API. By leveraging Go's idiomatic patterns, this SDK simplifies tasks like managing resources, creating environments, and interacting with various features of the platform.

Features

  • Authentication Support: Integrate your application with Avisi Cloud using personal access tokens (PAT).
  • Resource Management: Easily create, update, and query environments, and manage other cloud resources.
  • Error Handling: Provides robust mechanisms for handling API responses and errors.
  • Customizable Client: Set API URLs and other client options to connect with different environments.

Installation

To install the SDK, include the following in your project:

go get github.com/avisi-cloud/go-client

This command will add the SDK to your project’s go.mod file, making it ready for use.

Getting Started

To get started with the SDK, initialize the client using a personal access token and configure it with the appropriate API URL.

Setting Up the Client

package main
 
import (
    "github.com/avisi-cloud/go-client/pkg/acloudapi"
    "os"
)
 
func main() {
    // Retrieve your personal access token from environment variables
    personalAccessToken := os.Getenv("ACLOUD_PERSONAL_ACCESS_TOKEN")
 
    // Set up the authenticator
    authenticator := acloudapi.NewPersonalAccessTokenAuthenticator(personalAccessToken)
 
    // Set up client options
    clientOpts := acloudapi.ClientOpts{
        APIUrl: "https://api.avisi.cloud",
    }
 
    // Create the client
    client := acloudapi.NewClient(authenticator, clientOpts)
 
    // Example: Create a new environment
    createEnv := acloudapi.CreateEnvironment{
        Name:        "test-environment",
        Type:        "development",
        Description: "A development environment",
    }
 
    // Call the API to create the environment
    org := "my-org-slug"
    environment, err := client.CreateEnvironment(context.Background(), createEnv, org)
    if err != nil {
        panic(err)
    }
 
    // Output created environment details
    fmt.Println("Environment created:", environment)
}

This example demonstrates how to authenticate with the Avisi Cloud API and create a new environment. The SDK provides additional functionality for managing various aspects of your Avisi Cloud resources, such as listing environments, deleting resources, and more.

Documentation & Examples

For more information, visit the GitHub repository.

On this page