hpcloud

package module
v0.0.0-...-754c124 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2013 License: BSD-3-Clause Imports: 19 Imported by: 0

README

.. image:: https://travis-ci.org/AeroNotix/hpcloud.png?branch=master

HPCloud Go bindings
===================


These bindings are incredibly new and are definitely not complete, however I
am certainly looking for help!

A few examples:

.. code-block:: go

    acc, err := hpcloud.Authenticate(username, password, tenantID)
    if err != nil {
        fmt.Println(err)
        return
    }

    /*
      Upload files easily to the object store, their metadata will be set
      appropriately. The file will be MD5'd for end-to-end
      integrity checks.

      You can set extra headers with the fourth argument as described in the HPCloud
      documentation.
    */
    if err := acc.ObjectStoreUpload("/path/to/file", "container", nil); err != nil {
        Log.Fatal(err)
    }

    /* Delete items */
    if err := acc.ObjectStoreDelete("/path/to/file/on/objectstore/"); err != nil {
        Log.Fatal(err)
    }

    /* List objects in containers */
    expires_utc := "2147483647"
    list_objects, err := range acc.ListObjects("/container/")
    if err != nil {
        Log.Fatal(err)
    }
    for _, entry :=  *list_objects {
         fmt.Println(acc.TemporaryURL(entry.Name, expires_utc))
    }

    /* Create new servers, easily */
    s, err := acc.CreateServer(hpcloud.Server{
        FlavorRef: hpcloud.XSmall,
        Name:      "MyAwesomeNewServer",
        Key:       "me",
        ImageRef:  hpcloud.DebianSqueeze6_0_3Server,
    })
    if err != nil {
        Log.Fatal(err)
    }
    fmt.Sprintf("Status: %s\nID: %d\n", s.S.Status, s.S.ID)

    /* Delete that server we just created */
    fmt.Println(acc.DeleteServer(s.S.ID))

    /* You can also image your server */
    acc.CreateImage(s.S.ID, map[string]string{"Metadata":"Value"})

Any questions or bugs, please let me know and I will be happy to look over pull
requests or feature ideas.

Documentation

Overview

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const (
	XSmall = Flavor(100) + iota
	Small
	Medium
	Large
	XLarge
	DblXLarge
)

Variables

View Source
var (
	UbuntuLucid10_04Kernel    = ServerImage(1235)
	UbuntuLucid10_04          = ServerImage(1236)
	UbuntuMaverick10_10Kernel = ServerImage(1237)
	UbuntuMaverick10_10       = ServerImage(1238)
	UbuntuNatty11_04Kernel    = ServerImage(1239)
	UbuntuNatty11_04          = ServerImage(1240)
	UbuntuOneiric11_10        = ServerImage(5579)
	UbuntuPrecise12_04        = ServerImage(8419)
	CentOS5_8Server64         = ServerImage(54021)
	CentOS6_2Server64Kernel   = ServerImage(1356)
	CentOS6_2Server64Ramdisk  = ServerImage(1357)
	CentOS6_2Server64         = ServerImage(1358)
	DebianSqueeze6_0_3Kernel  = ServerImage(1359)
	DebianSqueeze6_0_3Ramdisk = ServerImage(1360)
	DebianSqueeze6_0_3Server  = ServerImage(1361)
	Fedora16Server64          = ServerImage(16291)
	BitNamiDrupal7_14_0       = ServerImage(22729)
	BitNamiWebPack1_2_0       = ServerImage(22731)
	BitNamiDevPack1_0_0       = ServerImage(4654)
	ActiveStateStackatov1_2_6 = ServerImage(14345)
	ActiveStateStackatov2_2_2 = ServerImage(59297)
	ActiveStateStackatov2_2_3 = ServerImage(60815)
	EnterpriseDBPPAS9_1_2     = ServerImage(9953)
	EnterpriseDBPSQL9_1_3     = ServerImage(9995)
)
View Source
var CDN_URL = "https://region-b.geo-1.cdnmgmt.hpcloudsvc.com/v1.0/"

