api

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 10 Imported by: 0

README

rackcorp-api-go

Documentation

Index

Constants

View Source
const (
	ServerClassBudget      = "BUDGET"
	ServerClassPerformance = "PERFORMANCE"
	ServerClassStorage     = "STORAGE"
	ServerClassTraffic     = "TRAFFIC"

	StorageTypeMagnetic = "MAGNETIC"
	StorageTypeSSD      = "SSD"

	FirewallPolicyDirectionAny      = "ANY"
	FirewallPolicyDirectionInbound  = "INBOUND"
	FirewallPolicyDirectionOutbound = "OUTBOUND"

	FirewallPolicyTypeAllow    = "ALLOW"
	FirewallPolicyTypeDeny     = "DENY"
	FirewallPolicyTypeDisabled = "DISABLED"
	FirewallPolicyTypeReject   = "REJECT"
)
View Source
const (
	TransactionObjectTypeDevice = "DEVICE"

	TransactionStatusCommenced = "COMMENCED"
	TransactionStatusCompleted = "COMPLETED"
	TransactionStatusPending   = "PENDING"

	TransactionTypeCancel        = "CANCEL"
	TransactionTypeCloseVNC      = "CLOSEVNC"
	TransactionTypeForceShutdown = "FORCESHUTDOWN"
	TransactionTypeOpenVNC       = "OPENVNC" // data parameter contains public IP that allows VNC
	TransactionTypeRefreshConfig = "REFRESHCONFIG"
	TransactionTypeSafeShutdown  = "SAFESHUTDOWN"
	TransactionTypeShutdown      = "SHUTDOWN"
	TransactionTypeStartup       = "STARTUP"
)

Variables

Functions

func GetVirtualServerProductCode

func GetVirtualServerProductCode(serverClass string, country string) string

Types

type ApiError

type ApiError struct {
	Message string
	Err     error
}

func (*ApiError) Error

func (e *ApiError) Error() string

type Client

type Client interface {
	OrderConfirm(ctx context.Context, orderId string) (*ConfirmedOrder, error)
	OrderCreate(ctx context.Context, productCode string, customerId string, productDetails ProductDetails) (*CreatedOrder, error)
	OrderGet(ctx context.Context, orderId string) (*Order, error)

	OrderContractGet(ctx context.Context, contractId string) (*OrderContract, error)

	DeviceGet(ctx context.Context, deviceId int) (*Device, error)
	DeviceUpdateFirewall(ctx context.Context, deviceId int, policies []FirewallPolicy) error

	TransactionCreate(ctx context.Context, transactionType string, objectType string, objectId string, confirm bool) (*Transaction, error)
	TransactionDeviceStartup(ctx context.Context, deviceId string, data TransactionStartupData) (*Transaction, error)
	TransactionGet(ctx context.Context, transactionId string) (*Transaction, error)
	TransactionGetAll(ctx context.Context, filter TransactionFilter) ([]Transaction, int, error)

	SetDebugLog(logFunc LogFunc)
}

func NewClient

func NewClient(uuid string, secret string) (Client, error)

type ConfirmedOrder

type ConfirmedOrder struct {
	ContractIds []string
}

type CreatedOrder

type CreatedOrder struct {
	OrderId    string
	ChangeText string
}

type Credential

type Credential struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Device

type Device struct {
	DeviceId         int              `json:"deviceId"`
	Name             string           `json:"name"`
	CustomerId       int              `json:"customerId"`
	PrimaryIP        string           `json:"primaryIP"`
	Status           string           `json:"status"`
	DataCenterId     int              `json:"dcid"`
	FirewallPolicies []FirewallPolicy `json:"firewallPolicies"`
	StdName          string           `json:"stdName"`
	DateCreated      int64            `json:"dateCreated"`
	DateModified     int64            `json:"dateModified"`
	TrafficShared    bool             `json:"trafficShared,omitempty"`
	TrafficCurrent   string           `json:"trafficCurrent"`
	TrafficEstimated float64          `json:"trafficEstimated"`
	TrafficMB        int64            `json:"trafficMB"`
	DCName           string           `json:"dcName"`

	Extra map[string]interface{} `json:"extra"`
}

type FirewallPolicy

