README

GoBitLaunch

GoBitLaunch is a Go client library for accessing the BitLaunch API.

You can view the client API docs here: http://godoc.org/github.com/bitlaunchio/gobitlaunch

You can view BitLaunch API docs here: https://developers.bitlaunch.io/

Install

go get -u github.com/bitlaunchio/gobitlaunch

Usage

import "github.com/bitlaunchio/gobitlaunch"
Authentication

You must use your API Token to authenticate with BitLaunch API. You can (re)generate your access token on the BitLaunch API Page.

You can then use your token to create a new client.

client := gobitlaunch.NewClient(token)

Documentation

For a comprehensive list of examples, check out the API documentation.

For details on all the functionality in this library, see the GoDoc

Contributing

Please do!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID                  string    `json:"id"`
	Email               string    `json:"email"`
	EmailConfirmed      bool      `json:"emailConfirmed"`
	Created             time.Time `json:"created"`
	Used                int       `json:"used"`
	Limit               int       `json:"limit"`
	Twofa               bool      `json:"twofa"`
	Balance             int       `json:"balance"`
	CostPerHr           int       `json:"costPerHr"`
	LowBalanceAlertDays int       `json:"billingAlert"`
	NegativeAllowance   int       `json:"negativeAllowance"`
}

    Account represents a BitLaunch account

    type AccountHistory

    type AccountHistory struct {
    	History []struct {
    		ID          string    `json:"id"`
    		Time        time.Time `json:"time"`
    		Description string    `json:"description"`
    	} `json:"history"`
    	Total int `json:"total"`
    }

      AccountHistory represents the usage data of a BitLaunch account

      type AccountService

      type AccountService struct {
      	// contains filtered or unexported fields
      }

        AccountService manages account API actions

        func (*AccountService) History

        func (as *AccountService) History(page, perPage int) (*AccountHistory, error)

          History shows the account history/activity

          func (*AccountService) Show

          func (as *AccountService) Show() (*Account, error)

            Show the account

            func (*AccountService) Usage

            func (as *AccountService) Usage(filter ...string) (*AccountUsage, error)

              Usage shows the account usage

              type AccountUsage

              type AccountUsage struct {
              	Server     []usageData `json:"serverUsage"`
              	Backup     []usageData `json:"backupUsage"`
              	Bandwidth  []usageData `json:"bandwidthUsage"`
              	Protection []usageData `json:"protectionUsage"`
              	TotalUSD   int         `json:"totalUsd"`
              	PrevMonth  string      `json:"prevMonth"`
              	ThisMonth  string      `json:"thisMonth"`
              	NextMonth  string      `json:"nextMonth"`
              }

                AccountUsage represents the usage data of a BitLaunch account

                type Client

                type Client struct {
                	Account       *AccountService
                	Server        *ServerService
                	Transaction   *TransactionService
                	CreateOptions *CreateOptionsService
                	SSHKey        *SSHKeyService
                	// contains filtered or unexported fields
                }

                  Client manages interaction with the API

                  func NewClient

                  func NewClient(token string) *Client

                    NewClient takes an API token and returns a new BitLaunch API client

                    func (*Client) DoRequest

                    func (c *Client) DoRequest(r *http.Request, data interface{}) error

                      DoRequest performs a http request

                      func (*Client) NewRequest

                      func (c *Client) NewRequest(method, path string, body []byte) (*http.Request, error)

                        NewRequest creates an API Request

                        type CreateOptionsService

                        type CreateOptionsService struct {
                        	// contains filtered or unexported fields
                        }

                          CreateOptionsService manages create options API actions

                          func (*CreateOptionsService) Show

                          func (co *CreateOptionsService) Show(hostID int) (*ServerCreateOptions, error)

                            Show the server create options

                            type CreateServerOptions

                            type CreateServerOptions struct {
                            	Name        string   `json:"name"`
                            	HostID      int      `json:"hostID"`
                            	HostImageID string   `json:"HostImageID"`
                            	SizeID      string   `json:"sizeID"`
                            	RegionID    string   `json:"regionID"`
                            	SSHKeys     []string `json:"sshKeys"`
                            	Password    string   `json:"password"`
                            	InitScript  string   `json:"initscript"`
                            }

                              CreateServerOptions defines options for creating a new server

                              type CreateTransactionOptions

                              type CreateTransactionOptions struct {
                              	AmountUSD        int    `json:"amountUsd"`
                              	CryptoSymbol     string `json:"cryptoSymbol"`
                              	LightningNetwork bool   `json:"lightningNetwork"`
                              }

                                CreateTransactionOptions represents options for create a new transaction

                                type HostDisks

                                type HostDisks struct {
                                	Type  string `json:"type"`
                                	Count int    `json:"count"`
                                	Size  string `json:"size"`
                                	Unit  string `json:"unit"`
                                }

                                  HostDisks represents a disk

                                  type HostImage

                                  type HostImage struct {
                                  	ID                 int                `json:"id"`
                                  	Name               string             `json:"name"`
                                  	Type               string             `json:"type"`
                                  	MinDiskSize        int                `json:"minDiskSize"`
                                  	UnavailableRegions []string           `json:"unavailableRegions"`
                                  	DefaultVersion     HostImageVersion   `json:"version"`
                                  	Versions           []HostImageVersion `json:"versions"`
                                  	ExtraCostPerMonth  int                `json:"extraCostPerMonth"`
                                  	Windows            bool               `json:"windows"`
                                  }

                                    HostImage represents an image

                                    type HostImageVersion

                                    type HostImageVersion struct {
                                    	ID                  string `json:"id"`
                                    	Description         string `json:"description"`
                                    	PasswordUnsupported bool   `json:"passwordUnsupported"`
                                    }

                                      HostImageVersion represents an image version

                                      type HostOptions

                                      type HostOptions struct {
                                      	Rebuild    bool `json:"rebuild"`
                                      	Resize     bool `json:"resize"`
                                      	Backups    bool `json:"backups"`
                                      	Userscript bool `json:"userScript"`
                                      }

                                        HostOptions represents what options a certain host provides

                                        type HostPlanType

                                        type HostPlanType struct {
                                        	Type        string `json:"type"`
                                        	Description string `json:"description"`
                                        	Name        string `json:"name"`
                                        }

                                          HostPlanType represents the type of plan

                                          type HostRegion

                                          type HostRegion struct {
                                          	ID               int             `json:"id"`
                                          	Name             string          `json:"name"`
                                          	ISO              string          `json:"iso"`
                                          	DefaultSubregion HostSubRegion   `json:"subregion"`
                                          	Subregions       []HostSubRegion `json:"subregions"`
                                          }

                                            HostRegion represents a region

                                            type HostSize

                                            type HostSize struct {
                                            	ID           string      `json:"id"`
                                            	Slug         string      `json:"slug"`
                                            	BandwidthGB  int         `json:"bandwidthGB"`
                                            	CPUCount     int         `json:"cpuCount"`
                                            	DiskGB       int         `json:"diskGB"`
                                            	Disks        []HostDisks `json:"disks"`
                                            	MemoryMB     int         `json:"memoryMB"`
                                            	CostPerHour  int         `json:"costPerHr"`
                                            	CostPerMonth float64     `json:"costPerMonth"`
                                            
                                            	// PlanType indicates the hardware plan of the server (Standard, CPU focused)
                                            	PlanType string `json:"planType"`
                                            }

                                              HostSize represents a server size

                                              type HostSubRegion

                                              type HostSubRegion struct {
                                              	ID               string   `json:"id"`
                                              	Description      string   `json:"description"`
                                              	Slug             string   `json:"slug"`
                                              	UnavailableSizes []string `json:"unavailableSizes"`
                                              }

                                                HostSubRegion represents a sub region

                                                type Ports

                                                type Ports struct {
                                                	PortNumber int    `json:"portNumber"`
                                                	Protocol   string `json:"protocol"`
                                                }

                                                  Ports represents a port slice object

                                                  type RebuildOptions

                                                  type RebuildOptions struct {
                                                  	ID          string `json:"hostImageID"`
                                                  	Description string `json:"imageDescription"`
                                                  }

                                                    RebuildOptions defines options for rebuilding a server

                                                    type SSHKey

                                                    type SSHKey struct {
                                                    	ID          string    `json:"id"`
                                                    	Name        string    `json:"name"`
                                                    	Fingerprint string    `json:"fingerprint"`
                                                    	Content     string    `json:"content"`
                                                    	Created     time.Time `json:"created"`
                                                    }

                                                      SSHKey represents an ssh key

                                                      type SSHKeyService

                                                      type SSHKeyService struct {
                                                      	// contains filtered or unexported fields
                                                      }

                                                        SSHKeyService manages ssh key API actions

                                                        func (*SSHKeyService) Create

                                                        func (ss *SSHKeyService) Create(k *SSHKey) (*SSHKey, error)

                                                          Create ssh key

                                                          func (*SSHKeyService) Delete

                                                          func (ss *SSHKeyService) Delete(id string) error

                                                            Delete an SSH Key

                                                            func (*SSHKeyService) List

                                                            func (ss *SSHKeyService) List() ([]SSHKey, error)

                                                              List ssh key

                                                              type Server

                                                              type Server struct {
                                                              	ID                 string    `json:"id"`
                                                              	Name               string    `json:"name"`
                                                              	HostID             int       `json:"host"`
                                                              	Ipv4               string    `json:"ipv4"`
                                                              	Region             string    `json:"region"`
                                                              	Size               string    `json:"size"`
                                                              	SizeDesc           string    `json:"sizeDescription"`
                                                              	Image              string    `json:"image"`
                                                              	ImageDesc          string    `json:"imageDescription"`
                                                              	Created            time.Time `json:"created"`
                                                              	Rate               int       `json:"rate"`
                                                              	BandwidthUsed      int       `json:"bandwidthUsed"`
                                                              	BandwidthAllowance int       `json:"bandwidthAllowance"`
                                                              	Status             string    `json:"status"`
                                                              	ErrorText          string    `json:"errorText"`
                                                              	BackupsEnabled     bool      `json:"backupsEnabled"`
                                                              	Version            string    `json:"version"`
                                                              	Abuse              bool      `json:"abuse"`
                                                              	DiskGB             int       `json:"diskGB"`
                                                              	Protection         struct {
                                                              		Enabled bool `json:"enabled"`
                                                              		Proxy   struct {
                                                              			IP     string  `json:"ip"`
                                                              			Region string  `json:"region"`
                                                              			Ports  []Ports `json:"ports"`
                                                              			Target string  `json:"target"`
                                                              		} `json:"proxy"`
                                                              	} `json:"protection"`
                                                              }

                                                                Server represents a server

                                                                type ServerCreateOptions

                                                                type ServerCreateOptions struct {
                                                                	HostID        int            `json:"hostID"`
                                                                	Images        []HostImage    `json:"image"`
                                                                	Regions       []HostRegion   `json:"region"`
                                                                	Sizes         []HostSize     `json:"size"`
                                                                	Available     bool           `json:"available"`
                                                                	BandwidthCost int            `json:"bandwidthCost"`
                                                                	PlanTypes     []HostPlanType `json:"planTypes"`
                                                                }

                                                                  ServerCreateOptions represents server creation options

                                                                  type ServerService

                                                                  type ServerService struct {
                                                                  	// contains filtered or unexported fields
                                                                  }

                                                                    ServerService manages server API actions

                                                                    func (*ServerService) Create

                                                                    func (ss *ServerService) Create(opts *CreateServerOptions) (*Server, error)

                                                                      Create server

                                                                      func (*ServerService) Destroy

                                                                      func (ss *ServerService) Destroy(id string) error

                                                                        Destroy a server

                                                                        func (*ServerService) List

                                                                        func (ss *ServerService) List() ([]Server, error)

                                                                          List servers

                                                                          func (*ServerService) Protection

                                                                          func (ss *ServerService) Protection(id string, enabled bool) (*Server, error)

                                                                            Protection is to enable/disable DDoS protection on a server

                                                                            func (*ServerService) Rebuild

                                                                            func (ss *ServerService) Rebuild(id string, opts *RebuildOptions) error

                                                                              Rebuild server

                                                                              func (*ServerService) Resize

                                                                              func (ss *ServerService) Resize(id string, size string) error

                                                                                Resize server

                                                                                func (*ServerService) Restart

                                                                                func (ss *ServerService) Restart(id string) error

                                                                                  Restart server

                                                                                  func (*ServerService) SetPorts

                                                                                  func (ss *ServerService) SetPorts(id string, ports *[]Ports) (*Server, error)

                                                                                    SetPorts sets the enabled ports on a server for DDoS protection (Needs Protection enabled)

                                                                                    func (*ServerService) Show

                                                                                    func (ss *ServerService) Show(id string) (*Server, error)

                                                                                      Show server

                                                                                      type Transaction

                                                                                      type Transaction struct {
                                                                                      	ID           string    `json:"id"`
                                                                                      	TID          string    `json:"transactionId"`
                                                                                      	Date         time.Time `json:"date"`
                                                                                      	Address      string    `json:"address"`
                                                                                      	Symbol       string    `json:"cryptoSymbol"`
                                                                                      	AmountUSD    float64   `json:"amountUsd"`
                                                                                      	AmountCrypto string    `json:"amountCrypto"`
                                                                                      	Status       string    `json:"status"`
                                                                                      	StatusURL    string    `json:"statusUrl"`
                                                                                      	QrCodeURL    string    `json:"qrCodeUrl"`
                                                                                      }

                                                                                        Transaction represents a transaction

                                                                                        type TransactionService

                                                                                        type TransactionService struct {
                                                                                        	// contains filtered or unexported fields
                                                                                        }

                                                                                          TransactionService manages account API actions

                                                                                          func (*TransactionService) Create

                                                                                            Create transaction

                                                                                            func (*TransactionService) List

                                                                                            func (ss *TransactionService) List(page, perPage int) ([]Transaction, error)

                                                                                              List transactions

                                                                                              func (*TransactionService) Show

                                                                                              func (ss *TransactionService) Show(id string) (*Transaction, error)

                                                                                                Show transaction