cherrygo

package module
v3.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 12 Imported by: 2

README

cherrygo

Cherry Servers golang API client library for Cherry Servers RESTful API.

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

You can view Cherry Servers API docs here: https://api.cherryservers.com/doc

Table of Contents

Installation

Download the library to you GOPATH:

go get github.com/cherryservers/cherrygo

Then import the library in your Go code:

import "github.com/cherryservers/cherrygo"
Authentication

To authenticate to the Cherry Servers API, you must have API token, you can create authentication tokens in the Cherry Server client portal. Token must be exported in env var CHERRY_AUTH_TOKEN or passed to client directly.

export CHERRY_AUTH_TOKEN="4bdc0acb8f7af4bdc0acb8f7afe78522e6dae9b7e03b0e78522e6dae9b7e03b0"

Use exported CHERRY_AUTH_TOKEN env variable:

func main() {
    c, err := cherrygo.NewClient()
}

Pass token directly to client:

func main() {
    c, err := cherrygo.NewClient(cherrygo.WithAuthToken("your-api-token"))
}
Examples
Get teams

You will need team ID for later calls, for example to get projects for specified team, you will need to provide team ID.

teams, _, err := c.Teams.List(nil)
if err != nil {
    log.Fatal("Error", err)
}

for _, t := range teams {
    log.Println(t.ID, t.Name, t.Credit.Promo.Remaining, t.Credit.Promo.Usage, t.Credit.Resources.Pricing.Price)
}
Get projects

After you have your team ID, you can list your projects. You will need your project ID to list your servers or order new ones.

projects, _, err := c.Projects.List(teamID, nil)
if err != nil {
    log.Fatal("Error", err)
}

for _, p := range projects {
    log.Println(p.ID, p.Name, p.Href)
}
Get plans

Next thing in order to get new server is to choose one, we call it plans

plans, _, err := c.Plans.List(teamID, nil)
if err != nil {
    log.Fatalf("Plans error: %v", err)
}

for _, p := range plans {
    log.Println(p.Name, p.Slug)
}
Get images

After you manage to know desired plan, you need to get available images for that plan

images, _, err := c.Images.List(planSlug, nil)
if err != nil {
    log.Fatal("Error", err)
}

for _, i := range images {
    log.Println(i.Name, i.Slug)
}
Order new server

Now you are ready to order new server

addServerRequest := cherrygo.CreateServer{
    ProjectID:   projectID,
    Hostname:    hostname,
    Image:       imageSlug,
    Region:      regionSlug,
    Plan:        planSlug,
}

server, _, err := c.Server.Create(&addServerRequest)
if err != nil {
    log.Fatal("Error while creating new server: ", err)
}

log.Println(server.ID, server.Name, server.Hostname)

Debug

In case you want to debug this library and get requests and responses from API you need to export CHERRY_DEBUG variable

export CHERRY_DEBUG="true"

When you done, just unset that variable:

unset CHERRY_DEBUG

License

See the LICENSE file for license rights and limitations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignIPAddress

type AssignIPAddress struct {
	ServerID int    `json:"targeted_to,omitempty"`
	IpID     string `json:"routed_to,omitempty"`
}

Subnet type IP addresses can be only assigned to a server. Floating IP address can be assigned directly to a server or routed to subnet type IP address.

type AssignedTo

type AssignedTo struct {
	ID       int     `json:"id,omitempty"`
	Name     string  `json:"name,omitempty"`
	Href     string  `json:"href,omitempty"`
	Hostname string  `json:"hostname,omitempty"`
	Image    string  `json:"image,omitempty"`
	Region   Region  `json:"region,omitempty"`
	State    string  `json:"state,omitempty"`
	Pricing  Pricing `json:"pricing,omitempty"`
}

AssignedTo fields

type AttachTo

type AttachTo struct {
	StorageID int `json:"storage_id"`
	AttachTo  int `json:"attach_to"`
}

type AttachedTo

type AttachedTo struct {
	ID       int    `json:"id"`
	Hostname string `json:"hostname,omitempty"`
	Href     string `json:"href"`
}

type AvailableRegions

type AvailableRegions struct {
	*Region
	StockQty int `json:"stock_qty,omitempty"`
	SpotQty  int `json:"spot_qty,omitempty"`
}

type BGPRoute

type BGPRoute struct {
	Subnet  string `json:"subnet,omitempty"`
	Active  bool   `json:"active,omitempty"`
	Router  string `json:"router,omitempty"`
	Age     string `json:"age,omitempty"`
	Updated string `json:"updated,omitempty"`
}

type BMC added in v3.2.0

type BMC struct {
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
}

type BackupMethod added in v3.1.0