CDN

View Source
var COMPUTE_URL = "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/"

Compute

View Source
var DNS_URL = "https://region-a.geo-1.dns.hpcloudsvc.com/v1/"

DNS

View Source
var OBJECT_STORE = "https://region-b.geo-1.objects.hpcloudsvc.com/v1.0/"

Object store

View Source
var RDB_URL = "https://region-a.geo-1.dbaas-mysql.hpcloudsvc.com/v1.0/"

RDB

View Source
var REGION_URL = "https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/"

Identity

View Source
var TENANT_URL = REGION_URL + "tenants"
View Source
var TOKEN_URL = REGION_URL + "tokens"

Functions

This section is empty.

Types

type Access

type Access struct {
	A struct {
		Token    Token            `json:"token"`
		User     User             `json:"user"`
		Catalogs []ServiceCatalog `json:"serviceCatalog"`
	} `json:"access"`
	Authenticated bool
	Tenants       []Tenant
	SecretKey     string
	AccessKey     string
	TenantID      string
	Client        http.Client
}

Access describes the reponse received from the /tokens endpoint when posting with username and password.

func Authenticate

func Authenticate(user, pass, tenantID string) (*Access, error)

Authenticate will send an authentication request to the HP Cloud and return an instance of the Access type.

func (Access) ActivateCDNContainer

func (a Access) ActivateCDNContainer(container string) error

Activates a container for the CDN network.

func (Access) AuthToken

func (a Access) AuthToken() string

Token is a helper method to traverse the Access type to retrieve the auth_token

func (Access) CreateDBInstance

func (a Access) CreateDBInstance(db DatabaseReq) (*NewDBInstance, error)
CreateDBInstance creates new database instance in the HPCloud using

settings found in the DatabaseReq instance passed to this function

This function implements the interface as described in:
http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/create-instance.html

func (Access) CreateDBSecRule

func (a Access) CreateDBSecRule(Req DBSecRuleReq) (*DBSecRule, error)

Creates new security group rule

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/create-security-group-rule.html

func (Access) CreateDomain

func (a Access) CreateDomain(name, email string, ttl int64) (*Domain, error)

func (Access) CreateImage

func (a Access) CreateImage(server_id string, metadata *map[string]string) error

CreateImage will make a snapshot of the server_id along with associating the relevant metadata with it.

func (Access) CreateRecord

func (a Access) CreateRecord(domain Domain, t, data string) (*Record, error)

func (Access) CreateServer

func (a Access) CreateServer(s Server) (*ServerResponse, error)

CreateServer creates a new server in the HPCloud using the settings found in the Server instance passed to this function.

This function implements the interface as described in:- * https://docs.hpcloud.com/api/compute/ * section 4.4.5.2 Create Server

func (Access) DBSecGroupDetails

func (a Access) DBSecGroupDetails(sg string) (*SecurityGroup, error)

This function lists specific security group.

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/get-security-group.html

func (Access) DeleteCDNEnabledContainer

func (a Access) DeleteCDNEnabledContainer(container string) error

Entirely deletes a container from the CDN, note: this does not delete the container from the objectstore.

func (Access) DeleteDBInstance

func (a Access) DeleteDBInstance(instanceID string) error
This function takes instance ID and deletes database instance with this ID.

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/delete-instance.html

func (Access) DeleteDomain

func (a Access) DeleteDomain(domain Domain) error

func (Access) DeleteImage

func (a Access) DeleteImage(image_id string) error

func (Access) DeleteServer

func (a Access) DeleteServer(server_id string) error

DeleteServer deletes the server with the `server_id`.

This function implements the interface described in:- * https://docs.hpcloud.com/api/compute/ * Section 4.4.6.3 Delete Server

func (Access) DetachVolume

