本文整理汇总了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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:14,代码来源:deployments.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:14,代码来源:deployments.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:18,代码来源:flavors.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:18,代码来源:deployments.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:18,代码来源:clusters.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:18,代码来源:projects.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:17,代码来源:vms.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:17,代码来源:vms.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:17,代码来源:vms.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:18,代码来源:tenants.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:19,代码来源:util.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:20,代码来源:auth.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:21,代码来源:deployments.go
示例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
}
开发者ID:vmware,项目名称:bosh-photon-cpi,代码行数:21,代码来源:hosts.go
注:本文中的github.com/vmware/photon-controller-go-sdk/photon/internal/rest.Post函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论