Ejemplo n.º 1
0
// Download is a function that retrieves the content and metadata for an object.
// To extract just the content, pass the DownloadResult response to the
// ExtractContent function.
func Download(c *gophercloud.ServiceClient, containerName, objectName string, opts DownloadOptsBuilder) (r DownloadResult) {
	url := downloadURL(c, containerName, objectName)
	h := make(map[string]string)
	if opts != nil {
		headers, query, err := opts.ToObjectDownloadParams()
		if err != nil {
			r.Err = err
			return
		}
		for k, v := range headers {
			h[k] = v
		}
		url += query
	}

	resp, err := c.Get(url, nil, &gophercloud.RequestOpts{
		MoreHeaders: h,
		OkCodes:     []int{200, 304},
	})
	if resp != nil {
		r.Header = resp.Header
		r.Body = resp.Body
	}
	r.Err = err
	return
}
Ejemplo n.º 2
0
// Ping retrieves a ping to the server.
func Ping(c *gophercloud.ServiceClient) (r PingResult) {
	_, r.Err = c.Get(pingURL(c), nil, &gophercloud.RequestOpts{
		OkCodes:     []int{204},
		MoreHeaders: map[string]string{"Accept": ""},
	})
	return
}
Ejemplo n.º 3
0
// Download retrieves file
func Download(client *gophercloud.ServiceClient, id string) (r DownloadResult) {
	var resp *http.Response
	resp, r.Err = client.Get(downloadURL(client, id), nil, nil)
	if resp != nil {
		r.Body = resp.Body
		r.Header = resp.Header
	}
	return
}
Ejemplo n.º 4
0
// Get retrieves a specific service based on its URL or its unique ID. For
// example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and
// "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
// are valid options for idOrURL.
func Get(c *gophercloud.ServiceClient, idOrURL string) (r GetResult) {
	var url string
	if strings.Contains(idOrURL, "/") {
		url = idOrURL
	} else {
		url = getURL(c, idOrURL)
	}
	_, r.Err = c.Get(url, &r.Body, nil)
	return
}
Ejemplo n.º 5
0
// Get validates and retrieves information about another token.
func Get(c *gophercloud.ServiceClient, token string) (r GetResult) {
	resp, err := c.Get(tokenURL(c), &r.Body, &gophercloud.RequestOpts{
		MoreHeaders: subjectTokenHeaders(c, token),
		OkCodes:     []int{200, 203},
	})
	if resp != nil {
		r.Err = err
		r.Header = resp.Header
	}
	return
}
Ejemplo n.º 6
0
// Get returns the limits about the currently scoped tenant.
func Get(client *gophercloud.ServiceClient, opts GetOptsBuilder) (r GetResult) {
	url := getURL(client)
	if opts != nil {
		query, err := opts.ToLimitsQuery()
		if err != nil {
			r.Err = err
			return
		}
		url += query
	}

	_, r.Err = client.Get(url, &r.Body, nil)
	return
}
// Get performs request to given service and deserializes json response to struct.
// out should be pointer to resulting structure. Returns error if request or
// deserialization failed.
func Get(client *gophercloud.ServiceClient, request string, out interface{}) error {
	url := client.ServiceURL(request)
	var resp interface{}
	_, err := client.Get(url, &resp, nil)

	if err != nil {
		return fmt.Errorf("request failed: (%v)", err)
	}

	err = mapstructure.Decode(resp, out)

	if err != nil {
		return fmt.Errorf("decoding failed: (%v)", err)
	}

	return nil
}
Ejemplo n.º 8
0
// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient, stackName, stackID string) (r GetResult) {
	_, r.Err = c.Get(getURL(c, stackName, stackID), &r.Body, nil)
	return
}
Ejemplo n.º 9
0
// GetVersion will retrieve the details of a specified datastore version.
func GetVersion(client *gophercloud.ServiceClient, datastoreID, versionID string) (r GetVersionResult) {
	_, r.Err = client.Get(versionURL(client, datastoreID, versionID), &r.Body, nil)
	return
}
Ejemplo n.º 10
0
// Get will retrieve the details of a specified datastore type.
func Get(client *gophercloud.ServiceClient, datastoreID string) (r GetResult) {
	_, r.Err = client.Get(resourceURL(client, datastoreID), &r.Body, nil)
	return
}
Ejemplo n.º 11
0
// GetDatastoreParam will retrieve information about a specific configuration
// parameter. For example, you can use this operation to understand more about
// "innodb_file_per_table" configuration param for MySQL datastores. You will
// need the param's ID first, which can be attained by using the ListDatastoreParams
// operation.
func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID, paramID string) (r ParamResult) {
	_, r.Err = client.Get(getDSParamURL(client, datastoreID, versionID, paramID), &r.Body, nil)
	return
}
Ejemplo n.º 12
0
// GetDefault will retrieve the default ShareType.
func GetDefault(client *gophercloud.ServiceClient) (r GetDefaultResult) {
	_, r.Err = client.Get(getDefaultURL(client), &r.Body, nil)
	return
}
Ejemplo n.º 13
0
// GetPassword makes a request against the nova API to get the encrypted administrative password.
func GetPassword(client *gophercloud.ServiceClient, serverId string) (r GetPasswordResult) {
	_, r.Err = client.Get(passwordURL(client, serverId), &r.Body, nil)
	return
}
Ejemplo n.º 14
0
// Metadata requests all the metadata for the given server ID.
func Metadata(client *gophercloud.ServiceClient, id string) (r GetMetadataResult) {
	_, r.Err = client.Get(metadataURL(client, id), &r.Body, nil)
	return
}
Ejemplo n.º 15
0
// Find retrieves stack events for the given stack name.
func Find(c *gophercloud.ServiceClient, stackName string) (r FindResult) {
	_, r.Err = c.Get(findURL(c, stackName), &r.Body, nil)
	return
}
Ejemplo n.º 16
0
func GetStatuses(c *gophercloud.ServiceClient, id string) (r GetStatusesResult) {
	_, r.Err = c.Get(statusRootURL(c, id), &r.Body, nil)
	return
}
Ejemplo n.º 17
0
// Get returns public data about a previously uploaded KeyPair.
func Get(client *gophercloud.ServiceClient, name string) (r GetResult) {
	_, r.Err = client.Get(getURL(client, name), &r.Body, nil)
	return
}
Ejemplo n.º 18
0
// Request performs an HTTP request and extracts the http.Response from the result.
func Request(client *gophercloud.ServiceClient, headers map[string]string, url string) (*http.Response, error) {
	return client.Get(url, nil, &gophercloud.RequestOpts{
		MoreHeaders: headers,
		OkCodes:     []int{200, 204},
	})
}
Ejemplo n.º 19
0
// GetMember retrieves a particular Pool Member based on its unique ID.
func GetMember(c *gophercloud.ServiceClient, poolID string, memberID string) (r GetMemberResult) {
	_, r.Err = c.Get(memberResourceURL(c, poolID, memberID), &r.Body, nil)
	return
}
Ejemplo n.º 20
0
// GetGlobalParam is similar to GetDatastoreParam but does not require a
// DatastoreID.
func GetGlobalParam(client *gophercloud.ServiceClient, versionID, paramID string) (r ParamResult) {
	_, r.Err = client.Get(getGlobalParamURL(client, versionID, paramID), &r.Body, nil)
	return
}
Ejemplo n.º 21
0
// Get returns additional information about a service, given its ID.
func Get(client *gophercloud.ServiceClient, serviceID string) (r GetResult) {
	_, r.Err = client.Get(serviceURL(client, serviceID), &r.Body, nil)
	return
}
Ejemplo n.º 22
0
// IsRootEnabled checks an instance to see if root access is enabled. It returns
// True if root user is enabled for the specified database instance or False
// otherwise.
func IsRootEnabled(client *gophercloud.ServiceClient, id string) (r IsRootEnabledResult) {
	_, r.Err = client.Get(userRootURL(client, id), &r.Body, nil)
	return
}
Ejemplo n.º 23
0
// Get requests details on a single server, by ID.
func Get(client *gophercloud.ServiceClient, id string) (r GetResult) {
	_, r.Err = client.Get(getURL(client, id), &r.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200, 203},
	})
	return
}
Ejemplo n.º 24
0
// Get retrieves the home document, allowing the user to discover the
// entire API.
func Get(c *gophercloud.ServiceClient) (r GetResult) {
	_, r.Err = c.Get(getURL(c), &r.Body, nil)
	return
}
Ejemplo n.º 25
0
// Metadatum requests the key-value pair with the given key for the given server ID.
func Metadatum(client *gophercloud.ServiceClient, id, key string) (r GetMetadatumResult) {
	_, r.Err = client.Get(metadatumURL(client, id, key), &r.Body, nil)
	return
}
Ejemplo n.º 26
0
// Get returns public data about a previously created QuotaSet.
func Get(client *gophercloud.ServiceClient, tenantID string) GetResult {
	var res GetResult
	_, res.Err = client.Get(getURL(client, tenantID), &res.Body, nil)
	return res
}
Ejemplo n.º 27
0
// GetExtraSpecs will retrieve the extra specifications for a given ShareType.
func GetExtraSpecs(client *gophercloud.ServiceClient, id string) (r GetExtraSpecsResult) {
	_, r.Err = client.Get(getExtraSpecsURL(client, id), &r.Body, nil)
	return
}
Ejemplo n.º 28
0
// Get retrieves information for a specific extension using its alias.
func Get(c *gophercloud.ServiceClient, alias string) (r GetResult) {
	_, r.Err = c.Get(ExtensionURL(c, alias), &r.Body, nil)
	return
}
Ejemplo n.º 29
0
// Get retrieves a particular firewall rule based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) (r GetResult) {
	_, r.Err = c.Get(resourceURL(c, id), &r.Body, nil)
	return
}
Ejemplo n.º 30
0
// Get image member details.
// More details: http://developer.openstack.org/api-ref-image-v2.html#getImageMember-v2
func Get(client *gophercloud.ServiceClient, imageID string, memberID string) (r DetailsResult) {
	_, r.Err = client.Get(getMemberURL(client, imageID, memberID), &r.Body, &gophercloud.RequestOpts{OkCodes: []int{200}})
	return
}