func (a Access) DetachVolume(at Attachment) error

DetachVolume will remove a volume from whatever server it is attached to.

func (Access) DisableCDNEnabledContainer

func (a Access) DisableCDNEnabledContainer(container string) error

Disables a container from the CDN. This is usually preferred over deleting the CDN container since the the container will remain in the CDN and thus can be activated at a later time with no overhead.

func (Access) EnableCDNEnabledContainer

func (a Access) EnableCDNEnabledContainer(container string) error

Re-enables a container.

func (Access) GetConsoleOutput

func (a Access) GetConsoleOutput(server_id string, length int) (string, error)

func (Access) GetDBFlavor

func (a Access) GetDBFlavor(ID string) (*DBFlavor, error)

This function returns flavor specs for given flavor.

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/get-flavor.html

func (Access) GetDBInstance

func (a Access) GetDBInstance(id string) (*InstDetails, error)
This function retrieves details of the instance with provided ID.

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/get-instance.html

func (Access) GetDBSecurityGroups

func (a Access) GetDBSecurityGroups() (*[]SecurityGroup, error)

This function lists all the security groups available for tenant.

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/list-security-groups.html

func (Access) GetEndpointURL

func (a Access) GetEndpointURL(servName string, region string) string
This function takes service name and region as parameters and returns

public URL for endpoint, that can be queried later on.

func (*Access) GetTenants

func (a *Access) GetTenants() error

func (Access) GetVNCConsole

func (a Access) GetVNCConsole(server_id int64) (string, error)

GetVNCConsole retrieves the VNC URL for the specified server.

func (Access) HMAC

func (a Access) HMAC(secret_key, tenant, hmac_body string) string

HMAC is a helper method to interpolate and properly format the HMAC signature which is used on the HPCloud.

func (Access) HMAC_PostBody

func (a Access) HMAC_PostBody(max_file_size, max_file_count, path,
	redirect, expires, tenant string) string

Generates the FilePOST body which should be hashed with using the HMAC-SHA1 hash and used as the signature for the POST request.

func (Access) ListAllFlavors

func (a Access) ListAllFlavors() (*DBFlavors, error)
ListAllFlavors lists all available database flavors.
This function implements interface as described in:-

http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/list-flavors.html

func (Access) ListCDNEnabledContainers

func (a Access) ListCDNEnabledContainers(enabled_only bool) (*CDNContainers, error)

Lists available containers.

When enabled_only == true you will only receive the containers which are enabled and the disabled containers will be ignored.

func (Access) ListDBInstances

func (a Access) ListDBInstances() (*DBInstances, error)
ListDBInstances will list all the available database instances

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/list-database-instances.html

func (Access) ListDomains

func (a Access) ListDomains() ([]Domain, error)

func (Access) ListFlavors

func (a Access) ListFlavors() (*Flavors, error)

ListFlavors will list all the available flavours on the HPCloud compute API.

func (Access) ListImage

func (a Access) ListImage(image_id string) (*Image, error)

func (Access) ListImages

func (a Access) ListImages() (*Images, error)

func (Access) ListObjects

func (a Access) ListObjects(directory string) (*FileList, error)

func (Access) ListServerAddresses

func (a Access) ListServerAddresses(server_id int64) ([]Address, error)

ListServerAddresses will list all the addresses associated with the provided server_id.

func (Access) ListServers

func (a Access) ListServers() ([]Server, error)

func (Access) ListSnapshots

func (a Access) ListSnapshots() ([]Volume, error)

ListSnapshots will return a slice of Volumes for which are in-fact snapshots of your systems.

func (Access) ListVolumes

func (a Access) ListVolumes() ([]Volume, error)

ListVolumes returns a slice of volumes which are currently associated with the token_id you provide.

func (Access) ListVolumesForServer

func (a Access) ListVolumesForServer(server_id string) ([]Attachment, error)