type BackupMethod struct {
	Name       string   `json:"name,omitempty"`
	Username   string   `json:"username,omitempty"`
	Password   string   `json:"password,omitempty"`
	Port       int      `json:"port,omitempty"`
	Host       string   `json:"host,omitempty"`
	SSHKey     string   `json:"ssh_key,omitempty"`
	WhiteList  []string `json:"whitelist,omitempty"`
	Enabled    bool     `json:"enabled,omitempty"`
	Processing bool     `json:"processing,omitempty"`
}

type BackupStorage added in v3.1.0

type BackupStorage struct {
	ID                   int            `json:"id,omitempty"`
	Status               string         `json:"status,omitempty"`
	State                string         `json:"state,omitempty"`
	PrivateIP            string         `json:"private_ip,omitempty"`
	PublicIP             string         `json:"public_ip,omitempty"`
	SizeGigabytes        int            `json:"size_gigabytes,omitempty"`
	UsedGigabytes        int            `json:"used_gigabytes,omitempty"`
	AttachedTo           AttachedTo     `json:"attached_to,omitempty"`
	Methods              []BackupMethod `json:"methods,omitempty"`
	AvailableIPAddresses []IPAddress    `json:"available_addresses,omitempty"`
	Rules                []Rule         `json:"rules,omitempty"`
	Plan                 Plan           `json:"plan,omitempty"`
	Pricing              Pricing        `json:"pricing,omitempty"`
	Region               Region         `json:"region,omitempty"`
	Href                 string         `json:"href,omitempty"`
}

type BackupStoragePlan added in v3.1.0

type BackupStoragePlan struct {
	ID            int       `json:"id,omitempty"`
	Name          string    `json:"name,omitempty"`
	Slug          string    `json:"slug,omitempty"`
	SizeGigabytes int       `json:"size_gigabytes,omitempty"`
	Pricing       []Pricing `json:"pricing,omitempty"`
	Regions       []Region  `json:"regions,omitempty"`
	Href          string    `json:"href,omitempty"`
}

type BackupsClient added in v3.1.0

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

func (*BackupsClient) Create added in v3.1.0

func (s *BackupsClient) Create(request *CreateBackup) (BackupStorage, *Response, error)

func (*BackupsClient) Delete added in v3.1.0

func (s *BackupsClient) Delete(backupID int) (*Response, error)

func (*BackupsClient) Get added in v3.1.0

func (s *BackupsClient) Get(backupID int, opts *GetOptions) (BackupStorage, *Response, error)

func (*BackupsClient) ListBackups added in v3.1.0

func (s *BackupsClient) ListBackups(projectID int, opts *GetOptions) ([]BackupStorage, *Response, error)

func (*BackupsClient) ListPlans added in v3.1.0

func (s *BackupsClient) ListPlans(opts *GetOptions) ([]BackupStoragePlan, *Response, error)

func (*BackupsClient) Update added in v3.1.0

func (*BackupsClient) UpdateBackupMethod added in v3.1.0

func (s *BackupsClient) UpdateBackupMethod(request *UpdateBackupMethod) ([]BackupMethod, *Response, error)

type BackupsService added in v3.1.0

type BackupsService interface {
	ListPlans(opts *GetOptions) ([]BackupStoragePlan, *Response, error)
	ListBackups(projectID int, opts *GetOptions) ([]BackupStorage, *Response, error)
	Get(backupID int, opts *GetOptions) (BackupStorage, *Response, error)
	Create(request *CreateBackup) (BackupStorage, *Response, error)
	Update(request *UpdateBackupStorage) (BackupStorage, *Response, error)
	UpdateBackupMethod(request *UpdateBackupMethod) ([]BackupMethod, *Response, error)
	Delete(backupID int) (*Response, error)
}

type Bandwidth

type Bandwidth struct {
	Name string `json:"name,omitempty"`
}

Bandwidth fields

type Billing

type Billing struct {
	Type        string `json:"type,omitempty"`
	CompanyName string `json:"company_name,omitempty"`
	CompanyCode string `json:"company_code,omitempty"`
	FirstName   string `json:"first_name,omitempty"`
	LastName    string `json:"last_name,omitempty"`
	Address1    string `json:"address_1,omitempty"`
	Address2    string `json:"address_2,omitempty"`
	CountryIso2 string `json:"country_iso_2,omitempty"`
	City        string `json:"city,omitempty"`
	Vat         Vat    `json:"vat,omitempty"`
	Currency    string `json:"currency,omitempty"`
}

type BlockStorage

type BlockStorage struct {
	ID            int        `json:"id"`
	Name          string     `json:"name"`
	Href          string     `json:"href"`
	Size          int        `json:"size"`
	AllowEditSize bool       `json:"allow_edit_size"`
	Unit          string     `json:"unit"`
	Description   string     `json:"description,omitempty"`
	AttachedTo    AttachedTo `json:"attached_to,omitempty"`
	VlanID        string     `json:"vlan_id"`
	VlanIP        string     `json:"vlan_ip"`
	Initiator     string     `json:"initiator"`
	DiscoveryIP   string     `json:"discovery_ip"`
	Region        Region     `json:"region"`
}

