本文整理匯總了Golang中github.com/gophercloud/gophercloud.ServiceClient.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceClient.Get方法的具體用法?Golang ServiceClient.Get怎麽用?Golang ServiceClient.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gophercloud/gophercloud.ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.Get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Download
// 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
}
示例2: Ping
// 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
}
示例3: Download
// 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
}
示例4: Get
// 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
}
示例5: Get
// 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
}
示例6: Get
// 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
}
示例7: Get
// 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
}
示例8: Get
// 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
}
示例9: GetVersion
// 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
}
示例10: Get
// 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
}
示例11: GetDatastoreParam
// 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
}
示例12: GetDefault
// GetDefault will retrieve the default ShareType.
func GetDefault(client *gophercloud.ServiceClient) (r GetDefaultResult) {
_, r.Err = client.Get(getDefaultURL(client), &r.Body, nil)
return
}
示例13: GetPassword
// 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
}
示例14: Metadata
// 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
}
示例15: Find
// 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
}