func (Access) NewVolume

func (a Access) NewVolume(v *Volume) error

NewVolume takes a volume instance and will create that in the cloud. This function will return *before* the instance is created. In order to know when the instance has been created you will need to check the status using the provided methods.

func (Access) ObjectStoreDelete

func (a Access) ObjectStoreDelete(filename string) error

func (Access) ObjectStoreUpload

func (a Access) ObjectStoreUpload(filename, container string, header *http.Header) error

ObjectStoreUpload allows you to upload a file onto the HPCloud, it will hash the file and check the returned hash to ensure end-to-end integrity.

It also takes an optional header which will have it's contents added to the request.

func (Access) RebootServer

func (a Access) RebootServer(server_id string) error

RebootServer will reboot the server with the `server_id`.

This function implements the interface described in:- * https://docs.hpcloud.com/api/compute/ * Section 4.4.7.1 Reboot Server

func (Access) RemoveDBSecRule

func (a Access) RemoveDBSecRule(ruleID string) error

Deletes security rule

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/delete-security-group-rule.html

func (Access) ResetDBPassword

func (a Access) ResetDBPassword(id string) (*DBCredentials, error)

This function takes instance ID and resets password for this instance. It returns a new instance password.

This function implements the interface as decribed in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/reset-instance-password.html

func (Access) RestartDBInstance

func (a Access) RestartDBInstance(instanceID string) error
This function takes instance ID and restarts DB instance with this ID.

This function implements the interface as described in: http://api-docs.hpcloud.com/hpcloud-rdb-mysql/1.0/content/restart-instance.html

func (Access) RetrieveCDNEnabledContainerMetadata

func (a Access) RetrieveCDNEnabledContainerMetadata(container string) (*http.Header, error)

Will return the metadata associated with a single container.

func (Access) ScopeToken

func (a Access) ScopeToken(name string) (*Access, error)

ScopeToken will scope or rescope an Auth Token to a different tenantID

func (Access) TemporaryURL

func (a Access) TemporaryURL(filename, expires string) string

TemporaryURL will generate the temporary URL for the supplied filename.

func (Access) TenantForName

func (a Access) TenantForName(name string) (string, error)

On the HP Cloud, tenants have name strings associated with them, you can find the tenantID associated with a name with this function

func (Access) UpdateCDNEnabledContainerMetadata

func (a Access) UpdateCDNEnabledContainerMetadata(container string, data map[string]string) error

Updates the metadata associated with a container.

data will be the extra headers sent with the request, which ultimately end up being the metadata.

type Address

type Address struct {
	Addr    string
	Version int64
}

type Addresses

type Addresses struct {
	Private []Address
}

type Attachment

type Attachment struct {
	ID       int64  `json:"id"`
	Device   string `json:"device"`
	ServerID int64  `json:"serverId"`
	VolumeID int64  `json:"volumeId"`
}

type BadRequest

type BadRequest struct {
	B struct {
		Message string `json:"message"`
		Details string `json:"details"`
		Code    int64  `json:"code"`
	} `json:"BadRequest"`
}

BadRequest describes the response from a JSON resource when the data which was sent in the original request was malformed or not compliant with the layout specified in the HPCloud documentation

func (BadRequest) Code

func (b BadRequest) Code() int64

func (BadRequest) Details

func (b BadRequest) Details() string

func (BadRequest) Message

func (b BadRequest) Message() string

type CDNContainer

type CDNContainer struct {
	Name         string `json:"name"`
	CDNEnabled   bool   `json:"cdn_enabled"`
	TTL          int64  `json:"ttl"`
	CDNUri       string `json:"x-cdn-uri"`
	SSLCDNUri    string `json:"x-cdn-ssl-uri"`
	LogRetention bool   `json:"log_retention"`
}

type CDNContainers

type CDNContainers []CDNContainer

type DBCredentials

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

This type describes Database Credentials

type DBFlavor

