flow

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 12 Imported by: 1

README

GoClient (deprecated)

Deprecation Notice: this is the old api integration which is deprecated since February 2021 and will be removed in a later version. Do not use this for new integrations.

Example

package main

import (
  "context"
  "fmt"

  "github.com/flowswiss/goclient/flow"
)

func main() {
  client := flow.NewClientWithToken("your-application-token")

  servers, _, err := client.Server.List(context.Background(), flow.PaginationOptions{
    Page:    1,
    PerPage: 5,
  })

  if err != nil {
    fmt.Println("error listing servers: ", err)
  }

  for _, server := range servers {
    fmt.Println("found server with id ", server.Id)
  }
}

Documentation

Index

Constants

View Source
const (
	VolumeStatusAvailable = Id(1)
	VolumeStatusInUse     = Id(2)
	VolumeStatusWorking   = Id(3)
	VolumeStatusError     = Id(4)
)
View Source
const (
	ErrorUnsupportedContentType = SystemError("received unsupported content type")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachElasticIp

type AttachElasticIp struct {
	ElasticIpId        Id `json:"elastic_ip_id"`
	NetworkInterfaceId Id `json:"network_interface_id"`
}

type AttachedNetworkInterface

type AttachedNetworkInterface struct {
	Id        Id     `json:"id"`
	PrivateIp string `json:"private_ip"`
	PublicIp  string `json:"public_ip"`
}

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	HttpClient *http.Client

	// General entities
	Product  ProductService
	Location LocationService
	Module   ModuleService
	Image    ImageService

	// Compute
	Server           ServerService
	ServerAttachment ServerAttachmentService
	KeyPair          KeyPairService
	Network          NetworkService
	ElasticIp        ElasticIpService
	Volume           VolumeService
	VolumeAction     VolumeActionService
	Snapshot         SnapshotService

	// Other
	Order OrderService
}

func NewClient

func NewClient(httpClient *http.Client) *Client

func NewClientWithToken

func NewClientWithToken(token string) *Client

func (*Client) Do

func (c *Client) Do(req *http.Request, val interface{}) (*Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method string, path string, body interface{}) (*http.Request, error)

type DateTime

type DateTime time.Time

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

func (DateTime) String

func (d DateTime) String() string

func (DateTime) Time

func (d DateTime) Time() time.Time

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(b []byte) error

type DeploymentFee

type DeploymentFee struct {
	Location        Location `json:"location"`
	Price           float64  `json:"price"`
	FreeDeployments int      `json:"free_deployments"`
}

type ElasticIp

type ElasticIp struct {
	Id               Id               `json:"id"`
	Product          ElasticIpProduct `json:"product"`
	Location         Location         `json:"location"`
	Price            float64          `json:"price"`
	PublicIp         string           `json:"public_ip"`
	PrivateIp        string           `json:"private_ip"`
	AttachedInstance *Server          `json:"attached_instance"`
}

type ElasticIpCreate

type ElasticIpCreate struct {
	LocationId Id `json:"location_id"`
}

type ElasticIpProduct

type ElasticIpProduct struct {
	Id   Id     `json:"id"`
	Name string `json:"name"`
	Type string `json:"type"`
}

type ElasticIpService

type ElasticIpService interface {
	List(ctx context.Context, options PaginationOptions) ([]*ElasticIp, *Response, error)
	Create(ctx context.Context, data *ElasticIpCreate) (*ElasticIp, *Response, error)
	Delete(ctx context.Context, id Id) (*Response, error)
}

type ErrorResponse

type ErrorResponse struct {
	Response  *http.Response
	Message   string
	RequestID string
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type Id

type Id uint

func ParseIdentifier

func ParseIdentifier(identifier string) Id

func (Id) String

func (i Id) String() string

func (Id) Valid

func (i Id) Valid() bool

type Image

type Image struct {
	Id                 Id         `json:"id"`
	OperatingSystem    string     `json:"os"`
	Version            string     `json:"version"`
	Key                string     `json:"key"`
	Category           string     `json:"category"`
	Type               string     `json:"type"`
	MinRootDiskSize    int        `json:"min_root_disk_size"`
	Sorting            int        `json:"sorting"`
	RequiredLicenses   []*Product `json:"required_licenses"`
	AvailableLocations []Id       `json:"available_locations"`
}

func (*Image) AvailableAt

func (i *Image) AvailableAt(location *Location) bool

type ImageService

type ImageService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Image, *Response, error)
	Get(ctx context.Context, id Id) (*Image, *Response, error)
}

