profitbricks

package module
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2016 License: Apache-2.0 Imports: 8 Imported by: 77

README

Go SDK

The ProfitBricks Client Library for Go provides you with access to the ProfitBricks REST API. It is designed for developers who are building applications in Go.

This guide will walk you through getting setup with the library and performing various actions against the API.

Table of Contents

Concepts

The Go SDK wraps the latest version of the ProfitBricks REST API. All API operations are performed over SSL and authenticated using your ProfitBricks portal credentials. The API can be accessed within an instance running in ProfitBricks or directly over the Internet from any application that can send an HTTPS request and receive an HTTPS response.

Getting Started

Before you begin you will need to have signed-up for a ProfitBricks account. The credentials you setup during sign-up will be used to authenticate against the API.

Install the Go language from: Go Installation

The GOPATH environment variable specifies the location of your Go workspace. It is likely the only environment variable you'll need to set when developing Go code. This is an example of pointing to a workspace configured underneath your home directory:

mkdir -p ~/go/bin
export GOPATH=~/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN

Installation

The following go command will download profitbricks-sdk-go to your configured GOPATH:

go get "github.com/profitbricks/profitbricks-sdk-go"

The source code of the package will be located at:

$GOBIN\src\profitbricks-sdk-go

Create main package file example.go:

package main

import (
	"fmt"
)

func main() {
}

Import GO SDK:

import(
	"github.com/profitbricks/profitbricks-sdk-go"
)

Add your credentials for connecting to ProfitBricks:

profitbricks.SetAuth("username", "password")

Set depth:

profitbricks.SetDepth("5")

Depth controls the amount of data returned from the REST server ( range 1-5 ). The larger the number the more information is returned from the server. This is especially useful if you are looking for the information in the nested objects.

Caution: You will want to ensure you follow security best practices when using credentials within your code or stored in a file.

How To's

How To: Create Data Center

ProfitBricks introduces the concept of Data Centers. These are logically separated from one another and allow you to have a self-contained environment for all servers, volumes, networking, snapshots, and so forth. The goal is to give you the same experience as you would have if you were running your own physical data center.

The following code example shows you how to programmatically create a data center:

dcrequest := profitbricks.Datacenter{
		Properties: profitbricks.DatacenterProperties{
			Name:        "example.go3",
			Description: "description",
			Location:    "us/lasdev",
		},
	}

datacenter := profitbricks.CreateDatacenter(dcrequest)

How To: Create Data Center with Multiple Resources

To create a complex Data Center you would do this. As you can see, you can create quite a few of the objects you will need later all in one request.:

datacenter := model.Datacenter{
		Properties: model.DatacenterProperties{
			Name: "composite test",
			Location:location,
		},
		Entities:model.DatacenterEntities{
			Servers: &model.Servers{
				Items:[]model.Server{
					model.Server{
						Properties: model.ServerProperties{
							Name : "server1",
							Ram: 2048,
							Cores: 1,
						},
						Entities:model.ServerEntities{
							Volumes: &model.AttachedVolumes{
								Items:[]model.Volume{
									model.Volume{
										Properties: model.VolumeProperties{
											Type_:"HDD",
											Size:10,
											Name:"volume1",
											Image:"1f46a4a3-3f47-11e6-91c6-52540005ab80",
											Bus:"VIRTIO",
											ImagePassword:"test1234",
											SshKeys: []string{"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoLVLHON4BSK3D8L4H79aFo..."},
										},
									},
								},
							},
							Nics: &model.Nics{
								Items: []model.Nic{
									model.Nic{
										Properties: model.NicProperties{
											Name : "nic",
											Lan : "1",
										},
									},
								},
							},
						},
					},
				},
			},
		},
	}
	
dc := CompositeCreateDatacenter(datacenter)

How To: Delete Data Center

You will want to exercise a bit of caution here. Removing a data center will destroy all objects contained within that data center -- servers, volumes, snapshots, and so on.

The code to remove a data center is as follows. This example assumes you want to remove previously data center:

profitbricks.DeleteDatacenter(response.Id)

How To: Create Server

The server create method has a list of required parameters followed by a hash of optional parameters. The optional parameters are specified within the "options" hash and the variable names match the REST API parameters.

The following example shows you how to create a new server in the data center created above:

req := profitbricks.Server{
 		Properties: profitbricks.ServerProperties{
 			Name:  "go01",
 			Ram:   1024,
 			Cores: 2,
 		},
}
server := CreateServer(datacenter.Id, req)