type DBFlavor struct {
	Id    int    `json:"id"`
	Links []Link `json:"links"`
	Name  string `json:"name"`
	Ram   int    `json:"ram"`
	Vcpu  int    `json:"vcpu"`
}

Type describing database flavor

type DBFlavors

type DBFlavors struct {
	Flavors []DBFlavor `json:"flavors"`
}

func (DBFlavors) GetFlavorRef

func (f DBFlavors) GetFlavorRef(fn string) string

type DBInstance

type DBInstance struct {
	Created string `json:"created"`
	Id      string `json:"id"`
	Links   []Link `json:"links"`
	Name    string `json:"name"`
	Status  string `json:"name"`
	Flavor  struct {
		Name  string `json:"name"`
		ID    string `json:"id"`
		Links []Link `json:"links"`
	} `json:"flavor"`
}

type DBInstances

type DBInstances struct {
	Instances []DBInstance `json:"instances"`
}

type DBSecGroups

type DBSecGroups struct {
	Id    string `json:"id"`
	Links []Link `json:"links"`
}

This type describes Database Security groups

type DBSecRule

type DBSecRule struct {
	ID              string `json:"id"`
	SecurityGroupID string `json:"security_group_rule"`
	Cidr            string `json:"cidr"`
	FromPort        int64  `json:"from_port"`
	ToPort          int64  `json:"to_port"`
	Created         string `json:"created"`
}

type DBSecRuleReq

type DBSecRuleReq struct {
	SecurityGroupID string `json:"security_group_rule"`
	Cidr            string `json:"cidr"`
	FromPort        int64  `json:"from_port"`
	ToPort          int64  `json:"to_port"`
}

DB Security Group Create request struct

func (DBSecRuleReq) MarshalJSON

func (rq DBSecRuleReq) MarshalJSON() ([]byte, error)

type DNSError

type DNSError struct {
	Path      string `json:"path"`
	Message   string `json:"message"`
	Validator string `json:"validator"`
}

type DNSErrorResponse

type DNSErrorResponse struct {
	Message string     `json:"message"`
	Code    int        `json:"code"`
	Type    string     `json:"type"`
	Errors  []DNSError `json:"errors"`
}

type Database

type Database struct {
	Name      string `json:"name"`
	FlavorRef string `json:"flavorRef"`
	Port      int    `json:"port"`
	DBType    struct {
		Name    string `json:"name"`
		Version string `json:"version"`
	} `json:"dbtype"`
}

type DatabaseReq

type DatabaseReq struct {
	Instance Database `json:"instance"`
}
This type describes the JSON data which should be sent to the

create database instance resource.

func (DatabaseReq) MarshalJSON

func (db DatabaseReq) MarshalJSON() ([]byte, error)

Creates JSON string for Create DB request

type Domain

type Domain struct {
	ID        string  `json:"id"`
	Name      string  `json:"name"`
	TTL       int64   `json:"ttl"`
	Serial    int64   `json:"serial"`
	Email     string  `json:"email"`
	CreateAt  string  `json:"created_at"`
	UpdatedAt *string `json:"updated_at"`
	Data      string  `json:"data"`
}

type Endpoint

type Endpoint struct {
	PublicURL   string `json:"publicURL"`
	Region      string `json:"region"`
	VersionID   string `json:"versionId"`
	VersionList string `json:"versionList"`
}

type FailureResponse

type FailureResponse interface {
	Code() int64
	Details() string
	Message() string
}

type File

type File struct {
	Hash            string `json:"hash"`
	StrLastModified string `json:"last_modified"`
	LastModified    *time.Time
	Bytes           int64  `json:"bytes"`
	Name            string `json:"name"`
	ContentType     string `json:"content_type"`
}

type FileList

type FileList []File

type Flavor

type Flavor int

Server flavours Smallest to Largest

type Flavor_

type Flavor_ struct {
	Name  string `json:"name"`
	ID    int64  `json:"id"`
	Links []Link `json:"links"`
}

type Flavors

type Flavors struct {
	F []Flavor_ `json:"flavors"`
}

type Forbidden

type Forbidden struct {
	F struct {
		Code            int64  `json:"code"`
		Details         string `json:"details"`
		Message         string `json:"message"`
		OtherAttributes struct {
		} `json:"otherAttributes"`
	} `json:"forbidden"`
}

Forbidden describes the response from a JSON resource when the request could not be completed due to the user making the request being disabled or suspended.

func (Forbidden) Code

func (f Forbidden) Code() int64

func (Forbidden) Details

func (f Forbidden) Details() string

func (Forbidden) Message

func (f Forbidden) Message() string

type HashedFile

type HashedFile struct {
	MD5          hash.Hash
	FileContents *bytes.Reader

	Length int
	// contains filtered or unexported fields
}

HashedFile is an io.ReadWriter which reads a file into memory whilst giving you access to the hashed contents and only reading the file once

func OpenAndHashFile

func OpenAndHashFile(filename string) (*HashedFile, error)

Helper function to open, hash and return an io.ReadWriter of the file.

func (HashedFile) Hash

func (h HashedFile) Hash() string

Returns the current hash of the file.

func (HashedFile) Read

func (h HashedFile) Read(p []byte) (n int, err error)

Implements io.Reader

func (*HashedFile) Write

func (h *HashedFile) Write(p []byte) (int, error)

Implements io.Writer

type IDLink struct {
	Name  string `json:"name"`
	ID    string `json:"id"`
	Links []Link `json:"links"`
}

Several embedded types are simply an ID string with a slice of Link

type Image

type Image struct {
	I struct {
		Name     string            `json:"name"`
		ID       string            `json:"id"`
		Links    []Link            `json:"links"`
		Progress int               `json:"progress"`
		Metadata map[string]string `json:"metadata"`
		Status   string            `json:"status"`
		Updated  string            `json:"updated"`
	} `json:"image"`
}

type Images

type Images struct {
	I []IDLink `json:"images"`
}

type InstDetails

type InstDetails struct {
	Created        string          `json:"created"`
	Hostname       string          `json:"hostname"`
	ID             string          `json:"id"`
	Links          []Link          `json:"links"`
	Name           string          `json:"name"`
	Port           int             `json:"port"`
	SecurityGroups []SecurityGroup `json:"security_groups"`
	Status         string          `json:"status"`
	Updated        string          `json:"updated"`
	Flavor         struct {
		Name  string `json:"name"`
		ID    string `json:"id"`
		Links []Link `json:"links"`
	} `json:"flavor"`
}

Instance Details type that is returned by server

type InternalServerError

type InternalServerError struct {
	ISE struct {
		Code            int64  `json:"code"`
		Details         string `json:"details"`
		Message         string `json:"message"`
		OtherAttributes struct {
		} `json:"otherAttributes"`
	} `json:"internalServerError"`
}

InternalServerError describes the response from a JSON resource when the request could not be completed due to the request causing the service to return a 500 status code.

func (InternalServerError) Code

func (ise InternalServerError) Code() int64

func (InternalServerError) Details

func (ise InternalServerError) Details() string

func (InternalServerError) Message

func (ise InternalServerError) Message() string
type Link struct {
	HREF string `json:"href"`
	Rel  string `json:"rel"`
}

Link data type used across modules

type Login

type Login struct {
	Auth auth `json:"auth"`
}

type NewDBInstance

type NewDBInstance struct {
	Created    string        `json:"created"`
	Credential DBCredentials `json:"credential"`
	Flavor     struct {
		Name  string `json:"name"`
		ID    string `json:"id"`
		Links []Link `json:"links"`
	} `json:"flavor"`
	Hostname       string        `json:"hostname"`
	Id             string        `json:"id"`
	Links          []Link        `json:"links"`
	Name           string        `json:"name"`
	SecurityGroups []DBSecGroups `json:"security_groups"`
	Status         string        `json:"status"`
}

This type describes JSON response from a successful CreateDBInstance call.

type NotFound

type NotFound struct {
	NF struct {
		Message string `json:"message"`
		Details string `json:"details"`
		Code    int64  `json:"code"`
	} `json:"itemNotFound"`
}

NotFound describes the response from a JSON resource when the resource which was interacted with in the original request was not able to be found.

func (NotFound) Code

func (nf NotFound) Code() int64

func (NotFound) Details

func (nf NotFound) Details() string

func (NotFound) Message

func (nf NotFound) Message() string

type Record

type Record Domain

Record and Domain have the same fields.

type Role

type Role struct {
	ID        string `json:"id"`
	ServiceID string `json:"serviceId"`
	Name      string `json:"name"`
}

Role describes in-part the response you will receive when making an authentication request.

Roles are services for with the user making an authentication request is authenticated to use.

A personality that a user assumes when performing a specific set of operations. A role includes a set of rights and privileges.

{
  "id": "00000000004003",
  "serviceId": "100",
  "name": "domainadmin"
}

type Rule

type Rule struct {
	FromPort      int    `json:"from_port"`
	ToPort        int    `json:"to_port"`
	ID            int64  `json:"id"`
	IPProtocol    string `json:"ip_protocol"`
	ParentGroupID int64  `json:"parent_group_id"`
	IPRange       struct {
		CIDR string `json:"cidr"`
	} `json:"ip_range"`
	Group struct {
		Name     string `json:"name"`
		TenandID string `json:"tenant_id"`
	} `json:"group"`
}

type Scope

type Scope struct {
	TenantName string   `json:"tenantName"`
	S          SubToken `json:"token"`
}

type SecurityGroup

type SecurityGroup struct {
	Id          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Rules       []Rule `json:"rules"`
	Links       []Link `json:"links"`
	Created     string `json:"created"`
}

type Server

type Server struct {
	ID             int64             `json:"id"`
	ConfigDrive    bool              `json:"config_drive"`
	FlavorRef      Flavor            `json:"flavorRef"`
	ImageRef       ServerImage       `json:"imageRef"`
	MaxCount       int               `json:"max_count"`
	MinCount       int               `json:"min_count"`
	Name           string            `json:"name"`
	Key            string            `json:"key_name"`
	Personality    string            `json:"personality"`
	UserData       string            `json:"user_data"`
	SecurityGroups []SecurityGroup   `json:"security_groups"`
	Links          []Link            `json:"links"`
	Metadata       map[string]string `json:"metadata"`
	UUID           string            `json:"uuid"`
}

This type describes the JSON data which should be sent to the create server resource.

func (Server) MarshalJSON

func (s Server) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface for the Server type.

We implement this interface because when creating a server we have optional values and since Go has zero-values and does *not* have configurable zero values we need to make sure that zero-values are converted to known good values.

As such:

  • FlavorRef is checked if it's a valid reference.
  • Ditto for ImageRef.
  • Name cannot be blank.
  • If the key is missing, it'll not put anything in.
  • The config_drive defaults to false anyway, no need to send a false value.
  • Min/MaxCount are ignored if they are zero.
  • UserData is ignored if it's a blank string.
  • Personality is ignored if it's a blank string.
  • Metadata/SecurityGroups are ignored if they have len(0)

type ServerImage

type ServerImage int

Available images

type ServerResponse

