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


Golang ServiceClient.Post方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: Create

// Create inserts a new Endpoint into the service catalog.
// Within EndpointOpts, Region may be omitted by being left as "", but all other fields are required.
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
	b, err := opts.ToEndpointCreateMap()
	if err != nil {
		r.Err = err
		return
	}
	_, r.Err = client.Post(listURL(client), &b, &r.Body, nil)
	return
}
開發者ID:jrperritt,項目名稱:gophercloud-1,代碼行數:11,代碼來源:requests.go

示例12: 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

示例13: Validate

// Validate validates the given stack template.
func Validate(c *gophercloud.ServiceClient, opts ValidateOptsBuilder) (r ValidateResult) {
	b, err := opts.ToStackTemplateValidateMap()
	if err != nil {
		r.Err = err
		return
	}
	_, r.Err = c.Post(validateURL(c), b, &r.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return
}
開發者ID:jrperritt,項目名稱:gophercloud-1,代碼行數:12,代碼來源:requests.go

示例14: Preview

// Preview accepts a PreviewOptsBuilder interface and creates a preview of a stack using the values
// provided.
func Preview(c *gophercloud.ServiceClient, opts PreviewOptsBuilder) (r PreviewResult) {
	b, err := opts.ToStackPreviewMap()
	if err != nil {
		r.Err = err
		return
	}
	_, r.Err = c.Post(previewURL(c), b, &r.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return
}
開發者ID:jrperritt,項目名稱:gophercloud-1,代碼行數:13,代碼來源:requests.go

示例15: Create

// Create accepts a CreateOpts struct and creates a new CDN service using the
// values provided.
func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult) {
	b, err := opts.ToCDNServiceCreateMap()
	if err != nil {
		r.Err = err
		return r
	}
	resp, err := c.Post(createURL(c), &b, nil, nil)
	r.Header = resp.Header
	r.Err = err
	return
}
開發者ID:jrperritt,項目名稱:gophercloud-1,代碼行數:13,代碼來源:requests.go


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