flow

package
v0.0.0-...-950a29a Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionMajor = 1
	VersionMinor = 0
	VersionPatch = 0

	FlagNoAuthentication ClientFlag = 1

	ErrorMissingCredentials     = ClientError("missing credentials provider for authenticated request")
	ErrorUnsupportedContentType = ClientError("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 AuthenticatedUser

type AuthenticatedUser struct {
	Token     string `json:"token"`
	TwoFactor bool   `json:"two_factor"`
	User
}

type AuthenticationService

type AuthenticationService interface {
	Login(ctx context.Context, username, password string) (*AuthenticatedUser, *Response, error)
	Verify(ctx context.Context, token, code string) (*AuthenticatedUser, *Response, error)
}

type Client

type Client struct {
	Base                 *url.URL
	UserAgent            string
	SelectedOrganization Id
	Flags                ClientFlag

	Client *http.Client

	CredentialsProvider CredentialsProvider
	TokenStorage        TokenStorage

	OnRequest  ClientRequestCallback
	OnResponse ClientResponseCallback

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

	// Compute
	Server           ServerService
	ServerAttachment ServerAttachmentService
	KeyPair          KeyPairService
	Network          NetworkService
	ElasticIp        ElasticIpService

	// Other
	Authentication AuthenticationService
	Order          OrderService
}

func NewClient

func NewClient(base *url.URL) *Client

func (*Client) AddUserAgent

func (c *Client) AddUserAgent(userAgent string)

func (*Client) AuthenticationToken

func (c *Client) AuthenticationToken(ctx context.Context) (string, error)

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{}, flags ClientFlag) (*http.Request, error)

type ClientError

type ClientError string

func (ClientError) Error

func (e ClientError) Error() string

type ClientFlag

type ClientFlag uint

type ClientRequestCallback

type ClientRequestCallback func(req *http.Request)

type ClientResponseCallback

type ClientResponseCallback func(res *http.Response)

type Country

type Country struct {
	Id          Id     `json:"id"`
	Name        string `json:"name"`
	IsoAlpha2   string `json:"iso_alpha_2"`
	IsoAlpha3   string `json:"iso_alpha_3"`
	CallingCode string `json:"calling_code"`
}

type CredentialsProvider

type CredentialsProvider interface {
	Username() string
	Password() string
	TwoFactorCode() string
}

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

func (*ElasticIp) String

func (e *ElasticIp) String() string

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

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

func (*Image) String

func (i *Image) String() string

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

func (*KeyPair) String

func (k *KeyPair) String() string

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

func (*Location) String

func (l *Location) String() string

type LocationService

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

type MemoryTokenStorage

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

func (*MemoryTokenStorage) IsValid

func (t *MemoryTokenStorage) IsValid() bool

func (*MemoryTokenStorage) SetToken

func (t *MemoryTokenStorage) SetToken(token string)

func (*MemoryTokenStorage) Token

func (t *MemoryTokenStorage) Token() string

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

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

func (*Network) String

func (n *Network) String() string

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 *KeyPairCreate) (*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 Organization

type Organization struct {
	Id                    Id        `json:"id"`
	Name                  string    `json:"name"`
	Address               string    `json:"address"`
	Zip                   string    `json:"zip"`
	City                  string    `json:"city"`
	PhoneNumber           string    `json:"phone_number"`
	InvoiceDeploymentFees bool      `json:"invoice_deployment_fees"`
	CreatedAt             time.Time `json:"created_at"`

	Status struct {
		Id            Id         `json:"id"`
		Name          string     `json:"name"`
		RetentionTime *time.Time `json:"retention_time"`
	} `json:"status"`

	RegisteredModules []*Module `json:"registered_modules"`

	Contacts struct {
		Primary   *User  `json:"primary"`
		Billing   *User  `json:"billing"`
		Technical []User `json:"technical"`
	} `json:"contacts"`
}

type OrganizationService

type OrganizationService interface {
	List(ctx context.Context, options PaginationOptions) ([]*Organization, *Response, error)
	Get(ctx context.Context, id Id) (*Organization, *Response, error)
	GetCurrent(ctx context.Context) (*Organization, *Response, 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

func (*Product) String

func (p *Product) String() string

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

func (s *Server) String() 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 TokenStorage

type TokenStorage interface {
	Token() string
	IsValid() bool
	SetToken(token string)
}

type User

type User struct {
	Id                    uint            `json:"id"`
	Username              string          `json:"username"`
	FirstName             string          `json:"firstname"`
	LastName              string          `json:"lastname"`
	PhoneNumber           string          `json:"phone_number"`
	AssignedOrganizations []*Organization `json:"assigned_organizations"`
	DefaultOrganization   *Organization   `json:"default_organization"`
}

Jump to

Keyboard shortcuts

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