本文整理汇总了Golang中github.com/rackspace/gophercloud.ServiceClient类的典型用法代码示例。如果您正苦于以下问题:Golang ServiceClient类的具体用法?Golang ServiceClient怎么用?Golang ServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Update
// Update changes an existing endpoint with new data.
// All fields are optional in the provided EndpointOpts.
func Update(client *gophercloud.ServiceClient, endpointID string, opts EndpointOpts) UpdateResult {
type endpoint struct {
Interface *string `json:"interface,omitempty"`
Name *string `json:"name,omitempty"`
Region *string `json:"region,omitempty"`
URL *string `json:"url,omitempty"`
ServiceID *string `json:"service_id,omitempty"`
}
type request struct {
Endpoint endpoint `json:"endpoint"`
}
reqBody := request{Endpoint: endpoint{}}
reqBody.Endpoint.Interface = gophercloud.MaybeString(string(opts.Availability))
reqBody.Endpoint.Name = gophercloud.MaybeString(opts.Name)
reqBody.Endpoint.Region = gophercloud.MaybeString(opts.Region)
reqBody.Endpoint.URL = gophercloud.MaybeString(opts.URL)
reqBody.Endpoint.ServiceID = gophercloud.MaybeString(opts.ServiceID)
var result UpdateResult
_, result.Err = client.Request("PATCH", endpointURL(client, endpointID), gophercloud.RequestOpts{
JSONBody: &reqBody,
JSONResponse: &result.Body,
OkCodes: []int{200},
})
return result
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:30,代码来源:requests.go
示例2: Update
// Update allows routers to be updated. You can update the name, administrative
// state, and the external gateway. For more information about how to set the
// external gateway for a router, see Create. This operation does not enable
// the update of router interfaces. To do this, use the AddInterface and
// RemoveInterface functions.
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult {
type router struct {
Name *string `json:"name,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
}
type request struct {
Router router `json:"router"`
}
reqBody := request{Router: router{
Name: gophercloud.MaybeString(opts.Name),
AdminStateUp: opts.AdminStateUp,
}}
if opts.GatewayInfo != nil {
reqBody.Router.GatewayInfo = opts.GatewayInfo
}
// Send request to API
var res UpdateResult
_, res.Err = perigee.Request("PUT", resourceURL(c, id), perigee.Options{
MoreHeaders: c.AuthenticatedHeaders(),
ReqBody: &reqBody,
Results: &res.Body,
OkCodes: []int{200},
})
return res
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:36,代码来源:requests.go
示例3: Create
// Create accepts a CreateOpts struct and uses the values to create a new
// logical router. When it is created, the router does not have an internal
// interface - it is not associated to any subnet.
//
// You can optionally specify an external gateway for a router using the
// GatewayInfo struct. The external gateway for the router must be plugged into
// an external network (it is external if its `router:external' field is set to
// true).
func Create(c *gophercloud.ServiceClient, opts CreateOpts) CreateResult {
type router struct {
Name *string `json:"name,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
TenantID *string `json:"tenant_id,omitempty"`
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
}
type request struct {
Router router `json:"router"`
}
reqBody := request{Router: router{
Name: gophercloud.MaybeString(opts.Name),
AdminStateUp: opts.AdminStateUp,
TenantID: gophercloud.MaybeString(opts.TenantID),
}}
if opts.GatewayInfo != nil {
reqBody.Router.GatewayInfo = opts.GatewayInfo
}
var res CreateResult
_, res.Err = perigee.Request("POST", rootURL(c), perigee.Options{
MoreHeaders: c.AuthenticatedHeaders(),
ReqBody: &reqBody,
Results: &res.Body,
OkCodes: []int{201},
})
return res
}
开发者ID:hortonworks,项目名称:kubernetes-yarn,代码行数:39,代码来源:requests.go
示例4: 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
示例5: Enable
// Enable is a function that enables/disables a CDN container.
func Enable(c *gophercloud.ServiceClient, containerName string, opts EnableOptsBuilder) EnableResult {
var res EnableResult
h := c.AuthenticatedHeaders()
if opts != nil {
headers, err := opts.ToCDNContainerEnableMap()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
}
resp, err := c.Request("PUT", enableURL(c, containerName), gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:27,代码来源:requests.go
示例6: DeleteMetadatum
// DeleteMetadatum will delete the key-value pair with the given key for the given server ID.
func DeleteMetadatum(client *gophercloud.ServiceClient, id, key string) DeleteMetadatumResult {
var res DeleteMetadatumResult
_, res.Err = client.Delete(metadatumURL(client, id, key), &gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:8,代码来源:requests.go
示例7: Update
// Update allows routers to be updated. You can update the name, administrative
// state, and the external gateway. For more information about how to set the
// external gateway for a router, see Create. This operation does not enable
// the update of router interfaces. To do this, use the AddInterface and
// RemoveInterface functions.
func Update(c *gophercloud.ServiceClient, id string, opts UpdateOpts) UpdateResult {
type router struct {
Name *string `json:"name,omitempty"`
AdminStateUp *bool `json:"admin_state_up,omitempty"`
GatewayInfo *GatewayInfo `json:"external_gateway_info,omitempty"`
Routes []Route `json:"routes"`
}
type request struct {
Router router `json:"router"`
}
reqBody := request{Router: router{
Name: gophercloud.MaybeString(opts.Name),
AdminStateUp: opts.AdminStateUp,
}}
if opts.GatewayInfo != nil {
reqBody.Router.GatewayInfo = opts.GatewayInfo
}
if opts.Routes != nil {
reqBody.Router.Routes = opts.Routes
}
// Send request to API
var res UpdateResult
_, res.Err = c.Put(resourceURL(c, id), reqBody, &res.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
return res
}
开发者ID:metalmolly,项目名称:packer,代码行数:38,代码来源:requests.go
示例8: Copy
// Copy is a function that copies one object to another.
func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts CopyOptsBuilder) CopyResult {
var res CopyResult
h := c.AuthenticatedHeaders()
headers, err := opts.ToObjectCopyMap()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
url := copyURL(c, containerName, objectName)
resp, err := c.Request("COPY", url, gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201},
})
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
}
开发者ID:CorainChicago,项目名称:gophercloud,代码行数:26,代码来源:requests.go
示例9: Update
// Update is a function that creates, updates, or deletes an object's metadata.
func Update(c *gophercloud.ServiceClient, containerName, objectName string, opts UpdateOptsBuilder) UpdateResult {
var res UpdateResult
h := c.AuthenticatedHeaders()
if opts != nil {
headers, err := opts.ToObjectUpdateMap()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
}
url := updateURL(c, containerName, objectName)
resp, err := c.Request("POST", url, gophercloud.RequestOpts{
MoreHeaders: h,
})
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
}
开发者ID:CorainChicago,项目名称:gophercloud,代码行数:27,代码来源:requests.go
示例10: 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) DownloadResult {
var res DownloadResult
url := downloadURL(c, containerName, objectName)
h := c.AuthenticatedHeaders()
if opts != nil {
headers, query, err := opts.ToObjectDownloadParams()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
url += query
}
resp, err := c.Request("GET", url, gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{200, 304},
})
if resp != nil {
res.Header = resp.Header
res.Body = resp.Body
}
res.Err = err
return res
}
开发者ID:CorainChicago,项目名称:gophercloud,代码行数:35,代码来源:requests.go
示例11: Create
// Create is a function that creates a new object or replaces an existing object.
func Create(c *gophercloud.ServiceClient, containerName, objectName string, content io.ReadSeeker, opts CreateOptsBuilder) CreateResult {
var res CreateResult
url := createURL(c, containerName, objectName)
h := make(map[string]string)
if opts != nil {
headers, query, err := opts.ToObjectCreateParams()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
url += query
}
ropts := gophercloud.RequestOpts{
RawBody: content,
MoreHeaders: h,
}
resp, err := c.Request("PUT", url, ropts)
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
}
开发者ID:CorainChicago,项目名称:gophercloud,代码行数:33,代码来源:requests.go
示例12: Update
// Update is a function that creates, updates, or deletes an account's metadata.
// To extract the headers returned, call the Extract method on the UpdateResult.
func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) UpdateResult {
var res UpdateResult
h := make(map[string]string)
if opts != nil {
headers, err := opts.ToAccountUpdateMap()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
}
resp, err := c.Request("POST", updateURL(c), gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{201, 202, 204},
})
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:27,代码来源:requests.go
示例13: Get
// Get is a function that retrieves an account's metadata. To extract just the
// custom metadata, call the ExtractMetadata method on the GetResult. To extract
// all the headers that are returned (including the metadata), call the
// ExtractHeader method on the GetResult.
func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) GetResult {
var res GetResult
h := c.AuthenticatedHeaders()
if opts != nil {
headers, err := opts.ToAccountGetMap()
if err != nil {
res.Err = err
return res
}
for k, v := range headers {
h[k] = v
}
}
resp, err := c.Request("HEAD", getURL(c), gophercloud.RequestOpts{
MoreHeaders: h,
OkCodes: []int{204},
})
if resp != nil {
res.Header = resp.Header
}
res.Err = err
return res
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:30,代码来源:requests.go
示例14: Delete
// Delete deletes the interface with interfaceID attached to the instance with
// instanceID.
func Delete(c *gophercloud.ServiceClient, instanceID, interfaceID string) DeleteResult {
var res DeleteResult
_, res.Err = c.Request("DELETE", deleteURL(c, instanceID, interfaceID), gophercloud.RequestOpts{
OkCodes: []int{200, 204},
})
return res
}
开发者ID:rtgoodwin,项目名称:cs-reboot-info,代码行数:9,代码来源:requests.go
示例15: 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
示例16: Delete
// Delete will delete objects or containers in bulk.
func Delete(c *gophercloud.ServiceClient, opts DeleteOptsBuilder) DeleteResult {
var res DeleteResult
if opts == nil {
return res
}
reqString, err := opts.ToBulkDeleteBody()
if err != nil {
res.Err = err
return res
}
reqBody := strings.NewReader(reqString)
resp, err := c.Request("DELETE", deleteURL(c), gophercloud.RequestOpts{
MoreHeaders: map[string]string{"Content-Type": "text/plain"},
OkCodes: []int{200},
JSONBody: reqBody,
JSONResponse: &res.Body,
})
res.Header = resp.Header
res.Err = err
return res
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:26,代码来源:requests.go
示例17: Metadatum
// Metadatum requests the key-value pair with the given key for the given server ID.
func Metadatum(client *gophercloud.ServiceClient, id, key string) GetMetadatumResult {
var res GetMetadatumResult
_, res.Err = client.Request("GET", metadatumURL(client, id, key), gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
}
开发者ID:chenzhen411,项目名称:kubernetes,代码行数:8,代码来源:requests.go
示例18: Revoke
// Revoke immediately makes specified token invalid.
func Revoke(c *gophercloud.ServiceClient, token string) RevokeResult {
var res RevokeResult
_, res.Err = c.Delete(tokenURL(c), &gophercloud.RequestOpts{
MoreHeaders: subjectTokenHeaders(c, token),
})
return res
}
开发者ID:eljefedelrodeodeljefe,项目名称:kubernetes,代码行数:8,代码来源:requests.go
示例19: Delete
// Delete is the operation responsible for permanently deleting a VIP.
func Delete(c *gophercloud.ServiceClient, lbID, vipID int) DeleteResult {
var res DeleteResult
_, res.Err = c.Request("DELETE", resourceURL(c, lbID, vipID), gophercloud.RequestOpts{
OkCodes: []int{202},
})
return res
}
开发者ID:rtgoodwin,项目名称:cs-reboot-info,代码行数:8,代码来源:requests.go
示例20: Delete
// Delete implements image delete request
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var res DeleteResult
_, res.Err = client.Delete(deleteURL(client, id), &gophercloud.RequestOpts{
OkCodes: []int{204},
})
return res
}
开发者ID:rackspace,项目名称:gophercloud,代码行数:8,代码来源:requests.go
注:本文中的github.com/rackspace/gophercloud.ServiceClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论