How To: List Available Images

A list of disk and ISO images are available from ProfitBricks for immediate use. These can be easily viewed and selected. The following shows you how to get a list of images. This list represents both CDROM images and HDD images.

images := profitbricks.ListImages()

This will return a collection object

How To: Create Storage Volume

ProfitBricks allows for the creation of multiple storage volumes that can be attached and detached as needed. It is useful to attach an image when creating a storage volume. The storage size is in gigabytes.

volumerequest := profitbricks.Volume{
		Properties: profitbricks.VolumeProperties{
			Size:        1,
			Name:        "Volume Test",
			LicenceType: "LINUX",
			Type:        "HDD",
		},
}

storage := CreateVolume(datacenter.Id, volumerequest)

How To: Update Cores and Memory

ProfitBricks allows users to dynamically update cores, memory, and disk independently of each other. This removes the restriction of needing to upgrade to the next size available size to receive an increase in memory. You can now simply increase the instances memory keeping your costs in-line with your resource needs.

Note: The memory parameter value must be a multiple of 256, e.g. 256, 512, 768, 1024, and so forth.

The following code illustrates how you can update cores and memory:

serverupdaterequest := profitbricks.ServerProperties{
	Cores: 1,
	Ram:   256,
}

resp := PatchServer(datacenter.Id, server.Id, serverupdaterequest)

How To: Attach or Detach Storage Volume

ProfitBricks allows for the creation of multiple storage volumes. You can detach and reattach these on the fly. This allows for various scenarios such as re-attaching a failed OS disk to another server for possible recovery or moving a volume to another location and spinning it up.

The following illustrates how you would attach and detach a volume and CDROM to/from a server:

profitbricks.AttachVolume(datacenter.Id, server.Id, volume.Id)
profitbricks.AttachCdrom(datacenter.Id, server.Id, images.Items[0].Id)

profitbricks.DetachVolume(datacenter.Id, server.Id, volume.Id)
profitbricks.DetachCdrom(datacenter.Id, server.Id, images.Items[0].Id)

How To: List Servers, Volumes, and Data Centers

Go SDK provides standard functions for retrieving a list of volumes, servers, and datacenters.

The following code illustrates how to pull these three list types:

volumes := profitbricks.ListVolumes(datacenter.Id)

servers := profitbricks.ListServers(datacenter.Id)

datacenters := profitbricks.ListDatacenters()

Example

package main

import (
	"fmt"
	"time"

	"github.com/profitbricks/profitbricks-sdk-go"
)

func main() {

	//Sets username and password
	profitbricks.SetAuth("username", "password")
	//Sets depth.
	profitbricks.SetDepth("5")

	dcrequest := profitbricks.Datacenter{
		Properties: profitbricks.DatacenterProperties{
			Name:        "example.go3",
			Description: "description",
			Location:    "us/lasdev",
		},
	}

	datacenter := profitbricks.CreateDatacenter(dcrequest)

	serverrequest := profitbricks.Server{
		Properties: profitbricks.ServerProperties{
			Name:  "go01",
			Ram:   1024,
			Cores: 2,
		},
	}
	server := profitbricks.CreateServer(datacenter.Id, serverrequest)

	volumerequest := profitbricks.Volume{
		Properties: profitbricks.VolumeProperties{
			Size:        1,
			Name:        "Volume Test",
			LicenceType: "LINUX",
			Type:        "HDD",
		},
	}

	storage := profitbricks.CreateVolume(datacenter.Id, volumerequest)

	serverupdaterequest := profitbricks.ServerProperties{
		Name:  "go01renamed",
		Cores: 1,
		Ram:   256,
	}

	profitbricks.PatchServer(datacenter.Id, server.Id, serverupdaterequest)
	//It takes a moment for a volume to be provisioned so we wait.
	time.Sleep(60 * time.Second)

	profitbricks.AttachVolume(datacenter.Id, server.Id, storage.Id)

	volumes := profitbricks.ListVolumes(datacenter.Id)
	fmt.Println(volumes.Items)
	servers := profitbricks.ListServers(datacenter.Id)
	fmt.Println(servers.Items)
	datacenters := profitbricks.ListDatacenters()
	fmt.Println(datacenters.Items)

	profitbricks.DeleteServer(datacenter.Id, server.Id)
	profitbricks.DeleteDatacenter(datacenter.Id)
}

Support

You are welcome to contact us with questions or comments at ProfitBricks DevOps Central. Please report any issues via GitHub's issue tracker.

