Skip to content

App and service metadata #966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,4 +71,8 @@ public Mono<Void> unshare(UnshareServiceInstanceRequest request) {
.checkpoint();
}

@Override
public Mono<UpdateServiceInstanceResponse> update(UpdateServiceInstanceRequest request) {
return patch(request, UpdateServiceInstanceResponse.class, builder -> builder.pathSegment("service_instances", request.getServiceInstanceId()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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()
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@
"java_buildpack"
]
}
},
"metadata": {
"labels": {
"isLive": "false",
"maintenance": "true"
},
"annotations": {
"version": "1.2.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"metadata": {
"labels": {
"test": "yes"
},
"annotations": {
"data": "potato"
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
@@ -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<String, String> getLabels();

/**
* The metadata annotations
*/
@JsonProperty("annotations")
@AllowNulls
@Nullable
abstract Map<String, String> getAnnotations();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,5 +59,12 @@ abstract class _CreateApplicationRequest {
*/
@JsonProperty("relationships")
abstract ApplicationRelationships getRelationships();

/**
* The metadata
*/
@JsonProperty("metadata")
@Nullable
abstract Metadata getMetadata();

}
Loading