Documentation ¶
Index ¶
- Constants
- Variables
- func BuildFilterQuery(filters []FilterInterface) string
- func BuildSortingQuery(sortings []*Sorting) string
- type APIClient
- type Action
- type ClientOptions
- type FilterInterface
- type InFilter
- type Instance
- type InstanceActionRequest
- type InstanceCreateRequest
- type InstanceDatacenter
- type InstanceDatacenterRegion
- type InstanceDestroyRequest
- type InstanceIPAddress
- type InstanceImage
- type InstanceNetworks
- type InstancePrivateNetwork
- type InstanceRegion
- type InstanceRenameRequest
- type InstanceSSHKey
- type InstanceUpgradeRequest
- type InstanceV4Network
- type InstanceVolume
- type InstancesAPI
- type InstancesService
- func (is *InstancesService) Create(ctx context.Context, createRequest *InstanceCreateRequest) (*Instance, error)
- func (is *InstancesService) Destroy(ctx context.Context, instanceID string) error
- func (is *InstancesService) Get(ctx context.Context, instanceID string) (*Instance, error)
- func (is *InstancesService) List(ctx context.Context, options *ListOptions) ([]Instance, *Meta, error)
- func (is *InstancesService) PowerOff(ctx context.Context, instanceID string) error
- func (is *InstancesService) Rename(ctx context.Context, instanceID, name string) (*Instance, error)
- func (is *InstancesService) Shutdown(ctx context.Context, instanceID string) error
- func (is *InstancesService) Upgrade(ctx context.Context, instanceID, productID string) error
- type ListMetaOptions
- type ListOptions
- type Meta
- type Sorting
Constants ¶
const InstanceShutDownStatus = "stopped"
InstanceShutDownStatus represents instance's shutdown statuse
Variables ¶
var ( // ErrPrimaryIPNotFound is returned when primary is not found ErrPrimaryIPNotFound = errors.New("primary ip is not found") )
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 ¶
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
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 ¶
ClientOptions represents options to communicate with AH API
type FilterInterface ¶
type FilterInterface interface {
Encode() []string
}
FilterInterface is an interface for Filter.
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
type InstanceActionRequest ¶
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 ¶
type InstancesAPI interface { List(context.Context, *ListOptions) ([]Instance, *Meta, error) Get(context.Context, string) (*Instance, error) Create(context.Context, *InstanceCreateRequest) (*Instance, error) Rename(context.Context, string, string) (*Instance, error) Upgrade(context.Context, string, string) error Shutdown(context.Context, string) error PowerOff(context.Context, string) error Destroy(context.Context, string) error }
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) 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.
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.