本文整理汇总了Golang中github.com/gophercloud/gophercloud.ServiceClient类的典型用法代码示例。如果您正苦于以下问题:Golang ServiceClient类的具体用法?Golang ServiceClient怎么用?Golang ServiceClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ServiceClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Create
// Create member for specific image
//
// Preconditions
// The specified images must exist.
// You can only add a new member to an image which 'visibility' attribute is private.
// You must be the owner of the specified image.
// Synchronous Postconditions
// With correct permissions, you can see the member status of the image as pending through API calls.
//
// More details here: http://developer.openstack.org/api-ref-image-v2.html#createImageMember-v2
func Create(client *gophercloud.ServiceClient, id string, member string) (r CreateResult) {
b := map[string]interface{}{"member": member}
_, r.Err = client.Post(createMemberURL(client, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200, 409, 403},
})
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:17,代码来源:requests.go
示例2: 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
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:29,代码来源:requests.go
示例3: BeginDetaching
// BeginDetach will mark the volume as detaching
func BeginDetaching(client *gophercloud.ServiceClient, id string) (r BeginDetachingResult) {
b := map[string]interface{}{"os-begin_detaching": make(map[string]interface{})}
_, r.Err = client.Post(beginDetachingURL(client, id), b, nil, &gophercloud.RequestOpts{
OkCodes: []int{202},
})
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:8,代码来源:requests.go
示例4: Create
// Create is a function that creates a new object or replaces an existing object. If the returned response's ETag
// header fails to match the local checksum, the failed request will automatically be retried up to a maximum of 3 times.
func Create(c *gophercloud.ServiceClient, containerName, objectName string, opts CreateOptsBuilder) (r CreateResult) {
url := createURL(c, containerName, objectName)
h := make(map[string]string)
var b io.Reader
if opts != nil {
tmpB, headers, query, err := opts.ToObjectCreateParams()
if err != nil {
r.Err = err
return
}
for k, v := range headers {
h[k] = v
}
url += query
b = tmpB
}
resp, err := c.Put(url, nil, nil, &gophercloud.RequestOpts{
RawBody: b,
MoreHeaders: h,
})
r.Err = err
if resp != nil {
r.Header = resp.Header
}
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:29,代码来源:requests.go
示例5: Upload
// Upload uploads image file
func Upload(client *gophercloud.ServiceClient, id string, data io.ReadSeeker) (r UploadResult) {
_, r.Err = client.Put(uploadURL(client, id), data, nil, &gophercloud.RequestOpts{
MoreHeaders: map[string]string{"Content-Type": "application/octet-stream"},
OkCodes: []int{204},
})
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:8,代码来源:requests.go
示例6: Reserve
// Reserve will reserve a volume based on volume id.
func Reserve(client *gophercloud.ServiceClient, id string) (r ReserveResult) {
b := map[string]interface{}{"os-reserve": make(map[string]interface{})}
_, r.Err = client.Post(reserveURL(client, id), b, nil, &gophercloud.RequestOpts{
OkCodes: []int{200, 201, 202},
})
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:8,代码来源:requests.go
示例7: RemoveRule
func RemoveRule(c *gophercloud.ServiceClient, id, ruleID string) (r RemoveRuleResult) {
b := map[string]interface{}{"firewall_rule_id": ruleID}
_, r.Err = c.Put(removeURL(c, id), b, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:7,代码来源:requests.go
示例8: Abandon
// Abandon deletes the stack with the provided stackName and stackID, but leaves its
// resources intact, and returns data describing the stack and its resources.
func Abandon(c *gophercloud.ServiceClient, stackName, stackID string) (r AbandonResult) {
_, r.Err = c.Delete(abandonURL(c, stackName, stackID), &gophercloud.RequestOpts{
JSONResponse: &r.Body,
OkCodes: []int{200},
})
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:9,代码来源:requests.go
示例9: 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
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:8,代码来源:requests.go
示例10: Update
// Update will modify an existing configuration group by performing a merge
// between new and existing values. If the key already exists, the new value
// will overwrite. All other keys will remain unaffected.
func Update(client *gophercloud.ServiceClient, configID string, opts UpdateOptsBuilder) (r UpdateResult) {
b, err := opts.ToConfigUpdateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Patch(resourceURL(client, configID), &b, nil, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:12,代码来源:requests.go
示例11: 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
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:10,代码来源:requests.go
示例12: CreateMember
// CreateMember will create and associate a Member with a particular Pool.
func CreateMember(c *gophercloud.ServiceClient, poolID string, opts CreateMemberOpts) (r CreateMemberResult) {
b, err := opts.ToMemberCreateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = c.Post(memberRootURL(c, poolID), b, &r.Body, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:10,代码来源:requests.go
示例13: Create
// Create accepts a CreateOpts struct and uses the values to create a new firewall rule
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
b, err := opts.ToRuleCreateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = c.Post(rootURL(c), b, &r.Body, nil)
return
}
开发者ID:mhlias,项目名称:terraform,代码行数:10,代码来源:requests.go
示例14: ChangeAdminPassword
// ChangeAdminPassword alters the administrator or root password for a specified server.
func ChangeAdminPassword(client *gophercloud.ServiceClient, id, newPassword string) (r ActionResult) {
b := map[string]interface{}{
"changePassword": map[string]string{
"adminPass": newPassword,
},
}
_, r.Err = client.Post(actionURL(client, id), b, nil, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:10,代码来源:requests.go
示例15: Rebuild
// Rebuild will reprovision the server according to the configuration options
// provided in the RebuildOpts struct.
func Rebuild(client *gophercloud.ServiceClient, id string, opts RebuildOptsBuilder) (r RebuildResult) {
b, err := opts.ToServerRebuildMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(actionURL(client, id), b, &r.Body, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:11,代码来源:requests.go
示例16: Create
// Create asynchronously provisions a new user for the specified database
// instance based on the configuration defined in CreateOpts. If databases are
// assigned for a particular user, the user will be granted all privileges
// for those specified databases. "root" is a reserved name and cannot be used.
func Create(client *gophercloud.ServiceClient, instanceID string, opts CreateOptsBuilder) (r CreateResult) {
b, err := opts.ToUserCreateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(baseURL(client, instanceID), &b, nil, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:13,代码来源:requests.go
示例17: AssociateInstance
// AssociateInstance pairs an allocated floating IP with an instance.
func AssociateInstance(client *gophercloud.ServiceClient, serverID string, opts AssociateOptsBuilder) (r AssociateResult) {
b, err := opts.ToFloatingIPAssociateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(associateURL(client, serverID), b, nil, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:10,代码来源:requests.go
示例18: Update
// Update accepts an UpdateOpts struct and updates an existing stack using the values
// provided.
func Update(c *gophercloud.ServiceClient, stackName, stackID string, opts UpdateOptsBuilder) (r UpdateResult) {
b, err := opts.ToStackUpdateMap()
if err != nil {
r.Err = err
return
}
_, r.Err = c.Put(updateURL(c, stackName, stackID), b, nil, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:11,代码来源:requests.go
示例19: Resize
// Resize instructs the provider to change the flavor of the server.
// Note that this implies rebuilding it.
// Unfortunately, one cannot pass rebuild parameters to the resize function.
// When the resize completes, the server will be in RESIZE_VERIFY state.
// While in this state, you can explore the use of the new server's configuration.
// If you like it, call ConfirmResize() to commit the resize permanently.
// Otherwise, call RevertResize() to restore the old configuration.
func Resize(client *gophercloud.ServiceClient, id string, opts ResizeOptsBuilder) (r ActionResult) {
b, err := opts.ToServerResizeMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(actionURL(client, id), b, nil, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:16,代码来源:requests.go
示例20: Adopt
// Adopt accepts an AdoptOpts struct and creates a new stack using the resources
// from another stack.
func Adopt(c *gophercloud.ServiceClient, opts AdoptOptsBuilder) (r AdoptResult) {
b, err := opts.ToStackAdoptMap()
if err != nil {
r.Err = err
return
}
_, r.Err = c.Post(adoptURL(c), b, &r.Body, nil)
return
}
开发者ID:jrperritt,项目名称:gophercloud-1,代码行数:11,代码来源:requests.go
注:本文中的github.com/gophercloud/gophercloud.ServiceClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论