profitbricks

package
v0.0.0-...-f0f9b94 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2017 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (
	PROFITBRICKS_USER        = "PROFITBRICKS_USER"
	PROFITBRICKS_PASSWORD    = "PROFITBRICKS_PASSWORD"
	GetAllDataCentersRequest = `<tns:getAllDataCenters></tns:getAllDataCenters>`
)
View Source
const (
	SOAP_HEADER = `` /* 259-byte string literal not displayed */
	SOAP_FOOTER = `</env:Body></env:Envelope>`
)

Variables

View Source
var (
	HoursPerMonth float64 = 24 * 30

	DE = &Pricing{
		CpuPerHour:        2,
		GbRamPerHour:      0.45,
		GbStoragePerMonth: 9,
	}

	US = &Pricing{
		CpuPerHour:        2.5,
		GbRamPerHour:      0.75,
		GbStoragePerMonth: 9,
	}
)

Functions

func NewSoapRequest

func NewSoapRequest(body string) string

Types

type Body

type Body struct {
	XMLName                 xml.Name               `xml:"Body"`
	GetAllDataCenters       []*DataCenter          `xml:"getAllDataCentersResponse>return"`
	GetDataCenterResponse   *GetDataCenterResponse `xml:"getDataCenterResponse>return"`
	GetAllImagesResponse    []*Image               `xml:"getAllImagesResponse>return"`
	GetAllSnapshotsResponse []*Snapshot            `xml:"getAllSnapshotsResponse>return"`
	GetAllStoragesResponse  []*Storage             `xml:"getAllStoragesResponse>return"`
	GetAllServersResponse   []*Server              `xml:"getAllServersResponse>return"`
}

type Client

type Client struct {
	User     string
	Password string
}

func NewFromEnv

func NewFromEnv() *Client

func (*Client) CreateServer

func (client *Client) CreateServer(req *CreateServerRequest) error

func (*Client) CreateSnapshot

func (client *Client) CreateSnapshot(req *UpdateSnapshotRequest) error

func (*Client) CreateStorage

func (client *Client) CreateStorage(req *CreateStorageRequest) error

func (*Client) DeleteServer

func (client *Client) DeleteServer(id string) error

func (*Client) DeleteStorage

func (client *Client) DeleteStorage(id string) error

func (*Client) GetAllDataCenters

func (client *Client) GetAllDataCenters() (dcs []*DataCenter, e error)

func (*Client) GetAllImages

func (client *Client) GetAllImages() (images []*Image, e error)

func (*Client) GetAllServers

func (client *Client) GetAllServers() (servers []*Server, e error)

func (*Client) GetAllSnapshots

func (client *Client) GetAllSnapshots() (snapshots []*Snapshot, e error)

func (*Client) GetAllStorages

func (client *Client) GetAllStorages() (storages []*Storage, e error)

func (*Client) GetDataCenter

func (client *Client) GetDataCenter(id string) (dc *DataCenter, e error)

func (*Client) ResetServer

func (client *Client) ResetServer(id string) error

func (*Client) RollbackSnapshot

func (client *Client) RollbackSnapshot(req *RollbackSnapshotRequest) error

func (*Client) StartServer

func (client *Client) StartServer(id string) error

func (*Client) StopServer

func (client *Client) StopServer(id string) error

func (*Client) UpdateSnapshot

func (client *Client) UpdateSnapshot(req *UpdateSnapshotRequest) error

type ConnectedStorage

type ConnectedStorage struct {
	BootDevice   bool   `xml:"bootDevice"`   // >true</bootDevice>
	BusType      string `xml:"busType"`      // >VIRTIO</busType>
	DeviceNumber int    `xml:"deviceNumber"` // >1</deviceNumber>
	Size         int    `xml:"size"`         // >10</size>
	StorageId    string `xml:"storageId"`    // >dd24d153-6cf7-4476-aab3-0b1d32d5e15c</storageId>
	StorageName  string `xml:"storageName"`  // >Ubuntu</storageName>
}

type CreateServerRequest

type CreateServerRequest struct {
	XMLName           xml.Name `xml:"request"`
	DataCenterId      string   `xml:"dataCenterId,omitempty"`
	Cores             int      `xml:"cores,omitempty"`
	Ram               int      `xml:"ram,omitempty"`
	ServerName        string   `xml:"serverName,omitempty"`
	BootFromStorageId string   `xml:"bootFromStorageId,omitempty"`
	BootFromImageId   string   `xml:"bootFromImageId,omitempty"`
	InternetAccess    bool     `xml:"internetAccess,omitempty"`
	LanId             int      `xml:"lanId,omitempty"`
	OsType            string   `xml:"osType,omitempty"`
	AvailabilityZone  string   `xml:"availabilityZone,omitempty"`
}