type Client

type Client struct {
	BaseURL *url.URL

	UserAgent string
	AuthToken string

	Teams       TeamsService
	Plans       PlansService
	Images      ImagesService
	Projects    ProjectsService
	SSHKeys     SSHKeysService
	Servers     ServersService
	IPAddresses IpAddressesService
	Storages    StoragesService
	Regions     RegionsService
	Users       UsersService
	Backups     BackupsService
	// contains filtered or unexported fields
}

Client returns struct for client

func NewClient

func NewClient(opts ...ClientOpt) (*Client, error)

NewClient initialization

func (*Client) MakeRequest

func (c *Client) MakeRequest(method, path string, body, v interface{}) (*Response, error)

MakeRequest makes request to API

type ClientOpt

type ClientOpt func(*options) error

func WithAuthToken

func WithAuthToken(authToken string) ClientOpt

WithAuthToken use provided auth token to make requests, defaults to environment variable CHERRY_AUTH_TOKEN

func WithHTTPClient

func WithHTTPClient(client *http.Client) ClientOpt

WithHTTPClient use client as the http.Client to make API requests

func WithURL

func WithURL(url string) ClientOpt

WithURL use url as endpoint for API requests

func WithUserAgent

func WithUserAgent(ua string) ClientOpt

WithUserAgent set user agent when making requests

type Cpus

type Cpus struct {
	Count     int     `json:"count,omitempty"`
	Name      string  `json:"name,omitempty"`
	Cores     int     `json:"cores,omitempty"`
	Frequency float32 `json:"frequency,omitempty"`
	Unit      string  `json:"unit,omitempty"`
}

Cpus fields

type CreateBackup added in v3.1.0

type CreateBackup struct {
	ServerID       int    `json:"server_id,omitempty"`
	BackupPlanSlug string `json:"slug"`
	RegionSlug     string `json:"region"`
	SSHKey         string `json:"ssh_key,omitempty"`
}

type CreateIPAddress

type CreateIPAddress struct {
	Region        string             `json:"region,omitempty"`
	PtrRecord     string             `json:"ptr_record,omitempty"`
	ARecord       string             `json:"a_record,omitempty"`
	RoutedTo      string             `json:"routed_to,omitempty"`
	AssignedTo    string             `json:"assigned_to,omitempty"`
	TargetedTo    string             `json:"targeted_to,omitempty"`
	Tags          *map[string]string `json:"tags,omitempty"`
	DDoSScrubbing bool               `json:"ddos_scrubbing,omitempty"`
}

CreateIPAddress fields for adding addition IP address

type CreateProject

type CreateProject struct {
	Name string `json:"name,omitempty"`
	Bgp  bool   `json:"bgp,omitempty"`
}

CreateProject fields for adding new project with specified name

type CreateSSHKey

type CreateSSHKey struct {
	Label string `json:"label"`
	Key   string `json:"key"`
}

CreateSSHKey fields for adding new key with label and raw key

type CreateServer

type CreateServer struct {
	ProjectID       int                `json:"project_id"`
	Plan            string             `json:"plan"`
	Hostname        string             `json:"hostname,omitempty"`
	Image           string             `json:"image,omitempty"`
	Region          string             `json:"region"`
	SSHKeys         []string           `json:"ssh_keys,omitempty"`
	IPAddresses     []string           `json:"ip_addresses,omitempty"`
	UserData        string             `json:"user_data,omitempty"`
	Tags            *map[string]string `json:"tags,omitempty"`
	SpotInstance    bool               `json:"spot_market"`
	OSPartitionSize int                `json:"os_partition_size,omitempty"`
}

CreateServer fields for ordering new server

type CreateStorage

type CreateStorage struct {
	ProjectID   int    `json:"project_id"`
	Description string `json:"description"`
	Size        int    `json:"size"`
	Region      string `json:"region"`
}

type CreateTeam

type CreateTeam struct {
	Name     string `json:"name,omitempty"`
	Type     string `json:"type,omitempty"`
	Currency string `json:"currency,omitempty"`
}

type Credit

type Credit struct {
	Account   CreditDetails `json:"account,omitempty"`
	Promo     CreditDetails `json:"promo,omitempty"`
	Resources Resources     `json:"resources,omitempty"`
}

type CreditDetails

type CreditDetails struct {
	Remaining float32 `json:"remaining,omitempty"`
	Usage     float32 `json:"usage,omitempty"`
	Currency  string  `json:"currency,omitempty"`
}

type EnabledMethods added in v3.1.0

