Documentation
¶
Overview ¶
Package profitbricks is a client library for interacting with Profitbricks RESTful APIs.
Index ¶
- Constants
- Variables
- func MkJson(i interface{}) string
- func SetAuth(u, p string)
- func SetDepth(newdepth string) string
- func SetEndpoint(newendpoint string) string
- func SetUserAgent(userAgent string)
- type BalancedNics
- type Cdroms
- type CreateServerRequest
- type CreateVolumeRequest
- type Datacenter
- type DatacenterElementMetadata
- type DatacenterEntities
- type DatacenterProperties
- type Datacenters
- type FirewallRule
- type FirewallRules
- type FirewallruleProperties
- type Image
- type ImageProperties
- type Images
- type IpBlock
- type IpBlockProperties
- type IpBlocks
- type Lan
- type LanEntities
- type LanNics
- type LanProperties
- type Lans
- type LoablanacerCreateRequest
- type Loadbalancer
- type LoadbalancerEntities
- type LoadbalancerProperties
- type Loadbalancers
- type Location
- type Locations
- type Nic
- type NicCreateRequest
- type NicEntities
- type NicProperties
- type Nics
- type Properties
- type RequestStatus
- type RequestStatusMetadata
- type RequestTarget
- type ResourceReference
- type Resp
- func DeleteBalancedNic(dcid, lbalid, balnicid string) Resp
- func DeleteDatacenter(dcid string) Resp
- func DeleteFirewallRule(dcid string, srvid string, nicId string, fwId string) Resp
- func DeleteLan(dcid, lanid string) Resp
- func DeleteLoadbalancer(dcid, lbalid string) Resp
- func DeleteNic(dcid, srvid, nicid string) Resp
- func DeleteServer(dcid, srvid string) Resp
- func DeleteSnapshot(snapshotId string) Resp
- func DeleteVolume(dcid, volid string) Resp
- func DetachCdrom(dcid, srvid, cdid string) Resp
- func DetachVolume(dcid, srvid, volid string) Resp
- func RebootServer(dcid, srvid string) Resp
- func ReleaseIpBlock(ipblockid string) Resp
- func RestoreSnapshot(dcid string, volid string, snapshotId string) Resp
- func StartServer(dcid, srvid string) Resp
- func StopServer(dcid, srvid string) Resp
- type Server
- type ServerEntities
- type ServerProperties
- type Servers
- type Snapshot
- type SnapshotProperties
- type Snapshots
- type Volume
- func AttachVolume(dcid string, srvid string, volid string) Volume
- func CreateVolume(dcid string, request Volume) Volume
- func GetAttachedCdrom(dcid, srvid, cdid string) Volume
- func GetAttachedVolume(dcid, srvid, volid string) Volume
- func GetVolume(dcid string, volumeId string) Volume
- func PatchVolume(dcid string, volid string, request VolumeProperties) Volume
- type VolumeProperties
- type Volumes
Constants ¶
const CommandHeader = "application/x-www-form-urlencoded"
CommandHeader is used with is_command
const FullHeader = "application/json"
FullHeader is the standard header to include with all http requests except is_patch and is_command
const PatchHeader = "application/json"
PatchHeader is used with is_patch .
Variables ¶
var AgentHeader = "profitbricks-sdk-go/3.0.0"
var Depth = "5"
var Endpoint = "https://api.profitbricks.com/cloudapi/v3"
Endpoint is the base url for REST requests.
var Passwd string
Password for authentication .
var Username string
Username for authentication .
Functions ¶
func SetEndpoint ¶
SetEndpoint is used to set the REST Endpoint. Endpoint is declared in config.go
func SetUserAgent ¶
func SetUserAgent(userAgent string)
Types ¶
type BalancedNics ¶
type Cdroms ¶
type Cdroms struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Image `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
type CreateServerRequest ¶
type CreateServerRequest struct {
ServerProperties `json:"properties"`
}
type CreateVolumeRequest ¶
type CreateVolumeRequest struct {
VolumeProperties `json:"properties"`
}
type Datacenter ¶
type Datacenter struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties DatacenterProperties `json:"properties,omitempty"`
Entities DatacenterEntities `json:"entities,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func CompositeCreateDatacenter ¶
func CompositeCreateDatacenter(datacenter Datacenter) Datacenter
func CreateDatacenter ¶
func CreateDatacenter(dc Datacenter) Datacenter
func GetDatacenter ¶
func GetDatacenter(dcid string) Datacenter
func PatchDatacenter ¶
func PatchDatacenter(dcid string, obj DatacenterProperties) Datacenter
type DatacenterElementMetadata ¶
type DatacenterElementMetadata struct {
CreatedDate time.Time `json:"createdDate,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
Etag string `json:"etag,omitempty"`
LastModifiedDate time.Time `json:"lastModifiedDate,omitempty"`
LastModifiedBy string `json:"lastModifiedBy,omitempty"`
State string `json:"state,omitempty"`
}
type DatacenterEntities ¶
type DatacenterEntities struct {
Servers *Servers `json:"servers,omitempty"`
Volumes *Volumes `json:"volumes,omitempty"`
Loadbalancers *Loadbalancers `json:"loadbalancers,omitempty"`
Lans *Lans `json:"lans,omitempty"`
}
type DatacenterProperties ¶
type Datacenters ¶
type Datacenters struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Datacenter `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListDatacenters ¶
func ListDatacenters() Datacenters
type FirewallRule ¶
type FirewallRule struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties FirewallruleProperties `json:"properties,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func CreateFirewallRule ¶
func CreateFirewallRule(dcid string, srvid string, nicId string, fw FirewallRule) FirewallRule
func GetFirewallRule ¶
func GetFirewallRule(dcid string, srvid string, nicId string, fwId string) FirewallRule
func PatchFirewallRule ¶
func PatchFirewallRule(dcid string, srvid string, nicId string, fwId string, obj FirewallruleProperties) FirewallRule
type FirewallRules ¶
type FirewallRules struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []FirewallRule `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListFirewallRules ¶
func ListFirewallRules(dcId string, serverid string, nicId string) FirewallRules
type FirewallruleProperties ¶
type FirewallruleProperties struct {
Name string `json:"name,omitempty"`
Protocol string `json:"protocol,omitempty"`
SourceMac string `json:"sourceMac,omitempty"`
SourceIp string `json:"sourceIp,omitempty"`
TargetIp string `json:"targetIp,omitempty"`
IcmpCode interface{} `json:"icmpCode,omitempty"`
IcmpType interface{} `json:"icmpType,omitempty"`
PortRangeStart interface{} `json:"portRangeStart,omitempty"`
PortRangeEnd interface{} `json:"portRangeEnd,omitempty"`
}
type Image ¶
type Image struct {
Id string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties ImageProperties `json:"properties,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
type ImageProperties ¶
type ImageProperties struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Location string `json:"location,omitempty"`
Size int `json:"size,omitempty"`
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
RamHotPlug bool `json:"ramHotPlug,omitempty"`
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
NicHotPlug bool `json:"nicHotPlug,omitempty"`
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
LicenceType string `json:"licenceType,omitempty"`
ImageType string `json:"imageType,omitempty"`
Public bool `json:"public,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
type Images ¶
type Images struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Image `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListAttachedCdroms ¶
type IpBlock ¶
type IpBlock struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties IpBlockProperties `json:"properties,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func GetIpBlock ¶
func ReserveIpBlock ¶
type IpBlockProperties ¶
type IpBlocks ¶
type IpBlocks struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []IpBlock `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
type Lan ¶
type Lan struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties LanProperties `json:"properties,omitempty"`
Entities *LanEntities `json:"entities,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func CreateLan ¶
CreateLan creates a lan in the datacenter from a jason []byte and returns a Instance struct
type LanEntities ¶
type LanEntities struct {
Nics *LanNics `json:"nics,omitempty"`
}
type LanProperties ¶
type LanProperties struct {
Name string `json:"name,omitempty"`
Public interface{} `json:"public,omitempty"`
}
type Lans ¶
type LoablanacerCreateRequest ¶
type LoablanacerCreateRequest struct {
LoadbalancerProperties `json:"properties"`
}
type Loadbalancer ¶
type Loadbalancer struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties LoadbalancerProperties `json:"properties,omitempty"`
Entities LoadbalancerEntities `json:"entities,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func CreateLoadbalancer ¶
func CreateLoadbalancer(dcid string, request Loadbalancer) Loadbalancer
Createloadbalancer creates a loadbalancer in the datacenter from a jason []byte and returns a Instance struct
func GetLoadbalancer ¶
func GetLoadbalancer(dcid, lbalid string) Loadbalancer
GetLoadbalancer pulls data for the Loadbalancer where id = lbalid returns a Instance struct
func PatchLoadbalancer ¶
func PatchLoadbalancer(dcid string, lbalid string, obj LoadbalancerProperties) Loadbalancer
type LoadbalancerEntities ¶
type LoadbalancerEntities struct {
Balancednics *BalancedNics `json:"balancednics,omitempty"`
}
type LoadbalancerProperties ¶
type Loadbalancers ¶
type Loadbalancers struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Loadbalancer `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListLoadbalancers ¶
func ListLoadbalancers(dcid string) Loadbalancers
Listloadbalancers returns a Collection struct for loadbalancers in the Datacenter
type Location ¶
type Location struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties Properties `json:"properties,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
type Locations ¶
type Locations struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Location `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
type Nic ¶
type Nic struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties NicProperties `json:"properties,omitempty"`
Entities *NicEntities `json:"entities,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func CreateNic ¶
CreateNic creates a nic on a server from a jason []byte and returns a Instance struct
func GetBalancedNic ¶
type NicCreateRequest ¶
type NicCreateRequest struct {
NicProperties `json:"properties"`
}
type NicEntities ¶
type NicEntities struct {
Firewallrules *FirewallRules `json:"firewallrules,omitempty"`
}
type NicProperties ¶
type Nics ¶
type Nics struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Nic `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListBalancedNics ¶
type Properties ¶
type Properties struct {
Name string `json:"name,omitempty"`
}
type RequestStatus ¶
type RequestStatus struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata RequestStatusMetadata `json:"metadata,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func GetRequestStatus ¶
func GetRequestStatus(path string) RequestStatus
type RequestStatusMetadata ¶
type RequestStatusMetadata struct {
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
Etag string `json:"etag,omitempty"`
Targets []RequestTarget `json:"targets,omitempty"`
}
type RequestTarget ¶
type RequestTarget struct {
Target ResourceReference `json:"target,omitempty"`
Status string `json:"status,omitempty"`
}
type ResourceReference ¶
type Resp ¶
Resp is the struct returned by all Rest request functions
func DeleteBalancedNic ¶
func DeleteDatacenter ¶
func DeleteFirewallRule ¶
func DeleteLoadbalancer ¶
func DeleteServer ¶
DeleteServer deletes the server where id=srvid and returns Resp struct
func DeleteSnapshot ¶
func DeleteVolume ¶
func DetachCdrom ¶
func DetachVolume ¶
func ReleaseIpBlock ¶
func (*Resp) PrintHeaders ¶
func (r *Resp) PrintHeaders()
PrintHeaders prints the http headers as k,v pairs
type Server ¶
type Server struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties ServerProperties `json:"properties,omitempty"`
Entities *ServerEntities `json:"entities,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func CreateServer ¶
CreateServer creates a server from a jason []byte and returns a Instance struct
func PatchServer ¶
func PatchServer(dcid string, srvid string, props ServerProperties) Server
PatchServer partial update of server properties passed in as jason []byte Returns Instance struct
type ServerEntities ¶
type ServerProperties ¶
type ServerProperties struct {
Name string `json:"name,omitempty"`
Cores int `json:"cores,omitempty"`
Ram int `json:"ram,omitempty"`
AvailabilityZone string `json:"availabilityZone,omitempty"`
VmState string `json:"vmState,omitempty"`
BootCdrom *ResourceReference `json:"bootCdrom,omitempty"`
BootVolume *ResourceReference `json:"bootVolume,omitempty"`
CpuFamily string `json:"cpuFamily,omitempty"`
}
type Servers ¶
type Servers struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Server `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListServers ¶
ListServers returns a server struct collection
type Snapshot ¶
type Snapshot struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata DatacenterElementMetadata `json:"metadata,omitempty"`
Properties SnapshotProperties `json:"properties,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func GetSnapshot ¶
func UpdateSnapshot ¶
func UpdateSnapshot(snapshotId string, request SnapshotProperties) Snapshot
type SnapshotProperties ¶
type SnapshotProperties struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Location string `json:"location,omitempty"`
Size int `json:"size,omitempty"`
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
RamHotPlug bool `json:"ramHotPlug,omitempty"`
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
NicHotPlug bool `json:"nicHotPlug,omitempty"`
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
LicenceType string `json:"licenceType,omitempty"`
}
type Snapshots ¶
type Snapshots struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Snapshot `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListSnapshots ¶
func ListSnapshots() Snapshots
type Volume ¶
type Volume struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Metadata *DatacenterElementMetadata `json:"metadata,omitempty"`
Properties VolumeProperties `json:"properties,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func CreateVolume ¶
func GetAttachedCdrom ¶
func GetAttachedVolume ¶
func PatchVolume ¶
func PatchVolume(dcid string, volid string, request VolumeProperties) Volume
type VolumeProperties ¶
type VolumeProperties struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Size int `json:"size,omitempty"`
AvailabilityZone string `json:"availabilityZone,omitempty"`
Image string `json:"image,omitempty"`
ImagePassword string `json:"imagePassword,omitempty"`
SshKeys []string `json:"sshKeys,omitempty"`
Bus string `json:"bus,omitempty"`
LicenceType string `json:"licenceType,omitempty"`
CpuHotPlug bool `json:"cpuHotPlug,omitempty"`
CpuHotUnplug bool `json:"cpuHotUnplug,omitempty"`
RamHotPlug bool `json:"ramHotPlug,omitempty"`
RamHotUnplug bool `json:"ramHotUnplug,omitempty"`
NicHotPlug bool `json:"nicHotPlug,omitempty"`
NicHotUnplug bool `json:"nicHotUnplug,omitempty"`
DiscVirtioHotPlug bool `json:"discVirtioHotPlug,omitempty"`
DiscVirtioHotUnplug bool `json:"discVirtioHotUnplug,omitempty"`
DiscScsiHotPlug bool `json:"discScsiHotPlug,omitempty"`
DiscScsiHotUnplug bool `json:"discScsiHotUnplug,omitempty"`
DeviceNumber int64 `json:"deviceNumber,omitempty"`
}
type Volumes ¶
type Volumes struct {
Id string `json:"id,omitempty"`
Type_ string `json:"type,omitempty"`
Href string `json:"href,omitempty"`
Items []Volume `json:"items,omitempty"`
Response string `json:"Response,omitempty"`
Headers *http.Header `json:"headers,omitempty"`
StatusCode int `json:"headers,omitempty"`
}
func ListAttachedVolumes ¶
func ListVolumes ¶
ListVolumes returns a Collection struct for volumes in the Datacenter