From f5d685f7aa0eaf1c87e55c9bdab67695e823ef97 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 22 Aug 2025 10:39:41 -0700 Subject: [PATCH 01/19] issue-1168 adding interface and model for CreateOrganizationQuotaDefinition --- .../client/CloudFoundryClient.java | 6 ++ .../OrganizationQuotaDefinition.java | 68 ++++++++++++++++++ .../OrganizationQuotaDefinitionsV3.java | 35 +++++++++ .../organizationquotadefinitions/_Apps.java | 66 +++++++++++++++++ ...ateOrganizationQuotaDefinitionRequest.java | 72 +++++++++++++++++++ ...teOrganizationQuotaDefinitionResponse.java | 29 ++++++++ .../_Domains.java | 39 ++++++++++ ...anizationQuotaDefinitionRelationships.java | 40 +++++++++++ .../organizationquotadefinitions/_Routes.java | 49 +++++++++++++ .../_Services.java | 53 ++++++++++++++ ...rganizationQuotaDefinitionRequestTest.java | 36 ++++++++++ 11 files changed, 493 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinition.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Apps.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Domains.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionRelationships.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Routes.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Services.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java index d3c0ec8164..c229b37230 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java @@ -57,6 +57,7 @@ import org.cloudfoundry.client.v3.droplets.Droplets; import org.cloudfoundry.client.v3.isolationsegments.IsolationSegments; import org.cloudfoundry.client.v3.jobs.JobsV3; +import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionsV3; import org.cloudfoundry.client.v3.organizations.OrganizationsV3; import org.cloudfoundry.client.v3.packages.Packages; import org.cloudfoundry.client.v3.processes.Processes; @@ -188,6 +189,11 @@ public interface CloudFoundryClient { */ OrganizationQuotaDefinitions organizationQuotaDefinitions(); + /** + * Main entry point to the Cloud Foundry Quota Definitions V3 Client API + */ + OrganizationQuotaDefinitionsV3 organizationQuotaDefinitionsV3(); + /** * Main entry point to the Cloud Foundry Organizations V2 Client API */ diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinition.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinition.java new file mode 100644 index 0000000000..ca295d7e9f --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinition.java @@ -0,0 +1,68 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Resource; + +/** + * Base class for responses that are organization quota definitions + */ +public abstract class OrganizationQuotaDefinition extends Resource { + + /** + * Name of the quota + */ + @JsonProperty("name") + abstract String getName(); + + /** + * Quotas that affect applications and application sub-resources + */ + @JsonProperty("apps") + @Nullable + abstract Apps getApps(); + + /** + * Quotas that affect services + */ + @JsonProperty("services") + @Nullable + abstract Services getServices(); + + /** + * Quotas that affect routes + */ + @JsonProperty("routes") + @Nullable + abstract Routes getRoutes(); + + /** + * Quotas that affect domains + */ + @JsonProperty("domains") + @Nullable + abstract Domains getDomains(); + + /** + * A relationship to the organizations where the quota is applied + */ + @JsonProperty("relationships") + @Nullable + abstract OrganizationQuotaDefinitionRelationships getRelationships(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java new file mode 100644 index 0000000000..527f242f8c --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import reactor.core.publisher.Mono; + +/** + * Main entry point to the Cloud Foundry Organization Quota Definitions Client API + */ +public interface OrganizationQuotaDefinitionsV3 { + + /** + * Makes the Create Organization Quota Definition + * request + * + * @param request the Create Organization Quota Definition request + * @return the response from the Create Organization Quota Definition request + */ + Mono create( + CreateOrganizationQuotaDefinitionRequest request); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Apps.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Apps.java new file mode 100644 index 0000000000..e9ca31725e --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Apps.java @@ -0,0 +1,66 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * Quotas that affect applications and application sub-resources + */ +@JsonDeserialize +@Value.Immutable +abstract class _Apps { + + /** + * Maximum memory for a single process or task + */ + @JsonProperty("per_process_memory_in_mb") + @Nullable + abstract Integer getPerProcessMemoryInMb(); + + /** + * Total memory allowed for all the started processes and running tasks in an organization + */ + @JsonProperty("total_memory_in_mb") + @Nullable + abstract Integer getTotalMemoryInMb(); + + /** + * Total instances of all the started processes allowed in an organization + */ + @JsonProperty("total_instances") + @Nullable + abstract Integer getTotalInstances(); + + /** + * Total log rate limit allowed for all the started processes and running tasks in an organization + */ + @JsonProperty("log_rate_limit_in_bytes_per_second") + @Nullable + abstract Integer getLogRateLimitInBytesPerSecond(); + + /** + * Maximum number of running tasks in an organization + */ + @JsonProperty("per_app_tasks") + @Nullable + abstract Integer getPerAppTasks(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionRequest.java new file mode 100644 index 0000000000..401a3e3cb2 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * The request payload to creates a new organization quota + */ +@JsonSerialize +@Value.Immutable +abstract class _CreateOrganizationQuotaDefinitionRequest { + + /** + * Name of the quota + */ + @JsonProperty("name") + abstract String getName(); + + /** + * Quotas that affect applications and application sub-resources + */ + @JsonProperty("apps") + @Nullable + abstract Apps getApps(); + + /** + * Quotas that affect services + */ + @JsonProperty("services") + @Nullable + abstract Services getServices(); + + /** + * Quotas that affect routes + */ + @JsonProperty("routes") + @Nullable + abstract Routes getRoutes(); + + /** + * Quotas that affect domains + */ + @JsonProperty("domains") + @Nullable + abstract Domains getDomains(); + + /** + * A relationship to the organizations where the quota is applied + */ + @JsonProperty("relationships") + @Nullable + abstract OrganizationQuotaDefinitionRelationships getRelationships(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionResponse.java new file mode 100644 index 0000000000..65eb015f87 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_CreateOrganizationQuotaDefinitionResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Create an Organization Quota Definition operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _CreateOrganizationQuotaDefinitionResponse extends OrganizationQuotaDefinition { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Domains.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Domains.java new file mode 100644 index 0000000000..10e2f217bc --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Domains.java @@ -0,0 +1,39 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * Quotas that affect domains + */ +@JsonDeserialize +@Value.Immutable +abstract class _Domains { + + /** + * Total number of domains that can be scoped to an organization + * + * @return the total number of domains that can be scoped to an organization + */ + @JsonProperty("total_domains") + @Nullable + abstract Integer getTotalDomains(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionRelationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionRelationships.java new file mode 100644 index 0000000000..4e677758c1 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionRelationships.java @@ -0,0 +1,40 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.immutables.value.Value; + +/** + * The relationships for the OrganizationQuotaDefinition entity + */ + +@Value.Immutable +@JsonDeserialize +abstract class _OrganizationQuotaDefinitionRelationships { + + /** + * The quota relationship + */ + @JsonProperty("organizations") + @Nullable + abstract ToManyRelationship getOrganizations(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Routes.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Routes.java new file mode 100644 index 0000000000..9ca4398379 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Routes.java @@ -0,0 +1,49 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * Quotas that affect routes + */ +@JsonDeserialize +@Value.Immutable +abstract class _Routes { + + /** + * Total number of routes allowed in an organization + * + * @return the total number of routes allowed in an organization + */ + @JsonProperty("total_routes") + @Nullable + abstract Integer getTotalRoutes(); + + /** + * Total number of ports that are reservable by routes in an organization + * + * @return the total number of reserved ports allowed in an organization + */ + @JsonProperty("total_reserved_ports") + @Nullable + abstract Integer getTotalReservedPorts(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Services.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Services.java new file mode 100644 index 0000000000..2e7e96cb13 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_Services.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * Quotas that affect services + */ +@JsonDeserialize +@Value.Immutable +abstract class _Services { + + /** + * Specifies whether instances of paid service plans can be created + * @return true if instances of paid service plans can be created, false otherwise + */ + @JsonProperty("paid_services_allowed") + abstract boolean isPaidServicesAllowed(); + + /** + * Total number of service instances allowed in an organization + * @return the total number of service instances allowed in an organization + */ + @JsonProperty("total_service_instances") + @Nullable + abstract Integer getTotalServiceInstances(); + + /** + * Total number of service keys allowed in an organization + * @return the total number of service keys allowed in an organization + */ + @JsonProperty("total_service_keys") + @Nullable + abstract Integer getTotalServiceKeys(); +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..0c0f8ca4b7 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class CreateOrganizationQuotaDefinitionRequestTest { + + @Test + void noName() { + assertThrows( + IllegalStateException.class, + () -> CreateOrganizationQuotaDefinitionRequest.builder().build()); + } + + @Test + void valid() { + CreateOrganizationQuotaDefinitionRequest.builder().name("test-quota").build(); + } +} From ec7e9b191601c37131e720807c35962226cfedc9 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 22 Aug 2025 10:41:47 -0700 Subject: [PATCH 02/19] issue-1168 adding interface and model for GetOrganizationQuotaDefinition --- .../OrganizationQuotaDefinitionsV3.java | 11 ++++++ ...GetOrganizationQuotaDefinitionRequest.java | 34 ++++++++++++++++++ ...etOrganizationQuotaDefinitionResponse.java | 29 +++++++++++++++ ...rganizationQuotaDefinitionRequestTest.java | 36 +++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionResponse.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java index 527f242f8c..224297fd27 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java @@ -32,4 +32,15 @@ public interface OrganizationQuotaDefinitionsV3 { */ Mono create( CreateOrganizationQuotaDefinitionRequest request); + + /** + * Makes the Get Organization Quota Definition + * request + * + * @param request the Get Organization Quota Definition request + * @return the response from the Get Organization Quota Definition request + */ + Mono get( + GetOrganizationQuotaDefinitionRequest request); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionRequest.java new file mode 100644 index 0000000000..92bd4dee5b --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.immutables.value.Value; + +/** + * The request payload for the Retrieve a Particular Organization Quota Definition operation + */ +@Value.Immutable +abstract class _GetOrganizationQuotaDefinitionRequest { + + /** + * The quota definition id + */ + @JsonIgnore + abstract String getOrganizationQuotaDefinitionId(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionResponse.java new file mode 100644 index 0000000000..c98b39ecb2 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_GetOrganizationQuotaDefinitionResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Retrieve a Particular Organization Quota Definition operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _GetOrganizationQuotaDefinitionResponse extends OrganizationQuotaDefinition { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..0cfae1e7fb --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class GetOrganizationQuotaDefinitionRequestTest { + + @Test + void noOrganizationQuotaDefinitionId() { + assertThrows( + IllegalStateException.class, + () -> GetOrganizationQuotaDefinitionRequest.builder().build()); + } + + @Test + void valid() { + GetOrganizationQuotaDefinitionRequest.builder().organizationQuotaDefinitionId("test-id").build(); + } +} From ab8bf51493b0f42533b5917c7345b2c47ec66716 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 22 Aug 2025 10:43:46 -0700 Subject: [PATCH 03/19] issue-1168 adding interface and model for ListOrganizationQuotaDefinition --- .../OrganizationQuotaDefinitionsV3.java | 9 ++++ ...stOrganizationQuotaDefinitionsRequest.java | 53 +++++++++++++++++++ ...tOrganizationQuotaDefinitionsResponse.java | 30 +++++++++++ .../_OrganizationQuotaDefinitionResource.java | 30 +++++++++++ ...ganizationQuotaDefinitionsRequestTest.java | 27 ++++++++++ 5 files changed, 149 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionResource.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/ListOrganizationQuotaDefinitionsRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java index 224297fd27..0080088017 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java @@ -43,4 +43,13 @@ Mono create( Mono get( GetOrganizationQuotaDefinitionRequest request); + /** + * Makes the List all Organization Quota Definitions + * request + * + * @param request the List all Organization Quota Definitions request + * @return the response from the List all Organization Quota Definitions request + */ + Mono list( + ListOrganizationQuotaDefinitionsRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsRequest.java new file mode 100644 index 0000000000..d5102ed43a --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.FilterParameter; +import org.cloudfoundry.client.v3.PaginatedRequest; +import org.immutables.value.Value; + +import java.util.List; + +/** + * The request payload for the List all Organization Quota Definitions operation + */ +@Value.Immutable +abstract class _ListOrganizationQuotaDefinitionsRequest extends PaginatedRequest { + + /** + * list of organization quota guids to filter by + */ + @FilterParameter("guids") + @Nullable + abstract List getGuids(); + + /** + * list of organization quota names to filter by + */ + @FilterParameter("names") + @Nullable + abstract List getNames(); + + /** + * list of organization guids to filter by + */ + @FilterParameter("organization_guids") + @Nullable + abstract List getOrganizationGuids(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsResponse.java new file mode 100644 index 0000000000..504b93fff8 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_ListOrganizationQuotaDefinitionsResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.client.v3.PaginatedResponse; +import org.immutables.value.Value; + +/** + * The response payload for the List all Organization Quota Definitions operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _ListOrganizationQuotaDefinitionsResponse extends PaginatedResponse { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionResource.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionResource.java new file mode 100644 index 0000000000..edebd290e8 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_OrganizationQuotaDefinitionResource.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * Base class for resources that contain Organization Quota Definitions + */ +@JsonDeserialize +@Value.Immutable +abstract class _OrganizationQuotaDefinitionResource extends OrganizationQuotaDefinition { + +} + diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/ListOrganizationQuotaDefinitionsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/ListOrganizationQuotaDefinitionsRequestTest.java new file mode 100644 index 0000000000..03054a4060 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/ListOrganizationQuotaDefinitionsRequestTest.java @@ -0,0 +1,27 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.junit.jupiter.api.Test; + +public class ListOrganizationQuotaDefinitionsRequestTest { + + @Test + void valid() { + ListOrganizationQuotaDefinitionsRequest.builder().build(); + } +} From 6a5e6756a18a94c0866098ba2be25c11d4c19c71 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 22 Aug 2025 10:45:01 -0700 Subject: [PATCH 04/19] issue-1168 adding interface and model for UpdateOrganizationQuotaDefinition --- .../OrganizationQuotaDefinitionsV3.java | 9 +++ ...ateOrganizationQuotaDefinitionRequest.java | 65 +++++++++++++++++++ ...teOrganizationQuotaDefinitionResponse.java | 29 +++++++++ ...rganizationQuotaDefinitionRequestTest.java | 36 ++++++++++ 4 files changed, 139 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionResponse.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java index 0080088017..8b3d52295b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java @@ -52,4 +52,13 @@ Mono get( */ Mono list( ListOrganizationQuotaDefinitionsRequest request); + + /** Makes the Update Organization Quota Definition + * request + * + * @param request the Update Organization Quota Definition request + * @return the response from the Update Organization Quota Definition request + */ + Mono update( + UpdateOrganizationQuotaDefinitionRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionRequest.java new file mode 100644 index 0000000000..5215d79ac3 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionRequest.java @@ -0,0 +1,65 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +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.immutables.value.Value; + +/** + * The request payload to update an organization quota + */ +@JsonSerialize +@Value.Immutable +abstract class _UpdateOrganizationQuotaDefinitionRequest { + + /** + * The quota definition id + */ + @JsonIgnore + abstract String getOrganizationQuotaDefinitionId(); + + /** + * Name of the quota + */ + @JsonProperty("name") + @Nullable + abstract String getName(); + + /** + * Quotas that affect applications and application sub-resources + */ + @JsonProperty("apps") + @Nullable + abstract Apps getApps(); + + /** + * Quotas that affect services + */ + @JsonProperty("services") + @Nullable + abstract Services getServices(); + + /** + * Quotas that affect routes + */ + @JsonProperty("routes") + @Nullable + abstract Routes getRoutes(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionResponse.java new file mode 100644 index 0000000000..0bb4f02ed7 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_UpdateOrganizationQuotaDefinitionResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Update an Organization Quota Definition operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _UpdateOrganizationQuotaDefinitionResponse extends OrganizationQuotaDefinition { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..7f35339c4f --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class UpdateOrganizationQuotaDefinitionRequestTest { + + @Test + void noOrganizationId() { + assertThrows( + IllegalStateException.class, + () -> UpdateOrganizationQuotaDefinitionRequest.builder().build()); + } + + @Test + void valid() { + UpdateOrganizationQuotaDefinitionRequest.builder().organizationQuotaDefinitionId("test-id").build(); + } +} From 8249d70dac9799f6a663f234ba6febe07e1e860a Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 22 Aug 2025 10:47:29 -0700 Subject: [PATCH 05/19] issue-1168 adding interface and model for DeleteOrganizationQuotaDefinition --- .../OrganizationQuotaDefinitionsV3.java | 10 ++++++ ...eteOrganizationQuotaDefinitionRequest.java | 34 ++++++++++++++++++ ...rganizationQuotaDefinitionRequestTest.java | 36 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_DeleteOrganizationQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java index 8b3d52295b..4217d8e2e4 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java @@ -61,4 +61,14 @@ Mono list( */ Mono update( UpdateOrganizationQuotaDefinitionRequest request); + + /** + * Makes the Delete Organization Quota Definition + * request + * + * @param request the Delete Organization Quota Definition request + * @return the response from the Delete Organization Quota Definition request + */ + Mono delete( + DeleteOrganizationQuotaDefinitionRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_DeleteOrganizationQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_DeleteOrganizationQuotaDefinitionRequest.java new file mode 100644 index 0000000000..d1ce45f83e --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/_DeleteOrganizationQuotaDefinitionRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.immutables.value.Value; + +/** + * The request payload for the Delete an Organization Quota Definition operation + */ +@Value.Immutable +abstract class _DeleteOrganizationQuotaDefinitionRequest { + + /** + * The quota definition id + */ + @JsonIgnore + abstract String getOrganizationQuotaDefinitionId(); + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..083f7639f9 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class DeleteOrganizationQuotaDefinitionRequestTest { + + @Test + void noOrganizationId() { + assertThrows( + IllegalStateException.class, + () -> DeleteOrganizationQuotaDefinitionRequest.builder().build()); + } + + @Test + void valid() { + DeleteOrganizationQuotaDefinitionRequest.builder().organizationQuotaDefinitionId("test-id").build(); + } +} From e6570c2b6a8dd163ee18e1f66776f5e5a1cea4f5 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 22 Aug 2025 11:03:58 -0700 Subject: [PATCH 06/19] issue-1168 adding reactor implementation for Create, Get, List, Update and Delete OrganizationQuotaDefinition --- .../client/_ReactorCloudFoundryClient.java | 9 + ...ReactorOrganizationQuotaDefinitionsV3.java | 105 +++++++ ...torOrganizationQuotaDefinitionsV3Test.java | 297 ++++++++++++++++++ .../v3/organization_quotas/GET_response.json | 86 +++++ .../GET_{id}_response.json | 35 +++ .../PATCH_{id}_request.json | 2 + .../PATCH_{id}_response.json | 35 +++ .../v3/organization_quotas/POST_request.json | 3 + .../v3/organization_quotas/POST_response.json | 35 +++ 9 files changed, 607 insertions(+) create mode 100644 cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java create mode 100644 cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_response.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_{id}_response.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_response.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_response.json diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java index 319a1bcfd6..7e43bd5820 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java @@ -34,6 +34,7 @@ import org.cloudfoundry.client.v2.routemappings.RouteMappings; import org.cloudfoundry.client.v2.routes.Routes; import org.cloudfoundry.client.v2.securitygroups.SecurityGroups; +import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionsV3; import org.cloudfoundry.client.v3.securitygroups.SecurityGroupsV3; import org.cloudfoundry.client.v2.servicebindings.ServiceBindingsV2; import org.cloudfoundry.client.v2.servicebrokers.ServiceBrokers; @@ -92,6 +93,7 @@ import org.cloudfoundry.reactor.client.v2.routemappings.ReactorRouteMappings; import org.cloudfoundry.reactor.client.v2.routes.ReactorRoutes; import org.cloudfoundry.reactor.client.v2.securitygroups.ReactorSecurityGroups; +import org.cloudfoundry.reactor.client.v3.organizationquotadefinitions.ReactorOrganizationQuotaDefinitionsV3; import org.cloudfoundry.reactor.client.v3.securitygroups.ReactorSecurityGroupsV3; import org.cloudfoundry.reactor.client.v2.servicebindings.ReactorServiceBindingsV2; import org.cloudfoundry.reactor.client.v2.servicebrokers.ReactorServiceBrokers; @@ -278,6 +280,13 @@ public OrganizationQuotaDefinitions organizationQuotaDefinitions() { getRequestTags()); } + @Override + @Value.Derived + public OrganizationQuotaDefinitionsV3 organizationQuotaDefinitionsV3() { + return new ReactorOrganizationQuotaDefinitionsV3(getConnectionContext(), getRootV3(), getTokenProvider(), + getRequestTags()); + } + @Override @Value.Derived public Organizations organizations() { diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java new file mode 100644 index 0000000000..f07d12cd4c --- /dev/null +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java @@ -0,0 +1,105 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.DeleteOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.GetOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.GetOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.ListOrganizationQuotaDefinitionsRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.ListOrganizationQuotaDefinitionsResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionsV3; +import org.cloudfoundry.client.v3.organizationquotadefinitions.UpdateOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.UpdateOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.reactor.ConnectionContext; +import org.cloudfoundry.reactor.TokenProvider; +import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; +import reactor.core.publisher.Mono; + +import java.util.Map; + +/** + * The Reactor-based implementation of {@link ReactorOrganizationQuotaDefinitionsV3} + */ +public class ReactorOrganizationQuotaDefinitionsV3 extends AbstractClientV3Operations + implements OrganizationQuotaDefinitionsV3 { + + /** + * 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 ReactorOrganizationQuotaDefinitionsV3( + ConnectionContext connectionContext, + Mono root, + TokenProvider tokenProvider, + Map requestTags) { + super(connectionContext, root, tokenProvider, requestTags); + } + + @Override + public Mono create(CreateOrganizationQuotaDefinitionRequest request) { + return post( + request, + CreateOrganizationQuotaDefinitionResponse.class, + builder -> builder.pathSegment("organization_quotas")) + .checkpoint(); + } + + @Override + public Mono get(GetOrganizationQuotaDefinitionRequest request) { + return get( + request, + GetOrganizationQuotaDefinitionResponse.class, + builder -> + builder.pathSegment("organization_quotas", request.getOrganizationQuotaDefinitionId())) + .checkpoint(); + } + + + @Override + public Mono list(ListOrganizationQuotaDefinitionsRequest request) { + return get( + request, + ListOrganizationQuotaDefinitionsResponse.class, + builder -> builder.pathSegment("organization_quotas")) + .checkpoint(); + } + + @Override + public Mono update(UpdateOrganizationQuotaDefinitionRequest request) { + return patch( + request, + UpdateOrganizationQuotaDefinitionResponse.class, + builder -> + builder.pathSegment("organization_quotas", request.getOrganizationQuotaDefinitionId())) + .checkpoint(); + } + + @Override + public Mono delete(DeleteOrganizationQuotaDefinitionRequest request) { + return delete( + request, + builder -> + builder.pathSegment("organization_quotas", request.getOrganizationQuotaDefinitionId())) + .checkpoint(); + } +} diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java new file mode 100644 index 0000000000..ff45ee68e1 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java @@ -0,0 +1,297 @@ +/* + * Copyright 2013-2025 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.organizationquotadefinitions; + +import org.cloudfoundry.client.v3.Link; +import org.cloudfoundry.client.v3.Pagination; +import org.cloudfoundry.client.v3.Relationship; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Apps; +import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.DeleteOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Domains; +import org.cloudfoundry.client.v3.organizationquotadefinitions.GetOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.GetOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.ListOrganizationQuotaDefinitionsRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.ListOrganizationQuotaDefinitionsResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionRelationships; +import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionResource; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Routes; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Services; +import org.cloudfoundry.client.v3.organizationquotadefinitions.UpdateOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.UpdateOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.reactor.InteractionContext; +import org.cloudfoundry.reactor.TestRequest; +import org.cloudfoundry.reactor.TestResponse; +import org.cloudfoundry.reactor.client.AbstractClientApiTest; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.Test; +import reactor.test.StepVerifier; + +import java.time.Duration; +import java.util.Collections; + +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.PATCH; +import static io.netty.handler.codec.http.HttpMethod.POST; +import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; + +class ReactorOrganizationQuotaDefinitionsV3Test extends AbstractClientApiTest { + + private final ReactorOrganizationQuotaDefinitionsV3 organizationQuotaDefinitionsV3 = + new ReactorOrganizationQuotaDefinitionsV3( + CONNECTION_CONTEXT, this.root, TOKEN_PROVIDER, Collections.emptyMap()); + + @Test + void create() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(POST) + .path("/organization_quotas") + .payload( + "fixtures/client/v3/organization_quotas/POST_request.json") + .build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/organization_quotas/POST_response.json") + .build()) + .build()); + + this.organizationQuotaDefinitionsV3 + .create(CreateOrganizationQuotaDefinitionRequest.builder().name("my-quota").build()) + .as(StepVerifier::create) + .expectNext( + CreateOrganizationQuotaDefinitionResponse + .builder() + .from(expectedOrganizationQuotaDefinitionResource1()) + .build() + ) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void delete() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(DELETE) + .path("/organization_quotas/test-organization-quota-id") + .build()) + .response( + TestResponse.builder() + .status(ACCEPTED) + .header( + "Location", + "https://api.example.org/v3/jobs/test-job-id") + .build()) + .build()); + + this.organizationQuotaDefinitionsV3 + .delete( + DeleteOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId("test-organization-quota-id") + .build()) + .as(StepVerifier::create) + .expectNext("test-job-id") + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void get() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(GET) + .path("/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52") + .build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/organization_quotas/GET_{id}_response.json") + .build()) + .build()); + + this.organizationQuotaDefinitionsV3 + .get( + GetOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId("24637893-3b77-489d-bb79-8466f0d88b52") + .build()) + .as(StepVerifier::create) + .expectNext( + GetOrganizationQuotaDefinitionResponse.builder() + .from(expectedOrganizationQuotaDefinitionResource1()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void list() { + mockRequest( + InteractionContext.builder() + .request(TestRequest.builder().method(GET).path("/organization_quotas").build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/organization_quotas/GET_response.json") + .build()) + .build()); + + this.organizationQuotaDefinitionsV3 + .list(ListOrganizationQuotaDefinitionsRequest.builder().build()) + .as(StepVerifier::create) + .expectNext( + ListOrganizationQuotaDefinitionsResponse.builder() + .pagination( + Pagination.builder() + .totalResults(2) + .totalPages(1) + .first( + Link.builder() + .href( + "https://api.example.org/v3/organization_quotas?page=1&per_page=50") + .build()) + .last( + Link.builder() + .href( + "https://api.example.org/v3/organization_quotas?page=1&per_page=50") + .build()) + .build()) + .resource( + OrganizationQuotaDefinitionResource + .builder() + .from(expectedOrganizationQuotaDefinitionResource1()).build() + ) + .resource( + OrganizationQuotaDefinitionResource + .builder() + .from(expectedOrganizationQuotaDefinitionResource2()).build() + ) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void update() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(PATCH) + .path("/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52") + .payload( + "fixtures/client/v3/organization_quotas/PATCH_{id}_request.json") + .build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/organization_quotas/PATCH_{id}_response.json") + .build()) + .build()); + + this.organizationQuotaDefinitionsV3 + .update( + UpdateOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId("24637893-3b77-489d-bb79-8466f0d88b52") + .build()) + .as(StepVerifier::create) + .expectNext( + UpdateOrganizationQuotaDefinitionResponse.builder() + .from(expectedOrganizationQuotaDefinitionResource1()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @NotNull + private static OrganizationQuotaDefinitionResource expectedOrganizationQuotaDefinitionResource1() { + return buildOrganizationQuotaDefinitionResource("24637893-3b77-489d-bb79-8466f0d88b52", "my-quota", "9b370018-c38e-44c9-86d6-155c76801104"); + } + + private static OrganizationQuotaDefinitionResource expectedOrganizationQuotaDefinitionResource2() { + return buildOrganizationQuotaDefinitionResource("bb49bf20-ad98-4729-93ae-38fbc564b630", "my-quota-2", "144251f2-a202-4ffe-ab47-9046c4077e99"); + } + + @NotNull + private static OrganizationQuotaDefinitionResource buildOrganizationQuotaDefinitionResource(String id, String name, String relatedOrganizationId) { + + Apps apps = Apps.builder() + .totalMemoryInMb(5120) + .perProcessMemoryInMb(1024) + .logRateLimitInBytesPerSecond(1024) + .totalInstances(10) + .perAppTasks(5) + .build(); + Services services = Services.builder() + .isPaidServicesAllowed(true) + .totalServiceInstances(10) + .totalServiceKeys(20) + .build(); + Routes routes = Routes.builder() + .totalRoutes(8) + .totalReservedPorts(4) + .build(); + Domains domains = Domains.builder() + .totalDomains(7) + .build(); + ToManyRelationship organizationRelationships = ToManyRelationship.builder() + .data( + Collections.singletonList( + Relationship + .builder() + .id(relatedOrganizationId) + .build())) + .build(); + OrganizationQuotaDefinitionRelationships relationships = + OrganizationQuotaDefinitionRelationships + .builder() + .organizations(organizationRelationships) + .build(); + + return OrganizationQuotaDefinitionResource.builder() + .createdAt("2016-05-04T17:00:41Z") + .id(id) + .link( + "self", + Link.builder() + .href("https://api.example.org/v3/organization_quotas/" + id) + .build()) + .name(name) + .updatedAt("2016-05-04T17:00:41Z") + .apps(apps) + .services(services) + .routes(routes) + .domains(domains) + .relationships(relationships) + .build(); + } +} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_response.json new file mode 100644 index 0000000000..7c33318b28 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_response.json @@ -0,0 +1,86 @@ +{ + "pagination": { + "total_results": 2, + "total_pages": 1, + "first": { + "href": "https://api.example.org/v3/organization_quotas?page=1&per_page=50" + }, + "last": { + "href": "https://api.example.org/v3/organization_quotas?page=1&per_page=50" + }, + "next": null, + "previous": null + }, + "resources": [ + { + "guid": "24637893-3b77-489d-bb79-8466f0d88b52", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T17:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "log_rate_limit_in_bytes_per_second": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "domains": { + "total_domains": 7 + }, + "relationships": { + "organizations": { + "data": [ + { "guid": "9b370018-c38e-44c9-86d6-155c76801104" } + ] + } + }, + "links": { + "self": { "href": "https://api.example.org/v3/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52" } + } + }, + { + "guid": "bb49bf20-ad98-4729-93ae-38fbc564b630", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T17:00:41Z", + "name": "my-quota-2", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "log_rate_limit_in_bytes_per_second": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "domains": { + "total_domains": 7 + }, + "relationships": { + "organizations": { + "data": [ + { "guid": "144251f2-a202-4ffe-ab47-9046c4077e99" } + ] + } + }, + "links": { + "self": { "href": "https://api.example.org/v3/organization_quotas/bb49bf20-ad98-4729-93ae-38fbc564b630" } + } + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_{id}_response.json new file mode 100644 index 0000000000..af547d449f --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/GET_{id}_response.json @@ -0,0 +1,35 @@ +{ + "guid": "24637893-3b77-489d-bb79-8466f0d88b52", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T17:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "log_rate_limit_in_bytes_per_second": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "domains": { + "total_domains": 7 + }, + "relationships": { + "organizations": { + "data": [ + { "guid": "9b370018-c38e-44c9-86d6-155c76801104" } + ] + } + }, + "links": { + "self": { "href": "https://api.example.org/v3/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52" } + } +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_request.json new file mode 100644 index 0000000000..7a73a41bfd --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_request.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_response.json new file mode 100644 index 0000000000..af547d449f --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/PATCH_{id}_response.json @@ -0,0 +1,35 @@ +{ + "guid": "24637893-3b77-489d-bb79-8466f0d88b52", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T17:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "log_rate_limit_in_bytes_per_second": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "domains": { + "total_domains": 7 + }, + "relationships": { + "organizations": { + "data": [ + { "guid": "9b370018-c38e-44c9-86d6-155c76801104" } + ] + } + }, + "links": { + "self": { "href": "https://api.example.org/v3/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52" } + } +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_request.json new file mode 100644 index 0000000000..fe1dcc937e --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_request.json @@ -0,0 +1,3 @@ +{ + "name": "my-quota" +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_response.json new file mode 100644 index 0000000000..af547d449f --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/organization_quotas/POST_response.json @@ -0,0 +1,35 @@ +{ + "guid": "24637893-3b77-489d-bb79-8466f0d88b52", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T17:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "log_rate_limit_in_bytes_per_second": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "domains": { + "total_domains": 7 + }, + "relationships": { + "organizations": { + "data": [ + { "guid": "9b370018-c38e-44c9-86d6-155c76801104" } + ] + } + }, + "links": { + "self": { "href": "https://api.example.org/v3/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52" } + } +} \ No newline at end of file From 07b697ca7627f89ce316ba199d3eb5e59489572a Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 22 Aug 2025 11:10:34 -0700 Subject: [PATCH 07/19] minor fix for DeleteOrganizationRequestTest to test appropriate builder --- .../v3/organizations/DeleteOrganizationRequestTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizations/DeleteOrganizationRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizations/DeleteOrganizationRequestTest.java index d76a8b7d6d..2e5eeec092 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizations/DeleteOrganizationRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizations/DeleteOrganizationRequestTest.java @@ -27,12 +27,12 @@ void noOrganizationId() { assertThrows( IllegalStateException.class, () -> { - GetOrganizationRequest.builder().build(); + DeleteOrganizationRequest.builder().build(); }); } @Test void valid() { - GetOrganizationRequest.builder().organizationId("test-id").build(); + DeleteOrganizationRequest.builder().organizationId("test-id").build(); } } From c429295f5dd11c72efe77219b2f20fa7504b523c Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Sun, 24 Aug 2025 18:20:05 -0700 Subject: [PATCH 08/19] issue-1168 adding integration test for version 3 implementation of OrganizationQuotaDefinition --- .../java/org/cloudfoundry/NameFactory.java | 12 + .../v3/OrganizationQuotaDefinitionsTest.java | 222 ++++++++++++++++++ 2 files changed, 234 insertions(+) create mode 100644 integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java diff --git a/integration-test/src/test/java/org/cloudfoundry/NameFactory.java b/integration-test/src/test/java/org/cloudfoundry/NameFactory.java index 7432672263..294dd78c8a 100644 --- a/integration-test/src/test/java/org/cloudfoundry/NameFactory.java +++ b/integration-test/src/test/java/org/cloudfoundry/NameFactory.java @@ -43,6 +43,8 @@ public interface NameFactory { String ORGANIZATION_PREFIX = "test-organization-"; + String ORGANIZATION_QUOTA_PREFIX = "test-organization-quota-definition-"; + String PASSWORD_PREFIX = "test-password-"; String PATH_PREFIX = "/test-path-"; @@ -189,6 +191,16 @@ default String getOrganizationName() { return getName(ORGANIZATION_PREFIX); } + /** + * Creates an organization quota name + * + * @return the organization quota name + */ + default String getOrganizationQuotaName() { + return getName(ORGANIZATION_QUOTA_PREFIX); + } + + /** * Creates a password * diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java new file mode 100644 index 0000000000..dd55f00fd7 --- /dev/null +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java @@ -0,0 +1,222 @@ +/* + * Copyright 2013-2021 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 org.cloudfoundry.AbstractIntegrationTest; +import org.cloudfoundry.CloudFoundryVersion; +import org.cloudfoundry.IfCloudFoundryVersion; +import org.cloudfoundry.client.CloudFoundryClient; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Apps; +import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.DeleteOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.GetOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.GetOrganizationQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.organizationquotadefinitions.ListOrganizationQuotaDefinitionsRequest; +import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionResource; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Routes; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Services; +import org.cloudfoundry.client.v3.organizationquotadefinitions.UpdateOrganizationQuotaDefinitionRequest; +import org.cloudfoundry.util.JobUtils; +import org.cloudfoundry.util.PaginationUtils; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +import java.time.Duration; + +import static org.assertj.core.api.Assertions.assertThat; + +@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_8) +public final class OrganizationQuotaDefinitionsTest extends AbstractIntegrationTest { + + @Autowired + private CloudFoundryClient cloudFoundryClient; + + @Test + public void create() { + String organizationQuotaName = this.nameFactory.getOrganizationQuotaName(); + this.cloudFoundryClient + .organizationQuotaDefinitionsV3() + .create(CreateOrganizationQuotaDefinitionRequest.builder().name(organizationQuotaName).build()) + .thenMany(requestListOrganizationQuotas(this.cloudFoundryClient, organizationQuotaName)) + .single() + .as(StepVerifier::create) + .expectNextCount(1) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + deleteOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName); + } + + @Test + public void delete() { + String organizationQuotaName = this.nameFactory.getOrganizationQuotaName(); + + createOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName) + .flatMap( + organizationId -> + this.cloudFoundryClient + .organizationQuotaDefinitionsV3() + .delete( + DeleteOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId(organizationId) + .build()) + .flatMap( + job -> + JobUtils.waitForCompletion( + this.cloudFoundryClient, + Duration.ofMinutes(5), + job))) + .thenMany(requestListOrganizationQuotas(this.cloudFoundryClient, organizationQuotaName)) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void get() { + String organizationQuotaName = this.nameFactory.getOrganizationQuotaName(); + + createOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName) + .flatMap( + organizationQuotaId -> + this.cloudFoundryClient + .organizationQuotaDefinitionsV3() + .get( + GetOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId(organizationQuotaId) + .build())) + .map(GetOrganizationQuotaDefinitionResponse::getName) + .as(StepVerifier::create) + .expectNext(organizationQuotaName) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + deleteOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName); + } + + @Test + public void list() { + String organizationQuotaName = this.nameFactory.getOrganizationQuotaName(); + + requestCreateOrganizationQuota(this.cloudFoundryClient, organizationQuotaName) + .thenMany( + PaginationUtils.requestClientV3Resources( + page -> + this.cloudFoundryClient + .organizationQuotaDefinitionsV3() + .list( + ListOrganizationQuotaDefinitionsRequest.builder() + .page(page) + .build()))) + .filter(resource -> organizationQuotaName.equals(resource.getName())) + .as(StepVerifier::create) + .expectNextCount(1) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + deleteOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName); + } + + @Test + public void update() { + String organizationQuotaName = this.nameFactory.getOrganizationQuotaName(); + int totalMemoryLimit = 64 * 1024; // 64 GB + + createOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName) + .flatMap( + organizationQuotaId -> + this.cloudFoundryClient + .organizationQuotaDefinitionsV3() + .update( + UpdateOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId(organizationQuotaId) + .apps(Apps.builder().totalMemoryInMb(totalMemoryLimit).build()) + .routes(Routes.builder().totalRoutes(100).build()) + .services(Services.builder().isPaidServicesAllowed(true).totalServiceInstances(100).build()) + .build())) + .thenMany(requestListOrganizationQuotas(this.cloudFoundryClient, organizationQuotaName)) + .as(StepVerifier::create) + .consumeNextWith( + organizationQuotaDefinitionResource -> { + assertThat(organizationQuotaDefinitionResource.getApps().getTotalMemoryInMb()).isEqualTo(totalMemoryLimit); + assertThat(organizationQuotaDefinitionResource.getRoutes().getTotalRoutes()).isEqualTo(100); + assertThat(organizationQuotaDefinitionResource.getServices().getTotalServiceInstances()).isEqualTo(100); + }) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + deleteOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName); + } + + private static Mono createOrganizationQuotaId( + CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { + return requestCreateOrganizationQuota(cloudFoundryClient, organizationQuotaName) + .map(CreateOrganizationQuotaDefinitionResponse::getId); + } + + private static Mono getOrganizationQuotaId( + CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { + return requestListOrganizationQuotas(cloudFoundryClient, organizationQuotaName) + .filter(organizationQuotaDefinitionResource -> organizationQuotaName.equals(organizationQuotaDefinitionResource.getName())) + .single() + .map(OrganizationQuotaDefinitionResource::getId); + } + + private static Mono requestCreateOrganizationQuota( + CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { + return cloudFoundryClient + .organizationQuotaDefinitionsV3() + .create(CreateOrganizationQuotaDefinitionRequest.builder().name(organizationQuotaName).build()); + } + + private static Flux requestListOrganizationQuotas( + CloudFoundryClient cloudFoundryClient, String organizationName) { + return PaginationUtils.requestClientV3Resources( + page -> + cloudFoundryClient + .organizationQuotaDefinitionsV3() + .list( + ListOrganizationQuotaDefinitionsRequest.builder() + .name(organizationName) + .page(page) + .build())); + } + + private static void deleteOrganizationQuotaId(CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { + + getOrganizationQuotaId(cloudFoundryClient, organizationQuotaName) + .flatMap( + organizationId -> + cloudFoundryClient + .organizationQuotaDefinitionsV3() + .delete( + DeleteOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId(organizationId) + .build()) + .flatMap( + job -> + JobUtils.waitForCompletion( + cloudFoundryClient, + Duration.ofMinutes(5), + job))) + .block(Duration.ofMinutes(5)); + } +} From c53cf2c451cf71f724393cffcf980e15d840d821 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Wed, 10 Sep 2025 09:59:08 -0700 Subject: [PATCH 09/19] adding model, interface and implementation for CreateSpaceQuotaDefinition --- .../client/_ReactorCloudFoundryClient.java | 21 ++++-- .../ReactorSpaceQuotaDefinitionsV3.java | 60 +++++++++++++++++ .../client/CloudFoundryClient.java | 6 ++ .../SpaceQuotaDefinition.java | 62 +++++++++++++++++ .../SpaceQuotaDefinitionsV3.java | 35 ++++++++++ .../v3/spacequotadefinitions/_Apps.java | 63 +++++++++++++++++ .../_CreateSpaceQuotaDefinitionRequest.java | 67 +++++++++++++++++++ .../_CreateSpaceQuotaDefinitionResponse.java | 29 ++++++++ .../v3/spacequotadefinitions/_Routes.java | 49 ++++++++++++++ .../v3/spacequotadefinitions/_Services.java | 53 +++++++++++++++ .../_SpaceQuotaDefinitionRelationships.java | 46 +++++++++++++ ...rganizationQuotaDefinitionRequestTest.java | 53 +++++++++++++++ 12 files changed, 538 insertions(+), 6 deletions(-) create mode 100644 cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Routes.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Services.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceOrganizationQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java index 7e43bd5820..c5aaf9197b 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/_ReactorCloudFoundryClient.java @@ -16,6 +16,7 @@ package org.cloudfoundry.reactor.client; +import jakarta.annotation.PostConstruct; import org.cloudfoundry.client.CloudFoundryClient; import org.cloudfoundry.client.v2.applications.ApplicationsV2; import org.cloudfoundry.client.v2.applicationusageevents.ApplicationUsageEvents; @@ -34,8 +35,6 @@ import org.cloudfoundry.client.v2.routemappings.RouteMappings; import org.cloudfoundry.client.v2.routes.Routes; import org.cloudfoundry.client.v2.securitygroups.SecurityGroups; -import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionsV3; -import org.cloudfoundry.client.v3.securitygroups.SecurityGroupsV3; import org.cloudfoundry.client.v2.servicebindings.ServiceBindingsV2; import org.cloudfoundry.client.v2.servicebrokers.ServiceBrokers; import org.cloudfoundry.client.v2.serviceinstances.ServiceInstances; @@ -60,17 +59,20 @@ import org.cloudfoundry.client.v3.droplets.Droplets; import org.cloudfoundry.client.v3.isolationsegments.IsolationSegments; import org.cloudfoundry.client.v3.jobs.JobsV3; +import org.cloudfoundry.client.v3.organizationquotadefinitions.OrganizationQuotaDefinitionsV3; import org.cloudfoundry.client.v3.organizations.OrganizationsV3; import org.cloudfoundry.client.v3.packages.Packages; import org.cloudfoundry.client.v3.processes.Processes; import org.cloudfoundry.client.v3.resourcematch.ResourceMatchV3; import org.cloudfoundry.client.v3.roles.RolesV3; import org.cloudfoundry.client.v3.routes.RoutesV3; -import org.cloudfoundry.client.v3.serviceinstances.ServiceInstancesV3; +import org.cloudfoundry.client.v3.securitygroups.SecurityGroupsV3; import org.cloudfoundry.client.v3.servicebindings.ServiceBindingsV3; import org.cloudfoundry.client.v3.servicebrokers.ServiceBrokersV3; +import org.cloudfoundry.client.v3.serviceinstances.ServiceInstancesV3; import org.cloudfoundry.client.v3.serviceofferings.ServiceOfferingsV3; import org.cloudfoundry.client.v3.serviceplans.ServicePlansV3; +import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionsV3; import org.cloudfoundry.client.v3.spaces.SpacesV3; import org.cloudfoundry.client.v3.stacks.StacksV3; import org.cloudfoundry.client.v3.tasks.Tasks; @@ -93,8 +95,6 @@ import org.cloudfoundry.reactor.client.v2.routemappings.ReactorRouteMappings; import org.cloudfoundry.reactor.client.v2.routes.ReactorRoutes; import org.cloudfoundry.reactor.client.v2.securitygroups.ReactorSecurityGroups; -import org.cloudfoundry.reactor.client.v3.organizationquotadefinitions.ReactorOrganizationQuotaDefinitionsV3; -import org.cloudfoundry.reactor.client.v3.securitygroups.ReactorSecurityGroupsV3; import org.cloudfoundry.reactor.client.v2.servicebindings.ReactorServiceBindingsV2; import org.cloudfoundry.reactor.client.v2.servicebrokers.ReactorServiceBrokers; import org.cloudfoundry.reactor.client.v2.serviceinstances.ReactorServiceInstances; @@ -119,24 +119,26 @@ import org.cloudfoundry.reactor.client.v3.droplets.ReactorDroplets; import org.cloudfoundry.reactor.client.v3.isolationsegments.ReactorIsolationSegments; import org.cloudfoundry.reactor.client.v3.jobs.ReactorJobsV3; +import org.cloudfoundry.reactor.client.v3.organizationquotadefinitions.ReactorOrganizationQuotaDefinitionsV3; import org.cloudfoundry.reactor.client.v3.organizations.ReactorOrganizationsV3; import org.cloudfoundry.reactor.client.v3.packages.ReactorPackages; import org.cloudfoundry.reactor.client.v3.processes.ReactorProcesses; import org.cloudfoundry.reactor.client.v3.resourcematch.ReactorResourceMatchV3; import org.cloudfoundry.reactor.client.v3.roles.ReactorRolesV3; import org.cloudfoundry.reactor.client.v3.routes.ReactorRoutesV3; +import org.cloudfoundry.reactor.client.v3.securitygroups.ReactorSecurityGroupsV3; import org.cloudfoundry.reactor.client.v3.servicebindings.ReactorServiceBindingsV3; import org.cloudfoundry.reactor.client.v3.servicebrokers.ReactorServiceBrokersV3; import org.cloudfoundry.reactor.client.v3.serviceinstances.ReactorServiceInstancesV3; import org.cloudfoundry.reactor.client.v3.serviceofferings.ReactorServiceOfferingsV3; import org.cloudfoundry.reactor.client.v3.serviceplans.ReactorServicePlansV3; +import org.cloudfoundry.reactor.client.v3.spacequotadefinition.ReactorSpaceQuotaDefinitionsV3; import org.cloudfoundry.reactor.client.v3.spaces.ReactorSpacesV3; import org.cloudfoundry.reactor.client.v3.stacks.ReactorStacksV3; import org.cloudfoundry.reactor.client.v3.tasks.ReactorTasks; import org.immutables.value.Value; import reactor.core.publisher.Mono; -import jakarta.annotation.PostConstruct; import java.util.Collections; import java.util.Map; @@ -457,6 +459,13 @@ public SpaceQuotaDefinitions spaceQuotaDefinitions() { getRequestTags()); } + @Override + @Value.Derived + public SpaceQuotaDefinitionsV3 spaceQuotaDefinitionsV3() { + return new ReactorSpaceQuotaDefinitionsV3(getConnectionContext(), getRootV3(), getTokenProvider(), + getRequestTags()); + } + @Override @Value.Derived public Spaces spaces() { diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java new file mode 100644 index 0000000000..b202909ca4 --- /dev/null +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java @@ -0,0 +1,60 @@ +/* + * Copyright 2013-2025 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.spacequotadefinition; + +import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionsV3; +import org.cloudfoundry.reactor.ConnectionContext; +import org.cloudfoundry.reactor.TokenProvider; +import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; +import reactor.core.publisher.Mono; + +import java.util.Map; + +/** + * The Reactor-based implementation of {@link ReactorSpaceQuotaDefinitionsV3} + */ +public class ReactorSpaceQuotaDefinitionsV3 extends AbstractClientV3Operations + implements SpaceQuotaDefinitionsV3 { + + /** + * 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 ReactorSpaceQuotaDefinitionsV3( + ConnectionContext connectionContext, + Mono root, + TokenProvider tokenProvider, + Map requestTags) { + super(connectionContext, root, tokenProvider, requestTags); + } + + @Override + public Mono create(CreateSpaceQuotaDefinitionRequest request) { + return post( + request, + CreateSpaceQuotaDefinitionResponse.class, + builder -> builder.pathSegment("space_quotas")) + .checkpoint(); + } + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java index c229b37230..a1df244917 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java @@ -70,6 +70,7 @@ import org.cloudfoundry.client.v3.serviceinstances.ServiceInstancesV3; import org.cloudfoundry.client.v3.serviceofferings.ServiceOfferingsV3; import org.cloudfoundry.client.v3.serviceplans.ServicePlansV3; +import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionsV3; import org.cloudfoundry.client.v3.spaces.SpacesV3; import org.cloudfoundry.client.v3.stacks.StacksV3; import org.cloudfoundry.client.v3.tasks.Tasks; @@ -334,6 +335,11 @@ public interface CloudFoundryClient { */ SpaceQuotaDefinitions spaceQuotaDefinitions(); + /** + * Main entry point to the Cloud Foundry Space Definitions V3 Client API + */ + SpaceQuotaDefinitionsV3 spaceQuotaDefinitionsV3(); + /** * Main entry point to the Cloud Foundry Spaces V2 Client API */ diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java new file mode 100644 index 0000000000..b2c9106935 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java @@ -0,0 +1,62 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Resource; + +/** + * Base class for responses that are space quota definitions + */ +public abstract class SpaceQuotaDefinition extends Resource { + + /** + * Name of the quota + */ + @JsonProperty("name") + abstract String getName(); + + /** + * Quotas that affect applications and application sub-resources + */ + @JsonProperty("apps") + @Nullable + abstract Apps getApps(); + + /** + * Quotas that affect services + */ + @JsonProperty("services") + @Nullable + abstract Services getServices(); + + /** + * Quotas that affect routes + */ + @JsonProperty("routes") + @Nullable + abstract Routes getRoutes(); + + + /** + * A relationship to the organizations where the quota is applied + */ + @JsonProperty("relationships") + @Nullable + abstract SpaceQuotaDefinitionRelationships getRelationships(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java new file mode 100644 index 0000000000..c5a5ecd158 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java @@ -0,0 +1,35 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import reactor.core.publisher.Mono; + +/** + * Main entry point to the Cloud Foundry Space Quota Definitions Client API + */ +public interface SpaceQuotaDefinitionsV3 { + + /** + * Makes the Create Space Quota Definition + * request + * + * @param request the Create Space Quota Definition request + * @return the response from the Create Space Quota Definition request + */ + Mono create( + CreateSpaceQuotaDefinitionRequest request); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java new file mode 100644 index 0000000000..91a88171fa --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java @@ -0,0 +1,63 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * Quotas that affect applications and application sub-resources + */ +@JsonDeserialize +@Value.Immutable +abstract class _Apps { + + /** + * Maximum memory for a single process or task + * @return the maximum memory for a single process or task + */ + @JsonProperty("per_process_memory_in_mb") + @Nullable + abstract Integer getPerProcessMemoryInMb(); + + /** + * Total memory allowed for all the started processes and running tasks in a space + * @return the total memory allowed for all the started processes and running tasks in a space + */ + @JsonProperty("total_memory_in_mb") + @Nullable + abstract Integer getTotalMemoryInMb(); + + /** + * Total instances of all the started processes allowed in a space + * @return the total instances of all the started processes allowed in a space + */ + @JsonProperty("total_instances") + @Nullable + abstract Integer getTotalInstances(); + + /** + * Maximum number of running tasks in a space + * @return the maximum number of running tasks in a space + */ + @JsonProperty("per_app_tasks") + @Nullable + abstract Integer getPerAppTasks(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java new file mode 100644 index 0000000000..627625e4f4 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Apps; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Routes; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Services; +import org.immutables.value.Value; + +/** + * The request payload to creates a new space quota + */ +@JsonSerialize +@Value.Immutable +abstract class _CreateSpaceQuotaDefinitionRequest { + + /** + * Name of the quota + */ + @JsonProperty("name") + abstract String getName(); + + /** + * A relationship to the organizations and spaces where the quota is applied + */ + @JsonProperty("relationships") + abstract SpaceQuotaDefinitionRelationships getRelationships(); + + /** + * Quotas that affect applications and application sub-resources + */ + @JsonProperty("apps") + @Nullable + abstract Apps getApps(); + + /** + * Quotas that affect services + */ + @JsonProperty("services") + @Nullable + abstract Services getServices(); + + /** + * Quotas that affect routes + */ + @JsonProperty("routes") + @Nullable + abstract Routes getRoutes(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionResponse.java new file mode 100644 index 0000000000..678390a6f3 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Create an Space Quota Definition operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _CreateSpaceQuotaDefinitionResponse extends SpaceQuotaDefinition { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Routes.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Routes.java new file mode 100644 index 0000000000..5c69e2fba4 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Routes.java @@ -0,0 +1,49 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * Quotas that affect routes + */ +@JsonDeserialize +@Value.Immutable +abstract class _Routes { + + /** + * Total number of routes allowed in a space + * + * @return the total number of routes allowed in a space + */ + @JsonProperty("total_routes") + @Nullable + abstract Integer getTotalRoutes(); + + /** + * Total number of ports that are reservable by routes in a space + * + * @return the total number of reserved ports allowed in a space + */ + @JsonProperty("total_reserved_ports") + @Nullable + abstract Integer getTotalReservedPorts(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Services.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Services.java new file mode 100644 index 0000000000..813e248e33 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Services.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * Quotas that affect services + */ +@JsonDeserialize +@Value.Immutable +abstract class _Services { + + /** + * Specifies whether instances of paid service plans can be created + * @return true if instances of paid service plans can be created, false otherwise + */ + @JsonProperty("paid_services_allowed") + abstract boolean isPaidServicesAllowed(); + + /** + * Total number of service instances allowed in a space + * @return the total number of service instances allowed in a space + */ + @JsonProperty("total_service_instances") + @Nullable + abstract Integer getTotalServiceInstances(); + + /** + * Total number of service keys allowed in a space + * @return the total number of service keys allowed in a space + */ + @JsonProperty("total_service_keys") + @Nullable + abstract Integer getTotalServiceKeys(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java new file mode 100644 index 0000000000..a26fb4e6a4 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java @@ -0,0 +1,46 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.immutables.value.Value; + +/** + * The relationships for the SpaceQuotaDefinition entity + */ + +@Value.Immutable +@JsonDeserialize +abstract class _SpaceQuotaDefinitionRelationships { + + /** + * A relationship to the organization where the quota belongs + */ + @JsonProperty("organizations") + abstract ToManyRelationship getOrganizations(); + + /** + * A relationship to the spaces where the quota is applied + */ + @JsonProperty("spaces") + @Nullable + abstract ToManyRelationship getSpaces(); + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceOrganizationQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..993e47d7cd --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceOrganizationQuotaDefinitionRequestTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import org.cloudfoundry.client.v3.Relationship; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.junit.jupiter.api.Test; + +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class SpaceOrganizationQuotaDefinitionRequestTest { + + @Test + void noName() { + assertThrows( + IllegalStateException.class, + () -> CreateSpaceQuotaDefinitionRequest.builder().build()); + } + + @Test + void noOrganizationsRelationship() { + assertThrows( + IllegalStateException.class, + () -> CreateSpaceQuotaDefinitionRequest.builder().name("test-quota").build()); + } + + @Test + void valid() { + + String organizationGuid = UUID.randomUUID().toString(); + ToManyRelationship organizationsRelationship = ToManyRelationship.builder().data(Relationship.builder().id(organizationGuid).build()).build(); + SpaceQuotaDefinitionRelationships relationships = SpaceQuotaDefinitionRelationships.builder() + .organizations(organizationsRelationship) + .build(); + CreateSpaceQuotaDefinitionRequest.builder().name("test-quota").relationships(relationships).build(); + } +} From 4a6840ace3a21f369d70e8d473af1fafe0aac8ea Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Wed, 10 Sep 2025 11:14:05 -0700 Subject: [PATCH 10/19] adding model, interface and implementation for GetSpaceQuotaDefinition --- .../ReactorSpaceQuotaDefinitionsV3.java | 13 +++++++ .../SpaceQuotaDefinitionsV3.java | 12 ++++++- .../_GetSpaceQuotaDefinitionRequest.java | 34 ++++++++++++++++++ .../_GetSpaceQuotaDefinitionResponse.java | 29 +++++++++++++++ .../GetSpaceQuotaDefinitionRequestTest.java | 36 +++++++++++++++++++ 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionResponse.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java index b202909ca4..195ee40a92 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java @@ -18,6 +18,8 @@ import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionRequest; import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionResponse; import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionsV3; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; @@ -57,4 +59,15 @@ public Mono create(CreateSpaceQuotaDefinitio .checkpoint(); } + @Override + public Mono get(GetSpaceQuotaDefinitionRequest request) { + return get( + request, + GetSpaceQuotaDefinitionResponse.class, + builder -> + builder.pathSegment("space_quotas", request.getSpaceQuotaDefinitionId())) + .checkpoint(); + } + + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java index c5a5ecd158..554619c832 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java @@ -24,7 +24,7 @@ public interface SpaceQuotaDefinitionsV3 { /** - * Makes the Create Space Quota Definition + * Makes the Create Space Quota * request * * @param request the Create Space Quota Definition request @@ -32,4 +32,14 @@ public interface SpaceQuotaDefinitionsV3 { */ Mono create( CreateSpaceQuotaDefinitionRequest request); + + /** + * Makes the Get Space Quota + * request + * + * @param request the Get Space Quota Definition request + * @return the response from the Get Space Quota request + */ + Mono get( + GetSpaceQuotaDefinitionRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionRequest.java new file mode 100644 index 0000000000..d73bfa7d98 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.immutables.value.Value; + +/** + * The request payload for the Retrieve a Particular Space Quota Definition operation + */ +@Value.Immutable +abstract class _GetSpaceQuotaDefinitionRequest { + + /** + * The quota definition id + */ + @JsonIgnore + abstract String getSpaceQuotaDefinitionId(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionResponse.java new file mode 100644 index 0000000000..8aa7f7dc94 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_GetSpaceQuotaDefinitionResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Retrieve a Particular Space Quota Definition operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _GetSpaceQuotaDefinitionResponse extends SpaceQuotaDefinition { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..b231eb3414 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class GetSpaceQuotaDefinitionRequestTest { + + @Test + void noSpaceQuotaDefinitionId() { + assertThrows( + IllegalStateException.class, + () -> GetSpaceQuotaDefinitionRequest.builder().build()); + } + + @Test + void valid() { + GetSpaceQuotaDefinitionRequest.builder().spaceQuotaDefinitionId("test-id").build(); + } +} From ce92dab8218a0e6e57b78f716ab9cd41aef296e9 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Wed, 10 Sep 2025 12:51:00 -0700 Subject: [PATCH 11/19] adding model, interface and implementation for ListSpaceQuotaDefinition --- .../ReactorSpaceQuotaDefinitionsV3.java | 10 ++++ .../SpaceQuotaDefinitionsV3.java | 10 ++++ .../_ListSpaceQuotaDefinitionsRequest.java | 59 +++++++++++++++++++ .../_ListSpaceQuotaDefinitionsResponse.java | 30 ++++++++++ .../_SpaceQuotaDefinitionResource.java | 30 ++++++++++ .../ListSpaceQuotaDefinitionsRequestTest.java | 27 +++++++++ 6 files changed, 166 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionResource.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/ListSpaceQuotaDefinitionsRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java index 195ee40a92..768261c1c4 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java @@ -20,6 +20,8 @@ import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionResponse; import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionRequest; import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsResponse; import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionsV3; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; @@ -69,5 +71,13 @@ public Mono get(GetSpaceQuotaDefinitionRequest .checkpoint(); } + @Override + public Mono list(ListSpaceQuotaDefinitionsRequest request) { + return get( + request, + ListSpaceQuotaDefinitionsResponse.class, + builder -> builder.pathSegment("space_quotas")) + .checkpoint(); + } } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java index 554619c832..5ffe584474 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java @@ -42,4 +42,14 @@ Mono create( */ Mono get( GetSpaceQuotaDefinitionRequest request); + + /** + * Makes the List all Space Quota Definitions request + * + * @param request the List all Space Quota Definitions request + * @return the response from the Space all Organization Quota Definitions request + */ + Mono list( + ListSpaceQuotaDefinitionsRequest request); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsRequest.java new file mode 100644 index 0000000000..99a075bdc3 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsRequest.java @@ -0,0 +1,59 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.FilterParameter; +import org.cloudfoundry.client.v3.PaginatedRequest; +import org.immutables.value.Value; + +import java.util.List; + +/** + * The request payload for the List all Space Quota Definitions operation + */ +@Value.Immutable +abstract class _ListSpaceQuotaDefinitionsRequest extends PaginatedRequest { + + /** + * Comma-delimited list of space quota guids to filter by + */ + @FilterParameter("guids") + @Nullable + abstract List getGuids(); + + /** + * Comma-delimited list of space quota names to filter by + */ + @FilterParameter("names") + @Nullable + abstract List getNames(); + + /** + * Comma-delimited list of organization guids to filter by + */ + @FilterParameter("organization_guids") + @Nullable + abstract List getOrganizationGuids(); + + /** + * Comma-delimited list of space guids to filter by + */ + @FilterParameter("space_guids") + @Nullable + abstract List getSpaceGuids(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsResponse.java new file mode 100644 index 0000000000..bfc64840b6 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_ListSpaceQuotaDefinitionsResponse.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.client.v3.PaginatedResponse; +import org.immutables.value.Value; + +/** + * The response payload for the List all Space Quota Definitions operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _ListSpaceQuotaDefinitionsResponse extends PaginatedResponse { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionResource.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionResource.java new file mode 100644 index 0000000000..4a9e5fb228 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionResource.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * Base class for resources that contain Space Quota Definitions + */ +@JsonDeserialize +@Value.Immutable +abstract class _SpaceQuotaDefinitionResource extends SpaceQuotaDefinition { + +} + diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/ListSpaceQuotaDefinitionsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/ListSpaceQuotaDefinitionsRequestTest.java new file mode 100644 index 0000000000..8f0e0f4f8c --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/ListSpaceQuotaDefinitionsRequestTest.java @@ -0,0 +1,27 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import org.junit.jupiter.api.Test; + +public class ListSpaceQuotaDefinitionsRequestTest { + + @Test + void valid() { + ListSpaceQuotaDefinitionsRequest.builder().build(); + } +} From d0876ee3a340e711e6e28f55edb154967e7cf67e Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Wed, 10 Sep 2025 14:23:20 -0700 Subject: [PATCH 12/19] adding model, interface and implementation for UpdateSpaceQuotaDefinition --- .../ReactorSpaceQuotaDefinitionsV3.java | 12 ++++ .../SpaceQuotaDefinitionsV3.java | 12 +++- .../_UpdateSpaceQuotaDefinitionRequest.java | 68 +++++++++++++++++++ .../_UpdateSpaceQuotaDefinitionResponse.java | 29 ++++++++ ...reateSpaceQuotaDefinitionRequestTest.java} | 2 +- ...UpdateSpaceQuotaDefinitionRequestTest.java | 36 ++++++++++ 6 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionResponse.java rename cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/{SpaceOrganizationQuotaDefinitionRequestTest.java => CreateSpaceQuotaDefinitionRequestTest.java} (96%) create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java index 768261c1c4..97edae71eb 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java @@ -23,6 +23,8 @@ import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsRequest; import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsResponse; import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionsV3; +import org.cloudfoundry.client.v3.spacequotadefinitions.UpdateSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.UpdateSpaceQuotaDefinitionResponse; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -80,4 +82,14 @@ public Mono list(ListSpaceQuotaDefinitionsReq .checkpoint(); } + @Override + public Mono update(UpdateSpaceQuotaDefinitionRequest request) { + return patch( + request, + UpdateSpaceQuotaDefinitionResponse.class, + builder -> + builder.pathSegment("space_quotas", request.getSpaceQuotaDefinitionId())) + .checkpoint(); + } + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java index 5ffe584474..b7de12240b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java @@ -44,7 +44,8 @@ Mono get( GetSpaceQuotaDefinitionRequest request); /** - * Makes the List all Space Quota Definitions request + * Makes the List all Space Quota Definitions + * request * * @param request the List all Space Quota Definitions request * @return the response from the Space all Organization Quota Definitions request @@ -52,4 +53,13 @@ Mono get( Mono list( ListSpaceQuotaDefinitionsRequest request); + /** Makes the Update Space Quota Definition + * request + * + * @param request the Update Space Quota Definition request + * @return the response from the Update Space Quota Definition request + */ + Mono update( + UpdateSpaceQuotaDefinitionRequest request); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java new file mode 100644 index 0000000000..153e5ce654 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +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.organizationquotadefinitions.Apps; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Routes; +import org.cloudfoundry.client.v3.organizationquotadefinitions.Services; +import org.immutables.value.Value; + +/** + * The request payload to update an space quota definition + */ +@JsonSerialize +@Value.Immutable +abstract class _UpdateSpaceQuotaDefinitionRequest { + + /** + * The space quota definition id + */ + @JsonIgnore + abstract String getSpaceQuotaDefinitionId(); + + /** + * Name of the quota + */ + @JsonProperty("name") + @Nullable + abstract String getName(); + + /** + * Quotas that affect applications and application sub-resources + */ + @JsonProperty("apps") + @Nullable + abstract Apps getApps(); + + /** + * Quotas that affect services + */ + @JsonProperty("services") + @Nullable + abstract Services getServices(); + + /** + * Quotas that affect routes + */ + @JsonProperty("routes") + @Nullable + abstract Routes getRoutes(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionResponse.java new file mode 100644 index 0000000000..e1df4f8b85 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionResponse.java @@ -0,0 +1,29 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Update an Space Quota Definition operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _UpdateSpaceQuotaDefinitionResponse extends SpaceQuotaDefinition { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java similarity index 96% rename from cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceOrganizationQuotaDefinitionRequestTest.java rename to cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java index 993e47d7cd..61c4f2fb10 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceOrganizationQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -final class SpaceOrganizationQuotaDefinitionRequestTest { +final class CreateSpaceQuotaDefinitionRequestTest { @Test void noName() { diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..9fc8b853ac --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class UpdateSpaceQuotaDefinitionRequestTest { + + @Test + void noSpaceQuotaDefinitionId() { + assertThrows( + IllegalStateException.class, + () -> UpdateSpaceQuotaDefinitionRequest.builder().build()); + } + + @Test + void valid() { + UpdateSpaceQuotaDefinitionRequest.builder().spaceQuotaDefinitionId("test-id").build(); + } +} From 76d5ae61bc68c0a0ec6b7a056d3b9625d572ecab Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 12 Sep 2025 12:37:46 -0700 Subject: [PATCH 13/19] adding model, interface and implementation for DeleteSpaceQuotaDefinition --- .../ReactorSpaceQuotaDefinitionsV3.java | 10 ++++++ .../SpaceQuotaDefinitionsV3.java | 9 +++++ .../_DeleteSpaceQuotaDefinitionRequest.java | 34 ++++++++++++++++++ ...DeleteSpaceQuotaDefinitionRequestTest.java | 36 +++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_DeleteSpaceQuotaDefinitionRequest.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java index 97edae71eb..cff8ed2028 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java @@ -18,6 +18,7 @@ import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionRequest; import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.DeleteSpaceQuotaDefinitionRequest; import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionRequest; import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionResponse; import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsRequest; @@ -92,4 +93,13 @@ public Mono update(UpdateSpaceQuotaDefinitio .checkpoint(); } + @Override + public Mono delete(DeleteSpaceQuotaDefinitionRequest request) { + return delete( + request, + builder -> + builder.pathSegment("organization_quotas", request.getSpaceQuotaDefinitionId())) + .checkpoint(); + } + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java index b7de12240b..dc3714d5f9 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java @@ -62,4 +62,13 @@ Mono list( Mono update( UpdateSpaceQuotaDefinitionRequest request); + /** + * Makes the Delete Space Quota Definition + * request + * + * @param request the Delete Space Quota Definition request + * @return the response from the Space Organization Quota Definition request + */ + Mono delete( + DeleteSpaceQuotaDefinitionRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_DeleteSpaceQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_DeleteSpaceQuotaDefinitionRequest.java new file mode 100644 index 0000000000..d41e4fb0c8 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_DeleteSpaceQuotaDefinitionRequest.java @@ -0,0 +1,34 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.immutables.value.Value; + +/** + * The request payload for the Delete an Space Quota Definition operation + */ +@Value.Immutable +abstract class _DeleteSpaceQuotaDefinitionRequest { + + /** + * The quota definition id + */ + @JsonIgnore + abstract String getSpaceQuotaDefinitionId(); + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java new file mode 100644 index 0000000000..0d45fa7c86 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2013-2025 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.spacequotadefinitions; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +final class DeleteSpaceQuotaDefinitionRequestTest { + + @Test + void noSpaceQuotaDefinitionId() { + assertThrows( + IllegalStateException.class, + () -> DeleteSpaceQuotaDefinitionRequest.builder().build()); + } + + @Test + void valid() { + DeleteSpaceQuotaDefinitionRequest.builder().spaceQuotaDefinitionId("test-id").build(); + } +} From c4cc7429bd0ee4d9bdd837a47374588a85636724 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Fri, 12 Sep 2025 16:20:20 -0700 Subject: [PATCH 14/19] unit test for ReactorSpaceQuotaDefinitionsV3 covering create, get, list, update and delete operations --- .../ReactorSpaceQuotaDefinitionsV3.java | 2 +- .../ReactorSpaceQuotaDefinitionsV3Test.java | 323 ++++++++++++++++++ .../client/v3/space_quotas/GET_response.json | 98 ++++++ .../v3/space_quotas/GET_{id}_response.json | 43 +++ .../v3/space_quotas/PATCH_{id}_request.json | 2 + .../v3/space_quotas/PATCH_{id}_response.json | 43 +++ .../client/v3/space_quotas/POST_request.json | 17 + .../client/v3/space_quotas/POST_response.json | 43 +++ .../SpaceQuotaDefinition.java | 5 +- .../_SpaceQuotaDefinitionRelationships.java | 5 +- ...CreateSpaceQuotaDefinitionRequestTest.java | 6 +- 11 files changed, 578 insertions(+), 9 deletions(-) create mode 100644 cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_response.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_{id}_response.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_response.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_response.json diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java index cff8ed2028..8198fae625 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java @@ -98,7 +98,7 @@ public Mono delete(DeleteSpaceQuotaDefinitionRequest request) { return delete( request, builder -> - builder.pathSegment("organization_quotas", request.getSpaceQuotaDefinitionId())) + builder.pathSegment("space_quotas", request.getSpaceQuotaDefinitionId())) .checkpoint(); } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java new file mode 100644 index 0000000000..c2072da56e --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java @@ -0,0 +1,323 @@ +/* + * Copyright 2013-2025 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.spacequotadefinition; + +import org.cloudfoundry.client.v3.Link; +import org.cloudfoundry.client.v3.Pagination; +import org.cloudfoundry.client.v3.Relationship; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.ToOneRelationship; +import org.cloudfoundry.client.v3.spacequotadefinitions.Apps; +import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.DeleteSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.Routes; +import org.cloudfoundry.client.v3.spacequotadefinitions.Services; +import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionRelationships; +import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionResource; +import org.cloudfoundry.client.v3.spacequotadefinitions.UpdateSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.UpdateSpaceQuotaDefinitionResponse; +import org.cloudfoundry.reactor.InteractionContext; +import org.cloudfoundry.reactor.TestRequest; +import org.cloudfoundry.reactor.TestResponse; +import org.cloudfoundry.reactor.client.AbstractClientApiTest; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.Test; +import reactor.test.StepVerifier; + +import java.time.Duration; +import java.util.Collections; + +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.PATCH; +import static io.netty.handler.codec.http.HttpMethod.POST; +import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; + +class ReactorSpaceQuotaDefinitionsV3Test extends AbstractClientApiTest { + + public static final String EXPECTED_SPACE_QUOTA_ID_1 = "f919ef8a-e333-472a-8172-baaf2c30d301"; + + private final ReactorSpaceQuotaDefinitionsV3 spaceQuotaDefinitionsV3 = + new ReactorSpaceQuotaDefinitionsV3( + CONNECTION_CONTEXT, this.root, TOKEN_PROVIDER, Collections.emptyMap()); + + @Test + void create() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(POST) + .path("/space_quotas") + .payload( + "fixtures/client/v3/space_quotas/POST_request.json") + .build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/space_quotas/POST_response.json") + .build()) + .build()); + + SpaceQuotaDefinitionRelationships relationships = SpaceQuotaDefinitionRelationships + .builder() + .organization(ToOneRelationship.builder() + .data(Relationship.builder() + .id("9b370018-c38e-44c9-86d6-155c76801104") + .build()) + .build()) + .spaces(ToManyRelationship.builder() + .data(Collections.singletonList(Relationship.builder() + .id("dcfd6a55-62b9-496e-a26f-0064cec076bf") + .build())) + .build()) + .build(); + this.spaceQuotaDefinitionsV3 + .create(CreateSpaceQuotaDefinitionRequest.builder().name("my-quota").relationships(relationships).build()) + .as(StepVerifier::create) + .expectNext( + CreateSpaceQuotaDefinitionResponse + .builder() + .from(expectedSpaceQuotaDefinitionResource1()) + .build() + ) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void delete() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(DELETE) + .path("/space_quotas/test-space-quota-id") + .build()) + .response( + TestResponse.builder() + .status(ACCEPTED) + .header( + "Location", + "https://api.example.org/v3/jobs/test-job-id") + .build()) + .build()); + + this.spaceQuotaDefinitionsV3 + .delete( + DeleteSpaceQuotaDefinitionRequest.builder() + .spaceQuotaDefinitionId("test-space-quota-id") + .build()) + .as(StepVerifier::create) + .expectNext("test-job-id") + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void get() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(GET) + .path("/space_quotas/" + EXPECTED_SPACE_QUOTA_ID_1) + .build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/space_quotas/GET_{id}_response.json") + .build()) + .build()); + + this.spaceQuotaDefinitionsV3 + .get( + GetSpaceQuotaDefinitionRequest.builder() + .spaceQuotaDefinitionId(EXPECTED_SPACE_QUOTA_ID_1) + .build()) + .as(StepVerifier::create) + .expectNext( + GetSpaceQuotaDefinitionResponse.builder() + .from(expectedSpaceQuotaDefinitionResource1()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void list() { + mockRequest( + InteractionContext.builder() + .request(TestRequest.builder().method(GET).path("/space_quotas").build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/space_quotas/GET_response.json") + .build()) + .build()); + + this.spaceQuotaDefinitionsV3 + .list(ListSpaceQuotaDefinitionsRequest.builder().build()) + .as(StepVerifier::create) + .expectNext( + ListSpaceQuotaDefinitionsResponse.builder() + .pagination( + Pagination.builder() + .totalResults(2) + .totalPages(1) + .first( + Link.builder() + .href( + "https://api.example.org/v3/space_quotas?page=1&per_page=50") + .build()) + .last( + Link.builder() + .href( + "https://api.example.org/v3/space_quotas?page=1&per_page=50") + .build()) + .build()) + .resource( + SpaceQuotaDefinitionResource + .builder() + .from(expectedSpaceQuotaDefinitionResource1()).build() + ) + .resource( + SpaceQuotaDefinitionResource + .builder() + .from(expectedSpaceQuotaDefinitionResource2()).build() + ) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + void update() { + mockRequest( + InteractionContext.builder() + .request( + TestRequest.builder() + .method(PATCH) + .path("/space_quotas/" + EXPECTED_SPACE_QUOTA_ID_1) + .payload( + "fixtures/client/v3/space_quotas/PATCH_{id}_request.json") + .build()) + .response( + TestResponse.builder() + .status(OK) + .payload( + "fixtures/client/v3/space_quotas/PATCH_{id}_response.json") + .build()) + .build()); + + this.spaceQuotaDefinitionsV3 + .update( + UpdateSpaceQuotaDefinitionRequest.builder() + .spaceQuotaDefinitionId(EXPECTED_SPACE_QUOTA_ID_1) + .build()) + .as(StepVerifier::create) + .expectNext( + UpdateSpaceQuotaDefinitionResponse.builder() + .from(expectedSpaceQuotaDefinitionResource1()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @NotNull + private static SpaceQuotaDefinitionResource expectedSpaceQuotaDefinitionResource1() { + return buildSpaceQuotaDefinitionResource(EXPECTED_SPACE_QUOTA_ID_1, "my-quota", "9b370018-c38e-44c9-86d6-155c76801104", "dcfd6a55-62b9-496e-a26f-0064cec076bf"); + } + + private static SpaceQuotaDefinitionResource expectedSpaceQuotaDefinitionResource2() { + return buildSpaceQuotaDefinitionResource("bb49bf20-ad98-4729-93ae-38fbc564b630", "my-quota-2", "9b370018-c38e-44c9-86d6-155c76801104", null); + } + + @NotNull + private static SpaceQuotaDefinitionResource buildSpaceQuotaDefinitionResource(String id, String name, String relatedOrganizationId, String relatedSpaceId) { + + Apps apps = Apps.builder() + .totalMemoryInMb(5120) + .perProcessMemoryInMb(1024) + .totalInstances(10) + .perAppTasks(5) + .build(); + Services services = Services.builder() + .isPaidServicesAllowed(true) + .totalServiceInstances(10) + .totalServiceKeys(20) + .build(); + Routes routes = Routes.builder() + .totalRoutes(8) + .totalReservedPorts(4) + .build(); + + ToOneRelationship organizationRelationship = ToOneRelationship.builder() + .data( + Relationship + .builder() + .id(relatedOrganizationId) + .build()) + .build(); + ToManyRelationship spaceRelationships = ToManyRelationship.builder().data(Collections.emptyList()).build(); + if (relatedSpaceId != null) { + spaceRelationships = ToManyRelationship.builder() + .data( + Collections.singletonList( + Relationship + .builder() + .id(relatedSpaceId) + .build())) + .build(); + } + SpaceQuotaDefinitionRelationships relationships = + SpaceQuotaDefinitionRelationships + .builder() + .organization(organizationRelationship) + .spaces(spaceRelationships) + .build(); + + return SpaceQuotaDefinitionResource.builder() + .createdAt("2016-05-04T17:00:41Z") + .id(id) + .link( + "self", + Link.builder() + .href("https://api.example.org/v3/space_quotas/" + id) + .build()) + .link("organization", + Link.builder() + .href("https://api.example.org/v3/organizations/" + relatedOrganizationId) + .build()) + .name(name) + .updatedAt("2016-05-04T18:00:41Z") + .apps(apps) + .services(services) + .routes(routes) + .relationships(relationships) + .build(); + } +} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_response.json new file mode 100644 index 0000000000..c695fa74b7 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_response.json @@ -0,0 +1,98 @@ +{ + "pagination": { + "total_results": 2, + "total_pages": 1, + "first": { + "href": "https://api.example.org/v3/space_quotas?page=1&per_page=50" + }, + "last": { + "href": "https://api.example.org/v3/space_quotas?page=1&per_page=50" + }, + "next": null, + "previous": null + }, + "resources": [ + { + "guid": "f919ef8a-e333-472a-8172-baaf2c30d301", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T18:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "relationships": { + "organization": { + "data": { + "guid": "9b370018-c38e-44c9-86d6-155c76801104" + } + }, + "spaces": { + "data": [ + { + "guid": "dcfd6a55-62b9-496e-a26f-0064cec076bf" + } + ] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/space_quotas/f919ef8a-e333-472a-8172-baaf2c30d301" + }, + "organization": { + "href": "https://api.example.org/v3/organizations/9b370018-c38e-44c9-86d6-155c76801104" + } + } + }, + { + "guid": "bb49bf20-ad98-4729-93ae-38fbc564b630", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T18:00:41Z", + "name": "my-quota-2", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "relationships": { + "organization": { + "data": { + "guid": "9b370018-c38e-44c9-86d6-155c76801104" + } + }, + "spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/space_quotas/bb49bf20-ad98-4729-93ae-38fbc564b630" + }, + "organization": { + "href": "https://api.example.org/v3/organizations/9b370018-c38e-44c9-86d6-155c76801104" + } + } + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_{id}_response.json new file mode 100644 index 0000000000..c90b41bbd2 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/GET_{id}_response.json @@ -0,0 +1,43 @@ +{ + "guid": "f919ef8a-e333-472a-8172-baaf2c30d301", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T18:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "relationships": { + "organization": { + "data": { + "guid": "9b370018-c38e-44c9-86d6-155c76801104" + } + }, + "spaces": { + "data": [ + { + "guid": "dcfd6a55-62b9-496e-a26f-0064cec076bf" + } + ] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/space_quotas/f919ef8a-e333-472a-8172-baaf2c30d301" + }, + "organization": { + "href": "https://api.example.org/v3/organizations/9b370018-c38e-44c9-86d6-155c76801104" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_request.json new file mode 100644 index 0000000000..7a73a41bfd --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_request.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_response.json new file mode 100644 index 0000000000..c90b41bbd2 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/PATCH_{id}_response.json @@ -0,0 +1,43 @@ +{ + "guid": "f919ef8a-e333-472a-8172-baaf2c30d301", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T18:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "relationships": { + "organization": { + "data": { + "guid": "9b370018-c38e-44c9-86d6-155c76801104" + } + }, + "spaces": { + "data": [ + { + "guid": "dcfd6a55-62b9-496e-a26f-0064cec076bf" + } + ] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/space_quotas/f919ef8a-e333-472a-8172-baaf2c30d301" + }, + "organization": { + "href": "https://api.example.org/v3/organizations/9b370018-c38e-44c9-86d6-155c76801104" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_request.json new file mode 100644 index 0000000000..59745ba5ea --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_request.json @@ -0,0 +1,17 @@ +{ + "name": "my-quota", + "relationships": { + "organization": { + "data": { + "guid": "9b370018-c38e-44c9-86d6-155c76801104" + } + }, + "spaces": { + "data": [ + { + "guid": "dcfd6a55-62b9-496e-a26f-0064cec076bf" + } + ] + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_response.json new file mode 100644 index 0000000000..883b8ef463 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/space_quotas/POST_response.json @@ -0,0 +1,43 @@ +{ + "guid": "f919ef8a-e333-472a-8172-baaf2c30d301", + "created_at": "2016-05-04T17:00:41Z", + "updated_at": "2016-05-04T18:00:41Z", + "name": "my-quota", + "apps": { + "total_memory_in_mb": 5120, + "per_process_memory_in_mb": 1024, + "total_instances": 10, + "per_app_tasks": 5 + }, + "services": { + "paid_services_allowed": true, + "total_service_instances": 10, + "total_service_keys": 20 + }, + "routes": { + "total_routes": 8, + "total_reserved_ports": 4 + }, + "relationships": { + "organization": { + "data": { + "guid": "9b370018-c38e-44c9-86d6-155c76801104" + } + }, + "spaces": { + "data": [ + { + "guid": "dcfd6a55-62b9-496e-a26f-0064cec076bf" + } + ] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/space_quotas/f919ef8a-e333-472a-8172-baaf2c30d301" + }, + "organization": { + "href": "https://api.example.org/v3/organizations/9b370018-c38e-44c9-86d6-155c76801104" + } + } +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java index b2c9106935..c0d27d8dd6 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinition.java @@ -52,11 +52,10 @@ public abstract class SpaceQuotaDefinition extends Resource { @Nullable abstract Routes getRoutes(); - /** - * A relationship to the organizations where the quota is applied + * A relationship to the space where the quota is applied + * A space quota must have a relationship to an organization */ @JsonProperty("relationships") - @Nullable abstract SpaceQuotaDefinitionRelationships getRelationships(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java index a26fb4e6a4..9400adcba2 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_SpaceQuotaDefinitionRelationships.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.ToOneRelationship; import org.immutables.value.Value; /** @@ -33,8 +34,8 @@ abstract class _SpaceQuotaDefinitionRelationships { /** * A relationship to the organization where the quota belongs */ - @JsonProperty("organizations") - abstract ToManyRelationship getOrganizations(); + @JsonProperty("organization") + abstract ToOneRelationship getOrganization(); /** * A relationship to the spaces where the quota is applied diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java index 61c4f2fb10..e5c94b238b 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java @@ -17,7 +17,7 @@ package org.cloudfoundry.client.v3.spacequotadefinitions; import org.cloudfoundry.client.v3.Relationship; -import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.ToOneRelationship; import org.junit.jupiter.api.Test; import java.util.UUID; @@ -44,9 +44,9 @@ void noOrganizationsRelationship() { void valid() { String organizationGuid = UUID.randomUUID().toString(); - ToManyRelationship organizationsRelationship = ToManyRelationship.builder().data(Relationship.builder().id(organizationGuid).build()).build(); + ToOneRelationship organizationsRelationship = ToOneRelationship.builder().data(Relationship.builder().id(organizationGuid).build()).build(); SpaceQuotaDefinitionRelationships relationships = SpaceQuotaDefinitionRelationships.builder() - .organizations(organizationsRelationship) + .organization(organizationsRelationship) .build(); CreateSpaceQuotaDefinitionRequest.builder().name("test-quota").relationships(relationships).build(); } From d14263e5ae4e48110616741b0a570d86a2990b3b Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Mon, 15 Sep 2025 12:55:43 -0700 Subject: [PATCH 15/19] integration test for SpaceQuotaDefinitionsV3 covering create, get, list, update and delete operations --- .../v3/spacequotadefinitions/_Apps.java | 7 + .../_CreateSpaceQuotaDefinitionRequest.java | 3 - .../_UpdateSpaceQuotaDefinitionRequest.java | 3 - .../client/v3/SpaceQuotaDefinitionsTest.java | 230 ++++++++++++++++++ 4 files changed, 237 insertions(+), 6 deletions(-) create mode 100644 integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java index 91a88171fa..732afd6ae2 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_Apps.java @@ -52,6 +52,13 @@ abstract class _Apps { @Nullable abstract Integer getTotalInstances(); + /** + * Total log rate limit allowed for all the started processes and running tasks in a space + */ + @JsonProperty("log_rate_limit_in_bytes_per_second") + @Nullable + abstract Integer getLogRateLimitInBytesPerSecond(); + /** * Maximum number of running tasks in a space * @return the maximum number of running tasks in a space diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java index 627625e4f4..e8d2fd207e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_CreateSpaceQuotaDefinitionRequest.java @@ -19,9 +19,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.cloudfoundry.Nullable; -import org.cloudfoundry.client.v3.organizationquotadefinitions.Apps; -import org.cloudfoundry.client.v3.organizationquotadefinitions.Routes; -import org.cloudfoundry.client.v3.organizationquotadefinitions.Services; import org.immutables.value.Value; /** diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java index 153e5ce654..ec10a0786b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/_UpdateSpaceQuotaDefinitionRequest.java @@ -20,9 +20,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.cloudfoundry.Nullable; -import org.cloudfoundry.client.v3.organizationquotadefinitions.Apps; -import org.cloudfoundry.client.v3.organizationquotadefinitions.Routes; -import org.cloudfoundry.client.v3.organizationquotadefinitions.Services; import org.immutables.value.Value; /** diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java new file mode 100644 index 0000000000..18812892d1 --- /dev/null +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java @@ -0,0 +1,230 @@ +/* + * Copyright 2013-2021 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 org.cloudfoundry.AbstractIntegrationTest; +import org.cloudfoundry.CloudFoundryVersion; +import org.cloudfoundry.IfCloudFoundryVersion; +import org.cloudfoundry.client.CloudFoundryClient; +import org.cloudfoundry.client.v3.organizations.CreateOrganizationRequest; +import org.cloudfoundry.client.v3.organizations.Organization; +import org.cloudfoundry.client.v3.spacequotadefinitions.Apps; +import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.DeleteSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.GetSpaceQuotaDefinitionResponse; +import org.cloudfoundry.client.v3.spacequotadefinitions.ListSpaceQuotaDefinitionsRequest; +import org.cloudfoundry.client.v3.spacequotadefinitions.Routes; +import org.cloudfoundry.client.v3.spacequotadefinitions.Services; +import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionRelationships; +import org.cloudfoundry.client.v3.spacequotadefinitions.SpaceQuotaDefinitionResource; +import org.cloudfoundry.client.v3.spacequotadefinitions.UpdateSpaceQuotaDefinitionRequest; +import org.cloudfoundry.util.JobUtils; +import org.cloudfoundry.util.PaginationUtils; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +import java.time.Duration; + +import static org.assertj.core.api.Assertions.assertThat; + +@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_8) +public final class SpaceQuotaDefinitionsTest extends AbstractIntegrationTest { + + @Autowired + private CloudFoundryClient cloudFoundryClient; + + private String organizationId; + + @BeforeEach + public void createOrganization() { + String orgName = this.nameFactory.getOrganizationName(); + organizationId = createOrganization(this.cloudFoundryClient, orgName).getId(); + } + + @Test + public void create() { + String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); + SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = createSpaceQuotaDefinitionRelationships(organizationId); + + this.cloudFoundryClient + .spaceQuotaDefinitionsV3() + .create(CreateSpaceQuotaDefinitionRequest.builder().name(spaceQuotaName).relationships(spaceQuotaDefinitionRelationships).build()) + .thenMany(requestListSpaceQuotas(this.cloudFoundryClient, spaceQuotaName)) + .single() + .as(StepVerifier::create) + .expectNextCount(1) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void get() { + String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); + + createSpaceQuotaId(this.cloudFoundryClient, spaceQuotaName, organizationId) + .flatMap( + spaceQuotaId -> + this.cloudFoundryClient + .spaceQuotaDefinitionsV3() + .get( + GetSpaceQuotaDefinitionRequest.builder() + .spaceQuotaDefinitionId(spaceQuotaId) + .build())) + .map(GetSpaceQuotaDefinitionResponse::getName) + .as(StepVerifier::create) + .expectNext(spaceQuotaName) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void list() { + String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); + + createSpaceQuota(this.cloudFoundryClient, spaceQuotaName, organizationId) + .thenMany( + PaginationUtils.requestClientV3Resources( + page -> + this.cloudFoundryClient + .spaceQuotaDefinitionsV3() + .list( + ListSpaceQuotaDefinitionsRequest.builder() + .page(page) + .build()))) + .filter(resource -> spaceQuotaName.equals(resource.getName())) + .as(StepVerifier::create) + .expectNextCount(1) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + } + + @Test + public void update() { + String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); + int totalMemoryLimit = 64 * 1024; // 64 GB + + createSpaceQuotaId(this.cloudFoundryClient, spaceQuotaName, organizationId) + .flatMap( + spaceQuotaId -> + this.cloudFoundryClient + .spaceQuotaDefinitionsV3() + .update( + UpdateSpaceQuotaDefinitionRequest.builder() + .spaceQuotaDefinitionId(spaceQuotaId) + .apps(Apps.builder().totalMemoryInMb(totalMemoryLimit).build()) + .routes(Routes.builder().totalRoutes(100).build()) + .services(Services.builder().isPaidServicesAllowed(true).totalServiceInstances(100).build()) + .build())) + .thenMany(requestListSpaceQuotas(this.cloudFoundryClient, spaceQuotaName)) + .as(StepVerifier::create) + .consumeNextWith( + organizationQuotaDefinitionResource -> { + assertThat(organizationQuotaDefinitionResource.getApps().getTotalMemoryInMb()).isEqualTo(totalMemoryLimit); + assertThat(organizationQuotaDefinitionResource.getRoutes().getTotalRoutes()).isEqualTo(100); + assertThat(organizationQuotaDefinitionResource.getServices().getTotalServiceInstances()).isEqualTo(100); + }) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + } + + + @Test + public void delete() { + String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); + + createSpaceQuotaId(this.cloudFoundryClient, spaceQuotaName, organizationId) + .flatMap( + spaceQuotaId -> + this.cloudFoundryClient + .spaceQuotaDefinitionsV3() + .delete( + DeleteSpaceQuotaDefinitionRequest.builder() + .spaceQuotaDefinitionId(spaceQuotaId) + .build()) + .flatMap( + job -> + JobUtils.waitForCompletion( + this.cloudFoundryClient, + Duration.ofMinutes(5), + job))) + .thenMany(requestListSpaceQuotas(this.cloudFoundryClient, spaceQuotaName)) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + + private static Organization createOrganization(CloudFoundryClient cloudFoundryClient, String orgName) { + return cloudFoundryClient.organizationsV3() + .create(CreateOrganizationRequest.builder().name(orgName).build()) + .block(Duration.ofMinutes(5)); + + } + + @NotNull + private static SpaceQuotaDefinitionRelationships createSpaceQuotaDefinitionRelationships(String orgGuid) { + ToOneRelationship organizationRelationship = ToOneRelationship + .builder() + .data(Relationship.builder().id(orgGuid).build()) + .build(); + return SpaceQuotaDefinitionRelationships + .builder() + .organization(organizationRelationship) + .build(); + } + + private static Mono createSpaceQuotaId( + CloudFoundryClient cloudFoundryClient, String spaceQuotaName, String orgGuid) { + return createSpaceQuota(cloudFoundryClient, spaceQuotaName, orgGuid) + .map(CreateSpaceQuotaDefinitionResponse::getId); + } + + private static Mono createSpaceQuota( + CloudFoundryClient cloudFoundryClient, String spaceQuotaName, String orgGuid) { + SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = createSpaceQuotaDefinitionRelationships(orgGuid); + return cloudFoundryClient + .spaceQuotaDefinitionsV3() + .create(CreateSpaceQuotaDefinitionRequest + .builder() + .name(spaceQuotaName) + .relationships(spaceQuotaDefinitionRelationships) + .build() + ); + } + + private static Flux requestListSpaceQuotas( + CloudFoundryClient cloudFoundryClient, String spaceName) { + return PaginationUtils.requestClientV3Resources( + page -> + cloudFoundryClient + .spaceQuotaDefinitionsV3() + .list( + ListSpaceQuotaDefinitionsRequest.builder() + .name(spaceName) + .page(page) + .build())); + } +} From 1d27f96de17724a0cce18e07da523eab3a7f2279 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Mon, 15 Sep 2025 13:37:57 -0700 Subject: [PATCH 16/19] running spotless:apply to fix formatting issues --- .../SpaceQuotaDefinitionsV3.java | 15 +-- ...CreateSpaceQuotaDefinitionRequestTest.java | 22 +++-- ...DeleteSpaceQuotaDefinitionRequestTest.java | 4 +- .../GetSpaceQuotaDefinitionRequestTest.java | 4 +- ...UpdateSpaceQuotaDefinitionRequestTest.java | 4 +- .../java/org/cloudfoundry/NameFactory.java | 1 - .../client/v3/SpaceQuotaDefinitionsTest.java | 95 ++++++++++++------- 7 files changed, 84 insertions(+), 61 deletions(-) diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java index dc3714d5f9..b97326da11 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spacequotadefinitions/SpaceQuotaDefinitionsV3.java @@ -30,8 +30,7 @@ public interface SpaceQuotaDefinitionsV3 { * @param request the Create Space Quota Definition request * @return the response from the Create Space Quota Definition request */ - Mono create( - CreateSpaceQuotaDefinitionRequest request); + Mono create(CreateSpaceQuotaDefinitionRequest request); /** * Makes the Get Space Quota @@ -40,8 +39,7 @@ Mono create( * @param request the Get Space Quota Definition request * @return the response from the Get Space Quota request */ - Mono get( - GetSpaceQuotaDefinitionRequest request); + Mono get(GetSpaceQuotaDefinitionRequest request); /** * Makes the List all Space Quota Definitions @@ -50,8 +48,7 @@ Mono get( * @param request the List all Space Quota Definitions request * @return the response from the Space all Organization Quota Definitions request */ - Mono list( - ListSpaceQuotaDefinitionsRequest request); + Mono list(ListSpaceQuotaDefinitionsRequest request); /** Makes the Update Space Quota Definition * request @@ -59,8 +56,7 @@ Mono list( * @param request the Update Space Quota Definition request * @return the response from the Update Space Quota Definition request */ - Mono update( - UpdateSpaceQuotaDefinitionRequest request); + Mono update(UpdateSpaceQuotaDefinitionRequest request); /** * Makes the Delete Space Quota Definition @@ -69,6 +65,5 @@ Mono update( * @param request the Delete Space Quota Definition request * @return the response from the Space Organization Quota Definition request */ - Mono delete( - DeleteSpaceQuotaDefinitionRequest request); + Mono delete(DeleteSpaceQuotaDefinitionRequest request); } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java index e5c94b238b..d2d10b68ea 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/CreateSpaceQuotaDefinitionRequestTest.java @@ -16,14 +16,13 @@ package org.cloudfoundry.client.v3.spacequotadefinitions; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.UUID; import org.cloudfoundry.client.v3.Relationship; import org.cloudfoundry.client.v3.ToOneRelationship; import org.junit.jupiter.api.Test; -import java.util.UUID; - -import static org.junit.jupiter.api.Assertions.assertThrows; - final class CreateSpaceQuotaDefinitionRequestTest { @Test @@ -44,10 +43,17 @@ void noOrganizationsRelationship() { void valid() { String organizationGuid = UUID.randomUUID().toString(); - ToOneRelationship organizationsRelationship = ToOneRelationship.builder().data(Relationship.builder().id(organizationGuid).build()).build(); - SpaceQuotaDefinitionRelationships relationships = SpaceQuotaDefinitionRelationships.builder() - .organization(organizationsRelationship) + ToOneRelationship organizationsRelationship = + ToOneRelationship.builder() + .data(Relationship.builder().id(organizationGuid).build()) + .build(); + SpaceQuotaDefinitionRelationships relationships = + SpaceQuotaDefinitionRelationships.builder() + .organization(organizationsRelationship) + .build(); + CreateSpaceQuotaDefinitionRequest.builder() + .name("test-quota") + .relationships(relationships) .build(); - CreateSpaceQuotaDefinitionRequest.builder().name("test-quota").relationships(relationships).build(); } } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java index 0d45fa7c86..f38f48ad69 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/DeleteSpaceQuotaDefinitionRequestTest.java @@ -16,10 +16,10 @@ package org.cloudfoundry.client.v3.spacequotadefinitions; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + final class DeleteSpaceQuotaDefinitionRequestTest { @Test diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java index b231eb3414..5141b92ef4 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/GetSpaceQuotaDefinitionRequestTest.java @@ -16,10 +16,10 @@ package org.cloudfoundry.client.v3.spacequotadefinitions; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + final class GetSpaceQuotaDefinitionRequestTest { @Test diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java index 9fc8b853ac..d5ea3e7c08 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/spacequotadefinitions/UpdateSpaceQuotaDefinitionRequestTest.java @@ -16,10 +16,10 @@ package org.cloudfoundry.client.v3.spacequotadefinitions; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + final class UpdateSpaceQuotaDefinitionRequestTest { @Test diff --git a/integration-test/src/test/java/org/cloudfoundry/NameFactory.java b/integration-test/src/test/java/org/cloudfoundry/NameFactory.java index 294dd78c8a..c09ee844c6 100644 --- a/integration-test/src/test/java/org/cloudfoundry/NameFactory.java +++ b/integration-test/src/test/java/org/cloudfoundry/NameFactory.java @@ -200,7 +200,6 @@ default String getOrganizationQuotaName() { return getName(ORGANIZATION_QUOTA_PREFIX); } - /** * Creates a password * diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java index 18812892d1..42ed7fea16 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java @@ -16,6 +16,9 @@ package org.cloudfoundry.client.v3; +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.Duration; import org.cloudfoundry.AbstractIntegrationTest; import org.cloudfoundry.CloudFoundryVersion; import org.cloudfoundry.IfCloudFoundryVersion; @@ -44,15 +47,10 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import java.time.Duration; - -import static org.assertj.core.api.Assertions.assertThat; - @IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_8) public final class SpaceQuotaDefinitionsTest extends AbstractIntegrationTest { - @Autowired - private CloudFoundryClient cloudFoundryClient; + @Autowired private CloudFoundryClient cloudFoundryClient; private String organizationId; @@ -65,11 +63,16 @@ public void createOrganization() { @Test public void create() { String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); - SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = createSpaceQuotaDefinitionRelationships(organizationId); + SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = + createSpaceQuotaDefinitionRelationships(organizationId); this.cloudFoundryClient .spaceQuotaDefinitionsV3() - .create(CreateSpaceQuotaDefinitionRequest.builder().name(spaceQuotaName).relationships(spaceQuotaDefinitionRelationships).build()) + .create( + CreateSpaceQuotaDefinitionRequest.builder() + .name(spaceQuotaName) + .relationships(spaceQuotaDefinitionRelationships) + .build()) .thenMany(requestListSpaceQuotas(this.cloudFoundryClient, spaceQuotaName)) .single() .as(StepVerifier::create) @@ -117,13 +120,12 @@ public void list() { .expectNextCount(1) .expectComplete() .verify(Duration.ofMinutes(5)); - } @Test public void update() { String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); - int totalMemoryLimit = 64 * 1024; // 64 GB + int totalMemoryLimit = 64 * 1024; // 64 GB createSpaceQuotaId(this.cloudFoundryClient, spaceQuotaName, organizationId) .flatMap( @@ -133,24 +135,45 @@ public void update() { .update( UpdateSpaceQuotaDefinitionRequest.builder() .spaceQuotaDefinitionId(spaceQuotaId) - .apps(Apps.builder().totalMemoryInMb(totalMemoryLimit).build()) - .routes(Routes.builder().totalRoutes(100).build()) - .services(Services.builder().isPaidServicesAllowed(true).totalServiceInstances(100).build()) + .apps( + Apps.builder() + .totalMemoryInMb( + totalMemoryLimit) + .build()) + .routes( + Routes.builder() + .totalRoutes(100) + .build()) + .services( + Services.builder() + .isPaidServicesAllowed(true) + .totalServiceInstances(100) + .build()) .build())) .thenMany(requestListSpaceQuotas(this.cloudFoundryClient, spaceQuotaName)) .as(StepVerifier::create) .consumeNextWith( organizationQuotaDefinitionResource -> { - assertThat(organizationQuotaDefinitionResource.getApps().getTotalMemoryInMb()).isEqualTo(totalMemoryLimit); - assertThat(organizationQuotaDefinitionResource.getRoutes().getTotalRoutes()).isEqualTo(100); - assertThat(organizationQuotaDefinitionResource.getServices().getTotalServiceInstances()).isEqualTo(100); + assertThat( + organizationQuotaDefinitionResource + .getApps() + .getTotalMemoryInMb()) + .isEqualTo(totalMemoryLimit); + assertThat( + organizationQuotaDefinitionResource + .getRoutes() + .getTotalRoutes()) + .isEqualTo(100); + assertThat( + organizationQuotaDefinitionResource + .getServices() + .getTotalServiceInstances()) + .isEqualTo(100); }) .expectComplete() .verify(Duration.ofMinutes(5)); - } - @Test public void delete() { String spaceQuotaName = this.nameFactory.getQuotaDefinitionName(); @@ -176,22 +199,22 @@ public void delete() { .verify(Duration.ofMinutes(5)); } - - private static Organization createOrganization(CloudFoundryClient cloudFoundryClient, String orgName) { - return cloudFoundryClient.organizationsV3() + private static Organization createOrganization( + CloudFoundryClient cloudFoundryClient, String orgName) { + return cloudFoundryClient + .organizationsV3() .create(CreateOrganizationRequest.builder().name(orgName).build()) .block(Duration.ofMinutes(5)); - } @NotNull - private static SpaceQuotaDefinitionRelationships createSpaceQuotaDefinitionRelationships(String orgGuid) { - ToOneRelationship organizationRelationship = ToOneRelationship - .builder() - .data(Relationship.builder().id(orgGuid).build()) - .build(); - return SpaceQuotaDefinitionRelationships - .builder() + private static SpaceQuotaDefinitionRelationships createSpaceQuotaDefinitionRelationships( + String orgGuid) { + ToOneRelationship organizationRelationship = + ToOneRelationship.builder() + .data(Relationship.builder().id(orgGuid).build()) + .build(); + return SpaceQuotaDefinitionRelationships.builder() .organization(organizationRelationship) .build(); } @@ -204,15 +227,15 @@ private static Mono createSpaceQuotaId( private static Mono createSpaceQuota( CloudFoundryClient cloudFoundryClient, String spaceQuotaName, String orgGuid) { - SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = createSpaceQuotaDefinitionRelationships(orgGuid); + SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = + createSpaceQuotaDefinitionRelationships(orgGuid); return cloudFoundryClient .spaceQuotaDefinitionsV3() - .create(CreateSpaceQuotaDefinitionRequest - .builder() - .name(spaceQuotaName) - .relationships(spaceQuotaDefinitionRelationships) - .build() - ); + .create( + CreateSpaceQuotaDefinitionRequest.builder() + .name(spaceQuotaName) + .relationships(spaceQuotaDefinitionRelationships) + .build()); } private static Flux requestListSpaceQuotas( From 7cb5cc1846d75355f35c88575839b98967864ba5 Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Tue, 16 Sep 2025 12:00:34 -0700 Subject: [PATCH 17/19] running spotless:apply to format the files --- ...ReactorOrganizationQuotaDefinitionsV3.java | 56 +++--- .../ReactorSpaceQuotaDefinitionsV3.java | 47 +++--- ...torOrganizationQuotaDefinitionsV3Test.java | 130 +++++++------- .../ReactorSpaceQuotaDefinitionsV3Test.java | 159 ++++++++++-------- .../OrganizationQuotaDefinitionsV3.java | 6 +- ...rganizationQuotaDefinitionRequestTest.java | 4 +- ...rganizationQuotaDefinitionRequestTest.java | 8 +- ...rganizationQuotaDefinitionRequestTest.java | 8 +- ...rganizationQuotaDefinitionRequestTest.java | 8 +- .../v3/OrganizationQuotaDefinitionsTest.java | 92 +++++++--- 10 files changed, 297 insertions(+), 221 deletions(-) diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java index f07d12cd4c..4d4fb69a49 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3.java @@ -16,6 +16,7 @@ package org.cloudfoundry.reactor.client.v3.organizationquotadefinitions; +import java.util.Map; import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionRequest; import org.cloudfoundry.client.v3.organizationquotadefinitions.CreateOrganizationQuotaDefinitionResponse; import org.cloudfoundry.client.v3.organizationquotadefinitions.DeleteOrganizationQuotaDefinitionRequest; @@ -31,8 +32,6 @@ import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; import reactor.core.publisher.Mono; -import java.util.Map; - /** * The Reactor-based implementation of {@link ReactorOrganizationQuotaDefinitionsV3} */ @@ -56,50 +55,59 @@ public ReactorOrganizationQuotaDefinitionsV3( } @Override - public Mono create(CreateOrganizationQuotaDefinitionRequest request) { + public Mono create( + CreateOrganizationQuotaDefinitionRequest request) { return post( - request, - CreateOrganizationQuotaDefinitionResponse.class, - builder -> builder.pathSegment("organization_quotas")) + request, + CreateOrganizationQuotaDefinitionResponse.class, + builder -> builder.pathSegment("organization_quotas")) .checkpoint(); } @Override - public Mono get(GetOrganizationQuotaDefinitionRequest request) { + public Mono get( + GetOrganizationQuotaDefinitionRequest request) { return get( - request, - GetOrganizationQuotaDefinitionResponse.class, - builder -> - builder.pathSegment("organization_quotas", request.getOrganizationQuotaDefinitionId())) + request, + GetOrganizationQuotaDefinitionResponse.class, + builder -> + builder.pathSegment( + "organization_quotas", + request.getOrganizationQuotaDefinitionId())) .checkpoint(); } - @Override - public Mono list(ListOrganizationQuotaDefinitionsRequest request) { + public Mono list( + ListOrganizationQuotaDefinitionsRequest request) { return get( - request, - ListOrganizationQuotaDefinitionsResponse.class, - builder -> builder.pathSegment("organization_quotas")) + request, + ListOrganizationQuotaDefinitionsResponse.class, + builder -> builder.pathSegment("organization_quotas")) .checkpoint(); } @Override - public Mono update(UpdateOrganizationQuotaDefinitionRequest request) { + public Mono update( + UpdateOrganizationQuotaDefinitionRequest request) { return patch( - request, - UpdateOrganizationQuotaDefinitionResponse.class, - builder -> - builder.pathSegment("organization_quotas", request.getOrganizationQuotaDefinitionId())) + request, + UpdateOrganizationQuotaDefinitionResponse.class, + builder -> + builder.pathSegment( + "organization_quotas", + request.getOrganizationQuotaDefinitionId())) .checkpoint(); } @Override public Mono delete(DeleteOrganizationQuotaDefinitionRequest request) { return delete( - request, - builder -> - builder.pathSegment("organization_quotas", request.getOrganizationQuotaDefinitionId())) + request, + builder -> + builder.pathSegment( + "organization_quotas", + request.getOrganizationQuotaDefinitionId())) .checkpoint(); } } diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java index 8198fae625..ffd4f11997 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3.java @@ -16,6 +16,7 @@ package org.cloudfoundry.reactor.client.v3.spacequotadefinition; +import java.util.Map; import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionRequest; import org.cloudfoundry.client.v3.spacequotadefinitions.CreateSpaceQuotaDefinitionResponse; import org.cloudfoundry.client.v3.spacequotadefinitions.DeleteSpaceQuotaDefinitionRequest; @@ -31,8 +32,6 @@ import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; import reactor.core.publisher.Mono; -import java.util.Map; - /** * The Reactor-based implementation of {@link ReactorSpaceQuotaDefinitionsV3} */ @@ -56,50 +55,54 @@ public ReactorSpaceQuotaDefinitionsV3( } @Override - public Mono create(CreateSpaceQuotaDefinitionRequest request) { + public Mono create( + CreateSpaceQuotaDefinitionRequest request) { return post( - request, - CreateSpaceQuotaDefinitionResponse.class, - builder -> builder.pathSegment("space_quotas")) + request, + CreateSpaceQuotaDefinitionResponse.class, + builder -> builder.pathSegment("space_quotas")) .checkpoint(); } @Override public Mono get(GetSpaceQuotaDefinitionRequest request) { return get( - request, - GetSpaceQuotaDefinitionResponse.class, - builder -> - builder.pathSegment("space_quotas", request.getSpaceQuotaDefinitionId())) + request, + GetSpaceQuotaDefinitionResponse.class, + builder -> + builder.pathSegment( + "space_quotas", request.getSpaceQuotaDefinitionId())) .checkpoint(); } @Override public Mono list(ListSpaceQuotaDefinitionsRequest request) { return get( - request, - ListSpaceQuotaDefinitionsResponse.class, - builder -> builder.pathSegment("space_quotas")) + request, + ListSpaceQuotaDefinitionsResponse.class, + builder -> builder.pathSegment("space_quotas")) .checkpoint(); } @Override - public Mono update(UpdateSpaceQuotaDefinitionRequest request) { + public Mono update( + UpdateSpaceQuotaDefinitionRequest request) { return patch( - request, - UpdateSpaceQuotaDefinitionResponse.class, - builder -> - builder.pathSegment("space_quotas", request.getSpaceQuotaDefinitionId())) + request, + UpdateSpaceQuotaDefinitionResponse.class, + builder -> + builder.pathSegment( + "space_quotas", request.getSpaceQuotaDefinitionId())) .checkpoint(); } @Override public Mono delete(DeleteSpaceQuotaDefinitionRequest request) { return delete( - request, - builder -> - builder.pathSegment("space_quotas", request.getSpaceQuotaDefinitionId())) + request, + builder -> + builder.pathSegment( + "space_quotas", request.getSpaceQuotaDefinitionId())) .checkpoint(); } - } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java index ff45ee68e1..60cd7eebdb 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/organizationquotadefinitions/ReactorOrganizationQuotaDefinitionsV3Test.java @@ -16,6 +16,15 @@ package org.cloudfoundry.reactor.client.v3.organizationquotadefinitions; +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.PATCH; +import static io.netty.handler.codec.http.HttpMethod.POST; +import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; +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.Relationship; @@ -43,16 +52,6 @@ import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; -import java.time.Duration; -import java.util.Collections; - -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.PATCH; -import static io.netty.handler.codec.http.HttpMethod.POST; -import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; -import static io.netty.handler.codec.http.HttpResponseStatus.OK; - class ReactorOrganizationQuotaDefinitionsV3Test extends AbstractClientApiTest { private final ReactorOrganizationQuotaDefinitionsV3 organizationQuotaDefinitionsV3 = @@ -82,11 +81,9 @@ void create() { .create(CreateOrganizationQuotaDefinitionRequest.builder().name("my-quota").build()) .as(StepVerifier::create) .expectNext( - CreateOrganizationQuotaDefinitionResponse - .builder() + CreateOrganizationQuotaDefinitionResponse.builder() .from(expectedOrganizationQuotaDefinitionResource1()) - .build() - ) + .build()) .expectComplete() .verify(Duration.ofSeconds(5)); } @@ -127,7 +124,8 @@ void get() { .request( TestRequest.builder() .method(GET) - .path("/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52") + .path( + "/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52") .build()) .response( TestResponse.builder() @@ -140,7 +138,8 @@ void get() { this.organizationQuotaDefinitionsV3 .get( GetOrganizationQuotaDefinitionRequest.builder() - .organizationQuotaDefinitionId("24637893-3b77-489d-bb79-8466f0d88b52") + .organizationQuotaDefinitionId( + "24637893-3b77-489d-bb79-8466f0d88b52") .build()) .as(StepVerifier::create) .expectNext( @@ -155,7 +154,11 @@ void get() { void list() { mockRequest( InteractionContext.builder() - .request(TestRequest.builder().method(GET).path("/organization_quotas").build()) + .request( + TestRequest.builder() + .method(GET) + .path("/organization_quotas") + .build()) .response( TestResponse.builder() .status(OK) @@ -185,15 +188,15 @@ void list() { .build()) .build()) .resource( - OrganizationQuotaDefinitionResource - .builder() - .from(expectedOrganizationQuotaDefinitionResource1()).build() - ) + OrganizationQuotaDefinitionResource.builder() + .from( + expectedOrganizationQuotaDefinitionResource1()) + .build()) .resource( - OrganizationQuotaDefinitionResource - .builder() - .from(expectedOrganizationQuotaDefinitionResource2()).build() - ) + OrganizationQuotaDefinitionResource.builder() + .from( + expectedOrganizationQuotaDefinitionResource2()) + .build()) .build()) .expectComplete() .verify(Duration.ofSeconds(5)); @@ -206,7 +209,8 @@ void update() { .request( TestRequest.builder() .method(PATCH) - .path("/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52") + .path( + "/organization_quotas/24637893-3b77-489d-bb79-8466f0d88b52") .payload( "fixtures/client/v3/organization_quotas/PATCH_{id}_request.json") .build()) @@ -221,7 +225,8 @@ void update() { this.organizationQuotaDefinitionsV3 .update( UpdateOrganizationQuotaDefinitionRequest.builder() - .organizationQuotaDefinitionId("24637893-3b77-489d-bb79-8466f0d88b52") + .organizationQuotaDefinitionId( + "24637893-3b77-489d-bb79-8466f0d88b52") .build()) .as(StepVerifier::create) .expectNext( @@ -233,47 +238,50 @@ void update() { } @NotNull - private static OrganizationQuotaDefinitionResource expectedOrganizationQuotaDefinitionResource1() { - return buildOrganizationQuotaDefinitionResource("24637893-3b77-489d-bb79-8466f0d88b52", "my-quota", "9b370018-c38e-44c9-86d6-155c76801104"); + private static OrganizationQuotaDefinitionResource + expectedOrganizationQuotaDefinitionResource1() { + return buildOrganizationQuotaDefinitionResource( + "24637893-3b77-489d-bb79-8466f0d88b52", + "my-quota", + "9b370018-c38e-44c9-86d6-155c76801104"); } - private static OrganizationQuotaDefinitionResource expectedOrganizationQuotaDefinitionResource2() { - return buildOrganizationQuotaDefinitionResource("bb49bf20-ad98-4729-93ae-38fbc564b630", "my-quota-2", "144251f2-a202-4ffe-ab47-9046c4077e99"); + private static OrganizationQuotaDefinitionResource + expectedOrganizationQuotaDefinitionResource2() { + return buildOrganizationQuotaDefinitionResource( + "bb49bf20-ad98-4729-93ae-38fbc564b630", + "my-quota-2", + "144251f2-a202-4ffe-ab47-9046c4077e99"); } @NotNull - private static OrganizationQuotaDefinitionResource buildOrganizationQuotaDefinitionResource(String id, String name, String relatedOrganizationId) { + private static OrganizationQuotaDefinitionResource buildOrganizationQuotaDefinitionResource( + String id, String name, String relatedOrganizationId) { - Apps apps = Apps.builder() - .totalMemoryInMb(5120) - .perProcessMemoryInMb(1024) - .logRateLimitInBytesPerSecond(1024) - .totalInstances(10) - .perAppTasks(5) - .build(); - Services services = Services.builder() - .isPaidServicesAllowed(true) - .totalServiceInstances(10) - .totalServiceKeys(20) - .build(); - Routes routes = Routes.builder() - .totalRoutes(8) - .totalReservedPorts(4) - .build(); - Domains domains = Domains.builder() - .totalDomains(7) - .build(); - ToManyRelationship organizationRelationships = ToManyRelationship.builder() - .data( - Collections.singletonList( - Relationship - .builder() - .id(relatedOrganizationId) - .build())) - .build(); + Apps apps = + Apps.builder() + .totalMemoryInMb(5120) + .perProcessMemoryInMb(1024) + .logRateLimitInBytesPerSecond(1024) + .totalInstances(10) + .perAppTasks(5) + .build(); + Services services = + Services.builder() + .isPaidServicesAllowed(true) + .totalServiceInstances(10) + .totalServiceKeys(20) + .build(); + Routes routes = Routes.builder().totalRoutes(8).totalReservedPorts(4).build(); + Domains domains = Domains.builder().totalDomains(7).build(); + ToManyRelationship organizationRelationships = + ToManyRelationship.builder() + .data( + Collections.singletonList( + Relationship.builder().id(relatedOrganizationId).build())) + .build(); OrganizationQuotaDefinitionRelationships relationships = - OrganizationQuotaDefinitionRelationships - .builder() + OrganizationQuotaDefinitionRelationships.builder() .organizations(organizationRelationships) .build(); diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java index c2072da56e..79f1a8b68f 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spacequotadefinition/ReactorSpaceQuotaDefinitionsV3Test.java @@ -16,6 +16,15 @@ package org.cloudfoundry.reactor.client.v3.spacequotadefinition; +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.PATCH; +import static io.netty.handler.codec.http.HttpMethod.POST; +import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; +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.Relationship; @@ -43,16 +52,6 @@ import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; -import java.time.Duration; -import java.util.Collections; - -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.PATCH; -import static io.netty.handler.codec.http.HttpMethod.POST; -import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; -import static io.netty.handler.codec.http.HttpResponseStatus.OK; - class ReactorSpaceQuotaDefinitionsV3Test extends AbstractClientApiTest { public static final String EXPECTED_SPACE_QUOTA_ID_1 = "f919ef8a-e333-472a-8172-baaf2c30d301"; @@ -80,28 +79,36 @@ void create() { .build()) .build()); - SpaceQuotaDefinitionRelationships relationships = SpaceQuotaDefinitionRelationships - .builder() - .organization(ToOneRelationship.builder() - .data(Relationship.builder() - .id("9b370018-c38e-44c9-86d6-155c76801104") - .build()) - .build()) - .spaces(ToManyRelationship.builder() - .data(Collections.singletonList(Relationship.builder() - .id("dcfd6a55-62b9-496e-a26f-0064cec076bf") - .build())) - .build()) - .build(); + SpaceQuotaDefinitionRelationships relationships = + SpaceQuotaDefinitionRelationships.builder() + .organization( + ToOneRelationship.builder() + .data( + Relationship.builder() + .id("9b370018-c38e-44c9-86d6-155c76801104") + .build()) + .build()) + .spaces( + ToManyRelationship.builder() + .data( + Collections.singletonList( + Relationship.builder() + .id( + "dcfd6a55-62b9-496e-a26f-0064cec076bf") + .build())) + .build()) + .build(); this.spaceQuotaDefinitionsV3 - .create(CreateSpaceQuotaDefinitionRequest.builder().name("my-quota").relationships(relationships).build()) + .create( + CreateSpaceQuotaDefinitionRequest.builder() + .name("my-quota") + .relationships(relationships) + .build()) .as(StepVerifier::create) .expectNext( - CreateSpaceQuotaDefinitionResponse - .builder() + CreateSpaceQuotaDefinitionResponse.builder() .from(expectedSpaceQuotaDefinitionResource1()) - .build() - ) + .build()) .expectComplete() .verify(Duration.ofSeconds(5)); } @@ -200,15 +207,13 @@ void list() { .build()) .build()) .resource( - SpaceQuotaDefinitionResource - .builder() - .from(expectedSpaceQuotaDefinitionResource1()).build() - ) + SpaceQuotaDefinitionResource.builder() + .from(expectedSpaceQuotaDefinitionResource1()) + .build()) .resource( - SpaceQuotaDefinitionResource - .builder() - .from(expectedSpaceQuotaDefinitionResource2()).build() - ) + SpaceQuotaDefinitionResource.builder() + .from(expectedSpaceQuotaDefinitionResource2()) + .build()) .build()) .expectComplete() .verify(Duration.ofSeconds(5)); @@ -249,53 +254,56 @@ void update() { @NotNull private static SpaceQuotaDefinitionResource expectedSpaceQuotaDefinitionResource1() { - return buildSpaceQuotaDefinitionResource(EXPECTED_SPACE_QUOTA_ID_1, "my-quota", "9b370018-c38e-44c9-86d6-155c76801104", "dcfd6a55-62b9-496e-a26f-0064cec076bf"); + return buildSpaceQuotaDefinitionResource( + EXPECTED_SPACE_QUOTA_ID_1, + "my-quota", + "9b370018-c38e-44c9-86d6-155c76801104", + "dcfd6a55-62b9-496e-a26f-0064cec076bf"); } private static SpaceQuotaDefinitionResource expectedSpaceQuotaDefinitionResource2() { - return buildSpaceQuotaDefinitionResource("bb49bf20-ad98-4729-93ae-38fbc564b630", "my-quota-2", "9b370018-c38e-44c9-86d6-155c76801104", null); + return buildSpaceQuotaDefinitionResource( + "bb49bf20-ad98-4729-93ae-38fbc564b630", + "my-quota-2", + "9b370018-c38e-44c9-86d6-155c76801104", + null); } @NotNull - private static SpaceQuotaDefinitionResource buildSpaceQuotaDefinitionResource(String id, String name, String relatedOrganizationId, String relatedSpaceId) { + private static SpaceQuotaDefinitionResource buildSpaceQuotaDefinitionResource( + String id, String name, String relatedOrganizationId, String relatedSpaceId) { - Apps apps = Apps.builder() - .totalMemoryInMb(5120) - .perProcessMemoryInMb(1024) - .totalInstances(10) - .perAppTasks(5) - .build(); - Services services = Services.builder() - .isPaidServicesAllowed(true) - .totalServiceInstances(10) - .totalServiceKeys(20) - .build(); - Routes routes = Routes.builder() - .totalRoutes(8) - .totalReservedPorts(4) - .build(); + Apps apps = + Apps.builder() + .totalMemoryInMb(5120) + .perProcessMemoryInMb(1024) + .totalInstances(10) + .perAppTasks(5) + .build(); + Services services = + Services.builder() + .isPaidServicesAllowed(true) + .totalServiceInstances(10) + .totalServiceKeys(20) + .build(); + Routes routes = Routes.builder().totalRoutes(8).totalReservedPorts(4).build(); - ToOneRelationship organizationRelationship = ToOneRelationship.builder() - .data( - Relationship - .builder() - .id(relatedOrganizationId) - .build()) - .build(); - ToManyRelationship spaceRelationships = ToManyRelationship.builder().data(Collections.emptyList()).build(); + ToOneRelationship organizationRelationship = + ToOneRelationship.builder() + .data(Relationship.builder().id(relatedOrganizationId).build()) + .build(); + ToManyRelationship spaceRelationships = + ToManyRelationship.builder().data(Collections.emptyList()).build(); if (relatedSpaceId != null) { - spaceRelationships = ToManyRelationship.builder() - .data( - Collections.singletonList( - Relationship - .builder() - .id(relatedSpaceId) - .build())) - .build(); + spaceRelationships = + ToManyRelationship.builder() + .data( + Collections.singletonList( + Relationship.builder().id(relatedSpaceId).build())) + .build(); } SpaceQuotaDefinitionRelationships relationships = - SpaceQuotaDefinitionRelationships - .builder() + SpaceQuotaDefinitionRelationships.builder() .organization(organizationRelationship) .spaces(spaceRelationships) .build(); @@ -308,9 +316,12 @@ private static SpaceQuotaDefinitionResource buildSpaceQuotaDefinitionResource(St Link.builder() .href("https://api.example.org/v3/space_quotas/" + id) .build()) - .link("organization", + .link( + "organization", Link.builder() - .href("https://api.example.org/v3/organizations/" + relatedOrganizationId) + .href( + "https://api.example.org/v3/organizations/" + + relatedOrganizationId) .build()) .name(name) .updatedAt("2016-05-04T18:00:41Z") diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java index 4217d8e2e4..de646a0701 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizationquotadefinitions/OrganizationQuotaDefinitionsV3.java @@ -40,8 +40,7 @@ Mono create( * @param request the Get Organization Quota Definition request * @return the response from the Get Organization Quota Definition request */ - Mono get( - GetOrganizationQuotaDefinitionRequest request); + Mono get(GetOrganizationQuotaDefinitionRequest request); /** * Makes the List all Organization Quota Definitions @@ -69,6 +68,5 @@ Mono update( * @param request the Delete Organization Quota Definition request * @return the response from the Delete Organization Quota Definition request */ - Mono delete( - DeleteOrganizationQuotaDefinitionRequest request); + Mono delete(DeleteOrganizationQuotaDefinitionRequest request); } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java index 0c0f8ca4b7..ea2c622021 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/CreateOrganizationQuotaDefinitionRequestTest.java @@ -16,10 +16,10 @@ package org.cloudfoundry.client.v3.organizationquotadefinitions; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + final class CreateOrganizationQuotaDefinitionRequestTest { @Test diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java index 083f7639f9..b1743c58f2 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/DeleteOrganizationQuotaDefinitionRequestTest.java @@ -16,10 +16,10 @@ package org.cloudfoundry.client.v3.organizationquotadefinitions; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + final class DeleteOrganizationQuotaDefinitionRequestTest { @Test @@ -31,6 +31,8 @@ void noOrganizationId() { @Test void valid() { - DeleteOrganizationQuotaDefinitionRequest.builder().organizationQuotaDefinitionId("test-id").build(); + DeleteOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId("test-id") + .build(); } } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java index 0cfae1e7fb..dd52243e8a 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/GetOrganizationQuotaDefinitionRequestTest.java @@ -16,10 +16,10 @@ package org.cloudfoundry.client.v3.organizationquotadefinitions; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + final class GetOrganizationQuotaDefinitionRequestTest { @Test @@ -31,6 +31,8 @@ void noOrganizationQuotaDefinitionId() { @Test void valid() { - GetOrganizationQuotaDefinitionRequest.builder().organizationQuotaDefinitionId("test-id").build(); + GetOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId("test-id") + .build(); } } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java index 7f35339c4f..d07b80fa3d 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/organizationquotadefinitions/UpdateOrganizationQuotaDefinitionRequestTest.java @@ -16,10 +16,10 @@ package org.cloudfoundry.client.v3.organizationquotadefinitions; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + final class UpdateOrganizationQuotaDefinitionRequestTest { @Test @@ -31,6 +31,8 @@ void noOrganizationId() { @Test void valid() { - UpdateOrganizationQuotaDefinitionRequest.builder().organizationQuotaDefinitionId("test-id").build(); + UpdateOrganizationQuotaDefinitionRequest.builder() + .organizationQuotaDefinitionId("test-id") + .build(); } } diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java index dd55f00fd7..4d73feb726 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/OrganizationQuotaDefinitionsTest.java @@ -16,6 +16,9 @@ package org.cloudfoundry.client.v3; +import static org.assertj.core.api.Assertions.assertThat; + +import java.time.Duration; import org.cloudfoundry.AbstractIntegrationTest; import org.cloudfoundry.CloudFoundryVersion; import org.cloudfoundry.IfCloudFoundryVersion; @@ -39,23 +42,23 @@ import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import java.time.Duration; - -import static org.assertj.core.api.Assertions.assertThat; - @IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_8) public final class OrganizationQuotaDefinitionsTest extends AbstractIntegrationTest { - @Autowired - private CloudFoundryClient cloudFoundryClient; + @Autowired private CloudFoundryClient cloudFoundryClient; @Test public void create() { String organizationQuotaName = this.nameFactory.getOrganizationQuotaName(); this.cloudFoundryClient .organizationQuotaDefinitionsV3() - .create(CreateOrganizationQuotaDefinitionRequest.builder().name(organizationQuotaName).build()) - .thenMany(requestListOrganizationQuotas(this.cloudFoundryClient, organizationQuotaName)) + .create( + CreateOrganizationQuotaDefinitionRequest.builder() + .name(organizationQuotaName) + .build()) + .thenMany( + requestListOrganizationQuotas( + this.cloudFoundryClient, organizationQuotaName)) .single() .as(StepVerifier::create) .expectNextCount(1) @@ -76,7 +79,8 @@ public void delete() { .organizationQuotaDefinitionsV3() .delete( DeleteOrganizationQuotaDefinitionRequest.builder() - .organizationQuotaDefinitionId(organizationId) + .organizationQuotaDefinitionId( + organizationId) .build()) .flatMap( job -> @@ -84,7 +88,9 @@ public void delete() { this.cloudFoundryClient, Duration.ofMinutes(5), job))) - .thenMany(requestListOrganizationQuotas(this.cloudFoundryClient, organizationQuotaName)) + .thenMany( + requestListOrganizationQuotas( + this.cloudFoundryClient, organizationQuotaName)) .as(StepVerifier::create) .expectComplete() .verify(Duration.ofMinutes(5)); @@ -101,7 +107,8 @@ public void get() { .organizationQuotaDefinitionsV3() .get( GetOrganizationQuotaDefinitionRequest.builder() - .organizationQuotaDefinitionId(organizationQuotaId) + .organizationQuotaDefinitionId( + organizationQuotaId) .build())) .map(GetOrganizationQuotaDefinitionResponse::getName) .as(StepVerifier::create) @@ -123,7 +130,8 @@ public void list() { this.cloudFoundryClient .organizationQuotaDefinitionsV3() .list( - ListOrganizationQuotaDefinitionsRequest.builder() + ListOrganizationQuotaDefinitionsRequest + .builder() .page(page) .build()))) .filter(resource -> organizationQuotaName.equals(resource.getName())) @@ -138,7 +146,7 @@ public void list() { @Test public void update() { String organizationQuotaName = this.nameFactory.getOrganizationQuotaName(); - int totalMemoryLimit = 64 * 1024; // 64 GB + int totalMemoryLimit = 64 * 1024; // 64 GB createOrganizationQuotaId(this.cloudFoundryClient, organizationQuotaName) .flatMap( @@ -147,18 +155,44 @@ public void update() { .organizationQuotaDefinitionsV3() .update( UpdateOrganizationQuotaDefinitionRequest.builder() - .organizationQuotaDefinitionId(organizationQuotaId) - .apps(Apps.builder().totalMemoryInMb(totalMemoryLimit).build()) - .routes(Routes.builder().totalRoutes(100).build()) - .services(Services.builder().isPaidServicesAllowed(true).totalServiceInstances(100).build()) + .organizationQuotaDefinitionId( + organizationQuotaId) + .apps( + Apps.builder() + .totalMemoryInMb( + totalMemoryLimit) + .build()) + .routes( + Routes.builder() + .totalRoutes(100) + .build()) + .services( + Services.builder() + .isPaidServicesAllowed(true) + .totalServiceInstances(100) + .build()) .build())) - .thenMany(requestListOrganizationQuotas(this.cloudFoundryClient, organizationQuotaName)) + .thenMany( + requestListOrganizationQuotas( + this.cloudFoundryClient, organizationQuotaName)) .as(StepVerifier::create) .consumeNextWith( organizationQuotaDefinitionResource -> { - assertThat(organizationQuotaDefinitionResource.getApps().getTotalMemoryInMb()).isEqualTo(totalMemoryLimit); - assertThat(organizationQuotaDefinitionResource.getRoutes().getTotalRoutes()).isEqualTo(100); - assertThat(organizationQuotaDefinitionResource.getServices().getTotalServiceInstances()).isEqualTo(100); + assertThat( + organizationQuotaDefinitionResource + .getApps() + .getTotalMemoryInMb()) + .isEqualTo(totalMemoryLimit); + assertThat( + organizationQuotaDefinitionResource + .getRoutes() + .getTotalRoutes()) + .isEqualTo(100); + assertThat( + organizationQuotaDefinitionResource + .getServices() + .getTotalServiceInstances()) + .isEqualTo(100); }) .expectComplete() .verify(Duration.ofMinutes(5)); @@ -175,7 +209,10 @@ private static Mono createOrganizationQuotaId( private static Mono getOrganizationQuotaId( CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { return requestListOrganizationQuotas(cloudFoundryClient, organizationQuotaName) - .filter(organizationQuotaDefinitionResource -> organizationQuotaName.equals(organizationQuotaDefinitionResource.getName())) + .filter( + organizationQuotaDefinitionResource -> + organizationQuotaName.equals( + organizationQuotaDefinitionResource.getName())) .single() .map(OrganizationQuotaDefinitionResource::getId); } @@ -184,7 +221,10 @@ private static Mono requestCreateOrga CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { return cloudFoundryClient .organizationQuotaDefinitionsV3() - .create(CreateOrganizationQuotaDefinitionRequest.builder().name(organizationQuotaName).build()); + .create( + CreateOrganizationQuotaDefinitionRequest.builder() + .name(organizationQuotaName) + .build()); } private static Flux requestListOrganizationQuotas( @@ -200,7 +240,8 @@ private static Flux requestListOrganization .build())); } - private static void deleteOrganizationQuotaId(CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { + private static void deleteOrganizationQuotaId( + CloudFoundryClient cloudFoundryClient, String organizationQuotaName) { getOrganizationQuotaId(cloudFoundryClient, organizationQuotaName) .flatMap( @@ -209,7 +250,8 @@ private static void deleteOrganizationQuotaId(CloudFoundryClient cloudFoundryCli .organizationQuotaDefinitionsV3() .delete( DeleteOrganizationQuotaDefinitionRequest.builder() - .organizationQuotaDefinitionId(organizationId) + .organizationQuotaDefinitionId( + organizationId) .build()) .flatMap( job -> From 0db8b78aad6fff63c1a2be69c272d2880f4bca4b Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Thu, 23 Oct 2025 12:11:21 -0700 Subject: [PATCH 18/19] enhancing SpaceQuotaDefinitionsTest integration test --- .../client/v3/SpaceQuotaDefinitionsTest.java | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java index 42ed7fea16..f49b57246e 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2025 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. @@ -66,17 +66,40 @@ public void create() { SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = createSpaceQuotaDefinitionRelationships(organizationId); + Apps spaceQuotaAppLimits = Apps.builder() + .perProcessMemoryInMb(1024) + .totalMemoryInMb(2048) + .logRateLimitInBytesPerSecond(0) + .build(); + Services spaceQuotaServiceLimits = Services.builder().isPaidServicesAllowed(false).totalServiceInstances(10).build(); + Routes spaceQuotaRouteLimits = Routes.builder().totalRoutes(10).build(); + this.cloudFoundryClient .spaceQuotaDefinitionsV3() .create( CreateSpaceQuotaDefinitionRequest.builder() .name(spaceQuotaName) + .apps(spaceQuotaAppLimits) + .services(spaceQuotaServiceLimits) + .routes(spaceQuotaRouteLimits) .relationships(spaceQuotaDefinitionRelationships) .build()) .thenMany(requestListSpaceQuotas(this.cloudFoundryClient, spaceQuotaName)) .single() .as(StepVerifier::create) - .expectNextCount(1) + .assertNext( + spaceQuotaDefinitionResource -> { + assertThat(spaceQuotaDefinitionResource).isNotNull(); + assertThat(spaceQuotaDefinitionResource.getId()).isNotNull(); + assertThat(spaceQuotaDefinitionResource.getName()) + .isEqualTo(spaceQuotaName); + assertThat(spaceQuotaDefinitionResource.getApps()) + .isEqualTo(spaceQuotaAppLimits); + assertThat(spaceQuotaDefinitionResource.getServices()) + .isEqualTo(spaceQuotaServiceLimits); + assertThat(spaceQuotaDefinitionResource.getRoutes()) + .isEqualTo(spaceQuotaRouteLimits); + }) .expectComplete() .verify(Duration.ofMinutes(5)); } @@ -155,19 +178,19 @@ public void update() { .consumeNextWith( organizationQuotaDefinitionResource -> { assertThat( - organizationQuotaDefinitionResource - .getApps() - .getTotalMemoryInMb()) + organizationQuotaDefinitionResource + .getApps() + .getTotalMemoryInMb()) .isEqualTo(totalMemoryLimit); assertThat( - organizationQuotaDefinitionResource - .getRoutes() - .getTotalRoutes()) + organizationQuotaDefinitionResource + .getRoutes() + .getTotalRoutes()) .isEqualTo(100); assertThat( - organizationQuotaDefinitionResource - .getServices() - .getTotalServiceInstances()) + organizationQuotaDefinitionResource + .getServices() + .getTotalServiceInstances()) .isEqualTo(100); }) .expectComplete() From d7fac5be16f71823ad5fd75b6451b2718dc5bedb Mon Sep 17 00:00:00 2001 From: "Merchant, Saifuddin A" Date: Thu, 23 Oct 2025 12:29:55 -0700 Subject: [PATCH 19/19] running mvn spotless:apply and removed unnecessary properties --- .../java/org/cloudfoundry/NameFactory.java | 11 ------- .../client/v3/SpaceQuotaDefinitionsTest.java | 32 ++++++++++--------- 2 files changed, 17 insertions(+), 26 deletions(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/NameFactory.java b/integration-test/src/test/java/org/cloudfoundry/NameFactory.java index c09ee844c6..7432672263 100644 --- a/integration-test/src/test/java/org/cloudfoundry/NameFactory.java +++ b/integration-test/src/test/java/org/cloudfoundry/NameFactory.java @@ -43,8 +43,6 @@ public interface NameFactory { String ORGANIZATION_PREFIX = "test-organization-"; - String ORGANIZATION_QUOTA_PREFIX = "test-organization-quota-definition-"; - String PASSWORD_PREFIX = "test-password-"; String PATH_PREFIX = "/test-path-"; @@ -191,15 +189,6 @@ default String getOrganizationName() { return getName(ORGANIZATION_PREFIX); } - /** - * Creates an organization quota name - * - * @return the organization quota name - */ - default String getOrganizationQuotaName() { - return getName(ORGANIZATION_QUOTA_PREFIX); - } - /** * Creates a password * diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java index f49b57246e..7b69f77f24 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SpaceQuotaDefinitionsTest.java @@ -66,12 +66,14 @@ public void create() { SpaceQuotaDefinitionRelationships spaceQuotaDefinitionRelationships = createSpaceQuotaDefinitionRelationships(organizationId); - Apps spaceQuotaAppLimits = Apps.builder() - .perProcessMemoryInMb(1024) - .totalMemoryInMb(2048) - .logRateLimitInBytesPerSecond(0) - .build(); - Services spaceQuotaServiceLimits = Services.builder().isPaidServicesAllowed(false).totalServiceInstances(10).build(); + Apps spaceQuotaAppLimits = + Apps.builder() + .perProcessMemoryInMb(1024) + .totalMemoryInMb(2048) + .logRateLimitInBytesPerSecond(0) + .build(); + Services spaceQuotaServiceLimits = + Services.builder().isPaidServicesAllowed(false).totalServiceInstances(10).build(); Routes spaceQuotaRouteLimits = Routes.builder().totalRoutes(10).build(); this.cloudFoundryClient @@ -178,19 +180,19 @@ public void update() { .consumeNextWith( organizationQuotaDefinitionResource -> { assertThat( - organizationQuotaDefinitionResource - .getApps() - .getTotalMemoryInMb()) + organizationQuotaDefinitionResource + .getApps() + .getTotalMemoryInMb()) .isEqualTo(totalMemoryLimit); assertThat( - organizationQuotaDefinitionResource - .getRoutes() - .getTotalRoutes()) + organizationQuotaDefinitionResource + .getRoutes() + .getTotalRoutes()) .isEqualTo(100); assertThat( - organizationQuotaDefinitionResource - .getServices() - .getTotalServiceInstances()) + organizationQuotaDefinitionResource + .getServices() + .getTotalServiceInstances()) .isEqualTo(100); }) .expectComplete()