type EnabledMethods struct {
	BORG bool `json:"borg,omitempty"`
	FTP  bool `json:"ftp,omitempty"`
	NFS  bool `json:"nfs,omitempty"`
	SMB  bool `json:"smb,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Response    *http.Response
	Errors      []string `json:"errors"`
	SingleError string   `json:"error"`
}

ErrorResponse fields

type GetOptions

type GetOptions struct {
	Fields []string `url:"fields,omitempty,comma"`
	Limit  int      `url:"limit,omitempty"`
	Offset int      `url:"offset,omitempty"`
	Type   []string `url:"type,ommitempty"`
	Status []string `url:"status,ommitempty"`
	// QueryParams for API URL, used for arbitrary filters
	QueryParams map[string]string `url:"-"`
}

func (*GetOptions) Encode

func (g *GetOptions) Encode() string

func (*GetOptions) WithQuery

func (g *GetOptions) WithQuery(apiPath string) string

type IPAddress

type IPAddress struct {
	ID            string             `json:"id,omitempty"`
	Address       string             `json:"address,omitempty"`
	AddressFamily int                `json:"address_family,omitempty"`
	Cidr          string             `json:"cidr,omitempty"`
	Gateway       string             `json:"gateway,omitempty"`
	Type          string             `json:"type,omitempty"`
	Region        Region             `json:"region,omitempty"`
	RoutedTo      RoutedTo           `json:"routed_to,omitempty"`
	AssignedTo    AssignedTo         `json:"assigned_to,omitempty"`
	TargetedTo    AssignedTo         `json:"targeted_to,omitempty"`
	Project       Project            `json:"project,omitempty"`
	PtrRecord     string             `json:"ptr_record,omitempty"`
	ARecord       string             `json:"a_record,omitempty"`
	Tags          *map[string]string `json:"tags,omitempty"`
	DDoSScrubbing bool               `json:"ddos_scrubbing,omitempty"`
	Href          string             `json:"href,omitempty"`
}

IPAddresses fields

type IPsClient

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

IPClient paveldi client

func (*IPsClient) Assign

func (i *IPsClient) Assign(ipID string, request *AssignIPAddress) (IPAddress, *Response, error)

func (*IPsClient) Create

func (i *IPsClient) Create(projectID int, request *CreateIPAddress) (IPAddress, *Response, error)

Create function orders new floating IP address

func (*IPsClient) Get

func (i *IPsClient) Get(ipID string, opts *GetOptions) (IPAddress, *Response, error)

List func lists teams

func (*IPsClient) List

func (i *IPsClient) List(projectID int, opts *GetOptions) ([]IPAddress, *Response, error)

List func lists ip addresses

func (*IPsClient) Remove

func (i *IPsClient) Remove(ipID string) (*Response, error)

Remove function removes existing project IP address

func (*IPsClient) Unassign

func (i *IPsClient) Unassign(ipID string) (*Response, error)

func (*IPsClient) Update

func (i *IPsClient) Update(ipID string, request *UpdateIPAddress) (IPAddress, *Response, error)

Update function updates existing IP address

type Image

type Image struct {
	ID      int       `json:"id,omitempty"`
	Name    string    `json:"name,omitempty"`
	Slug    string    `json:"slug,omitempty"`
	Pricing []Pricing `json:"pricing,omitempty"`
}

type ImagesClient

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

func (*ImagesClient) List

func (i *ImagesClient) List(plan string, opts *GetOptions) ([]Image, *Response, error)

List func lists images

type ImagesService

type ImagesService interface {
	List(plan string, opts *GetOptions) ([]Image, *Response, error)
}

ImagesService is an interface for interfacing with the the Images endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Images

type IpAddressesService

type IpAddressesService interface {
	List(projectID int, opts *GetOptions) ([]IPAddress, *Response, error)
	Get(ipID string, opts *GetOptions) (IPAddress, *Response, error)
	Create(projectID int, request *CreateIPAddress) (IPAddress, *Response, error)
	Remove(ipID string) (*Response, error)
	Update(ipID string, request *UpdateIPAddress) (IPAddress, *Response, error)
	Assign(ipID string, request *AssignIPAddress) (IPAddress, *Response, error)
	Unassign(ipID string) (*Response, error)
}

IpAddressesService is an interface for interfacing with the the Server endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Ip-Addresses

type Membership added in v3.0.1

type Membership struct {
	ID       int       `json:"id,omitempty"`
	Roles    []string  `json:"roles,omitempty"`
	User     User      `json:"user,omitempty"`
	Projects []Project `json:"projects,omitempty"`
	Href     string    `json:"href,omitempty"`
}

type Memory

type Memory struct {
	Count int    `json:"count,omitempty"`
	Total int    `json:"total,omitempty"`
	Unit  string `json:"unit,omitempty"`
	Name  string `json:"name,omitempty"`
}

Memory fields

type Meta

type Meta struct {
	Total int
}

type Nics

type Nics struct {
	Name string `json:"name,omitempty"`
}

Nics fields

type Plan

type Plan struct {
	ID               int                `json:"id,omitempty"`
	Name             string             `json:"name,omitempty"`
	Slug             string             `json:"slug,omitempty"`
	Custom           bool               `json:"custom,omitempty"`
	Type             string             `json:"type,omitempty"`
	Specs            Specs              `json:"specs,omitempty"`
	Pricing          []Pricing          `json:"pricing,omitempty"`
	AvailableRegions []AvailableRegions `json:"available_regions,omitempty"`
}

type PlansClient

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

func (*PlansClient) List

func (p *PlansClient) List(teamID int, opts *GetOptions) ([]Plan, *Response, error)

List func lists plans

type PlansService

type PlansService interface {
	List(teamID int, opts *GetOptions) ([]Plan, *Response, error)
}

PlansService is an interface for interfacing with the Plan endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Plans

type PowerState

type PowerState struct {
	Power string `json:"power"`
}

PowerState fields

type Pricing

type Pricing struct {
	Price    float32 `json:"price,omitempty"`
	Taxed    bool    `json:"taxed,omitempty"`
	Currency string  `json:"currency,omitempty"`
	Unit     string  `json:"unit,omitempty"`
}

type Project

type Project struct {
	ID   int        `json:"id,omitempty"`
	Name string     `json:"name,omitempty"`
	Bgp  ProjectBGP `json:"bgp,omitempty"`
	Href string     `json:"href,omitempty"`
}

type ProjectBGP

type ProjectBGP struct {
	Enabled  bool `json:"enabled,omitempty"`
	LocalASN int  `json:"local_asn,omitempty"`
}

type ProjectsClient

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

func (*ProjectsClient) Create

func (p *ProjectsClient) Create(teamID int, request *CreateProject) (Project, *Response, error)

Create func will create new Project for specified team

func (*ProjectsClient) Delete

func (p *ProjectsClient) Delete(projectID int) (*Response, error)

Delete func will delete a project

func (*ProjectsClient) Get

func (p *ProjectsClient) Get(projectID int, opts *GetOptions) (Project, *Response, error)

func (*ProjectsClient) List

func (p *ProjectsClient) List(teamID int, opts *GetOptions) ([]Project, *Response, error)

List func lists projects

func (*ProjectsClient) ListSSHKeys

func (p *ProjectsClient) ListSSHKeys(projectID int, opts *GetOptions) ([]SSHKey, *Response, error)

func (*ProjectsClient) Update

func (p *ProjectsClient) Update(projectID int, request *UpdateProject) (Project, *Response, error)

Update func will update a project

type ProjectsService

type ProjectsService interface {
	List(teamID int, opts *GetOptions) ([]Project, *Response, error)
	Get(projectID int, opts *GetOptions) (Project, *Response, error)
	Create(teamID int, request *CreateProject) (Project, *Response, error)
	Update(projectID int, request *UpdateProject) (Project, *Response, error)
	ListSSHKeys(projectID int, opts *GetOptions) ([]SSHKey, *Response, error)
	Delete(projectID int) (*Response, error)
}

ProjectsService is an interface for interfacing with the Projects endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Projects

type Raid

type Raid struct {
	Name string `json:"name,omitempty"`
}

Raid fields

type Region

type Region struct {
	ID         int       `json:"id,omitempty"`
	Name       string    `json:"name,omitempty"`
	Slug       string    `json:"slug,omitempty"`
	RegionIso2 string    `json:"region_iso_2,omitempty"`
	BGP        RegionBGP `json:"bgp,omitempty"`
	Location   string    `json:"location,omitempty"`
	Href       string    `json:"href,omitempty"`
}

Region fields

type RegionBGP

type RegionBGP struct {
	Hosts []string `json:"hosts,omitempty"`
	Asn   int      `json:"asn,omitempty"`
}

type RegionsClient

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

func (*RegionsClient) Get

func (i *RegionsClient) Get(region string, opts *GetOptions) (Region, *Response, error)

func (*RegionsClient) List

func (i *RegionsClient) List(opts *GetOptions) ([]Region, *Response, error)

type RegionsService

type RegionsService interface {
	List(opts *GetOptions) ([]Region, *Response, error)
	Get(region string, opts *GetOptions) (Region, *Response, error)
}

RegionsService is an interface for interfacing with the the Images endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Regions

type ReinstallServer

type ReinstallServer struct {
	ServerAction
	*ReinstallServerFields
}

type ReinstallServerFields

type ReinstallServerFields struct {
	Image           string   `json:"image"`
	Hostname        string   `json:"hostname,omitempty"`
	Password        string   `json:"password"`
	SSHKeys         []string `json:"ssh_key,omitempty"`
	UserData        string   `json:"user_data,omitempty"`
	OSPartitionSize int      `json:"os_partition_size,omitempty"`
}

type RemainingTime added in v3.0.1

type RemainingTime struct {
	Time int    `json:"time,omitempty"`
	Unit string `json:"unit,omitempty"`
}

type Resources

type Resources struct {
	Pricing   Pricing       `json:"pricing,omitempty"`
	Remaining RemainingTime `json:"remaining,omitempty"`
}

type Response

type Response struct {
	*http.Response
	Meta
}

Response is the http response from api calls

type RoutedTo

type RoutedTo struct {
	ID            string `json:"id,omitempty"`
	Address       string `json:"address,omitempty"`
	AddressFamily int    `json:"address_family,omitempty"`
	Cidr          string `json:"cidr,omitempty"`
	Gateway       string `json:"gateway,omitempty"`
	Type          string `json:"type,omitempty"`
	Region        Region `json:"region,omitempty"`
}

RoutedTo fields

type Rule added in v3.1.0

type Rule struct {
	IPAddress      IPAddress      `json:"ip,omitempty"`
	EnabledMethods EnabledMethods `json:"methods,omitempty"`
}

type SSHKey

type SSHKey struct {
	ID          int    `json:"id,omitempty"`
	Label       string `json:"label,omitempty"`
	Key         string `json:"key,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
	User        User   `json:"user,omitempty"`
	Updated     string `json:"updated,omitempty"`
	Created     string `json:"created,omitempty"`
	Href        string `json:"href,omitempty"`
}

