ah

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const InstanceShutDownStatus = "stopped"

InstanceShutDownStatus represents instance's shutdown statuse

Variables

View Source
var (
	// ErrPrimaryIPNotFound is returned when primary is not found
	ErrPrimaryIPNotFound = errors.New("primary ip is not found")
)
View Source
var (
	// ErrResourceNotFound is returned when resource is not found
	ErrResourceNotFound = errors.New("resource not found")
)

Functions

func BuildFilterQuery

func BuildFilterQuery(filters []FilterInterface) string

BuildFilterQuery returns Ransack filter expression

func BuildSortingQuery

func BuildSortingQuery(sortings []*Sorting) string

BuildSortingQuery returns Ransack sorting expression

Types

type APIClient

type APIClient struct {
	Instances InstancesAPI
	// contains filtered or unexported fields
}

APIClient implements communication with AH API

func NewAPIClient

func NewAPIClient(options *ClientOptions) (*APIClient, error)

NewAPIClient returns APIClient instance

func (*APIClient) Do

func (c *APIClient) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request

type Action

type Action struct {
	ID           string `json:"id,omitempty"`
	ResourceID   string `json:"resource_id,omitempty"`
	State        string `json:"state,omitempty"`
	ResourceType string `json:"resource_type,omitempty"`
	Type         string `json:"type,omitempty"`
	UserID       string `json:"user_id,omitempty"`
	Note         string `json:"note,omitempty"`
	CreatedAt    string `json:"created_at,omitempty"`
	UpdatedAt    string `json:"updated_at,omitempty"`
	StartedAt    string `json:"started_at,omitempty"`
	CompletedAt  string `json:"completed_at,omitempty"`
}

Action object

type ClientOptions

type ClientOptions struct {
	BaseURL    string
	Token      string
	HTTPClient *http.Client
}

ClientOptions represents options to communicate with AH API

type FilterInterface

type FilterInterface interface {
	Encode() []string
}

FilterInterface is an interface for Filter.

type InFilter

type InFilter struct {
	Keys   []string
	Values []string
}

InFilter represents ransack's "*_in" filter .

func (*InFilter) Encode

func (f *InFilter) Encode() []string

Encode returns Ransack filter expression

type Instance

type Instance struct {
	ID                         string                   `json:"id,omitempty"`
	CreatedAt                  string                   `json:"created_at,omitempty"`
	UpdatedAt                  string                   `json:"updated_at,omitempty"`
	Number                     string                   `json:"number,omitempty"`
	Name                       string                   `json:"name,omitempty"`
	State                      string                   `json:"state,omitempty"`
	Disk                       int                      `json:"disk,omitempty"`
	StateDescription           string                   `json:"state_description,omitempty"`
	Locked                     bool                     `json:"locked,omitempty"`
	UseSSHPassword             bool                     `json:"use_ssh_password,omitempty"`
	SSHKeys                    []InstanceSSHKey         `json:"ssh_keys,omitempty"`
	ProductID                  string                   `json:"product_id,omitempty"`
	Vcpu                       int                      `json:"vcpu,omitempty"`
	RAM                        int                      `json:"ram,omitempty"`
	Traffic                    int                      `json:"traffic,omitempty"`
	Tags                       []string                 `json:"tags,omitempty"`
	PrimaryInstanceIPAddressID string                   `json:"primary_instance_ip_address_id,omitempty"`
	IPScheme                   string                   `json:"ip_scheme,omitempty"`
	Region                     *InstanceRegion          `json:"region,omitempty"`
	Datacenter                 *InstanceDatacenter      `json:"datacenter,omitempty"`
	Features                   []string                 `json:"features,omitempty"`
	Networks                   *InstanceNetworks        `json:"networks,omitempty"`
	CurrentAction              *Action                  `json:"current_action,omitempty"`
	LastAction                 *Action                  `json:"last_action,omitempty"`
	Reason                     string                   `json:"reason,omitempty"`
	SnapshotBySchedule         bool                     `json:"snapshot_by_schedule,omitempty"`
	SnapshotPeriod             string                   `json:"snapshot_period,omitempty"`
	MaxVolumesNumber           int                      `json:"max_volumes_number,omitempty"`
	PrivateNetworks            []InstancePrivateNetwork `json:"instance_private_networks,omitempty"`
	IPAddresses                []InstanceIPAddress      `json:"instance_ip_addresses,omitempty"`
	Image                      *InstanceImage           `json:"image,omitempty"`
	Volumes                    []InstanceVolume         `json:"volumes,omitempty"`
}

