Example #1
0
func (repo CloudControllerRepository) Create(params models.AppParams) (models.Application, error) {
	appResource := resources.NewApplicationEntityFromAppParams(params)
	data, err := json.Marshal(appResource)
	if err != nil {
		return models.Application{}, fmt.Errorf("%s: %s", T("Failed to marshal JSON"), err.Error())
	}

	resource := new(resources.ApplicationResource)
	err = repo.gateway.CreateResource(repo.config.APIEndpoint(), "/v2/apps", bytes.NewReader(data), resource)
	if err != nil {
		return models.Application{}, err
	}

	return resource.ToModel(), nil
}
Example #2
0
func (repo CloudControllerRepository) Update(appGUID string, params models.AppParams) (updatedApp models.Application, apiErr error) {
	appResource := resources.NewApplicationEntityFromAppParams(params)
	data, err := json.Marshal(appResource)
	if err != nil {
		return models.Application{}, fmt.Errorf("%s: %s", T("Failed to marshal JSON"), err.Error())
	}

	path := fmt.Sprintf("/v2/apps/%s?inline-relations-depth=1", appGUID)
	resource := new(resources.ApplicationResource)
	apiErr = repo.gateway.UpdateResource(repo.config.APIEndpoint(), path, bytes.NewReader(data), resource)
	if apiErr != nil {
		return
	}

	updatedApp = resource.ToModel()
	return
}
Example #3
0
				DockerImage:        &dockerImage,
				Diego:              &diego,
				EnableSSH:          &enableSSH,
				InstanceCount:      &instanceCount,
				Memory:             &memory,
				Name:               &name,
				SpaceGUID:          &spaceGUID,
				StackGUID:          &stackGUID,
				State:              &state,
				PackageUpdatedAt:   &packageUpdatedAt,
				AppPorts:           &appPorts,
			}
		})

		It("directly assigns some attributes", func() {
			entity := resources.NewApplicationEntityFromAppParams(appParams)
			Expect(*entity.Buildpack).To(Equal(buildpackURL))
			Expect(*entity.Name).To(Equal(name))
			Expect(*entity.SpaceGUID).To(Equal(spaceGUID))
			Expect(*entity.Instances).To(Equal(instanceCount))
			Expect(*entity.Memory).To(Equal(memory))
			Expect(*entity.DiskQuota).To(Equal(diskQuota))
			Expect(*entity.StackGUID).To(Equal(stackGUID))
			Expect(*entity.Command).To(Equal(command))
			Expect(*entity.HealthCheckType).To(Equal(healthCheckType))
			Expect(*entity.HealthCheckTimeout).To(Equal(healthCheckTimeout))
			Expect(*entity.DockerImage).To(Equal(dockerImage))
			Expect(*entity.Diego).To(Equal(diego))
			Expect(*entity.EnableSSH).To(Equal(enableSSH))
			Expect(*entity.PackageUpdatedAt).To(Equal(packageUpdatedAt))
			Expect(*entity.AppPorts).To(Equal(appPorts))