Skip to content

Commit 4852d52

Browse files
committed
Merge branch 'app-features' into 3.x
2 parents 4dcec97 + 3eb3cb6 commit 4852d52

File tree

20 files changed

+708
-3
lines changed

20 files changed

+708
-3
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.cloudfoundry.client.v3.applications.GetApplicationEnvironmentResponse;
2929
import org.cloudfoundry.client.v3.applications.GetApplicationEnvironmentVariablesRequest;
3030
import org.cloudfoundry.client.v3.applications.GetApplicationEnvironmentVariablesResponse;
31+
import org.cloudfoundry.client.v3.applications.GetApplicationFeatureRequest;
32+
import org.cloudfoundry.client.v3.applications.GetApplicationFeatureResponse;
3133
import org.cloudfoundry.client.v3.applications.GetApplicationProcessRequest;
3234
import org.cloudfoundry.client.v3.applications.GetApplicationProcessResponse;
3335
import org.cloudfoundry.client.v3.applications.GetApplicationProcessStatisticsRequest;
@@ -38,6 +40,8 @@
3840
import org.cloudfoundry.client.v3.applications.ListApplicationBuildsResponse;
3941
import org.cloudfoundry.client.v3.applications.ListApplicationDropletsRequest;
4042
import org.cloudfoundry.client.v3.applications.ListApplicationDropletsResponse;
43+
import org.cloudfoundry.client.v3.applications.ListApplicationFeaturesRequest;
44+
import org.cloudfoundry.client.v3.applications.ListApplicationFeaturesResponse;
4145
import org.cloudfoundry.client.v3.applications.ListApplicationPackagesRequest;
4246
import org.cloudfoundry.client.v3.applications.ListApplicationPackagesResponse;
4347
import org.cloudfoundry.client.v3.applications.ListApplicationProcessesRequest;
@@ -59,6 +63,8 @@
5963
import org.cloudfoundry.client.v3.applications.TerminateApplicationInstanceRequest;
6064
import org.cloudfoundry.client.v3.applications.UpdateApplicationEnvironmentVariablesRequest;
6165
import org.cloudfoundry.client.v3.applications.UpdateApplicationEnvironmentVariablesResponse;
66+
import org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureRequest;
67+
import org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureResponse;
6268
import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest;
6369
import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse;
6470
import org.cloudfoundry.reactor.ConnectionContext;
@@ -127,6 +133,12 @@ public Mono<GetApplicationEnvironmentVariablesResponse> getEnvironmentVariables(
127133
.checkpoint();
128134
}
129135