SSHKeys fields for return values after creation

type SSHKeysClient

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

func (*SSHKeysClient) Create

func (s *SSHKeysClient) Create(request *CreateSSHKey) (SSHKey, *Response, error)

Create adds new SSH key

func (*SSHKeysClient) Delete

func (s *SSHKeysClient) Delete(sshKeyID int) (SSHKey, *Response, error)

Delete removes desired SSH key by its ID

func (*SSHKeysClient) Get

func (s *SSHKeysClient) Get(sshKeyID int, opts *GetOptions) (SSHKey, *Response, error)

func (*SSHKeysClient) List

func (s *SSHKeysClient) List(opts *GetOptions) ([]SSHKey, *Response, error)

List all available ssh keys

func (*SSHKeysClient) Update

func (s *SSHKeysClient) Update(sshKeyID int, request *UpdateSSHKey) (SSHKey, *Response, error)

Update function updates keys Label or key itself

type SSHKeysService

type SSHKeysService interface {
	List(opts *GetOptions) ([]SSHKey, *Response, error)
	Get(sshKeyID int, opts *GetOptions) (SSHKey, *Response, error)
	Create(request *CreateSSHKey) (SSHKey, *Response, error)
	Delete(sshKeyID int) (SSHKey, *Response, error)
	Update(sshKeyID int, request *UpdateSSHKey) (SSHKey, *Response, error)
}