Documentation

Overview

Package profitbricks is a client library for interacting with Profitbricks RESTful APIs.

Index

Constants

View Source
const AgentHeader = "profitbricks-sdk-go/3.0.0"
View Source
const CommandHeader = "application/x-www-form-urlencoded"

CommandHeader is used with is_command

View Source
const FullHeader = "application/json"

FullHeader is the standard header to include with all http requests except is_patch and is_command

View Source
const PatchHeader = "application/json"

PatchHeader is used with is_patch .

Variables

View Source
var Depth = "5"
View Source
var Endpoint = "https://api.profitbricks.com/cloudapi/v3"

Endpoint is the base url for REST requests.

View Source
var Passwd string

Password for authentication .

View Source
var Username string

Username for authentication .

Functions

func MkJson

func MkJson(i interface{}) string

func SetAuth

func SetAuth(u, p string)

func SetDepth

func SetDepth(newdepth string) string

SetDepth is used to set Depth

func SetEndpoint

func SetEndpoint(newendpoint string) string

SetEndpoint is used to set the REST Endpoint. Endpoint is declared in config.go

Types

type BalancedNics

type BalancedNics struct {
	Id    string `json:"id,omitempty"`
	Type_ string `json:"type,omitempty"`
	Href  string `json:"href,omitempty"`
	Items []Nic  `json:"items,omitempty"`
}

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 DatacenterProperties struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Location    string `json:"location,omitempty"`
	Version     int32  `json:"version,omitempty"`
}

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"`
}

func AttachCdrom

func AttachCdrom(dcid string, srvid string, cdid string) Image

func GetImage

func GetImage(imageid string) Image

GetImage returns an Instance struct where id ==imageid

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

func ListAttachedCdroms(dcid, srvid string) Images

func ListImages

func ListImages() Images

ListImages returns an Collection struct

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 GetIpBlock(ipblockid string) IpBlock

func ReserveIpBlock

func ReserveIpBlock(request IpBlock) IpBlock

type IpBlockProperties

type IpBlockProperties struct {
	Ips      []string `json:"ips,omitempty"`
	Location string   `json:"location,omitempty"`
	Size     int      `json:"size,omitempty"`
}

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"`
}

func ListIpBlocks

func ListIpBlocks() IpBlocks

ListIpBlocks

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

func CreateLan(dcid string, request Lan) Lan

CreateLan creates a lan in the datacenter from a jason []byte and returns a Instance struct

func GetLan

func GetLan(dcid, lanid string) Lan

GetLan pulls data for the lan where id = lanid returns an Instance struct

func PatchLan

func PatchLan(dcid string, lanid string, obj LanProperties) Lan

PatchLan does a partial update to a lan using json from []byte jason returns a Instance struct

type LanEntities

type LanEntities struct {
	Nics *LanNics `json:"nics,omitempty"`
}

type LanNics

type LanNics struct {
	Id    string `json:"id,omitempty"`
	Type_ string `json:"type,omitempty"`
	Href  string `json:"href,omitempty"`
	Items []Nic  `json:"items,omitempty"`
}

type LanProperties

type LanProperties struct {
	Name   string      `json:"name,omitempty"`
	Public interface{} `json:"public,omitempty"`
}

type Lans

type Lans struct {
	Id         string       `json:"id,omitempty"`
	Type_      string       `json:"type,omitempty"`
	Href       string       `json:"href,omitempty"`
	Items      []Lan        `json:"items,omitempty"`
	Response   string       `json:"Response,omitempty"`
	Headers    *http.Header `json:"headers,omitempty"`
	StatusCode int          `json:"headers,omitempty"`
}

func ListLans

func ListLans(dcid string) Lans

ListLan returns a Collection for lans in the Datacenter

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 LoadbalancerProperties struct {
	Name string `json:"name,omitempty"`
	Ip   string `json:"ip,omitempty"`
	Dhcp bool   `json:"dhcp,omitempty"`
}

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"`
}

func GetLocation

func GetLocation(locid string) Location

GetLocation returns location data

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"`
}

func ListLocations

func ListLocations() Locations

ListLocations returns location collection data

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 AssociateNic

func AssociateNic(dcid string, lbalid string, nicid string) Nic

func CreateNic

func CreateNic(dcid string, srvid string, request Nic) Nic

CreateNic creates a nic on a server from a jason []byte and returns a Instance struct

func GetBalancedNic

func GetBalancedNic(dcid, lbalid, balnicid string) Nic

