This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
gophercloud/package.go
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (29 sloc)
1.42 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Package gophercloud provides a multi-vendor interface to OpenStack-compatible | |
clouds. The library has a three-level hierarchy: providers, services, and | |
resources. | |
Provider structs represent the service providers that offer and manage a | |
collection of services. Examples of providers include: OpenStack, Rackspace, | |
HP. These are defined like so: | |
opts := gophercloud.AuthOptions{ | |
IdentityEndpoint: "https://my-openstack.com:5000/v2.0", | |
Username: "{username}", | |
Password: "{password}", | |
TenantID: "{tenant_id}", | |
} | |
provider, err := openstack.AuthenticatedClient(opts) | |
Service structs are specific to a provider and handle all of the logic and | |
operations for a particular OpenStack service. Examples of services include: | |
Compute, Object Storage, Block Storage. In order to define one, you need to | |
pass in the parent provider, like so: | |
opts := gophercloud.EndpointOpts{Region: "RegionOne"} | |
client := openstack.NewComputeV2(provider, opts) | |
Resource structs are the domain models that services make use of in order | |
to work with and represent the state of API resources: | |
server, err := servers.Get(client, "{serverId}").Extract() | |
Another convention is to return Result structs for API operations, which allow | |
you to access the HTTP headers, response body, and associated errors with the | |
network transaction. To get a resource struct, you then call the Extract | |
method which is chained to the response. | |
*/ | |
package gophercloud |