本文整理匯總了Golang中github.com/vmware/photon-controller-go-sdk/photon/internal/rest.Post函數的典型用法代碼示例。如果您正苦於以下問題:Golang Post函數的具體用法?Golang Post怎麽用?Golang Post使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Post函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: InitializeDeploymentMigration
// Initialize deployment migration from source to destination
func (api *DeploymentsAPI) InitializeDeploymentMigration(sourceDeploymentId string, id string) (task *Task, err error) {
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+deploymentUrl+"/"+id+"/initialize_migration",
"application/json",
bytes.NewBuffer([]byte(id)),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例2: Destroy
// Destroys a deployment with specified ID.
func (api *DeploymentsAPI) Destroy(id string) (task *Task, err error) {
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+deploymentUrl+"/"+id+"/destroy",
"application/json",
bytes.NewBuffer([]byte("")),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例3: Create
// Creates a flavor.
func (api *FlavorsAPI) Create(spec *FlavorCreateSpec) (task *Task, err error) {
body, err := json.Marshal(spec)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+flavorUrl,
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例4: Create
// Creates a deployment
func (api *DeploymentsAPI) Create(deploymentSpec *DeploymentCreateSpec) (task *Task, err error) {
body, err := json.Marshal(deploymentSpec)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+deploymentUrl,
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例5: Resize
// Resize a cluster to specified count
func (api *ClustersAPI) Resize(id string, resize *ClusterResizeOperation) (task *Task, err error) {
body, err := json.Marshal(resize)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+clusterUrl+id+"/resize",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例6: CreateVM
// Creates a VM on the specified project.
func (api *ProjectsAPI) CreateVM(projectID string, spec *VmCreateSpec) (task *Task, err error) {
body, err := json.Marshal(spec)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+projectUrl+projectID+"/vms",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例7: DetachDisk
func (api *VmAPI) DetachDisk(id string, op *VmDiskOperation) (task *Task, err error) {
body, err := json.Marshal(op)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+vmUrl+id+"/detach_disk",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例8: SetTag
func (api *VmAPI) SetTag(id string, tag *VmTag) (task *Task, err error) {
body, err := json.Marshal(tag)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+vmUrl+id+"/tags",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例9: Suspend
func (api *VmAPI) Suspend(id string) (task *Task, err error) {
body := []byte{}
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+vmUrl+id+"/suspend",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例10: CreateResourceTicket
// Creates a resource ticket on the specified tenant.
func (api *TenantsAPI) CreateResourceTicket(tenantId string, spec *ResourceTicketCreateSpec) (task *Task, err error) {
body, err := json.Marshal(spec)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+tenantUrl+"/"+tenantId+"/resource-tickets",
"application/json",
bytes.NewReader(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例11: setSecurityGroups
// Sets security groups for a given entity (deployment/tenant/project)
func setSecurityGroups(client *Client, entityUrl string, securityGroups *SecurityGroups) (task *Task, err error) {
body, err := json.Marshal(securityGroups)
if err != nil {
return
}
url := entityUrl + "/set_security_groups"
res, err := rest.Post(client.httpClient,
url,
"application/json",
bytes.NewReader(body),
client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例12: GetTokensByRefreshToken
// Gets tokens from refresh token.
func (api *AuthAPI) GetTokensByRefreshToken(refreshtoken string) (tokenOptions *TokenOptions, err error) {
body := strings.NewReader("grant_type=prefresh_token&refresh_token=" + refreshtoken + "&scope=openid offline_access")
res, err := rest.Post(api.client.httpClient,
api.client.AuthEndpoint+tokenUrl,
"application/x-www-form-urlencoded",
body,
"")
if err != nil {
return
}
defer res.Body.Close()
res, err = getError(res)
if err != nil {
return
}
tokenOptions = &TokenOptions{}
err = json.NewDecoder(res.Body).Decode(tokenOptions)
return
}
示例13: UpdateImageDatastores
// Update image datastores of a deployment.
func (api *DeploymentsAPI) UpdateImageDatastores(id string, imageDatastores *ImageDatastores) (task *Task, err error) {
body, err := json.Marshal(imageDatastores)
if err != nil {
return
}
uri := api.client.Endpoint + deploymentUrl + "/" + id + "/set_image_datastores"
res, err := rest.Post(api.client.httpClient,
uri,
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}
示例14: SetAvailabilityZone
// Sets host's availability zone.
func (api *HostsAPI) SetAvailabilityZone(id string, availabilityZone *HostSetAvailabilityZoneOperation) (task *Task, err error) {
body, err := json.Marshal(availabilityZone)
if err != nil {
return
}
res, err := rest.Post(api.client.httpClient,
api.client.Endpoint+hostUrl+"/"+id+"/set_availability_zone",
"application/json",
bytes.NewBuffer(body),
api.client.options.TokenOptions.AccessToken)
if err != nil {
return
}
defer res.Body.Close()
task, err = getTask(getError(res))
return
}