func GetNic

func GetNic(dcid, srvid, nicid string) Nic

GetNic pulls data for the nic where id = srvid returns a Instance struct

func PatchNic

func PatchNic(dcid string, srvid string, nicid string, obj NicProperties) Nic

PatchNic partial update of nic properties passed in as jason []byte Returns Instance struct

type NicCreateRequest

type NicCreateRequest struct {
	NicProperties `json:"properties"`
}

type NicEntities

type NicEntities struct {
	Firewallrules *FirewallRules `json:"firewallrules,omitempty"`
}

type NicProperties

type NicProperties struct {
	Name           string   `json:"name,omitempty"`
	Mac            string   `json:"mac,omitempty"`
	Ips            []string `json:"ips,omitempty"`
	Dhcp           bool     `json:"dhcp,omitempty"`
	Lan            int      `json:"lan,omitempty"`
	FirewallActive bool     `json:"firewallActive,omitempty"`
	Nat            bool     `json:"nat,omitempty"`
}

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

func ListBalancedNics(dcid, lbalid string) Nics

func ListNics

func ListNics(dcid, srvid string) Nics

ListNics returns a Nics struct collection

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 ResourceReference struct {
	Id    string `json:"id,omitempty"`
	Type_ string `json:"type,omitempty"`
	Href  string `json:"href,omitempty"`
}

type Resp

type Resp struct {
	Req        *http.Request
	StatusCode int
	Headers    http.Header
	Body       []byte
}

Resp is the struct returned by all Rest request functions

func DeleteBalancedNic

func DeleteBalancedNic(dcid, lbalid, balnicid string) Resp

func DeleteDatacenter

func DeleteDatacenter(dcid string) Resp

func DeleteFirewallRule

func DeleteFirewallRule(dcid string, srvid string, nicId string, fwId string) Resp

func DeleteLan

func DeleteLan(dcid, lanid string) Resp

DeleteLan deletes a lan where id == lanid

func DeleteLoadbalancer

func DeleteLoadbalancer(dcid, lbalid string) Resp

func DeleteNic

func DeleteNic(dcid, srvid, nicid string) Resp

DeleteNic deletes the nic where id=nicid and returns a Resp struct

func DeleteServer

func DeleteServer(dcid, srvid string) Resp

DeleteServer deletes the server where id=srvid and returns Resp struct

func DeleteSnapshot

func DeleteSnapshot(snapshotId string) Resp

func DeleteVolume

func DeleteVolume(dcid, volid string) Resp

func DetachCdrom

func DetachCdrom(dcid, srvid, cdid string) Resp

func DetachVolume

func DetachVolume(dcid, srvid, volid string) Resp

func RebootServer

func RebootServer(dcid, srvid string) Resp

RebootServer reboots a server

func ReleaseIpBlock

func ReleaseIpBlock(ipblockid string) Resp

func RestoreSnapshot

func RestoreSnapshot(dcid string, volid string, snapshotId string) Resp

func StartServer

func StartServer(dcid, srvid string) Resp

StartServer starts a server

func StopServer

func StopServer(dcid, srvid string) Resp

StopServer stops a server

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

func CreateServer(dcid string, server Server) Server

CreateServer creates a server from a jason []byte and returns a Instance struct

func GetServer

func GetServer(dcid, srvid string) Server

GetServer pulls data for the server where id = srvid 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 ServerEntities struct {
	Cdroms  *Cdroms  `json:"cdroms,omitempty"`
	Volumes *Volumes `json:"volumes,omitempty"`
	Nics    *Nics    `json:"nics,omitempty"`
}

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

func ListServers(dcid string) Servers

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 CreateSnapshot

func CreateSnapshot(dcid string, volid string, name string) Snapshot

func GetSnapshot

func GetSnapshot(snapshotId string) Snapshot

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 AttachVolume

func AttachVolume(dcid string, srvid string, volid string) Volume

func CreateVolume

func CreateVolume(dcid string, request Volume) Volume

func GetAttachedCdrom

func GetAttachedCdrom(dcid, srvid, cdid string) Volume

func GetAttachedVolume

func GetAttachedVolume(dcid, srvid, volid string) Volume

func GetVolume

func GetVolume(dcid string, volumeId string) Volume

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 ListAttachedVolumes(dcid, srvid string) Volumes

func ListVolumes

func ListVolumes(dcid string) Volumes

ListVolumes returns a Collection struct for volumes in the Datacenter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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