本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/resources.BuildpackResource.ToFields方法的典型用法代碼示例。如果您正苦於以下問題:Golang BuildpackResource.ToFields方法的具體用法?Golang BuildpackResource.ToFields怎麽用?Golang BuildpackResource.ToFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/api/resources.BuildpackResource
的用法示例。
在下文中一共展示了BuildpackResource.ToFields方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Update
func (repo CloudControllerBuildpackRepository) Update(buildpack models.Buildpack) (updatedBuildpack models.Buildpack, apiErr error) {
path := fmt.Sprintf("%s%s/%s", repo.config.ApiEndpoint(), buildpacks_path, buildpack.Guid)
entity := resources.BuildpackEntity{
Name: buildpack.Name,
Position: buildpack.Position,
Enabled: buildpack.Enabled,
Key: "",
Filename: "",
Locked: buildpack.Locked,
}
body, err := json.Marshal(entity)
if err != nil {
apiErr = errors.NewWithError("Could not serialize updates.", err)
return
}
resource := new(resources.BuildpackResource)
apiErr = repo.gateway.UpdateResource(path, bytes.NewReader(body), resource)
if apiErr != nil {
return
}
updatedBuildpack = resource.ToFields()
return
}
示例2: Create
func (repo CloudControllerBuildpackRepository) Create(name string, position *int, enabled *bool, locked *bool) (createdBuildpack models.Buildpack, apiErr error) {
entity := resources.BuildpackEntity{Name: name, Position: position, Enabled: enabled, Locked: locked}
body, err := json.Marshal(entity)
if err != nil {
apiErr = fmt.Errorf("%s: %s", T("Could not serialize information"), err.Error())
return
}
resource := new(resources.BuildpackResource)
apiErr = repo.gateway.CreateResource(repo.config.ApiEndpoint(), buildpacks_path, bytes.NewReader(body), resource)
if apiErr != nil {
return
}
createdBuildpack = resource.ToFields()
return
}