Skip to content

bizflycloud/gobizfly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gobizfly

Gobizfly is a Go client library for accessing Bizfly API

You can view the client API docs here: https://pkg.go.dev/github.com/bizflycloud/gobizfly

Install

go get github.com/bizflycloud/gobizfly@vX

Usage

import "github.com/bizflycloud/gobizfly"

Create a new Bizfly Cloud client, then use the exposed services to access different part of the Bizfly API

Authentication

Currently, token is the only method of authenticating with the API. You can generate token via username/password or application credential

package main
import (
	"github.com/bizflycloud/gobizfly"
	"log"
)

func main() {
	tok, err := client.Token.Create(ctx, &gobizfly.TokenCreateRequest{Username: username, Password: password, AuthMethod: "password"})
	if err != nil {
		log.Fatal(err)
	}
	client.SetKeystoneToken(tok)
}

Example

package main

import (
	"context"
	"log"
	"time"

	"github.com/bizflycloud/gobizfly"
)

const (
	host     = "https://manage.bizflycloud.vn"
	username = "foo@bar"
	password = "foobar"
)

func main() {
	client, err := gobizfly.NewClient(
		gobizfly.WithAPIURL(host),
	)
	if err != nil {
		log.Fatal(err)
	}

	ctx, cancelFunc := context.WithTimeout(context.Background(), time.Second*10)
	defer cancelFunc()
	tok, err := client.Token.Create(ctx, &gobizfly.TokenCreateRequest{Username: username, Password: password})
	if err != nil {
		log.Fatal(err)
	}
	client.SetKeystoneToken(tok)

	lbs, err := client.CloudLoadBalancer.List(ctx, &gobizfly.ListOptions{})
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("%#v\n", lbs)
}

Documentation

For details on all the functionality in this library, checkout Gobizfly documentation