Instance object

func (*Instance) PrimaryIP

func (i *Instance) PrimaryIP() (string, error)

PrimaryIP return primary IP of the instance

type InstanceActionRequest

type InstanceActionRequest struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

InstanceActionRequest represents an action request.

type InstanceCreateRequest

type InstanceCreateRequest struct {
	Name                  string   `json:"name"`
	DatacenterID          string   `json:"datacenter_id"`
	ImageID               string   `json:"image_id"`
	ProductID             string   `json:"product_id"`
	UseSSHPassword        bool     `json:"use_ssh_password"`
	Tags                  []string `json:"tags"`
	SSHKeyIDs             []string `json:"ssh_key_ids"`
	CreatePublicIPAddress bool     `json:"create_public_ip_address"`
	SnapshotPeriod        string   `json:"snapshot_period"`
	SnapshotBySchedule    bool     `json:"snapshot_by_schedule"`
}

InstanceCreateRequest represents a request to create a instance.

type InstanceDatacenter

type InstanceDatacenter struct {
	ID                string                    `json:"id,omitempty"`
	Name              string                    `json:"name,omitempty"`
	FullName          string                    `json:"full_name,omitempty"`
	InstancesRunning  int                       `json:"instances_running,omitempty"`
	PrivateNodesCount int                       `json:"private_nodes_count,omitempty"`
	Region            *InstanceDatacenterRegion `json:"region,omitempty"`
}

InstanceDatacenter object

type InstanceDatacenterRegion

type InstanceDatacenterRegion struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	CountryCode string `json:"country_code,omitempty"`
}

InstanceDatacenterRegion object

type InstanceDestroyRequest

type InstanceDestroyRequest struct {
	BackupsStrategy string `json:"backups_strategy"`
}

InstanceDestroyRequest represents a request to destroy the instance.

type InstanceIPAddress

type InstanceIPAddress struct {
	ID          string `json:"id,omitempty"`
	InstanceID  string `json:"instance_id,omitempty"`
	CreatedAt   string `json:"created_at,omitempty"`
	UpdatedAt   string `json:"updated_at,omitempty"`
	IPAddressID string `json:"ip_address_id,omitempty"`
	Address     string `json:"address,omitempty"`
}

InstanceIPAddress object

type InstanceImage

type InstanceImage struct {
	ID           string `json:"id,omitempty"`
	CreatedAt    string `json:"created_at,omitempty"`
	UpdatedAt    string `json:"updated_at,omitempty"`
	Type         string `json:"type,omitempty"`
	Name         string `json:"name,omitempty"`
	Distribution string `json:"distribution,omitempty"`
	Version      string `json:"version,omitempty"`
	Architecture string `json:"architecture,omitempty"`
	Slug         string `json:"slug,omitempty"`
	Public       bool   `json:"public,omitempty"`
}

InstanceImage object

type InstanceNetworks

type InstanceNetworks struct {
	V4 []InstanceV4Network `json:"v4,omitempty"`
}

InstanceNetworks object

type InstancePrivateNetwork

type InstancePrivateNetwork struct {
	ID             string `json:"id,omitempty"`
	IP             string `json:"ip,omitempty"`
	MacAddress     string `json:"mac_address,omitempty"`
	State          string `json:"state,omitempty"`
	ConnectedAt    string `json:"connected_at,omitempty"`
	PrivateNetwork struct {
		ID string `json:"id,omitempty"`
	} `json:"private_network,omitempty"`
}

InstancePrivateNetwork object

type InstanceRegion