type KeyPair

type KeyPair struct {
	Id          Id     `json:"id"`
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
}

type KeyPairCreate

type KeyPairCreate struct {
	Name      string `json:"name"`
	PublicKey string `json:"public_key"`
}

type KeyPairService

type KeyPairService interface {
	List(ctx context.Context, options PaginationOptions) ([]*KeyPair, *Response, error)
	Create(ctx context.Context, data *KeyPairCreate) (*KeyPair, *Response, error)
	Delete(ctx context.Context, id Id) (*Response, error)
}
type Links struct {
	First   string
	Last    string
	Current string
	Prev    string
	Next    string
}

type Location

type Location struct {
	Id   Id     `json:"id"`
	Name string `json:"name"`
	Key  string `json:"key"`
	City string `json:"city"`
}

type LocationService

type LocationService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Location, *Response, error)
	Get(ctx context.Context, id Id) (*Location, *Response, error)
}

type Module

type Module struct {
	Id        Id          `json:"id"`
	Name      string      `json:"name"`
	Parent    *Module     `json:"parent"`
	Sorting   int         `json:"sorting"`
	Locations []*Location `json:"locations"`
}

func (*Module) AvailableAt

func (m *Module) AvailableAt(location *Location) bool

type ModuleService

type ModuleService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Module, *Response, error)
	Get(ctx context.Context, id Id) (*Module, *Response, error)
}

type Network

type Network struct {
	Id                  Id       `json:"id"`
	Name                string   `json:"name"`
	Description         string   `json:"description"`
	Cidr                string   `json:"cidr"`
	Location            Location `json:"location"`
	DomainNameServers   []string `json:"domain_name_servers"`
	AllocationPoolStart string   `json:"allocation_pool_start"`
	AllocationPoolEnd   string   `json:"allocation_pool_end"`
	GatewayIp           string   `json:"gateway_ip"`
	UsedIps             int      `json:"used_ips"`
	TotalIps            int      `json:"total_ips"`
}

type NetworkCreate

type NetworkCreate struct {
	Name                string   `json:"name"`
	Description         string   `json:"description"`
	LocationId          Id       `json:"location_id"`
	DomainNameServer    []string `json:"domain_name_server"`
	Cidr                string   `json:"cidr"`
	AllocationPoolStart string   `json:"allocation_pool_start"`
	AllocationPoolEnd   string   `json:"allocation_pool_end"`
	GatewayIp           string   `json:"gateway_ip"`
}

type NetworkInterface

type NetworkInterface struct {
	Id                Id               `json:"id"`
	PrivateIp         string           `json:"private_ip"`
	MacAddress        string           `json:"mac_address"`
	Network           *Network         `json:"network"`
	AttachedElasticIp *ElasticIp       `json:"attached_elastic_ip"`
	SecurityGroups    []*SecurityGroup `json:"security_groups"`
	Security          bool             `json:"security"`
}

type NetworkInterfaceCreate

type NetworkInterfaceCreate struct {
	NetworkId Id     `json:"network_id"`
	PrivateIp string `json:"private_ip"`
}

type NetworkInterfaceService

type NetworkInterfaceService interface {
	List(ctx context.Context, options PaginationOptions) ([]*NetworkInterface, *Response, error)
	Create(ctx context.Context, data *NetworkInterfaceCreate) (*NetworkInterface, *Response, error)
	Delete(ctx context.Context, id Id) (*Response, error)
}

type NetworkService

type NetworkService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Network, *Response, error)
	Get(ctx context.Context, id Id) (*Network, *Response, error)
	Create(ctx context.Context, data *NetworkCreate) (*Network, *Response, error)
	Delete(ctx context.Context, id Id) (*Response, error)
}

type Order

type Order struct {
	Id     Id          `json:"id"`
	Status OrderStatus `json:"status"`
}

type OrderService