type FirewallPolicy struct {
	ID            int    `json:"id"`
	Direction     string `json:"direction"`
	Policy        string `json:"policy"`
	Order         int    `json:"order"`
	Comment       string `json:"comment,omitempty"`
	IpAddressFrom string `json:"ipAddressFrom,omitempty"`
	IpAddressTo   string `json:"ipAddressTo,omitempty"`
	Protocol      string `json:"protocol,omitempty"`
	PortFrom      string `json:"portFrom,omitempty"`
	PortTo        string `json:"portTo,omitempty"`
	DeviceId      int    `json:"deviceId"`
	OldDeviceID   string `json:"deviceID,omitempty"` //needed b/c of quirks with case-sensitivity in the GO json parser https://github.com/golang/go/issues/14750
}

type Install

type Install struct {
	OperatingSystem   string `json:"operatingSystem,omitempty"`
	PostInstallScript string `json:"postInstallScript,omitempty"`
	Template          string `json:"template,omitempty"`
}

type LogFunc

type LogFunc func(message string)

type Nic

type Nic struct {
	Name     string `json:"name,omitempty"`
	Vlan     int    `json:"vlan,omitempty"`
	Speed    int    `json:"speed"`
	IPV4     int    `json:"ipv4"`
	PoolIPv4 int    `json:"poolIPv4,omitempty"`
	IPV6     int    `json:"ipv6,omitempty"`
	PoolIPv6 int    `json:"poolIPv6,omitempty"`
}

type Order

type Order struct {
	OrderId    string `json:"orderId"`
	CustomerId string `json:"customerId"`
	Status     string `json:"status"`
	ContractId string `json:"contractId"`
}

type OrderContract

type OrderContract struct {
	ContractId string `json:"contractId"`
	CustomerId string `json:"customerId"`
	DeviceId   string `json:"deviceID"`
	Status     string `json:"status"` // TODO enum
	Type       string `json:"type"`   // TODO enum

}

type ProductDetails

type ProductDetails struct {
	Hostname         string           `json:"hostname,omitempty"`
	DataCenterId     string           `json:"dcId,omitempty"`
	Credentials      []Credential     `json:"credentials"`
	Install          Install          `json:"install"`
	CpuCount         int              `json:"cpu"`
	Storage          []Storage        `json:"storage,omitempty"`
	MemoryGB         int              `json:"memoryGB"`
	TrafficGB        int              `json:"trafficGB,omitempty"`
	FirewallPolicies []FirewallPolicy `json:"firewallPolicies,omitempty"`
	Nics             []Nic            `json:"nics,omitempty"`
	HostGroupID      *int             `json:"hostGroupId,omitempty"`
	Location         string           `json:"location,omitempty"`
	Timezone         string           `json:"timezone,omitempty"`
}

type Storage

type Storage struct {
	Name        string `json:"name,omitempty"`
	SizeGB      int    `json:"sizeGB"`
	StorageType string `json:"type"`
	SortOrder   int    `json:"order,omitempty"`
}

type Transaction

type Transaction struct {
	TransactionId        string
	ObjectType           string
	ObjectId             string
	Type                 string
	Data                 string
	ConfirmationRequired bool
	ConfirmationText     string
	Status               string
	StatusInfo           string
}

type TransactionFilter

type TransactionFilter struct {
	ObjectType   string   `json:"objType"`
	ObjectId     []string `json:"objId,omitempty"`
	Type         []string `json:"method,omitempty"`
	Status       []string `json:"status,omitempty"`
	CustomerId   []string `json:"customerId,omitempty"`
	ResultStart  int      `json:"resStart,omitempty"`
	ResultWindow int      `json:"resWindow,omitempty"`
}

type TransactionStartupCloudInit

type TransactionStartupCloudInit struct {
	MetaData      string `json:"metaData,omitempty"`
	NetworkConfig string `json:"networkConfig,omitempty"`
	UserData      string `json:"userData,omitempty"`
}

type TransactionStartupData

type TransactionStartupData struct {
	DeployMediaImageAccessKey    string `json:"deployMediaImageAccessKey,omitempty"`
	DeployMediaImageAccessSecret string `json:"deployMediaImageAccessSecret,omitempty"`
	DeployMediaImageBucket       string `json:"deployMediaImageBucket,omitempty"`
	DeployMediaImageId           string `json:"deployMediaImageId,omitempty"`
	DeployMediaImagePath         string `json:"deployMediaImagePath,omitempty"`

	CloudInit TransactionStartupCloudInit `json:"cloudInit"`
}

Jump to

Keyboard shortcuts

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