Back to godoc.org
github.com/BitLaunchIO/gobitlaunch

package gobitlaunch

v1.0.0
Latest Go to latest
Published: Apr 8, 2020 | License: MIT | Module: github.com/BitLaunchIO/gobitlaunch

Index

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 AccountService

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

AccountService manages account API actions

func (*AccountService) Show

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

Show the 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 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"`
}

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) 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

func (ss *TransactionService) Create(opts *CreateTransactionOptions) (*Transaction, error)

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

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier