Jamie Hannaford | d258b79 | 2014-10-24 14:46:41 +0200 | [diff] [blame] | 1 | /* |
| 2 | Package gophercloud provides a multi-vendor interface to OpenStack-compatible |
| 3 | clouds. The library has a three-level hierarchy: providers, services, and |
| 4 | resources. |
| 5 | |
| 6 | Provider structs represent the service providers that offer and manage a |
| 7 | collection of services. Examples of providers include: OpenStack, Rackspace, |
| 8 | HP. These are defined like so: |
| 9 | |
| 10 | opts := gophercloud.AuthOptions{ |
| 11 | IdentityEndpoint: "https://my-openstack.com:5000/v2.0", |
| 12 | Username: "{username}", |
| 13 | Password: "{password}", |
| 14 | TenantID: "{tenant_id}", |
| 15 | } |
| 16 | |
| 17 | provider, err := openstack.AuthenticatedClient(opts) |
| 18 | |
| 19 | Service structs are specific to a provider and handle all of the logic and |
| 20 | operations for a particular OpenStack service. Examples of services include: |
| 21 | Compute, Object Storage, Block Storage. In order to define one, you need to |
| 22 | pass in the parent provider, like so: |
| 23 | |
| 24 | opts := gophercloud.EndpointOpts{Region: "RegionOne"} |
| 25 | |
| 26 | client := openstack.NewComputeV2(provider, opts) |
| 27 | |
| 28 | Resource structs are the domain models that services make use of in order |
| 29 | to work with and represent the state of API resources: |
| 30 | |
| 31 | server, err := servers.Get(client, "{serverId}").Extract() |
| 32 | |
| 33 | Another convention is to return Result structs for API operations, which allow |
| 34 | you to access the HTTP headers, response body, and associated errors with the |
| 35 | network transaction. To get a resource struct, you then call the Extract |
| 36 | method which is chained to the response. |
| 37 | */ |
Samuel A. Falvo II | 1d3fa66 | 2013-06-25 15:29:32 -0700 | [diff] [blame] | 38 | package gophercloud |