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 }
func (repo CloudControllerBuildpackRepository) Create(name string, position *int, enabled *bool, locked *bool) (createdBuildpack models.Buildpack, apiErr error) { path := repo.config.ApiEndpoint() + buildpacks_path entity := resources.BuildpackEntity{Name: name, Position: position, Enabled: enabled, Locked: locked} body, err := json.Marshal(entity) if err != nil { apiErr = errors.NewWithError("Could not serialize information", err) return } resource := new(resources.BuildpackResource) apiErr = repo.gateway.CreateResource(path, bytes.NewReader(body), resource) if apiErr != nil { return } createdBuildpack = resource.ToFields() return }