type CreateStorageRequest

type CreateStorageRequest struct {
	XMLName                   xml.Name `xml:"request"`
	DataCenterId              string   `xml:"dataCenterId,omitempty"`
	StorageName               string   `xml:"storageName,omitempty"`
	Size                      int      `xml:"size,omitempty"`
	MountImageId              string   `xml:"mountImageId,omitempty"`
	ProfitBricksImagePassword string   `xml:"profitBricksImagePassword,omitempty"`
}

type DataCenter

type DataCenter struct {
	DataCenterId      string     `xml:"dataCenterId"`
	DataCenterName    string     `xml:"dataCenterName"`
	DataCenterVersion int        `xml:"dataCenterVersion"`
	Servers           []*Server  `xml:"servers"`
	Storages          []*Storage `xml:"storages"`
	ProvisioningState string     `xml:"provisioningState"`
	Region            string     `xml:"region"`
}

type Envelope

type Envelope struct {
	XMLName xml.Name `xml:"Envelope"`
	Body    *Body    `xml:"Body"`
}

type Firewall

type Firewall struct {
	Active            string `xml:"active"`            // >false</active>
	FirewallId        string `xml:"firewallId"`        // >29f279de-027e-40e4-99f2-4f09aa086903</firewallId>
	NicId             string `xml:"nicId"`             // >910910a2-a4c5-45fe-aeff-fe7ec4d8d4d9</nicId>
	ProvisioningState string `xml:"provisioningState"` // >AVAILABLE</provisioningState>
}

type GetAllDataCenters

type GetAllDataCenters struct {
}

type GetAllDataCentersResponse

type GetAllDataCentersResponse struct {
	*DataCenter
}

type GetAllSnapshotsResponse

type GetAllSnapshotsResponse struct {
	*DataCenter
}

type GetDataCenterResponse

type GetDataCenterResponse struct {
	*DataCenter
}

type Image

type Image struct {
	CpuHotpluggable    bool   `xml:"cpuHotpluggable"`    // type="xs:boolean" minOccurs="0"/>
	ImageId            string `xml:"imageId"`            // type="xs:string" minOccurs="0"/>
	ImageName          string `xml:"imageName"`          // type="xs:string" minOccurs="0"/>
	ImageSize          int    `xml:"imageSize"`          // type="xs:long" minOccurs="0"/>
	ImageType          string `xml:"imageType"`          // type="tns:imageType" minOccurs="0"/>
	MemoryHotpluggable bool   `xml:"memoryHotpluggable"` // type="xs:boolean" minOccurs="0"/>
	OsType             string `xml:"osType"`             // type="tns:osType" minOccurs="0"/>
	Region             string `xml:"region"`             // type="tns:region" minOccurs="0"/>
	ServerIds          string `xml:"serverIds"`          // type="xs:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
	Writeable          bool   `xml:"writeable"`          // type="xs:boolean" minOccurs="0"/>
}

type Nic

type Nic struct {
	DataCenterId      string    `xml:"dataCenterId"`      // eb394325-b2f1-418c-93e4-377697e3c597</dataCenterId>
	DataCenterVersion int       `xml:"dataCenterVersion"` // 4</dataCenterVersion>
	NicId             string    `xml:"nicId"`             // 910910a2-a4c5-45fe-aeff-fe7ec4d8d4d9</nicId>
	LanId             int       `xml:"lanId"`             // 1</lanId>
	InternetAccess    bool      `xml:"internetAccess"`    // true</internetAccess>
	ServerId          string    `xml:"serverId"`          // 5d0a9936-94c0-44a8-85cc-9a9cae082202</serverId>
	Ips               string    `xml:"ips"`               // 46.16.78.173</ips>
	MacAddress        string    `xml:"macAddress"`        // 02:01:0f:f6:2c:b5</macAddress>
	Firewall          *Firewall `xml:"firewall"`
	DhcpActive        bool      `xml:"dhcpActive"`        // >true</dhcpActive>
	GatewayIp         string    `xml:"gatewayIp"`         // >46.16.78.1</gatewayIp>
	ProvisioningState string    `xml:"provisioningState"` // >AVAILABLE</provisioningState>
}