SSHKeysService is an interface for interfacing with the the SSH keys endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/SshKeys

type Server

type Server struct {
	ID               int               `json:"id,omitempty"`
	Name             string            `json:"name,omitempty"`
	Href             string            `json:"href,omitempty"`
	BMC              BMC               `json:"bmc,omitempty"`
	Hostname         string            `json:"hostname,omitempty"`
	Username         string            `json:"username,omitempty"`
	Password         string            `json:"password"`
	Image            string            `json:"image,omitempty"`
	SpotInstance     bool              `json:"spot_instance"`
	BGP              ServerBGP         `json:"bgp,omitempty"`
	Project          Project           `json:"project,omitempty"`
	Region           Region            `json:"region,omitempty"`
	State            string            `json:"state,omitempty"`
	Plan             Plan              `json:"plan,omitempty"`
	AvailableRegions AvailableRegions  `json:"availableregions,omitempty"`
	Pricing          Pricing           `json:"pricing,omitempty"`
	IPAddresses      []IPAddress       `json:"ip_addresses,omitempty"`
	SSHKeys          []SSHKey          `json:"ssh_keys,omitempty"`
	Tags             map[string]string `json:"tags,omitempty"`
	Storage          BlockStorage      `json:"storage,omitempty"`
	Backup           BackupStorage     `json:"backup_storage,omitempty"`
	Created          string            `json:"created_at,omitempty"`
	TerminationDate  string            `json:"termination_date,omitempty"`
}

Server response object

type ServerAction

type ServerAction struct {
	Type string `json:"type"`
}

ServerAction fields for performed action on server

type ServerBGP

type ServerBGP struct {
	Enabled   bool       `json:"enabled"`
	Available bool       `json:"available,omitempty"`
	Status    string     `json:"status,omitempty"`
	Routers   int        `json:"routers,omitempty"`
	Connected int        `json:"connected,omitempty"`
	Limit     int        `json:"limit,omitempty"`
	Active    int        `json:"active,omitempty"`
	Routes    []BGPRoute `json:"routes,omitempty"`
	Updated   string     `json:"updated,omitempty"`
}

type ServersClient

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

func (*ServersClient) Create