136+
@Override
137+
public Mono<GetApplicationFeatureResponse> getFeature(GetApplicationFeatureRequest request) {
138+
return get(request, GetApplicationFeatureResponse.class, builder -> builder.pathSegment("apps", request.getApplicationId(), "features", request.getFeatureName()))
139+
.checkpoint();
140+
}
141+
130142
@Override
131143
public Mono<GetApplicationProcessResponse> getProcess(GetApplicationProcessRequest request) {
132144
return get(request, GetApplicationProcessResponse.class, builder -> builder.pathSegment("apps", request.getApplicationId(), "processes", request.getType()))
@@ -157,6 +169,12 @@ public Mono<ListApplicationDropletsResponse> listDroplets(ListApplicationDroplet
157169
.checkpoint();
158170
}
159171

172+
@Override
173+
public Mono<ListApplicationFeaturesResponse> listFeatures(ListApplicationFeaturesRequest request) {
174+
return get(request, ListApplicationFeaturesResponse.class, builder -> builder.pathSegment("apps", request.getApplicationId(), "features"))
175+
.checkpoint();
176+
}
177+
160178
@Override
161179
public Mono<ListApplicationPackagesResponse> listPackages(ListApplicationPackagesRequest request) {
162180
return get(request, ListApplicationPackagesResponse.class, builder -> builder.pathSegment("apps", request.getApplicationId(), "packages"))
@@ -223,4 +241,10 @@ public Mono<UpdateApplicationEnvironmentVariablesResponse> updateEnvironmentVari
223241
.checkpoint();
224242
}
225243

244+
@Override
245+
public Mono<UpdateApplicationFeatureResponse> updateFeature(UpdateApplicationFeatureRequest request) {
246+
return patch(request, UpdateApplicationFeatureResponse.class, builder -> builder.pathSegment("apps", request.getApplicationId(), "features", request.getFeatureName()))
247+
.checkpoint();
248+
}
249+
226250
}

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.cloudfoundry.client.v3.Pagination;
2828
import org.cloudfoundry.client.v3.Relationship;
2929
import org.cloudfoundry.client.v3.ToOneRelationship;
30+
import org.cloudfoundry.client.v3.applications.ApplicationFeatureResource;
3031
import org.cloudfoundry.client.v3.applications.ApplicationRelationships;
3132
import org.cloudfoundry.client.v3.applications.ApplicationResource;
3233
import org.cloudfoundry.client.v3.applications.ApplicationState;
@@ -41,6 +42,8 @@
4142
import org.cloudfoundry.client.v3.applications.GetApplicationEnvironmentResponse;
4243
import org.cloudfoundry.client.v3.applications.GetApplicationEnvironmentVariablesRequest;
4344
import org.cloudfoundry.client.v3.applications.GetApplicationEnvironmentVariablesResponse;
45+
import org.cloudfoundry.client.v3.applications.GetApplicationFeatureRequest;
46+
import org.cloudfoundry.client.v3.applications.GetApplicationFeatureResponse;
4447
import org.cloudfoundry.client.v3.applications.GetApplicationProcessRequest;
4548
import org.cloudfoundry.client.v3.applications.GetApplicationProcessResponse;
4649
import org.cloudfoundry.client.v3.applications.GetApplicationProcessStatisticsRequest;
@@ -51,6 +54,8 @@
5154
import org.cloudfoundry.client.v3.applications.ListApplicationBuildsResponse;
5255
import org.cloudfoundry.client.v3.applications.ListApplicationDropletsRequest;
5356
import org.cloudfoundry.client.v3.applications.ListApplicationDropletsResponse;
57+
import org.cloudfoundry.client.v3.applications.ListApplicationFeaturesRequest;
58+
import org.cloudfoundry.client.v3.applications.ListApplicationFeaturesResponse;
5459
import org.cloudfoundry.client.v3.applications.ListApplicationPackagesRequest;
5560
import org.cloudfoundry.client.v3.applications.ListApplicationPackagesResponse;
5661
import org.cloudfoundry.client.v3.applications.ListApplicationProcessesRequest;
@@ -72,6 +77,8 @@
7277
import org.cloudfoundry.client.v3.applications.TerminateApplicationInstanceRequest;
7378
import org.cloudfoundry.client.v3.applications.UpdateApplicationEnvironmentVariablesRequest;
7479
import org.cloudfoundry.client.v3.applications.UpdateApplicationEnvironmentVariablesResponse;
80+
import org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureRequest;
81+
import org.cloudfoundry.client.v3.applications.UpdateApplicationFeatureResponse;
7582
import org.cloudfoundry.client.v3.applications.UpdateApplicationRequest;
7683
import org.cloudfoundry.client.v3.applications.UpdateApplicationResponse;
7784
import org.cloudfoundry.client.v3.builds.BuildResource;
@@ -96,7 +103,6 @@
96103
import org.cloudfoundry.client.v3.routes.Application;
97104
import org.cloudfoundry.client.v3.routes.Destination;
98105
import org.cloudfoundry.client.v3.routes.Process;
99-
import org.cloudfoundry.client.v3.routes.Protocol;
100106
import org.cloudfoundry.client.v3.routes.RouteRelationships;
101107
import org.cloudfoundry.client.v3.routes.RouteResource;
102108
import org.cloudfoundry.client.v3.tasks.Result;
@@ -118,7 +124,6 @@
118124
import static io.netty.handler.codec.http.HttpMethod.GET;
119125
import static io.netty.handler.codec.http.HttpMethod.PATCH;
120126
import static io.netty.handler.codec.http.HttpMethod.POST;
121-
import static io.netty.handler.codec.http.HttpMethod.PUT;
122127
import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED;
123128
import static io.netty.handler.codec.http.HttpResponseStatus.CREATED;
124129
import static io.netty.handler.codec.http.HttpResponseStatus.NO_CONTENT;
@@ -499,6 +504,33 @@ public void getEnvironmentVariables() {
499504
.verify(Duration.ofSeconds(5));
500505
}
501506

