Пример #1
0
func (repo CloudControllerSpaceRepository) Create(name string, orgGuid string) (space models.Space, apiErr error) {
	path := fmt.Sprintf("%s/v2/spaces?inline-relations-depth=1", repo.config.ApiEndpoint())
	body := fmt.Sprintf(`{"name":"%s","organization_guid":"%s"}`, name, orgGuid)
	resource := new(resources.SpaceResource)
	apiErr = repo.gateway.CreateResource(path, strings.NewReader(body), resource)
	if apiErr != nil {
		return
	}
	space = resource.ToModel()
	return
}
Пример #2
0
func (repo CloudControllerSpaceRepository) Create(name, orgGuid, spaceQuotaGuid string) (space models.Space, apiErr error) {
	path := "/v2/spaces?inline-relations-depth=1"

	bodyMap := map[string]string{"name": name, "organization_guid": orgGuid}
	if spaceQuotaGuid != "" {
		bodyMap["space_quota_definition_guid"] = spaceQuotaGuid
	}

	body, apiErr := json.Marshal(bodyMap)
	if apiErr != nil {
		return
	}

	resource := new(resources.SpaceResource)
	apiErr = repo.gateway.CreateResource(repo.config.ApiEndpoint(), path, strings.NewReader(string(body)), resource)
	if apiErr != nil {
		return
	}
	space = resource.ToModel()
	return
}
Пример #3
0
func (repo CloudControllerSpaceRepository) Create(name, orgGUID, spaceQuotaGUID string) (models.Space, error) {
	var space models.Space
	path := "/v2/spaces?inline-relations-depth=1"

	bodyMap := map[string]string{"name": name, "organization_guid": orgGUID}
	if spaceQuotaGUID != "" {
		bodyMap["space_quota_definition_guid"] = spaceQuotaGUID
	}

	body, err := json.Marshal(bodyMap)
	if err != nil {
		return models.Space{}, err
	}

	resource := new(resources.SpaceResource)
	err = repo.gateway.CreateResource(repo.config.APIEndpoint(), path, strings.NewReader(string(body)), resource)
	if err != nil {
		return models.Space{}, err
	}
	space = resource.ToModel()
	return space, nil
}