Documentation ¶
Overview ¶
The csclient package provides access to the charm store API.
Index ¶
- type Client
- func (c *Client) Do(req *http.Request, path string) (*http.Response, error)
- func (c *Client) Get(path string, result interface{}) error
- func (c *Client) Meta(id *charm.Reference, result interface{}) (*charm.Reference, error)
- func (c *Client) PutExtraInfo(id *charm.Reference, info map[string]interface{}) error
- type Params
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the client side of a charm store.
func (*Client) Do ¶
Do makes an arbitrary request to the charm store. It adds appropriate headers to the given HTTP request, sends it to the charm store, and returns the resulting response. Do never returns a response with a status that is not http.StatusOK.
The URL field in the request is ignored and overwritten.
This is a low level method - more specific Client methods should be used when possible.
func (*Client) Get ¶
Get makes a GET request to the charm store, parsing the result as JSON into the given result value, which should be a pointer to the expected data, but may be nil if no result is desired.
func (*Client) Meta ¶
Meta fetches metadata on the charm or bundle with the given id. The result value provides a value to be filled in with the result, which must be a pointer to a struct containing members corresponding to possible metadata include parameters (see http://tinyurl.com/nysdjly).
It returns the fully qualified id of the entity.
The name of the struct member is translated to a lower case hyphen-separated form; for example, ArchiveSize becomes "archive-size", and BundleMachineCount becomes "bundle-machine-count", but may also be specified in the field's tag
This example will fill in the result structure with information about the given id, including information on its archive size (include archive-size), upload time (include archive-upload-time) and digest (include extra-info/digest).
var result struct { ArchiveSize params.ArchiveSizeResponse ArchiveUploadTime params.ArchiveUploadTimeResponse Digest string `csclient:"extra-info/digest"` } id, err := client.Meta(id, &result)
func (*Client) PutExtraInfo ¶
PutExtraInfo puts extra-info data for the given id. Each entry in the info map causes a value in extra-info with that key to be set to the associated value. Entries not set in the map will be unchanged.
type Params ¶
type Params struct { // URL holds the root endpoint URL of the charmstore, // with no trailing slash, not including the version. // For example http://charms.ubuntu.com // TODO default this to global charm store address. URL string // User and Password hold the authentication credentials // for the client. If User is empty, no credentials will be // sent. User string Password string // HTTPClient holds the HTTP client to use when making // requests to the store. If nil, http.DefaultClient will // be used. HTTPClient *http.Client }
Params holds parameters for creating a new charm store client.