507+
@Test
508+
public void getFeature() {
509+
mockRequest(InteractionContext.builder()
510+
.request(TestRequest.builder()
511+
.method(GET).path("/apps/test-application-id/features/test-feature-name")
512+
.build())
513+
.response(TestResponse.builder()
514+
.status(OK)
515+
.payload("fixtures/client/v3/apps/GET_{id}_features_{name}_response.json")
516+
.build())
517+
.build());
518+
519+
this.applications
520+
.getFeature(GetApplicationFeatureRequest.builder()
521+
.applicationId("test-application-id")
522+
.featureName("test-feature-name")
523+
.build())
524+
.as(StepVerifier::create)
525+
.expectNext(GetApplicationFeatureResponse.builder()
526+
.description("Enable SSHing into the app.")
527+
.enabled(true)
528+
.name("ssh")
529+
.build())
530+
.expectComplete()
531+
.verify(Duration.ofSeconds(5));
532+
}
533+
502534
@Test
503535
public void getProcess() {
504536
mockRequest(InteractionContext.builder()
@@ -918,6 +950,49 @@ public void listDroplets() {
918950
.verify(Duration.ofSeconds(5));
919951
}
920952

953+
@Test
954+
public void listFeatures() {
955+
mockRequest(InteractionContext.builder()
956+
.request(TestRequest.builder()
957+
.method(GET).path("/apps/test-application-id/features")
958+
.build())
959+
.response(TestResponse.builder()
960+
.status(OK)
961+
.payload("fixtures/client/v3/apps/GET_{id}_features_response.json")
962+
.build())
963+
.build());
964+
965+
this.applications
966+
.listFeatures(ListApplicationFeaturesRequest.builder()
967+
.applicationId("test-application-id")
968+
.build())
969+
.as(StepVerifier::create)
970+
.expectNext(ListApplicationFeaturesResponse.builder()
971+
.pagination(Pagination.builder()
972+
.totalResults(1)
973+
.totalPages(1)
974+
.first(Link.builder()
975+
.href("/v3/apps/05d39de4-2c9e-4c76-8fd6-10417da07e42/features")
976+
.build())
977+
.last(Link.builder()
978+
.href("/v3/apps/05d39de4-2c9e-4c76-8fd6-10417da07e42/features")
979+
.build())
980+
.build())
981+
.resource(ApplicationFeatureResource.builder()
982+
.name("ssh")
983+
.description("Enable SSHing into the app.")
984+
.enabled(true)
985+
.build())
986+
.resource(ApplicationFeatureResource.builder()
987+
.name("revisions")
988+
.description("Enable versioning of an application")
989+
.enabled(false)
990+
.build())
991+
.build())
992+
.expectComplete()
993+
.verify(Duration.ofSeconds(5));
994+
}
995+
921996
@Test
922997
public void listPackages() {
923998
mockRequest(InteractionContext.builder()
@@ -1679,4 +1754,33 @@ public void updateEnvironmentVariables() {
16791754
.verify(Duration.ofSeconds(5));
16801755
}
16811756

1757+
@Test
1758+
public void updateFeature() {
1759+
mockRequest(InteractionContext.builder()
1760+
.request(TestRequest.builder()
1761+
.method(PATCH).path("/apps/test-application-id/features/ssh")
1762+
.payload("fixtures/client/v3/apps/PATCH_{id}_features_{name}_request.json")
1763+
.build())
1764+
.response(TestResponse.builder()
1765+
.status(OK)
1766+
.payload("fixtures/client/v3/apps/PATCH_{id}_features_{name}_response.json")
1767+
.build())
1768+
.build());
1769+
1770+
this.applications
1771+
.updateFeature(UpdateApplicationFeatureRequest.builder()
1772+
.applicationId("test-application-id")
1773+
.enabled(false)
1774+
.featureName("ssh")
1775+
.build())
1776+
.as(StepVerifier::create)
1777+
.expectNext(UpdateApplicationFeatureResponse.builder()
1778+
.description("Enable SSHing into the app.")
1779+
.enabled(true)
1780+
.name("ssh")
1781+
.build())
1782+
.expectComplete()
1783+
.verify(Duration.ofSeconds(5));
1784+
}
1785+
16821786
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"resources": [
3+
{
4+
"name": "ssh",
5+
"description": "Enable SSHing into the app.",
6+
"enabled": true
7+
},
8+
{
9+
"name": "revisions",
10+
"description": "Enable versioning of an application",
11+
"enabled": false
12+
}
13+
],
14+
"pagination": {
15+
"total_results": 1,
16+
"total_pages": 1,
17+
"first": {
18+
"href": "/v3/apps/05d39de4-2c9e-4c76-8fd6-10417da07e42/features"
19+
},
20+
"last": {
21+
"href": "/v3/apps/05d39de4-2c9e-4c76-8fd6-10417da07e42/features"
22+
},
23+
"next": null,
24+
"previous": null
25+
}
26+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "ssh",
3+
"description": "Enable SSHing into the app.",
4+
"enabled": true
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"enabled": false
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "ssh",
3+
"description": "Enable SSHing into the app.",
4+
"enabled": true
5+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2013-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.cloudfoundry.client.v3.applications;
18+
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import org.cloudfoundry.Nullable;
21+
22+
/**
23+
* Base class for responses that are Application Features
24+
*/
25+
public abstract class ApplicationFeature {
26+
27+
/**
28+
* The description of the application feature
29+
*/
30+
@JsonProperty("description")
31+
@Nullable
32+
public abstract String getDescription();
33+
34+
/**
35+
* Denotes whether or not the application feature is enabled
36+
*/
37+
@JsonProperty("enabled")
38+
@Nullable
39+
public abstract Boolean getEnabled();
40+
41+
/**
42+
* The name of the application feature
43+
*/
44+
@JsonProperty("name")
45+
@Nullable
46+
public abstract String getName();
47+
48+
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/ApplicationsV3.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ public interface ApplicationsV3 {
7979
*/
8080
Mono<GetApplicationEnvironmentVariablesResponse> getEnvironmentVariables(GetApplicationEnvironmentVariablesRequest request);
8181

82+
/**
83+
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.88.0/index.html#get-an-app-feature">Get Application Feature</a> request
84+
*
85+
* @param request the Get Application Feature request
86+
* @return the response from the Get Application Feature request
87+
*/
88+
Mono<GetApplicationFeatureResponse> getFeature(GetApplicationFeatureRequest request);
89+
8290
/**
8391
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.27.0/#get-a-process">Get Application Process</a> request
8492
*
@@ -119,6 +127,14 @@ public interface ApplicationsV3 {
119127
*/
120128
Mono<ListApplicationDropletsResponse> listDroplets(ListApplicationDropletsRequest request);
121129

130+
/**
131+
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.88.0/index.html#list-app-features">List Application Features</a> request
132+
*
133+
* @param request the List Application Features request
134+
* @return the response from the List Application Features request
135+
*/
136+
Mono<ListApplicationFeaturesResponse> listFeatures(ListApplicationFeaturesRequest request);
137+
122138
/**
123139
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.27.0/#list-packages-for-an-app">List Application Packages</a> request
124140
*
@@ -207,4 +223,12 @@ public interface ApplicationsV3 {
207223
*/
208224
Mono<UpdateApplicationEnvironmentVariablesResponse> updateEnvironmentVariables(UpdateApplicationEnvironmentVariablesRequest request);
209225

226+
/**
227+
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.88.0/index.html#update-an-app-feature">Update Application Feature</a> request
228+
*
229+
* @param request the Update Application Feature request
230+
* @return the response from the Update Application Feature request
231+
*/
232+
Mono<UpdateApplicationFeatureResponse> updateFeature(UpdateApplicationFeatureRequest request);
233+
210234
}

0 commit comments

Comments
 (0)