diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/serviceinstances/ReactorServiceInstancesV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/serviceinstances/ReactorServiceInstancesV3.java index 303183328d6..ada97880c4c 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/serviceinstances/ReactorServiceInstancesV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/serviceinstances/ReactorServiceInstancesV3.java @@ -24,6 +24,8 @@ import org.cloudfoundry.client.v3.serviceInstances.ShareServiceInstanceRequest; import org.cloudfoundry.client.v3.serviceInstances.ShareServiceInstanceResponse; import org.cloudfoundry.client.v3.serviceInstances.UnshareServiceInstanceRequest; +import org.cloudfoundry.client.v3.serviceInstances.UpdateServiceInstanceRequest; +import org.cloudfoundry.client.v3.serviceInstances.UpdateServiceInstanceResponse; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -69,4 +71,8 @@ public Mono unshare(UnshareServiceInstanceRequest request) { .checkpoint(); } + @Override + public Mono update(UpdateServiceInstanceRequest request) { + return patch(request, UpdateServiceInstanceResponse.class, builder -> builder.pathSegment("service_instances", request.getServiceInstanceId())); + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java index d92f3a31bff..4c3272e048b 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java @@ -23,6 +23,7 @@ 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; @@ -141,6 +142,10 @@ public void create() { .build()) .build()) .build()) + .metadata(Metadata.builder() + .label("isLive", Boolean.toString(true)) + .annotation("version", "1.2.3") + .build()) .build()) .as(StepVerifier::create) .expectNext(CreateApplicationResponse.builder() @@ -163,6 +168,10 @@ public void create() { .build()) .build()) .build()) + .metadata(Metadata.builder() + .label("isLive", Boolean.toString(true)) + .annotation("version", "1.2.3") + .build()) .link("self", Link.builder() .href("https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446") .build()) @@ -262,6 +271,11 @@ public void get() { .build()) .build()) .build()) + .metadata(Metadata.builder() + .label("isLive", Boolean.toString(false)) + .label("maintenance", Boolean.toString(true)) + .annotation("version", "1.2.4") + .build()) .link("self", Link.builder() .href("https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446") .build()) @@ -624,6 +638,10 @@ public void list() { .build()) .build()) .build()) + .metadata(Metadata.builder() + .label("isLive", Boolean.toString(true)) + .annotation("version", "1.2.3") + .build()) .link("self", Link.builder() .href("https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446") .build()) @@ -1428,6 +1446,11 @@ public void update() { .buildpack("java_buildpack") .build()) .build()) + .metadata(Metadata.builder() + .label("isLive", Boolean.toString(false)) + .label("maintenance", Boolean.toString(true)) + .annotation("version", "1.2.4") + .build()) .build()) .as(StepVerifier::create) .expectNext(UpdateApplicationResponse.builder() @@ -1450,6 +1473,11 @@ public void update() { .build()) .build()) .build()) + .metadata(Metadata.builder() + .label("isLive", Boolean.toString(false)) + .label("maintenance", Boolean.toString(true)) + .annotation("version", "1.2.4") + .build()) .link("self", Link.builder() .href("https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446") .build()) diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/serviceInstances/ReactorServiceInstancesV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/serviceInstances/ReactorServiceInstancesV3Test.java index 6bd6de76236..589642ab106 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/serviceInstances/ReactorServiceInstancesV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/serviceInstances/ReactorServiceInstancesV3Test.java @@ -17,6 +17,7 @@ package org.cloudfoundry.reactor.client.v3.serviceInstances; 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; @@ -29,6 +30,8 @@ import org.cloudfoundry.client.v3.serviceInstances.ShareServiceInstanceRequest; import org.cloudfoundry.client.v3.serviceInstances.ShareServiceInstanceResponse; import org.cloudfoundry.client.v3.serviceInstances.UnshareServiceInstanceRequest; +import org.cloudfoundry.client.v3.serviceInstances.UpdateServiceInstanceRequest; +import org.cloudfoundry.client.v3.serviceInstances.UpdateServiceInstanceResponse; import org.cloudfoundry.reactor.InteractionContext; import org.cloudfoundry.reactor.TestRequest; import org.cloudfoundry.reactor.TestResponse; @@ -42,6 +45,7 @@ import static io.netty.handler.codec.http.HttpMethod.DELETE; import static io.netty.handler.codec.http.HttpMethod.GET; import static io.netty.handler.codec.http.HttpMethod.POST; +import static io.netty.handler.codec.http.HttpMethod.PATCH; import static io.netty.handler.codec.http.HttpResponseStatus.CREATED; import static io.netty.handler.codec.http.HttpResponseStatus.NO_CONTENT; import static io.netty.handler.codec.http.HttpResponseStatus.OK; @@ -224,4 +228,39 @@ public void unshare() { .expectComplete() .verify(Duration.ofSeconds(5)); } + + @Test + public void update() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(PATCH).path("/service_instances/68d54d31-9b3a-463b-ba94-e8e4c32edbac") + .payload("fixtures/client/v3/serviceinstances/PATCH_request.json") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/serviceinstances/PATCH_response.json") + .build()) + .build()); + + this.serviceInstances + .update(UpdateServiceInstanceRequest.builder() + .serviceInstanceId("68d54d31-9b3a-463b-ba94-e8e4c32edbac") + .metadata(Metadata.builder() + .label("test", "yes") + .annotation("data", "potato") + .build()) + .build()) + .as(StepVerifier::create) + .expectNext(UpdateServiceInstanceResponse.builder() + .id("68d54d31-9b3a-463b-ba94-e8e4c32edbac") + .metadata(Metadata.builder() + .label("test", "yes") + .annotation("data", "potato") + .build()) + .name("my_service_instance1") + .createdAt("2017-11-17T13:54:21Z") + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } } diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_response.json index 4ae2009694d..a2f71578978 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_response.json @@ -36,6 +36,14 @@ } } }, + "metadata": { + "labels": { + "isLive": true + }, + "annotations": { + "version": "1.2.3" + } + }, "links": { "self": { "href": "https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446" diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_response.json index b6430254ada..54ca79c951f 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_response.json @@ -20,6 +20,15 @@ } } }, + "metadata": { + "labels": { + "isLive": "false", + "maintenance": "true" + }, + "annotations": { + "version": "1.2.4" + } + }, "links": { "self": { "href": "https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446" diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_request.json index 4b292197464..21c19266ad5 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_request.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_request.json @@ -7,5 +7,14 @@ "java_buildpack" ] } + }, + "metadata": { + "labels": { + "isLive": "false", + "maintenance": "true" + }, + "annotations": { + "version": "1.2.4" + } } } diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_response.json index 3f62a9593e7..373dd814c38 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PATCH_{id}_response.json @@ -20,6 +20,15 @@ } } }, + "metadata": { + "labels": { + "isLive": "false", + "maintenance": "true" + }, + "annotations": { + "version": "1.2.4" + } + }, "links": { "self": { "href": "https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446" diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_request.json index 2b3c070fa50..18e7305fea9 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_request.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_request.json @@ -1,10 +1,18 @@ { - "name": "my_app", - "relationships": { - "space": { - "data": { - "guid": "2f35885d-0c9d-4423-83ad-fd05066f8576" - } - } - } + "name": "my_app", + "relationships": { + "space": { + "data": { + "guid": "2f35885d-0c9d-4423-83ad-fd05066f8576" + } + } + }, + "metadata": { + "labels": { + "isLive": "true" + }, + "annotations": { + "version": "1.2.3" + } + } } diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_response.json index 6d87ec0e01e..df6057ccf9a 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/POST_response.json @@ -18,6 +18,14 @@ } } }, + "metadata": { + "labels": { + "isLive": true + }, + "annotations": { + "version": "1.2.3" + } + }, "links": { "self": { "href": "https://api.example.org/v3/apps/1cb006ee-fb05-47e1-b541-c34179ddc446" diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/serviceinstances/PATCH_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/serviceinstances/PATCH_request.json new file mode 100644 index 00000000000..6b97a78279d --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/serviceinstances/PATCH_request.json @@ -0,0 +1,10 @@ +{ + "metadata": { + "labels": { + "test": "yes" + }, + "annotations": { + "data": "potato" + } + } +} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/serviceinstances/PATCH_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/serviceinstances/PATCH_response.json new file mode 100644 index 00000000000..e63b7a028d3 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/serviceinstances/PATCH_response.json @@ -0,0 +1,13 @@ +{ + "guid": "68d54d31-9b3a-463b-ba94-e8e4c32edbac", + "created_at": "2017-11-17T13:54:21Z", + "name": "my_service_instance1", + "metadata": { + "labels": { + "test": "yes" + }, + "annotations": { + "data": "potato" + } + } +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Metadata.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Metadata.java new file mode 100644 index 00000000000..f8a9c01501c --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Metadata.java @@ -0,0 +1,51 @@ +/* + * Copyright 2013-2019 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; + +import java.util.Map; + +import org.cloudfoundry.AllowNulls; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +/** + * The metadata payload for a resource + */ +@JsonDeserialize +@Value.Immutable +abstract class _Metadata { + + /** + * The metadata lables + */ + @JsonProperty("labels") + @AllowNulls + @Nullable + abstract Map getLabels(); + + /** + * The metadata annotations + */ + @JsonProperty("annotations") + @AllowNulls + @Nullable + abstract Map getAnnotations(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/Application.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/Application.java index 9a5a17bdbbb..79806634556 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/Application.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/Application.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.Lifecycle; +import org.cloudfoundry.client.v3.Metadata; import org.cloudfoundry.client.v3.Resource; /** @@ -50,5 +51,12 @@ public abstract class Application extends Resource { */ @JsonProperty("state") public abstract ApplicationState getState(); + + /** + * The metadata + */ + @JsonProperty("metadata") + @Nullable + public abstract Metadata getMetadata(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_CreateApplicationRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_CreateApplicationRequest.java index c24fe389650..a64ea71e101 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_CreateApplicationRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_CreateApplicationRequest.java @@ -21,6 +21,7 @@ import org.cloudfoundry.AllowNulls; import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.Lifecycle; +import org.cloudfoundry.client.v3.Metadata; import org.immutables.value.Value; import java.util.Map; @@ -58,5 +59,12 @@ abstract class _CreateApplicationRequest { */ @JsonProperty("relationships") abstract ApplicationRelationships getRelationships(); + + /** + * The metadata + */ + @JsonProperty("metadata") + @Nullable + abstract Metadata getMetadata(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ListApplicationsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ListApplicationsRequest.java index eaf4ee700fd..66377fe5b97 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ListApplicationsRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ListApplicationsRequest.java @@ -16,6 +16,7 @@ package org.cloudfoundry.client.v3.applications; +import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.FilterParameter; import org.cloudfoundry.client.v3.PaginatedRequest; import org.immutables.value.Value; @@ -51,5 +52,12 @@ abstract class _ListApplicationsRequest extends PaginatedRequest { */ @FilterParameter("space_guids") abstract List getSpaceIds(); - + + /** + * The metadata query + */ + @FilterParameter("label_selector") + @Nullable + abstract String getLabelSelector(); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_UpdateApplicationRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_UpdateApplicationRequest.java index 82ac00ebcd5..390eeabf603 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_UpdateApplicationRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_UpdateApplicationRequest.java @@ -21,6 +21,7 @@ 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; /** @@ -49,5 +50,12 @@ abstract class _UpdateApplicationRequest { @JsonProperty("name") @Nullable abstract String getName(); + + /** + * The metadata + */ + @JsonProperty("metadata") + @Nullable + abstract Metadata getMetadata(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstance.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstance.java index 0f3dcbaf167..e2c8ed381d8 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstance.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstance.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Metadata; import org.cloudfoundry.client.v3.Resource; /** @@ -37,5 +38,12 @@ public abstract class ServiceInstance extends Resource { @JsonProperty("relationships") @Nullable public abstract ServiceInstanceRelationships getRelationships(); + + /** + * The metadata + */ + @JsonProperty("metadata") + @Nullable + public abstract Metadata getMetadata(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstancesV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstancesV3.java index b7045cd3a18..e6b3dee3ece 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstancesV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/ServiceInstancesV3.java @@ -57,4 +57,13 @@ public interface ServiceInstancesV3 { * @return the response from the Unshare Service Instance From Another Space request */ Mono unshare(UnshareServiceInstanceRequest request); + + /** + * Makes the + * Update a service instance request + * + * @param request the Update Service Instance request + * @return the response from the Update Service Instance request + */ + Mono update(UpdateServiceInstanceRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_ListServiceInstancesRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_ListServiceInstancesRequest.java index ac94d30ab58..b4a1f926508 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_ListServiceInstancesRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_ListServiceInstancesRequest.java @@ -16,6 +16,7 @@ package org.cloudfoundry.client.v3.serviceInstances; +import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.FilterParameter; import org.cloudfoundry.client.v3.PaginatedRequest; import org.immutables.value.Value; @@ -39,4 +40,11 @@ abstract class _ListServiceInstancesRequest extends PaginatedRequest { */ @FilterParameter("space_guids") abstract List getSpaceIds(); + + /** + * The metadata query + */ + @FilterParameter("label_selector") + @Nullable + abstract String getLabelSelector(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_UpdateServiceInstanceRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_UpdateServiceInstanceRequest.java new file mode 100644 index 00000000000..985c2bef4e0 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_UpdateServiceInstanceRequest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2013-2019 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.serviceInstances; + +import org.cloudfoundry.client.v3.Metadata; +import org.immutables.value.Value; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +/** + * The request payload for the Update Application operation + */ +@JsonSerialize +@Value.Immutable +abstract class _UpdateServiceInstanceRequest { + + /** + * The service instance id + */ + @JsonIgnore + abstract String getServiceInstanceId(); + + /** + * The metadata + */ + @JsonProperty("metadata") + abstract Metadata getMetadata(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_UpdateServiceInstanceResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_UpdateServiceInstanceResponse.java new file mode 100644 index 00000000000..bb0883992d6 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/serviceInstances/_UpdateServiceInstanceResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2019 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.serviceInstances; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Update Application operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _UpdateServiceInstanceResponse extends ServiceInstance { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/serviceinstances/UpdateServiceInstanceRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/serviceinstances/UpdateServiceInstanceRequestTest.java new file mode 100644 index 00000000000..c10b16827b2 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/serviceinstances/UpdateServiceInstanceRequestTest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2013-2019 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.serviceinstances; + +import org.cloudfoundry.client.v3.Metadata; +import org.cloudfoundry.client.v3.serviceInstances.UpdateServiceInstanceRequest; +import org.junit.Test; + +public class UpdateServiceInstanceRequestTest { + + @Test(expected = IllegalStateException.class) + public void noServiceInstanceId() { + UpdateServiceInstanceRequest.builder() + .metadata(Metadata.builder().build()) + .build(); + } + + @Test(expected = IllegalStateException.class) + public void noMetadata() { + UpdateServiceInstanceRequest.builder() + .serviceInstanceId("test-service-instance-id") + .build(); + } + + @Test + public void valid() { + UpdateServiceInstanceRequest.builder() + .serviceInstanceId("test-service-instance-id") + .metadata(Metadata.builder().build()) + .build(); + } +}