GithubHelp home page GithubHelp logo

huylvt / gobizfly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bizflycloud/gobizfly

1.0 1.0 0.0 1.24 MB

BizFly Client in Golang

License: MIT License

Go 99.82% Dockerfile 0.06% Makefile 0.12%

gobizfly's Introduction

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.LoadBalancer.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

gobizfly's People

Contributors

greatbn avatar tung491 avatar cuonglm avatar botranvan avatar chpiano2000 avatar toannd96 avatar duc20176723 avatar lmq1999 avatar huylvt avatar trisduong avatar duyleekun avatar enixdark avatar huyduong2792 avatar

Stargazers

Roman avatar

Watchers

Jareer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.