type Output

type Output struct {
	Message string `xml:"message,attr"`
}

type Price

type Price struct {
	Cpu     float64
	Ram     float64
	Storage float64
}

func (*Price) TotalPrice

func (price *Price) TotalPrice() float64

type Pricing

type Pricing struct {
	CpuPerHour        float64
	GbRamPerHour      float64
	GbStoragePerMonth float64
}

func (*Pricing) Calculate

func (pricing *Pricing) Calculate(cpus int, ram int, storage int) *Price

type RollbackSnapshotRequest

type RollbackSnapshotRequest struct {
	XMLName    xml.Name `xml:"request"`
	SnapshotId string   `xml:"snapshotId"`
	StorageId  string   `xml:"storageId"`
}

type Server

type Server struct {
	ServerId             string              `xml:"serverId"`
	ServerName           string              `xml:"serverName"`
	Cores                int                 `xml:"cores"`
	Ram                  int                 `xml:"ram"`
	InternetAccess       bool                `xml:"internetAccess"`
	ProvisioningState    string              `xml:"provisioningState"`
	Ips                  []string            `xml:"ips"`
	LastModificationTime time.Time           `xml:"lastModificationTime"`
	CreationTime         time.Time           `xml:"creationTime"`
	VirtualMachineState  string              `xml:"virtualMachineState"`
	AvailabilityZone     string              `xml:"availabilityZone"`
	Region               string              `xml:"region"`
	Nics                 []*Nic              `xml:"nics"`
	ConnectedStorages    []*ConnectedStorage `xml:"connectedStorages"`
}

func (*Server) Lans

func (server *Server) Lans() string

type Snapshot

type Snapshot struct {
	SnapshotId        string `xml:"snapshotId"`        // type="xs:string"/>
	Description       string `xml:"description"`       // type="xs:string" minOccurs="0"/>
	SnapshotSize      int    `xml:"snapshotSize"`      // type="xs:long"/>
	SnapshotName      string `xml:"snapshotName"`      // type="xs:string" minOccurs="0"/>
	ProvisioningState string `xml:"provisioningState"` // type="tns:provisioningState"/>
	Bootable          bool   `xml:"bootable"`          // type="xs:boolean" minOccurs="0"/>
	OsType            string `xml:"osType"`            // type="tns:osType" minOccurs="0"/>
	CpuHotPlug        bool   `xml:"cpuHotPlug"`        // type="xs:boolean" minOccurs="0"/>
	RamHotPlug        bool   `xml:"ramHotPlug"`        // type="xs:boolean" minOccurs="0"/>
	NicHotPlug        bool   `xml:"nicHotPlug"`        // type="xs:boolean" minOccurs="0"/>
	NicHotUnPlug      bool   `xml:"nicHotUnPlug"`      // type="xs:boolean" minOccurs="0"/>
	Region            string `xml:"region"`            // type="tns:region"/>
}

type SoapAddress

type SoapAddress struct {
	Location string `xml:"location,attr"`
}

type SoapBinding

type SoapBinding struct {
	Transport string `xml:"transport,attr"`
}

type SoapBody

type SoapBody struct {
	Use string `xml:"use,attr"`
}

type SoapOperation

type SoapOperation struct {
	SoapAction string `xml:"soapAction,attr"`
	Style      string `xml:"style,attr"`
}

type StartServerRequest

type StartServerRequest struct {
	DataCenterId      string
	Cores             int
	Ram               int
	ServerName        string
	BootFromStorageId string
	BootFromImageId   string
	InternetAccess    string
	LanId             int
	OsType            string
	AvailabilityZone  string
}

type Storage

type Storage struct {
	DataCenterId         string    `xml:"dataCenterId,omitempty"`
	DataCenterVersion    string    `xml:"dataCenterVersion,omitempty"`
	StorageId            string    `xml:"storageId"`
	Size                 int       `xml:"size"`
	StorageName          string    `xml:"storageName"`
	BootDevice           bool      `xml:"bootDevice"`
	BusType              string    `xml:"busType"`
	DeviceNumber         int       `xml:"deviceNumber"`
	ImageId              string    `xml:"mountImage>imageId,omitempty"`
	ImageName            string    `xml:"mountImage>imageName,omitempty"`
	ServerIds            []string  `xml:"serverIds,omitempty"`
	ProvisioningState    string    `xml:"provisioningState,omitempty"`
	CreationTime         time.Time `xml:"creationTime,omitempty"`
	LastModificationTime time.Time `xml:"lastModificationTime,omitempty"`
}