func (s *ServersClient) Create(request *CreateServer) (Server, *Response, error)

func (*ServersClient) Delete

func (s *ServersClient) Delete(serverID int) (Server, *Response, error)

func (*ServersClient) Get

func (s *ServersClient) Get(serverID int, opts *GetOptions) (Server, *Response, error)

func (*ServersClient) List

func (s *ServersClient) List(projectID int, opts *GetOptions) ([]Server, *Response, error)

List func lists teams

func (*ServersClient) ListSSHKeys

func (s *ServersClient) ListSSHKeys(serverID int, opts *GetOptions) ([]SSHKey, *Response, error)

func (*ServersClient) PowerOff

func (s *ServersClient) PowerOff(serverID int) (Server, *Response, error)

PowerOff function turns server off

func (*ServersClient) PowerOn

func (s *ServersClient) PowerOn(serverID int) (Server, *Response, error)

PowerOn function turns server on

func (*ServersClient) PowerState

func (s *ServersClient) PowerState(serverID int) (PowerState, *Response, error)

func (*ServersClient) Reboot

func (s *ServersClient) Reboot(serverID int) (Server, *Response, error)

Reboot function restarts desired server

func (*ServersClient) Reinstall

func (s *ServersClient) Reinstall(serverID int, fields *ReinstallServerFields) (Server, *Response, error)

func (*ServersClient) ResetBMCPassword added in v3.2.0

func (s *ServersClient) ResetBMCPassword(serverID int) (Server, *Response, error)

func (*ServersClient) Update

func (s *ServersClient) Update(serverID int, request *UpdateServer) (Server, *Response, error)

type ServersService

type ServersService interface {
	List(projectID int, opts *GetOptions) ([]Server, *Response, error)
	Get(serverID int, opts *GetOptions) (Server, *Response, error)
	PowerOff(serverID int) (Server, *Response, error)
	PowerOn(serverID int) (Server, *Response, error)
	Create(request *CreateServer) (Server, *Response, error)
	Delete(serverID int) (Server, *Response, error)
	PowerState(serverID int) (PowerState, *Response, error)
	Reboot(serverID int) (Server, *Response, error)
	Update(serverID int, request *UpdateServer) (Server, *Response, error)
	Reinstall(serverID int, fields *ReinstallServerFields) (Server, *Response, error)
	ListSSHKeys(serverID int, opts *GetOptions) ([]SSHKey, *Response, error)
	ResetBMCPassword(serverID int) (Server, *Response, error)
}

ServersService is an interface for interfacing with the the Server endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Servers

type Specs

type Specs struct {
	Cpus      Cpus      `json:"cpus,omitempty"`
	Memory    Memory    `json:"memory,omitempty"`
	Storage   []Storage `json:"storage,omitempty"`
	Raid      Raid      `json:"raid,omitempty"`
	Nics      Nics      `json:"nics,omitempty"`
	Bandwidth Bandwidth `json:"bandwidth,omitempty"`
}

Specs specifies fields for specs

type Storage

type Storage struct {
	Count int     `json:"count,omitempty"`
	Name  string  `json:"name,omitempty"`
	Size  float32 `json:"size,omitempty"`
	Unit  string  `json:"unit,omitempty"`
}

Storage fields

type StorageClient

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

type StoragesClient

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

func (*StoragesClient) Attach

func (s *StoragesClient) Attach(request *AttachTo) (BlockStorage, *Response, error)

func (*StoragesClient) Create

func (s *StoragesClient) Create(request *CreateStorage) (BlockStorage, *Response, error)

func (*StoragesClient) Delete

func (s *StoragesClient) Delete(storageID int) (*Response, error)

func (*StoragesClient) Detach

func (s *StoragesClient) Detach(storageID int) (*Response, error)

func (*StoragesClient) Get

func (s *StoragesClient) Get(storageID int, opts *GetOptions) (BlockStorage, *Response, error)

func (*StoragesClient) List

func (c *StoragesClient) List(projectID int, opts *GetOptions) ([]BlockStorage, *Response, error)

func (*StoragesClient) Update

func (s *StoragesClient) Update(request *UpdateStorage) (BlockStorage, *Response, error)

type StoragesService

type StoragesService interface {
	List(projectID int, opts *GetOptions) ([]BlockStorage, *Response, error)
	Get(storageID int, opts *GetOptions) (BlockStorage, *Response, error)
	Create(request *CreateStorage) (BlockStorage, *Response, error)
	Delete(storageID int) (*Response, error)
	Attach(request *AttachTo) (BlockStorage, *Response, error)
	Detach(storageID int) (*Response, error)
	Update(request *UpdateStorage) (BlockStorage, *Response, error)
}

StoragesService is an interface for interfacing with the Storages endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Storage

type Team