type OrderService interface {
	Get(ctx context.Context, id Id) (*Order, *Response, error)
}

type OrderStatus

type OrderStatus struct {
	Id   Id     `json:"id"`
	Name string `json:"name"`
}

type Ordering

type Ordering struct {
	Ref string `json:"ref"`
}

func (*Ordering) Id

func (o *Ordering) Id() (Id, error)

type Pagination

type Pagination struct {
	Count      int
	Limit      int
	TotalCount int

	CurrentPage int
	TotalPages  int

	Links Links
}

type PaginationOptions

type PaginationOptions struct {
	Page     int `url:"page,omitempty"`
	PerPage  int `url:"per_page,omitempty"`
	NoFilter int `url:"no_filter,omitempty"`
}

type Product

type Product struct {
	Id             Id                    `json:"id"`
	Name           string                `json:"product_name"`
	Type           ProductType           `json:"type"`
	Visibility     string                `json:"visibility"`
	UsageCycle     ProductUsageCycle     `json:"usage_cycle"`
	Items          []*ProductItem        `json:"items"`
	Price          float64               `json:"price"`
	Availability   []ProductAvailability `json:"availability"`
	Category       string                `json:"category"`
	DeploymentFees []*DeploymentFee      `json:"deployment_fees"`
}

func (*Product) AvailableAt

func (p *Product) AvailableAt(location *Location) bool

func (*Product) FindItem

func (p *Product) FindItem(id Id) *ProductItem

type ProductAvailability

type ProductAvailability struct {
	Location  Location `json:"location"`
	Available int      `json:"available"`
}

type ProductItem