type UpdateServerRequest

type UpdateServerRequest struct {
}

type UpdateSnapshotRequest

type UpdateSnapshotRequest struct {
	XMLName      xml.Name `xml:"request"`
	SnapshotId   string   `xml:"snapshotId"`   // type="xs:string"/>
	Description  string   `xml:"description"`  // type="xs:string" minOccurs="0"/>
	SnapshotName string   `xml:"snapshotName"` // type="xs:string" minOccurs="0"/>
	Bootable     bool     `xml:"bootable"`     // type="xs:boolean" minOccurs="0"/>
	OsType       string   `xml:"osType"`       // type="tns:osType" minOccurs="0"/>
	CpuHotPlug   string   `xml:"cpuHotPlug"`   // type="xs:boolean" minOccurs="0"/>
	RamHotPlug   string   `xml:"ramHotPlug"`   // type="xs:boolean" minOccurs="0"/>
	NicHotPlug   string   `xml:"nicHotPlug"`   // type="xs:boolean" minOccurs="0"/>
	NicHotUnPlug string   `xml:"nicHotUnPlug"` // type="xs:boolean" minOccurs="0"/>
}

type WsdlBinding

type WsdlBinding struct {
	Name         string           `xml:"name,attr"`
	Type         string           `xml:"type,attr"`
	Operations   []*WsdlOperation `xml:"http://schemas.xmlsoap.org/wsdl/ operation"`
	SoapBindings []*SoapBinding   `xml:"http://schemas.xmlsoap.org/wsdl/soap/ binding"`
}

type WsdlDefinitions

type WsdlDefinitions struct {
	Name            string           `xml:"name,attr"`
	TargetNamespace string           `xml:"targetNamespace,attr"`
	Imports         []*WsdlImport    `xml:"http://schemas.xmlsoap.org/wsdl/ import"`
	Types           []*WsdlTypes     `xml:"http://schemas.xmlsoap.org/wsdl/ types"`
	Messages        []*WsdlMessage   `xml:"http://schemas.xmlsoap.org/wsdl/ message"`
	PortTypes       []*WsdlPortTypes `xml:"http://schemas.xmlsoap.org/wsdl/ portType"`
	Services        []*WsdlService   `xml:"http://schemas.xmlsoap.org/wsdl/ service"`
	Bindings        []*WsdlBinding   `xml:"http://schemas.xmlsoap.org/wsdl/ binding"`
}

func ParseWSDL

func ParseWSDL(b []byte) (def *WsdlDefinitions, e error)

func (*WsdlDefinitions) FindComplexType

func (wsdl *WsdlDefinitions) FindComplexType(name string) *XsdComplexType

func (*WsdlDefinitions) FindMessage

func (wsdl *WsdlDefinitions) FindMessage(name string) *WsdlMessage

func (*WsdlDefinitions) Operations

func (wsdl *WsdlDefinitions) Operations()

type WsdlImport

type WsdlImport struct {
	Namespace string `xml:"namespace,attr"`
	Location  string `xml:"location,attr"`
}

type WsdlMessage

type WsdlMessage struct {
	Name  string             `xml:"name,attr"`
	Parts []*WsdlMessagePart `xml:"http://schemas.xmlsoap.org/wsdl/ part"`
}

type WsdlMessagePart

type WsdlMessagePart struct {
	Name    string `xml:"name,attr"`
	Element string `xml:"element,attr"`
}

type WsdlOperation

type WsdlOperation struct {
	Name           string                 `xml:"name,attr"`
	Inputs         []*WsdlOperationInput  `xml:"http://schemas.xmlsoap.org/wsdl/ input"`
	Outputs        []*WsdlOperationOutput `xml:"http://schemas.xmlsoap.org/wsdl/ output"`
	Faults         []*WsdlOperationFault  `xml:"http://schemas.xmlsoap.org/wsdl/ fault"`
	SoapOperations []*SoapOperation       `xml:"http://schemas.xmlsoap.org/wsdl/soap/ operation"`
}

type WsdlOperationFault

type WsdlOperationFault struct {
	Name       string `xml:"name,attr"`
	Message    string `xml:"message,attr"`
	WsawAction string `xml:"http://www.w3.org/2006/05/addressing/wsdl Action,attr"`
}

