diff --git a/api/payloads/params/include.go b/api/payloads/params/include.go index 65fbe0bc5..03e84fac2 100644 --- a/api/payloads/params/include.go +++ b/api/payloads/params/include.go @@ -16,7 +16,7 @@ type IncludeResourceRule struct { func (r IncludeResourceRule) Validate() error { return jellidation.ValidateStruct(&r, - jellidation.Field(&r.RelationshipPath, jellidation.Each(validation.OneOf("service_offering", "service_broker"))), + jellidation.Field(&r.RelationshipPath, jellidation.Each(validation.OneOf("service_offering", "service_broker", "space", "organization"))), jellidation.Field(&r.Fields, jellidation.Each(validation.OneOf("guid", "name"))), ) } diff --git a/api/payloads/service_plan_test.go b/api/payloads/service_plan_test.go index 82001138d..045ff0f0b 100644 --- a/api/payloads/service_plan_test.go +++ b/api/payloads/service_plan_test.go @@ -25,12 +25,18 @@ var _ = Describe("ServicePlan", func() { Entry("names", "names=b1,b2", payloads.ServicePlanList{Names: "b1,b2"}), Entry("available", "available=true", payloads.ServicePlanList{Available: tools.PtrTo(true)}), Entry("not available", "available=false", payloads.ServicePlanList{Available: tools.PtrTo(false)}), - Entry("include", "include=service_offering", payloads.ServicePlanList{ + Entry("include service offering", "include=service_offering", payloads.ServicePlanList{ IncludeResourceRules: []params.IncludeResourceRule{{ RelationshipPath: []string{"service_offering"}, Fields: []string{}, }}, }), + Entry("include space organization", "include=space.organization", payloads.ServicePlanList{ + IncludeResourceRules: []params.IncludeResourceRule{{ + RelationshipPath: []string{"space", "organization"}, + Fields: []string{}, + }}, + }), Entry("service broker fields", "fields[service_offering.service_broker]=guid,name", payloads.ServicePlanList{ IncludeResourceRules: []params.IncludeResourceRule{{ RelationshipPath: []string{"service_offering", "service_broker"}, diff --git a/api/repositories/relationships/repository.go b/api/repositories/relationships/repository.go index 6820be41a..c5b264213 100644 --- a/api/repositories/relationships/repository.go +++ b/api/repositories/relationships/repository.go @@ -59,6 +59,8 @@ func (r *ResourceRelationshipsRepo) ListRelatedResources(ctx context.Context, au authInfo, repositories.ListServiceBrokerMessage{GUIDs: relatedResourceGUIDs}, )) + case "space", "organization": + return nil, nil } return nil, fmt.Errorf("no repository for type %q", relatedResourceType) diff --git a/api/repositories/relationships/repository_test.go b/api/repositories/relationships/repository_test.go index b76cf2b29..8cc344a62 100644 --- a/api/repositories/relationships/repository_test.go +++ b/api/repositories/relationships/repository_test.go @@ -42,7 +42,7 @@ var _ = Describe("ResourceRelationshipsRepository", func() { Expect(listError).To(MatchError(ContainSubstring(`no repository for type "foo"`))) }) - Describe("resorce type service_offering", func() { + Describe("resource type service_offering", func() { BeforeEach(func() { resourceType = "service_offering" @@ -91,7 +91,7 @@ var _ = Describe("ResourceRelationshipsRepository", func() { }) }) - Describe("resorce type service_broker", func() { + Describe("resource type service_broker", func() { BeforeEach(func() { resourceType = "service_broker" @@ -139,4 +139,26 @@ var _ = Describe("ResourceRelationshipsRepository", func() { }) }) }) + + Describe("resource type space", func() { + BeforeEach(func() { + resourceType = "space" + }) + + It("does not fail and returns an empty result", func() { + Expect(listError).NotTo(HaveOccurred()) + Expect(result).To(BeEmpty()) + }) + }) + + Describe("resource type organization", func() { + BeforeEach(func() { + resourceType = "organization" + }) + + It("does not fail and returns an empty result", func() { + Expect(listError).NotTo(HaveOccurred()) + Expect(result).To(BeEmpty()) + }) + }) })