type ServerResponse struct {
	S struct {
		Status         string            `json:"status"`
		Updated        string            `json:"update"`
		HostID         string            `json:"hostId"`
		UserID         string            `json:"user_id"`
		Name           string            `json:"name"`
		Links          []Link            `json:"links"`
		Addresses      Addresses         `json:"addresses"`
		TenantID       string            `json:"tenant_id"`
		Image          IDLink            `json:"image"`
		Created        string            `json:"created"`
		UUID           string            `json:"uuid"`
		AccessIPv4     string            `json:"accessIPv4"`
		AccessIPv6     string            `json:"accessIPv6"`
		KeyName        string            `json:"key_name"`
		AdminPass      string            `json:"adminPass"`
		Flavor         IDLink            `json:"flavor"`
		ConfigDrive    string            `json:"config_drive"`
		ID             int64             `json:"id"`
		SecurityGroups []SecurityGroup   `json:"security_groups"`
		Metadata       map[string]string `json:"metadata"`
	} `json:"server"`
}

This type describes the JSON response from a successful CreateServer call.

type ServiceCatalog

type ServiceCatalog struct {
	Name      string     `json:"name"`
	Type      string     `json:"type"`
	Endpoints []Endpoint `json:"endpoints"`
}

type SubToken

type SubToken struct {
	ID string `json:"id"`
}

type Tenant

type Tenant struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Enabled     bool   `json:"enabled"`
	Created     string `json:"created"`
	Updated     string `json:"updated"`
}

Tenant describes the response which is returned from any resource which contains Tenant information

type TenantScope

type TenantScope struct {
	S Scope `json:"auth"`
}

type Tenants

type Tenants struct {
	T []Tenant `json:"tenants"`
}

type Token

type Token struct {
	Expires string  `json:"expires"`
	ID      string  `json:"id"`
	Tenant  *Tenant `json:"tenant"`
}

Token describes in-part the response you will receive when making an authentication request.

If you didn't supply a tenantID (currently this library does not support unscoped authorization requests.) then the tenant section will be null, hence using a pointer type for this field.

"token": {
   "expires": "<token_expiry_date>",
   "id": "<your_auth_token>",
   "tenant": {
     "id": "<tenant_id>",
     "name": "<tenant_name>"
   }

type Unauthorized

type Unauthorized struct {
	U struct {
		Code            int64  `json:"code"`
		Details         string `json:"details"`
		Message         string `json:"message"`
		OtherAttributes struct {
		} `json:"otherAttributes"`
	} `json:"unauthorized"`
}

Unauthorized describes the response from a JSON resource when the request could not be completed due to none or incorrect authentication was used to make the request.

func (Unauthorized) Code

func (u Unauthorized) Code() int64

func (Unauthorized) Details

func (u Unauthorized) Details() string

func (Unauthorized) Message

func (u Unauthorized) Message() string

type User

type User struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Roles []Role `json:"roles"`
}
User describes in-part the response you will receive when making
an authentication request.
"user": {
    "id": "<tenant_id>",
    "name": "<username>",
    "roles": [<array_of_roles]
}

type Volume

type Volume struct {
	Status           string            `json:"status"`
	CreatedAt        string            `json:"createdAt"`
	Size             int64             `json:"size"`
	DisplayName      string            `json:"display_name"`
	DisplayDesc      string            `json:"display_description"`
	SnapshotID       int64             `json:"snapshot_id"`
	ImageRef         int64             `json:"imageRef"`
	Metadata         map[string]string `json:"metadata"`
	AvailabilityZone string            `json:"availability_zone"`
	VolumeType       string            `json:"volume_type"`
	Attachments      []Attachment      `json:"attachments"`
}

Volume encapsulates the volumes available in the OpenStack/HP Cloud system *as well as* the volumes you are actually running.

Typically you would create a value of this type and pass it to the CreateVolume function. This type will be returned from any query endpoints which return containers of info about the volumes you may have.

func (Volume) MarshalJSON

func (v Volume) MarshalJSON() ([]byte, error)

We override MarshalJSON because we want to provide additional marshaling logic when creating new compute nodes. This is because the zero values of Volumes are not valid parameters for the compute API.

Jump to

Keyboard shortcuts

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