type InstanceRegion struct {
	ID           string   `json:"id,omitempty"`
	Name         string   `json:"name,omitempty"`
	Slug         string   `json:"slug,omitempty"`
	CountryCode  string   `json:"country_code,omitempty"`
	Country      string   `json:"country,omitempty"`
	City         string   `json:"city,omitempty"`
	ParentID     string   `json:"parent_id,omitempty"`
	Group        bool     `json:"group,omitempty"`
	RegionsCount int      `json:"regions_count,omitempty"`
	Services     []string `json:"services,omitempty"`
}

InstanceRegion object

type InstanceRenameRequest

type InstanceRenameRequest struct {
	Name string `json:"name"`
}

InstanceRenameRequest represents a request to rename the instance.

type InstanceSSHKey

type InstanceSSHKey struct {
	CreatedAt   string `json:"created_at,omitempty"`
	Name        string `json:"name,omitempty"`
	ID          string `json:"id,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
	PublicKey   string `json:"public_key,omitempty"`
}

InstanceSSHKey object

type InstanceUpgradeRequest

type InstanceUpgradeRequest struct {
	ID        string `json:"id"`
	Type      string `json:"type"`
	ProductID string `json:"product_id"`
}

InstanceUpgradeRequest represents a request to upgrade the instance.

type InstanceV4Network

type InstanceV4Network struct {
	Type      string `json:"type,omitempty"`
	IPAddress string `json:"ip_address,omitempty"`
	Netmask   string `json:"netmask,omitempty"`
	Gateway   string `json:"gateway,omitempty"`
}

InstanceV4Network object

type InstanceVolume

type InstanceVolume struct {
	ID         string `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	Size       int    `json:"size,omitempty"`
	Number     string `json:"number,omitempty"`
	ProductID  string `json:"product_id,omitempty"`
	Port       int    `json:"port,omitempty"`
	FileSystem string `json:"file_system,omitempty"`
	State      string `json:"state,omitempty"`
	CreatedAt  string `json:"created_at,omitempty"`
	AttachedAt string `json:"attached_at,omitempty"`
}

InstanceVolume object

type InstancesAPI

InstancesAPI is an interface for instances.

type InstancesService

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

InstancesService implements InstancesApi interface.

func (*InstancesService) Create

func (is *InstancesService) Create(ctx context.Context, createRequest *InstanceCreateRequest) (*Instance, error)

Create new instance.

func (*InstancesService) Destroy

func (is *InstancesService) Destroy(ctx context.Context, instanceID string) error

Destroy isntance.

func (*InstancesService) Get

func (is *InstancesService) Get(ctx context.Context, instanceID string) (*Instance, error)

Get returns all instance by instanceID

func (*InstancesService) List

func (is *InstancesService) List(ctx context.Context, options *ListOptions) ([]Instance, *Meta, error)

List returns all available instances

func (*InstancesService) PowerOff

func (is *InstancesService) PowerOff(ctx context.Context, instanceID string) error

PowerOff instance.

func (*InstancesService) Rename

func (is *InstancesService) Rename(ctx context.Context, instanceID, name string) (*Instance, error)

Rename instance.

func (*InstancesService) Shutdown

func (is *InstancesService) Shutdown(ctx context.Context, instanceID string) error

Shutdown instance.

func (*InstancesService) Upgrade

func (is *InstancesService) Upgrade(ctx context.Context, instanceID, productID string) error

Upgrade instance.

type ListMetaOptions

type ListMetaOptions struct {
	Page int `url:"page"`
}

ListMetaOptions represents meta options.

type ListOptions

type ListOptions struct {
	Meta     *ListMetaOptions
	Filters  []FilterInterface
	Sortings []*Sorting
}

ListOptions represents options to get list of resources.

type Meta

type Meta struct {
	Page    int `json:"page,omitempty"`
	PerPage int `json:"per_page,omitempty"`
	Total   int `json:"total,omitempty"`
}

Meta object

func (*Meta) IsLastPage

func (m *Meta) IsLastPage() bool

IsLastPage returns true if the current page is the last

type Sorting

type Sorting struct {
	Key   string
	Order string
}

Sorting represents Ransack sorting expression

func (*Sorting) Encode

func (s *Sorting) Encode() []string

Encode returns Ransack sorting expression

Jump to

Keyboard shortcuts

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