diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java index 56e0a0d0a12..10e0db06939 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java @@ -27,6 +27,8 @@ import org.cloudfoundry.client.v3.organizations.ListOrganizationsRequest; import org.cloudfoundry.client.v3.organizations.ListOrganizationsResponse; import org.cloudfoundry.client.v3.organizations.OrganizationsV3; +import org.cloudfoundry.client.v3.organizations.UpdateOrganizationRequest; +import org.cloudfoundry.client.v3.organizations.UpdateOrganizationResponse; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -85,4 +87,10 @@ public Mono list(ListOrganizationsRequest request) { .checkpoint(); } + @Override + public Mono update(UpdateOrganizationRequest request) { + return patch(request, UpdateOrganizationResponse.class, builder -> builder.pathSegment("organizations", request.getOrganizationId())) + .checkpoint(); + } + } diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3.java index d8706823004..2d7cbbb93e2 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3.java @@ -16,6 +16,8 @@ package org.cloudfoundry.reactor.client.v3.spaces; +import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest; +import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse; import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentRequest; import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentResponse; import org.cloudfoundry.client.v3.spaces.CreateSpaceRequest; @@ -27,6 +29,8 @@ import org.cloudfoundry.client.v3.spaces.ListSpacesRequest; import org.cloudfoundry.client.v3.spaces.ListSpacesResponse; import org.cloudfoundry.client.v3.spaces.SpacesV3; +import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest; +import org.cloudfoundry.client.v3.spaces.UpdateSpaceResponse; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -81,4 +85,10 @@ public Mono list(ListSpacesRequest request) { .checkpoint(); } + @Override + public Mono update(UpdateSpaceRequest request) { + return patch(request, UpdateSpaceResponse.class, builder -> builder.pathSegment("spaces", request.getSpaceId())) + .checkpoint(); + } + } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3Test.java index 70d4ee8fc44..54d50c1b9fa 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3Test.java @@ -16,10 +16,18 @@ package org.cloudfoundry.reactor.client.v3.organizations; +import org.cloudfoundry.client.v3.BuildpackData; +import org.cloudfoundry.client.v3.Lifecycle; +import org.cloudfoundry.client.v3.LifecycleType; import org.cloudfoundry.client.v3.Link; import org.cloudfoundry.client.v3.Metadata; import org.cloudfoundry.client.v3.Pagination; import org.cloudfoundry.client.v3.Relationship; +import org.cloudfoundry.client.v3.ToOneRelationship; +import org.cloudfoundry.client.v3.applications.ApplicationRelationships; +import org.cloudfoundry.client.v3.applications.ApplicationState; +import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest; +import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse; import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentRequest; import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentResponse; import org.cloudfoundry.client.v3.organizations.CreateOrganizationRequest; @@ -31,6 +39,8 @@ import org.cloudfoundry.client.v3.organizations.ListOrganizationsRequest; import org.cloudfoundry.client.v3.organizations.ListOrganizationsResponse; import org.cloudfoundry.client.v3.organizations.OrganizationResource; +import org.cloudfoundry.client.v3.organizations.UpdateOrganizationRequest; +import org.cloudfoundry.client.v3.organizations.UpdateOrganizationResponse; import org.cloudfoundry.reactor.InteractionContext; import org.cloudfoundry.reactor.TestRequest; import org.cloudfoundry.reactor.TestResponse; @@ -239,4 +249,44 @@ public void list() { .verify(Duration.ofSeconds(5)); } + + @Test + public void update() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(PATCH).path("/organizations/test-organization-id") + .payload("fixtures/client/v3/organizations/PATCH_{id}_request.json") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/organizations/PATCH_{id}_response.json") + .build()) + .build()); + + this.organizations + .update(UpdateOrganizationRequest.builder() + .organizationId("test-organization-id") + .metadata(Metadata.builder() + .annotation("version", "1.2.4") + .label("dept", "1234") + .build()) + .build()) + .as(StepVerifier::create) + .expectNext(UpdateOrganizationResponse.builder() + .createdAt("2017-02-01T01:33:58Z") + .id("24637893-3b77-489d-bb79-8466f0d88b52") + .link("self", Link.builder() + .href("https://api.example.org/v3/organizations/24637893-3b77-489d-bb79-8466f0d88b52") + .build()) + .metadata(Metadata.builder() + .annotation("version", "1.2.4") + .label("dept", "1234") + .build()) + .name("my-organization") + .updatedAt("2017-02-01T01:33:58Z") + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3Test.java index fea82baf70d..355d48c65cb 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3Test.java @@ -17,9 +17,12 @@ package org.cloudfoundry.reactor.client.v3.spaces; import org.cloudfoundry.client.v3.Link; +import org.cloudfoundry.client.v3.Metadata; import org.cloudfoundry.client.v3.Pagination; import org.cloudfoundry.client.v3.Relationship; import org.cloudfoundry.client.v3.ToOneRelationship; +import org.cloudfoundry.client.v3.organizations.UpdateOrganizationRequest; +import org.cloudfoundry.client.v3.organizations.UpdateOrganizationResponse; import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentRequest; import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentResponse; import org.cloudfoundry.client.v3.spaces.CreateSpaceRequest; @@ -32,6 +35,8 @@ import org.cloudfoundry.client.v3.spaces.ListSpacesResponse; import org.cloudfoundry.client.v3.spaces.SpaceRelationships; import org.cloudfoundry.client.v3.spaces.SpaceResource; +import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest; +import org.cloudfoundry.client.v3.spaces.UpdateSpaceResponse; import org.cloudfoundry.reactor.InteractionContext; import org.cloudfoundry.reactor.TestRequest; import org.cloudfoundry.reactor.TestResponse; @@ -157,6 +162,10 @@ public void get() { .createdAt("2017-02-01T01:33:58Z") .updatedAt("2017-02-01T01:33:58Z") .name("space1") + .metadata(Metadata.builder() + .annotations(Collections.emptyMap()) + .labels(Collections.emptyMap()) + .build()) .link("self", Link.builder() .href("https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920") .build()) @@ -247,4 +256,43 @@ public void list() { .verify(Duration.ofSeconds(5)); } + @Test + public void update() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(PATCH).path("/spaces/test-space-id") + .payload("fixtures/client/v3/spaces/PATCH_{id}_request.json") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/spaces/PATCH_{id}_response.json") + .build()) + .build()); + + this.spaces + .update(UpdateSpaceRequest.builder() + .spaceId("test-space-id") + .metadata(Metadata.builder() + .annotation("version", "1.2.4") + .label("dept", "1234") + .build()) + .build()) + .as(StepVerifier::create) + .expectNext(UpdateSpaceResponse.builder() + .id("885735b5-aea4-4cf5-8e44-961af0e41920") + .createdAt("2017-02-01T01:33:58Z") + .updatedAt("2017-02-01T01:33:58Z") + .name("space1") + .metadata(Metadata.builder() + .annotation("version", "1.2.4") + .label("dept", "1234") + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920") + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + } diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organizations/PATCH_{id}_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organizations/PATCH_{id}_request.json new file mode 100644 index 00000000000..2c1715c8960 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organizations/PATCH_{id}_request.json @@ -0,0 +1,10 @@ +{ + "metadata": { + "labels": { + "dept": "1234" + }, + "annotations": { + "version": "1.2.4" + } + } +} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organizations/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organizations/PATCH_{id}_response.json new file mode 100644 index 00000000000..fbd801bcd6d --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organizations/PATCH_{id}_response.json @@ -0,0 +1,19 @@ +{ + "guid": "24637893-3b77-489d-bb79-8466f0d88b52", + "created_at": "2017-02-01T01:33:58Z", + "updated_at": "2017-02-01T01:33:58Z", + "metadata": { + "labels": { + "dept": "1234" + }, + "annotations": { + "version": "1.2.4" + } + }, + "name": "my-organization", + "links": { + "self": { + "href": "https://api.example.org/v3/organizations/24637893-3b77-489d-bb79-8466f0d88b52" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/GET_{id}_response.json index 4c8dc296226..83ce1b25b3a 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/GET_{id}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/GET_{id}_response.json @@ -3,6 +3,10 @@ "created_at": "2017-02-01T01:33:58Z", "updated_at": "2017-02-01T01:33:58Z", "name": "space1", + "metadata": { + "labels": {}, + "annotations": {} + }, "links": { "self": { "href": "https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920" diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/PATCH_{id}_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/PATCH_{id}_request.json new file mode 100644 index 00000000000..2c1715c8960 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/PATCH_{id}_request.json @@ -0,0 +1,10 @@ +{ + "metadata": { + "labels": { + "dept": "1234" + }, + "annotations": { + "version": "1.2.4" + } + } +} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/PATCH_{id}_response.json new file mode 100644 index 00000000000..8138a1d38ba --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/spaces/PATCH_{id}_response.json @@ -0,0 +1,19 @@ +{ + "guid": "885735b5-aea4-4cf5-8e44-961af0e41920", + "created_at": "2017-02-01T01:33:58Z", + "updated_at": "2017-02-01T01:33:58Z", + "metadata": { + "labels": { + "dept": "1234" + }, + "annotations": { + "version": "1.2.4" + } + }, + "name": "space1", + "links": { + "self": { + "href": "https://api.example.org/v3/spaces/885735b5-aea4-4cf5-8e44-961af0e41920" + } + } +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java index 799dac4c648..e0d540f6f3b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java @@ -16,6 +16,8 @@ package org.cloudfoundry.client.v3.organizations; +import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest; +import org.cloudfoundry.client.v3.spaces.UpdateSpaceResponse; import reactor.core.publisher.Mono; /** @@ -63,4 +65,10 @@ public interface OrganizationsV3 { */ Mono list(ListOrganizationsRequest request); + /** + * @param request the Update Organization request + * @return the response from the Update Organization request + */ + Mono update(UpdateOrganizationRequest request); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_UpdateOrganizationRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_UpdateOrganizationRequest.java new file mode 100644 index 00000000000..5048ce1428f --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_UpdateOrganizationRequest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2013-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cloudfoundry.client.v3.organizations; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Metadata; +import org.immutables.value.Value; + +/** + * The request payload for the Update Space operation + */ +@JsonSerialize +@Value.Immutable +abstract class _UpdateOrganizationRequest { + + /** + * The space id + */ + @JsonIgnore + abstract String getOrganizationId(); + + /** + * The metadata + */ + @JsonProperty("metadata") + @Nullable + abstract Metadata getMetadata(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_UpdateOrganizationResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_UpdateOrganizationResponse.java new file mode 100644 index 00000000000..c754ba29066 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_UpdateOrganizationResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cloudfoundry.client.v3.organizations; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.client.v3.spaces.Space; +import org.immutables.value.Value; + +/** + * The response payload for the Update Space operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _UpdateOrganizationResponse extends Organization { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/SpacesV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/SpacesV3.java index 7dc1dff28ae..927fdb11fb9 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/SpacesV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/SpacesV3.java @@ -16,6 +16,8 @@ package org.cloudfoundry.client.v3.spaces; +import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest; +import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse; import reactor.core.publisher.Mono; /** @@ -63,4 +65,11 @@ public interface SpacesV3 { */ Mono list(ListSpacesRequest request); + /** + * @param request the Update Space request + * @return the response from the Update Space request + */ + Mono update(UpdateSpaceRequest request); + + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/_UpdateSpaceRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/_UpdateSpaceRequest.java new file mode 100644 index 00000000000..9f987c7c914 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/_UpdateSpaceRequest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2013-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cloudfoundry.client.v3.spaces; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Lifecycle; +import org.cloudfoundry.client.v3.Metadata; +import org.immutables.value.Value; + +/** + * The request payload for the Update Space operation + */ +@JsonSerialize +@Value.Immutable +abstract class _UpdateSpaceRequest { + + /** + * The space id + */ + @JsonIgnore + abstract String getSpaceId(); + + /** + * The metadata + */ + @JsonProperty("metadata") + @Nullable + abstract Metadata getMetadata(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/_UpdateSpaceResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/_UpdateSpaceResponse.java new file mode 100644 index 00000000000..db14b505c29 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/_UpdateSpaceResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cloudfoundry.client.v3.spaces; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.client.v3.applications.Application; +import org.immutables.value.Value; + +/** + * The response payload for the Update Space operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _UpdateSpaceResponse extends Space { + +} diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationsTest.java index 36e1a3607e7..d5996167748 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationsTest.java @@ -33,6 +33,7 @@ import org.cloudfoundry.client.v3.organizations.GetOrganizationResponse; import org.cloudfoundry.client.v3.organizations.ListOrganizationsRequest; import org.cloudfoundry.client.v3.organizations.OrganizationResource; +import org.cloudfoundry.client.v3.organizations.UpdateOrganizationRequest; import org.cloudfoundry.util.PaginationUtils; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -134,6 +135,31 @@ public void getDefaultIsolationSegment() { .verify(Duration.ofMinutes(5)); } + @Test + public void update() { + String organizationName = this.nameFactory.getOrganizationName(); + + requestCreateOrganization(this.cloudFoundryClient, organizationName) + .flatMap(resp -> this.cloudFoundryClient.organizationsV3().update(UpdateOrganizationRequest.builder() + .organizationId(resp.getId()) + .metadata(Metadata.builder() + .annotation("annotationKey", "annotationValue") + .label("labelKey", "labelValue") + .build()) + .build())) + .thenMany(PaginationUtils.requestClientV3Resources(page -> this.cloudFoundryClient.organizationsV3() + .list(ListOrganizationsRequest.builder() + .page(page) + .build()))) + .filter(resource -> organizationName.equals(resource.getName()) && + "annotationValue".equals(resource.getMetadata().getAnnotations().get("annotationKey")) && + "labelValue".equals(resource.getMetadata().getAnnotations().get("labelKey"))) + .as(StepVerifier::create) + .expectNextCount(1) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + @Test public void list() { String organizationName = this.nameFactory.getOrganizationName(); diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java index 5a33214e64b..9e430ff3835 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java @@ -32,6 +32,7 @@ import org.cloudfoundry.client.v3.spaces.ListSpacesRequest; import org.cloudfoundry.client.v3.spaces.SpaceRelationships; import org.cloudfoundry.client.v3.spaces.SpaceResource; +import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest; import org.cloudfoundry.util.PaginationUtils; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -128,6 +129,32 @@ public void getIsolationSegment() { .verify(Duration.ofMinutes(5)); } + @Test + public void update() { + String spaceName = this.nameFactory.getSpaceName(); + + this.organizationId + .flatMap(organizationId -> requestCreateSpace(this.cloudFoundryClient, organizationId, spaceName)) + .flatMap(resp -> this.cloudFoundryClient.spacesV3().update(UpdateSpaceRequest.builder() + .spaceId(resp.getId()) + .metadata(Metadata.builder() + .annotation("annotationKey", "annotationValue") + .label("labelKey", "labelValue") + .build()) + .build())) + .thenMany(PaginationUtils.requestClientV3Resources(page -> this.cloudFoundryClient.spacesV3() + .list(ListSpacesRequest.builder() + .page(page) + .build()))) + .filter(resource -> spaceName.equals(resource.getName()) && + "annotationValue".equals(resource.getMetadata().getAnnotations().get("annotationKey")) && + "labelValue".equals(resource.getMetadata().getAnnotations().get("labelKey"))) + .as(StepVerifier::create) + .expectNextCount(1) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + @Test public void list() { String spaceName = this.nameFactory.getSpaceName();