Skip to content
Open
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
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 the original author or authors.
* Copyright 2013-2026 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.
Expand Down Expand Up @@ -58,6 +58,7 @@
import org.cloudfoundry.client.v3.deployments.DeploymentsV3;
import org.cloudfoundry.client.v3.domains.DomainsV3;
import org.cloudfoundry.client.v3.droplets.Droplets;
import org.cloudfoundry.client.v3.featureflags.FeatureFlagsV3;
import org.cloudfoundry.client.v3.isolationsegments.IsolationSegments;
import org.cloudfoundry.client.v3.jobs.JobsV3;
import org.cloudfoundry.client.v3.quotas.organizations.OrganizationQuotasV3;
Expand Down Expand Up @@ -120,6 +121,7 @@
import org.cloudfoundry.reactor.client.v3.deployments.ReactorDeploymentsV3;
import org.cloudfoundry.reactor.client.v3.domains.ReactorDomainsV3;
import org.cloudfoundry.reactor.client.v3.droplets.ReactorDroplets;
import org.cloudfoundry.reactor.client.v3.featureflags.ReactorFeatureFlagsV3;
import org.cloudfoundry.reactor.client.v3.isolationsegments.ReactorIsolationSegments;
import org.cloudfoundry.reactor.client.v3.jobs.ReactorJobsV3;
import org.cloudfoundry.reactor.client.v3.quotas.organizations.ReactorOrganizationQuotasV3;
Expand Down Expand Up @@ -256,6 +258,12 @@ public FeatureFlags featureFlags() {
return new ReactorFeatureFlags(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags());
}

@Override
@Value.Derived
public FeatureFlagsV3 featureFlagsV3() {
return new ReactorFeatureFlagsV3(getConnectionContext(), getRootV3(), getTokenProvider(), getRequestTags());
}

@Override
@Value.Derived
public Info info() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright 2026 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.reactor.client.v3.featureflags;

import java.util.Map;
import org.cloudfoundry.client.v3.featureflags.FeatureFlagsV3;
import org.cloudfoundry.client.v3.featureflags.GetFeatureFlagRequest;
import org.cloudfoundry.client.v3.featureflags.GetFeatureFlagResponse;
import org.cloudfoundry.client.v3.featureflags.ListFeatureFlagsRequest;
import org.cloudfoundry.client.v3.featureflags.ListFeatureFlagsResponse;
import org.cloudfoundry.client.v3.featureflags.UpdateFeatureFlagRequest;
import org.cloudfoundry.client.v3.featureflags.UpdateFeatureFlagResponse;
import org.cloudfoundry.reactor.ConnectionContext;
import org.cloudfoundry.reactor.TokenProvider;
import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations;
import reactor.core.publisher.Mono;

/**
* The Reactor-based implementation of {@link FeatureFlagsV3}
*/
public final class ReactorFeatureFlagsV3 extends AbstractClientV3Operations
implements FeatureFlagsV3 {

/**
* Creates an instance
*
* @param connectionContext the {@link ConnectionContext} to use when communicating with the server
* @param root the root URI of the server. Typically something like {@code https://api.run.pivotal.io}.
* @param tokenProvider the {@link TokenProvider} to use when communicating with the server
* @param requestTags map with custom http headers which will be added to web request
*/
public ReactorFeatureFlagsV3(
ConnectionContext connectionContext,
Mono<String> root,
TokenProvider tokenProvider,
Map<String, String> requestTags) {
super(connectionContext, root, tokenProvider, requestTags);
}

@Override
public Mono<GetFeatureFlagResponse> get(GetFeatureFlagRequest request) {
return get(
request,
GetFeatureFlagResponse.class,
builder -> builder.pathSegment("feature_flags", request.getName()))
.checkpoint();
}

@Override
public Mono<ListFeatureFlagsResponse> list(ListFeatureFlagsRequest request) {
return get(
request,
ListFeatureFlagsResponse.class,
builder -> builder.pathSegment("feature_flags"))
.checkpoint();
}

@Override
public Mono<UpdateFeatureFlagResponse> update(UpdateFeatureFlagRequest request) {
return patch(
request,
UpdateFeatureFlagResponse.class,
builder -> builder.pathSegment("feature_flags", request.getName()))
.checkpoint();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Mono<ListPackageDropletsResponse> listDroplets(ListPackageDropletsRequest
public Mono<UploadPackageResponse> upload(UploadPackageRequest request) {
Path bits = request.getBits();

if (bits.toFile().isDirectory()) {
if (bits != null && bits.toFile().isDirectory()) {
return FileUtils.compress(bits)
.map(
temporaryFile ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
* Copyright 2026 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.reactor.client.v3.featureflags;

import static io.netty.handler.codec.http.HttpMethod.GET;
import static io.netty.handler.codec.http.HttpMethod.PATCH;
import static io.netty.handler.codec.http.HttpResponseStatus.OK;

import java.time.Duration;
import java.util.Collections;
import org.cloudfoundry.client.v3.Link;
import org.cloudfoundry.client.v3.Pagination;
import org.cloudfoundry.client.v3.featureflags.GetFeatureFlagRequest;
import org.cloudfoundry.client.v3.featureflags.GetFeatureFlagResponse;
import org.cloudfoundry.client.v3.featureflags.ListFeatureFlagsRequest;
import org.cloudfoundry.client.v3.featureflags.ListFeatureFlagsResponse;
import org.cloudfoundry.client.v3.featureflags.UpdateFeatureFlagRequest;
import org.cloudfoundry.client.v3.featureflags.UpdateFeatureFlagResponse;
import org.cloudfoundry.reactor.InteractionContext;
import org.cloudfoundry.reactor.TestRequest;
import org.cloudfoundry.reactor.TestResponse;
import org.cloudfoundry.reactor.client.AbstractClientApiTest;
import org.junit.jupiter.api.Test;
import reactor.test.StepVerifier;

final class ReactorFeatureFlagsV3Test extends AbstractClientApiTest {

private static final String BASE_URL = "https://api.example.org/v3/feature_flags/";
private static final String UPDATED_AT = "2020-03-10T15:49:32Z";

private final ReactorFeatureFlagsV3 featureFlags =
new ReactorFeatureFlagsV3(
CONNECTION_CONTEXT, this.root, TOKEN_PROVIDER, Collections.emptyMap());

@Test
void get() {
mockRequest(
InteractionContext.builder()
.request(
TestRequest.builder()
.method(GET)
.path("/feature_flags/app_scaling")
.build())
.response(
TestResponse.builder()
.status(OK)
.payload(
"fixtures/client/v3/featureflags/GET_{feature_flag_name}_response.json")
.build())
.build());

this.featureFlags
.get(GetFeatureFlagRequest.builder().name("app_scaling").build())
.as(StepVerifier::create)
.expectNext(
GetFeatureFlagResponse.builder()
.name("app_scaling")
.enabled(true)
.updatedAt(UPDATED_AT)
.link("self", selfLink("app_scaling"))
.build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}

@Test
void list() {
mockRequest(
InteractionContext.builder()
.request(TestRequest.builder().method(GET).path("/feature_flags").build())
.response(
TestResponse.builder()
.status(OK)
.payload(
"fixtures/client/v3/featureflags/GET_response.json")
.build())
.build());

this.featureFlags
.list(ListFeatureFlagsRequest.builder().build())
.as(StepVerifier::create)
.expectNext(
ListFeatureFlagsResponse.builder()
.pagination(
Pagination.builder()
.totalResults(2)
.first(
Link.builder()
.href(
"https://api.example.org/v3/feature_flags?page=1&per_page=50")
.build())
.last(
Link.builder()
.href(
"https://api.example.org/v3/feature_flags?page=1&per_page=50")
.build())
.build())
.resource(
GetFeatureFlagResponse.builder()
.name("app_scaling")
.enabled(true)
.updatedAt(UPDATED_AT)
.link("self", selfLink("app_scaling"))
.build())
.resource(
GetFeatureFlagResponse.builder()
.name("user_org_creation")
.enabled(false)
.customErrorMessage("This feature is disabled")
.updatedAt(UPDATED_AT)
.link("self", selfLink("user_org_creation"))
.build())
.build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}

@Test
void update() {
mockRequest(
InteractionContext.builder()
.request(
TestRequest.builder()
.method(PATCH)
.path("/feature_flags/app_scaling")
.payload(
"fixtures/client/v3/featureflags/PATCH_{feature_flag_name}_request.json")
.build())
.response(
TestResponse.builder()
.status(OK)
.payload(
"fixtures/client/v3/featureflags/PATCH_{feature_flag_name}_response.json")
.build())
.build());

this.featureFlags
.update(
UpdateFeatureFlagRequest.builder()
.name("app_scaling")
.enabled(false)
.customErrorMessage("This feature is disabled")
.build())
.as(StepVerifier::create)
.expectNext(
UpdateFeatureFlagResponse.builder()
.name("app_scaling")
.enabled(false)
.customErrorMessage("This feature is disabled")
.updatedAt(UPDATED_AT)
.link("self", selfLink("app_scaling"))
.build())
.expectComplete()
.verify(Duration.ofSeconds(5));
}

private static Link selfLink(String flagName) {
return Link.builder().href(BASE_URL + flagName).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"pagination": {
"total_results": 2,
"first": {
"href": "https://api.example.org/v3/feature_flags?page=1&per_page=50"
},
"last": {
"href": "https://api.example.org/v3/feature_flags?page=1&per_page=50"
},
"next": null,
"previous": null
},
"resources": [
{
"name": "app_scaling",
"enabled": true,
"custom_error_message": null,
"updated_at": "2020-03-10T15:49:32Z",
"links": {
"self": {
"href": "https://api.example.org/v3/feature_flags/app_scaling"
}
}
},
{
"name": "user_org_creation",
"enabled": false,
"custom_error_message": "This feature is disabled",
"updated_at": "2020-03-10T15:49:32Z",
"links": {
"self": {
"href": "https://api.example.org/v3/feature_flags/user_org_creation"
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "app_scaling",
"enabled": true,
"custom_error_message": null,
"updated_at": "2020-03-10T15:49:32Z",
"links": {
"self": {
"href": "https://api.example.org/v3/feature_flags/app_scaling"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"enabled": false,
"custom_error_message": "This feature is disabled"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "app_scaling",
"enabled": false,
"custom_error_message": "This feature is disabled",
"updated_at": "2020-03-10T15:49:32Z",
"links": {
"self": {
"href": "https://api.example.org/v3/feature_flags/app_scaling"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 the original author or authors.
* Copyright 2013-2026 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.
Expand Down Expand Up @@ -55,6 +55,7 @@
import org.cloudfoundry.client.v3.deployments.DeploymentsV3;
import org.cloudfoundry.client.v3.domains.DomainsV3;
import org.cloudfoundry.client.v3.droplets.Droplets;
import org.cloudfoundry.client.v3.featureflags.FeatureFlagsV3;
import org.cloudfoundry.client.v3.isolationsegments.IsolationSegments;
import org.cloudfoundry.client.v3.jobs.JobsV3;
import org.cloudfoundry.client.v3.organizations.OrganizationsV3;
Expand Down Expand Up @@ -169,6 +170,11 @@ public interface CloudFoundryClient {
*/
FeatureFlags featureFlags();

/**
* Main entry point to the Cloud Foundry Feature Flags V3 Client API
*/
FeatureFlagsV3 featureFlagsV3();

/**
* Main entry point to the Cloud Foundry Info Client API
*/
Expand Down
Loading
Loading