type ProductItem struct {
	Id          Id     `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Amount      int    `json:"amount"`
}

type ProductService

type ProductService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Product, *Response, error)
	ListByType(ctx context.Context, options PaginationOptions, t string) ([]*Product, *Response, error)
	Get(ctx context.Context, id Id) (*Product, *Response, error)
}

type ProductType

type ProductType struct {
	Id   Id     `json:"id"`
	Name string `json:"name"`
	Key  string `json:"key"`
}

type ProductUsageCycle

type ProductUsageCycle struct {
	Id       Id     `json:"id"`
	Name     string `json:"name"`
	Duration int    `json:"duration"`
}

type Response

type Response struct {
	*http.Response
	Pagination
}

type SecurityGroup

type SecurityGroup struct {
	Id   Id     `json:"id"`
	Name string `json:"name"`
}

type Server

type Server struct {
	Id       Id                         `json:"id"`
	Name     string                     `json:"name"`
	Status   ServerStatus               `json:"status"`
	Image    Image                      `json:"image"`
	Product  Product                    `json:"product"`
	Location Location                   `json:"location"`
	Networks []*ServerNetworkAttachment `json:"networks"`
	KeyPair  KeyPair                    `json:"key_pair"`
}

func (*Server) GetFirstPublicIp

func (s *Server) GetFirstPublicIp() string

type ServerAction

type ServerAction struct {
	Id      Id     `json:"id"`
	Name    string `json:"name"`
	Command string `json:"command"`
	Sorting int    `json:"sorting"`
}

type ServerAttachmentService

type ServerAttachmentService interface {
	ListAttachedElasticIps(ctx context.Context, server Id, options PaginationOptions) ([]*ElasticIp, *Response, error)
	AttachElasticIp(ctx context.Context, server Id, data *AttachElasticIp) (*ElasticIp, *Response, error)
	DetachElasticIp(ctx context.Context, server Id, elasticIp Id) (*Response, error)
}

type ServerCreate

type ServerCreate struct {
	Name             string `json:"name"`
	LocationId       Id     `json:"location_id"`
	ImageId          Id     `json:"image_id"`
	ProductId        Id     `json:"product_id"`
	AttachExternalIp bool   `json:"attach_external_ip"`
	NetworkId        Id     `json:"network_id"`
	PrivateIp        string `json:"private_ip,omitempty"`
	KeyPairId        Id     `json:"key_pair_id,omitempty"`
	Password         string `json:"password,omitempty"`
	CloudInit        string `json:"cloud_init,omitempty"`
}

type ServerNetworkAttachment

type ServerNetworkAttachment struct {
	Network
	Interfaces []AttachedNetworkInterface `json:"network_interfaces"`
}

type ServerService

type ServerService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Server, *Response, error)
	Get(ctx context.Context, id Id) (*Server, *Response, error)
	Create(ctx context.Context, data *ServerCreate) (*Ordering, *Response, error)
	Update(ctx context.Context, id Id) (*Server, *Response, error)
	Delete(ctx context.Context, id Id) (*Response, error)

	RunAction(ctx context.Context, id Id, command string) (*Server, *Response, error)
}

type ServerStatus

type ServerStatus struct {
	Id      Id             `json:"id"`
	Name    string         `json:"name"`
	Key     string         `json:"key"`
	Actions []ServerAction `json:"actions"`
}

type SnaphostStatusKey added in v0.0.1

type SnaphostStatusKey = string
const (
	SnapshotStatusKeyAvailable SnaphostStatusKey = "available"
	SnapshotStatusKeyCreating  SnaphostStatusKey = "creating"
	SnapshotStatusKeyError     SnaphostStatusKey = "error"
)

type Snapshot

type Snapshot struct {
	Id        Id       `json:"id"`
	Name      string   `json:"name"`
	Size      int      `json:"size"`
	Status    Status   `json:"status"`
	Volume    Volume   `json:"volume"`
	Product   Product  `json:"product"`
	CreatedAt DateTime `json:"created_at"`
}

func (*Snapshot) IsAvailable added in v0.0.1

func (snapshot *Snapshot) IsAvailable() bool

type SnapshotCreate

type SnapshotCreate struct {
	Name     string `json:"name"`
	VolumeId Id     `json:"volume_id"`
}

type SnapshotService

type SnapshotService interface {
	Get(ctx context.Context, snapshotId Id) (*Snapshot, *Response, error)
	List(ctx context.Context, options PaginationOptions) ([]*Snapshot, *Response, error)
	Create(ctx context.Context, data *SnapshotCreate) (*Snapshot, *Response, error)
	Delete(ctx context.Context, snapshotId Id) (*Response, error)
}

type Status added in v0.0.1

type Status struct {
	Id   Id     `json:"id"`
	Name string `json:"name"`
	Key  string `json:"key"`
}

type SystemError

type SystemError string

func (SystemError) Error

func (e SystemError) Error() string

type Volume

type Volume struct {
	Id           Id           `json:"id"`
	Product      Product      `json:"product"`
	Location     Location     `json:"location"`
	Status       VolumeStatus `json:"status"`
	Name         string       `json:"name"`
	Size         int          `json:"size"`
	SerialNumber string       `json:"serial"`
	Snapshots    int          `json:"snapshots"`
	Bootable     bool         `json:"bootable"`
	RootVolume   bool         `json:"root_volume"`
	AttachedTo   *Server      `json:"instance"`
	CreatedAt    DateTime     `json:"created_at"`
}

type VolumeActionService

type VolumeActionService interface {
	Attach(ctx context.Context, volumeId Id, data *VolumeAttach) (*Volume, *Response, error)
	Detach(ctx context.Context, volumeId Id, serverId Id) (*Response, error)
}

type VolumeAttach

type VolumeAttach struct {
	ServerId Id `json:"instance_id"`
}

type VolumeCreate

type VolumeCreate struct {
	Name       string `json:"name"`
	Size       int    `json:"size"`
	LocationId Id     `json:"location_id"`
	SnapshotId Id     `json:"snapshot_id,omitempty"`
	InstanceId Id     `json:"instance_id,omitempty"`
}

type VolumeExpand

type VolumeExpand struct {
	Size int `json:"size"`
}

type VolumeService

type VolumeService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Volume, *Response, error)
	Get(ctx context.Context, id Id) (*Volume, *Response, error)
	Create(ctx context.Context, data *VolumeCreate) (*Volume, *Response, error)
	Delete(ctx context.Context, id Id) (*Response, error)

	Expand(ctx context.Context, id Id, data *VolumeExpand) (*Volume, *Response, error)
}

type VolumeStatus

type VolumeStatus struct {
	Id   Id     `json:"id"`
	Name string `json:"name"`
	Key  string `json:"key"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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