type Team struct {
	ID          int          `json:"id,omitempty"`
	Name        string       `json:"name,omitempty"`
	Credit      Credit       `json:"credit,omitempty"`
	Billing     Billing      `json:"billing,omitempty"`
	Projects    []Project    `json:"projects,omitempty"`
	Memberships []Membership `json:"memberships,omitempty"`
	Href        string       `json:"href,omitempty"`
}

type TeamsClient

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

func (*TeamsClient) Create

func (p *TeamsClient) Create(request *CreateTeam) (Team, *Response, error)

func (*TeamsClient) Delete

func (p *TeamsClient) Delete(teamID int) (*Response, error)

func (*TeamsClient) Get

func (p *TeamsClient) Get(teamID int, opts *GetOptions) (Team, *Response, error)

func (*TeamsClient) List

func (t *TeamsClient) List(opts *GetOptions) ([]Team, *Response, error)

List func lists teams

func (*TeamsClient) Update

func (p *TeamsClient) Update(teamID int, request *UpdateTeam) (Team, *Response, error)

type TeamsService

type TeamsService interface {
	List(opts *GetOptions) ([]Team, *Response, error)
	Get(teamID int, opts *GetOptions) (Team, *Response, error)
	Create(request *CreateTeam) (Team, *Response, error)
	Update(teamID int, request *UpdateTeam) (Team, *Response, error)
	Delete(teamID int) (*Response, error)
}

TeamsService is an interface for interfacing with the Teams endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Teams

type UpdateBackupMethod added in v3.1.0

type UpdateBackupMethod struct {
	BackupStorageID  int      `json:"id"`
	BackupMethodName string   `json:"name"`
	Enabled          bool     `json:"enabled"`
	Whitelist        []string `json:"whitelist"`
}

type UpdateBackupStorage added in v3.1.0

type UpdateBackupStorage struct {
	BackupStorageID int    `json:"id"`
	BackupPlanSlug  string `json:"slug,omitempty"`
	Password        string `json:"password,omitempty"`
	SSHKey          string `json:"ssh_key,omitempty"`
}

type UpdateIPAddress

type UpdateIPAddress struct {
	PtrRecord  string             `json:"ptr_record,omitempty"`
	ARecord    string             `json:"a_record,omitempty"`
	RoutedTo   string             `json:"routed_to,omitempty"`
	AssignedTo string             `json:"assigned_to,omitempty"`
	TargetedTo string             `json:"targeted_to,omitempty"`
	Tags       *map[string]string `json:"tags,omitempty"`
}

UpdateIPAddress fields for updating IP address

type UpdateProject

type UpdateProject struct {
	Name *string `json:"name,omitempty"`
	Bgp  *bool   `json:"bgp,omitempty"`
}

UpdateProject fields for updating a project with specified name

type UpdateSSHKey

type UpdateSSHKey struct {
	Label *string `json:"label,omitempty"`
	Key   *string `json:"key,omitempty"`
}

UpdateSSHKey fields for label or key update

type UpdateServer

type UpdateServer struct {
	Name     string             `json:"name,omitempty"`
	Hostname string             `json:"hostname,omitempty"`
	Tags     *map[string]string `json:"tags,omitempty"`
	Bgp      bool               `json:"bgp"`
}

UpdateServer fields for updating a server with specified tags

type UpdateStorage

type UpdateStorage struct {
	StorageID   int    `json:"storage_id"`
	Size        int    `json:"size"`
	Description string `json:"description,omitempty"`
}

type UpdateTeam

type UpdateTeam struct {
	Name     *string `json:"name,omitempty"`
	Type     *string `json:"type,omitempty"`
	Currency *string `json:"currency,omitempty"`
}

type User

type User struct {
	ID                    int    `json:"id,omitempty"`
	FirstName             string `json:"first_name,omitempty"`
	LastName              string `json:"last_name,omitempty"`
	Email                 string `json:"email,omitempty"`
	EmailVerified         bool   `json:"email_verified,omitempty"`
	Phone                 string `json:"phone,omitempty"`
	SecurityPhone         string `json:"security_phone,omitempty"`
	SecurityPhoneVerified bool   `json:"security_phone_verified,omitempty"`
	Href                  string `json:"href,omitempty"`
}

type UsersClient

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

func (*UsersClient) CurrentUser

func (s *UsersClient) CurrentUser(opts *GetOptions) (User, *Response, error)

func (*UsersClient) Get

func (s *UsersClient) Get(userID int, opts *GetOptions) (User, *Response, error)

type UsersService

type UsersService interface {
	CurrentUser(opts *GetOptions) (User, *Response, error)
	Get(userID int, opts *GetOptions) (User, *Response, error)
}

UsersService is an interface for interfacing with the the User endpoints of the CherryServers API See: https://api.cherryservers.com/doc/#tag/Users

type Vat

type Vat struct {
	Amount int    `json:"amount"`
	Number string `json:"number,omitempty"`
	Valid  bool   `json:"valid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL