當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ServiceClient.Get方法代碼示例

本文整理匯總了Golang中github.com/rackspace/gophercloud.ServiceClient.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceClient.Get方法的具體用法?Golang ServiceClient.Get怎麽用?Golang ServiceClient.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/rackspace/gophercloud.ServiceClient的用法示例。


在下文中一共展示了ServiceClient.Get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Get

// Get requests details on a single server, by ID.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
	var result GetResult
	_, result.Err = client.Get(getURL(client, id), &result.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200, 203},
	})
	return result
}
開發者ID:chenzhen411,項目名稱:kubernetes,代碼行數:8,代碼來源:requests.go

示例2: MeterStatistics

// MeterStatistics gathers statistics based on filters, groups, and period options
func MeterStatistics(client *gophercloud.ServiceClient, n string, optsBuilder MeterStatisticsOptsBuilder) statisticsResult {
	var (
		res  statisticsResult
		url  = statisticsURL(client, n)
		opts gophercloud.RequestOpts
		err  error
		kind OptsKind
	)

	if optsBuilder != nil {
		kind = optsBuilder.Kind()
	}

	switch kind {
	case QueryOpts:
		query, err := optsBuilder.ToMeterStatisticsQuery()
		url += query
	case BodyContentOpts:
		opts.JSONBody, err = optsBuilder.ToMeterStatisticsQuery()
	}

	if err != nil {
		res.Err = err
		return res
	}

	_, res.Err = client.Get(url, &res.Body, &opts)
	return res
}
開發者ID:dudymas,項目名稱:gophercloud,代碼行數:30,代碼來源:requests.go

示例3: Get

// Get requests the details of a single policy with the given ID.
func Get(client *gophercloud.ServiceClient, groupID, policyID string) GetResult {
	var result GetResult

	_, result.Err = client.Get(getURL(client, groupID, policyID), &result.Body, nil)

	return result
}
開發者ID:sstrato,項目名稱:gophercloud,代碼行數:8,代碼來源:requests.go

示例4: Get

// Get retreives data for the given stack resource.
func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) GetResult {
	var res GetResult
	_, res.Err = c.Get(getURL(c, stackName, stackID, resourceName, eventID), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
開發者ID:johndmulhausen,項目名稱:kubernetes,代碼行數:8,代碼來源:requests.go

示例5: OpenstackGet

//OpenstackGet gets a resource using OpenStack API
func OpenstackGet(client *gophercloud.ServiceClient, url string) (interface{}, error) {
	var response interface{}
	_, err := client.Get(url, &response, nil)
	if err != nil {
		return nil, err
	}
	return response, nil
}
開發者ID:marcin-ptaszynski,項目名稱:gohan,代碼行數:9,代碼來源:openstack.go

示例6: Ping

// Ping retrieves a ping to the server.
func Ping(c *gophercloud.ServiceClient) PingResult {
	var res PingResult
	_, res.Err = c.Get(pingURL(c), nil, &gophercloud.RequestOpts{
		OkCodes:     []int{204},
		MoreHeaders: map[string]string{"Accept": ""},
	})
	return res
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:9,代碼來源:requests.go

示例7: Metadata

// Metadata retreives the metadata for the given stack resource.
func Metadata(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) MetadataResult {
	var res MetadataResult

	// Send request to API
	_, res.Err = c.Get(metadataURL(c, stackName, stackID, resourceName), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:10,代碼來源:requests.go

示例8: Schema

// Schema retreives the schema for the given resource type.
func Schema(c *gophercloud.ServiceClient, resourceType string) SchemaResult {
	var res SchemaResult

	// Send request to API
	_, res.Err = c.Get(schemaURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:10,代碼來源:requests.go

示例9: Get

// Get is the operation responsible for providing detailed information
// regarding a specific load balancer which is configured and associated with
// your account. This operation is not capable of returning details for a load
// balancer which has been deleted.
func Get(c *gophercloud.ServiceClient, id int) GetResult {
	var res GetResult

	_, res.Err = c.Get(resourceURL(c, id), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})

	return res
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:13,代碼來源:requests.go

示例10: Template

// Template retreives the template representation for the given resource type.
func Template(c *gophercloud.ServiceClient, resourceType string) TemplateResult {
	var res TemplateResult

	// Send request to API
	_, res.Err = c.Get(templateURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
開發者ID:Clarifai,項目名稱:kubernetes,代碼行數:10,代碼來源:requests.go

示例11: GetDataByResolution

// GetDataByPoints retrieve metric data by resolution, for the specified tenant associated with RackspaceMetrics.
func GetDataByResolution(c *gophercloud.ServiceClient, metric string, opts QueryParams) GetResult {
	var res GetResult

	url := getURLForResolution(c, metric)
	query, _ := gophercloud.BuildQueryString(opts)
	url += query.String()
	_, res.Err = c.Get(url, &res.Body, nil)
	return res
}
開發者ID:goru97,項目名稱:Metrics_GO,代碼行數:10,代碼來源:requests.go

示例12: Get

// Validates and retrieves information for user's token.
func Get(client *gophercloud.ServiceClient, token string) GetResult {
	var result GetResult
	_, result.Err = client.Get(GetURL(client, token), &result.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200, 203},
	})
	if result.Err != nil {
		return result
	}
	return result
}
開發者ID:chaolou,項目名稱:gophercloud,代碼行數:11,代碼來源:requests.go

示例13: verifyV2Token

//TODO(nati) this should be implemented in openstack go client side package
func verifyV2Token(c *gophercloud.ServiceClient, token string) (interface{}, error) {
	var result interface{}
	_, err := c.Get(tokenURL(c, token), &result, &gophercloud.RequestOpts{
		OkCodes: []int{200, 203},
	})
	if err != nil {
		return nil, err
	}
	return result, nil
}
開發者ID:masaki-saeki,項目名稱:gohan,代碼行數:11,代碼來源:keystone.go

示例14: GetLimits

// GetLimits retrieves the number of API transaction that are available for the specified tenant associated with RackspaceMetrics.
func GetLimits(c *gophercloud.ServiceClient) (Limits, error) {
	var res GetResult
	_, res.Err = c.Get(getLimits(c), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200, 404},
	})
	b := res.Body.(map[string]interface{})
	var limits Limits
	err := mapstructure.Decode(b["limits"], &limits)
	return limits, err
}
開發者ID:goru97,項目名稱:Metrics_GO,代碼行數:11,代碼來源:requests.go

示例15: OpenstackEnsure

//OpenstackEnsure keep resource status to sync
func OpenstackEnsure(client *gophercloud.ServiceClient, url string, postURL string, data interface{}) (interface{}, error) {
	var response interface{}
	resp, err := client.Get(url, &response, nil)
	if err != nil {
		if resp.StatusCode != http.StatusNotFound {
			return nil, err
		}
		return OpenstackPost(client, postURL, data)
	}
	return OpenstackPut(client, url, data)
}
開發者ID:marcin-ptaszynski,項目名稱:gohan,代碼行數:12,代碼來源:openstack.go


注:本文中的github.com/rackspace/gophercloud.ServiceClient.Get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。