type WsdlOperationInput

type WsdlOperationInput struct {
	Message    string `xml:"message,attr"`
	WsawAction string `xml:"http://www.w3.org/2006/05/addressing/wsdl Action,attr"`
}

type WsdlOperationOutput

type WsdlOperationOutput struct {
	Message    string `xml:"message,attr"`
	WsawAction string `xml:"http://www.w3.org/2006/05/addressing/wsdl Action,attr"`
}

type WsdlPort

type WsdlPort struct {
	Name          string         `xml:"name,attr"`
	Binding       string         `xml:"binding,attr"`
	SoapAddresses []*SoapAddress `xml:"http://schemas.xmlsoap.org/wsdl/soap/ address"`
}

type WsdlPortTypes

type WsdlPortTypes struct {
	Name       string           `xml:"name,attr"`
	Operations []*WsdlOperation `xml:"operation"`
}

type WsdlService

type WsdlService struct {
	Name  string      `xml:"name,attr"`
	Ports []*WsdlPort `xml:"http://schemas.xmlsoap.org/wsdl/ port"`
}

type WsdlTypes

type WsdlTypes struct {
	XsdSchema []*XsdSchema `xml:"http://www.w3.org/2001/XMLSchema schema"`
}

type XsdComplexContent

type XsdComplexContent struct {
	Extension *XsdExtension `xml:"http://www.w3.org/2001/XMLSchema extension"`
}

type XsdComplexType

type XsdComplexType struct {
	Name           string             `xml:"name,attr"`
	Sequence       *XsdSequence       `xml:"http://www.w3.org/2001/XMLSchema sequence"`
	ComplexContent *XsdComplexContent `xml:"http://www.w3.org/2001/XMLSchema complexContent"`
}

type XsdElement

type XsdElement struct {
	Name        string          `xml:"name,attr"`
	Nillable    bool            `xml:"nillable,attr"`
	Type        string          `xml:"type,attr"`
	MinOccurs   string          `xml:"minOccurs,attr"`
	MaxOccurs   string          `xml:"maxOccurs,attr"`
	ComplexType *XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"`
	SimpleType  *XsdSimpleType  `xml:"http://www.w3.org/2001/XMLSchema simpleType"`
}

type XsdExtension

type XsdExtension struct {
	Sequence *XsdSequence `xml:"http://www.w3.org/2001/XMLSchema sequence"`
}

type XsdImport

type XsdImport struct {
	SchemaLocation string `xml:"schemaLocation,attr"`
	Namespace      string `xml:"namespace,attr"`
}

type XsdMaxInclusive

type XsdMaxInclusive struct {
	Value string `xml:"value,attr"`
}

type XsdMinInclusive

type XsdMinInclusive struct {
	Value string `xml:"value,attr"`
}

type XsdPattern

type XsdPattern struct {
	Value string `xml:"value,attr"`
}

type XsdRestriction

type XsdRestriction struct {
	Base         string           `xml:"base,attr"`
	Pattern      *XsdPattern      `xml:"http://www.w3.org/2001/XMLSchema pattern"`
	MinInclusive *XsdMinInclusive `xml:"http://www.w3.org/2001/XMLSchema minInclusive"`
	MaxInclusive *XsdMaxInclusive `xml:"http://www.w3.org/2001/XMLSchema maxInclusive"`
}

type XsdSchema

type XsdSchema struct {
	TargetNamespace    string            `xml:"targetNamespace,attr"`
	ElementFormDefault string            `xml:"elementFormDefault,attr"`
	Imports            []*XsdImport      `xml:"http://www.w3.org/2001/XMLSchema import"`
	Elements           []*XsdElement     `xml:"http://www.w3.org/2001/XMLSchema element"`
	ComplexTypes       []*XsdComplexType `xml:"http://www.w3.org/2001/XMLSchema complexType"`
	SimpleTypes        []*XsdSimpleType  `xml:"http://www.w3.org/2001/XMLSchema simpleType"`
}

type XsdSequence

type XsdSequence struct {
	Elements []*XsdElement `xml:"http://www.w3.org/2001/XMLSchema element"`
}

type XsdSimpleType

type XsdSimpleType struct {
	Name     string          `xml:"name,attr"`
	Sequence *XsdRestriction `xml:"http://www.w3.org/2001/XMLSchema restriction"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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