From b5aea46b244bcf3fe4375e40749e8bb4b8499b1f Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Thu, 6 Jul 2023 07:48:59 +0000 Subject: [PATCH 01/21] adding security groups v3 create api --- .../client/v3/securitygroups/Protocol.java | 79 ++++++++++++++++++ .../v3/securitygroups/SecurityGroup.java | 59 ++++++++++++++ .../_CreateSecurityGroupRequest.java | 60 ++++++++++++++ .../_CreateSecurityGroupResponse.java | 29 +++++++ .../v3/securitygroups/_GloballyEnabled.java | 29 +++++++ .../v3/securitygroups/_Relationships.java | 30 +++++++ .../client/v3/securitygroups/_Rule.java | 80 +++++++++++++++++++ .../CreateSecurityGroupRequestTest.java | 30 +++++++ 8 files changed, 396 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java new file mode 100644 index 0000000000..74b2aec1fe --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java @@ -0,0 +1,79 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The protocol of a {@link RuleEntity} + */ +public enum Protocol { + + /** + * All protocols + */ + ALL("all"), + + /** + * ICMP protocol + */ + ICMP("icmp"), + + /** + * TCP protocol + */ + TCP("tcp"), + + /** + * UDP protocol + */ + UDP("udp"); + + private final String value; + + Protocol(String value) { + this.value = value; + } + + @JsonCreator + public static Protocol from(String s) { + switch (s.toLowerCase()) { + case "all": + return ALL; + case "icmp": + return ICMP; + case "tcp": + return TCP; + case "udp": + return UDP; + default: + throw new IllegalArgumentException(String.format("Unknown protocol: %s", s)); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + @Override + public String toString() { + return getValue(); + } + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java new file mode 100644 index 0000000000..6dbda398a4 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java @@ -0,0 +1,59 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; +import org.cloudfoundry.client.v3.Resource; +import java.util.List; + +/** + * The entity response payload for the Security Group resource + */ +@JsonDeserialize +public abstract class SecurityGroup extends Resource { + + /** + * The name + */ + @JsonProperty("name") + abstract String getName(); + + /** + * The globally enabled + */ + @JsonProperty("globally_enabled") + @Nullable + abstract GloballyEnabled getGloballyEnabled(); + + /** + * The rules + */ + @JsonProperty("rules") + @Nullable + abstract List getRules(); + + /** + * The space relationships + */ + @JsonProperty("relationships") + @Nullable + abstract Relationships getRelationships(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupRequest.java new file mode 100644 index 0000000000..e2d6b4f6c0 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupRequest.java @@ -0,0 +1,60 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +import java.util.List; + +/** + * The request payload for the Create a Security Group operation + */ +@JsonSerialize +@Value.Immutable +abstract class _CreateSecurityGroupRequest { + + /** + * The security group name + */ + @JsonProperty("name") + abstract String getName(); + + /** + * the security group glbally enabled field + */ + @JsonProperty("globally_enabled") + @Nullable + abstract GloballyEnabled getGloballyEnabled(); + + /** + * The security group rules + */ + @JsonProperty("rules") + @Nullable + abstract List getRules(); + + /** + * The security group relationships + */ + @JsonProperty("relationships") + @Nullable + abstract Relationships getRelationships(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java new file mode 100644 index 0000000000..f3f7c3d080 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java @@ -0,0 +1,29 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Creating a Security Group operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _CreateSecurityGroupResponse extends SecurityGroup { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java new file mode 100644 index 0000000000..109bdf9d92 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java @@ -0,0 +1,29 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * Controls if the group is applied globally to the lifecycle of all + * applications + */ +@JsonDeserialize +@Value.Immutable +abstract class _GloballyEnabled { + + /** + * Specifies whether the group should be applied globally to all running + * applications + */ + @JsonProperty("running") + abstract Boolean getRunning(); + + /** + * Specifies whether the group should be applied globally to all staging + * applications + */ + @JsonProperty("staging") + abstract Boolean getStaging(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java new file mode 100644 index 0000000000..8f0a5112e1 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java @@ -0,0 +1,30 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.immutables.value.Value; + +/** + * Holds relationships to running/staging spaces where security groups is + * applied + */ +@JsonDeserialize +@Value.Immutable +abstract class _Relationships { + + /** + * A relationship to the spaces where the security_group is applied to + * applications during runtime + */ + @JsonProperty("running_spaces") + abstract ToManyRelationship getRunningSpaces(); + + /** + * A relationship to the spaces where the security_group is applied to + * applications during runtime + */ + @JsonProperty("staging_spaces") + abstract ToManyRelationship getStagingSpaces(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java new file mode 100644 index 0000000000..73938c6c03 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java @@ -0,0 +1,80 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * A security group rule + */ +@JsonDeserialize +@Value.Immutable +abstract class _Rule { + + /** + * The code control signal for icmp + */ + @JsonProperty("code") + @Nullable + abstract Integer getCode(); + + /** + * The description of the rule + */ + @JsonProperty("description") + @Nullable + abstract String getDescription(); + + /** + * The destination + */ + @JsonProperty("destination") + @Nullable + abstract String getDestination(); + + /** + * Enables logging for the egress rule + */ + @JsonProperty("log") + @Nullable + abstract Boolean getLog(); + + /** + * The ports + */ + @JsonProperty("ports") + @Nullable + abstract String getPorts(); + + /** + * The protocol + */ + @JsonProperty("protocol") + @Nullable + abstract Protocol getProtocol(); + + /** + * The type control signal for icmp + */ + @JsonProperty("type") + @Nullable + abstract Integer getType(); + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java new file mode 100644 index 0000000000..ad9f6a1d4c --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java @@ -0,0 +1,30 @@ +/* + * 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.securitygroups; + +import org.junit.Test; + +public class CreateSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noName() { + CreateSecurityGroupRequest.builder() + .rule(Rule.builder().build()) + .build(); + } + +} \ No newline at end of file From 92fa5dbbcf8180947ac2a01f72c0dcdeb6b57fdb Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Thu, 6 Jul 2023 13:05:43 +0000 Subject: [PATCH 02/21] adding create security group impl and tests --- .../client/_ReactorCloudFoundryClient.java | 31 +++-- .../ReactorSecurityGroupsV3.java | 57 +++++++++ .../ReactorSecurityGroupsV3Test.java | 120 ++++++++++++++++++ .../v3/security_groups/POST_request.json | 17 +++ .../v3/security_groups/POST_response.json | 44 +++++++ .../client/CloudFoundryClient.java | 9 +- .../v3/securitygroups/SecurityGroupsV3.java | 33 +++++ 7 files changed, 302 insertions(+), 9 deletions(-) create mode 100644 cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java create mode 100644 cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_response.json create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.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 90833d4e66..d7e3747c2a 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.securitygroups.SecurityGroupsV3; import org.cloudfoundry.client.v2.servicebindings.ServiceBindingsV2; import org.cloudfoundry.client.v2.servicebrokers.ServiceBrokers; import org.cloudfoundry.client.v2.serviceinstances.ServiceInstances; @@ -91,6 +92,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.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; @@ -151,7 +153,8 @@ public AdminV3 adminV3() { @Override @Value.Derived public ApplicationUsageEvents applicationUsageEvents() { - return new ReactorApplicationUsageEvents(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + return new ReactorApplicationUsageEvents(getConnectionContext(), getRootV2(), getTokenProvider(), + getRequestTags()); } @Override @@ -228,7 +231,8 @@ public Droplets droplets() { @Override @Value.Derived public EnvironmentVariableGroups environmentVariableGroups() { - return new ReactorEnvironmentVariableGroups(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + return new ReactorEnvironmentVariableGroups(getConnectionContext(), getRootV2(), getTokenProvider(), + getRequestTags()); } @Override @@ -270,7 +274,8 @@ public JobsV3 jobsV3() { @Override @Value.Derived public OrganizationQuotaDefinitions organizationQuotaDefinitions() { - return new ReactorOrganizationQuotaDefinitions(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + return new ReactorOrganizationQuotaDefinitions(getConnectionContext(), getRootV2(), getTokenProvider(), + getRequestTags()); } @Override @@ -345,6 +350,12 @@ public SecurityGroups securityGroups() { return new ReactorSecurityGroups(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); } + @Override + @Value.Derived + public SecurityGroupsV3 securityGroupsV3() { + return new ReactorSecurityGroupsV3(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + } + @Override @Value.Derived public ServiceBindingsV2 serviceBindingsV2() { @@ -366,7 +377,7 @@ public ServiceBrokers serviceBrokers() { @Override @Value.Derived public ServiceBrokersV3 serviceBrokersV3() { - return new ReactorServiceBrokersV3(getConnectionContext(), getRootV3(), getTokenProvider(), getRequestTags()); + return new ReactorServiceBrokersV3(getConnectionContext(), getRootV3(), getTokenProvider(), getRequestTags()); } @Override @@ -396,7 +407,8 @@ public ServiceOfferingsV3 serviceOfferingsV3() { @Override @Value.Derived public ServicePlanVisibilities servicePlanVisibilities() { - return new ReactorServicePlanVisibilities(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + return new ReactorServicePlanVisibilities(getConnectionContext(), getRootV2(), getTokenProvider(), + getRequestTags()); } @Override @@ -432,7 +444,8 @@ public SharedDomains sharedDomains() { @Override @Value.Derived public SpaceQuotaDefinitions spaceQuotaDefinitions() { - return new ReactorSpaceQuotaDefinitions(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + return new ReactorSpaceQuotaDefinitions(getConnectionContext(), getRootV2(), getTokenProvider(), + getRequestTags()); } @Override @@ -468,7 +481,8 @@ public Tasks tasks() { @Override @Value.Derived public UserProvidedServiceInstances userProvidedServiceInstances() { - return new ReactorUserProvidedServiceInstances(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + return new ReactorUserProvidedServiceInstances(getConnectionContext(), getRootV2(), getTokenProvider(), + getRequestTags()); } @Override @@ -483,7 +497,8 @@ public Users users() { abstract ConnectionContext getConnectionContext(); /** - * Map of http header name and value which will be added to every request to the controller + * Map of http header name and value which will be added to every request to the + * controller */ @Value.Default Map getRequestTags() { diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java new file mode 100644 index 0000000000..c3a7be1acb --- /dev/null +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -0,0 +1,57 @@ +/* + * 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.reactor.client.v3.securitygroups; + +import org.cloudfoundry.client.v3.securitygroups.SecurityGroupsV3; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; +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 ServiceBindingsV3} + */ +public final class ReactorSecurityGroupsV3 extends AbstractClientV3Operations implements SecurityGroupsV3 { + + /** + * 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 ReactorSecurityGroupsV3(ConnectionContext connectionContext, Mono root, TokenProvider tokenProvider, + Map requestTags) { + super(connectionContext, root, tokenProvider, requestTags); + } + + @Override + public Mono create(CreateSecurityGroupRequest request) { + return post(request, CreateSecurityGroupResponse.class, builder -> builder.pathSegment("security_groups")) + .checkpoint(); + + } + +} diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java new file mode 100644 index 0000000000..453089a63e --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -0,0 +1,120 @@ +/* + * 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.reactor.client.v3.securitygroups; + +import org.cloudfoundry.reactor.InteractionContext; +import org.cloudfoundry.reactor.TestRequest; +import org.cloudfoundry.reactor.TestResponse; +import org.cloudfoundry.client.v3.securitygroups.Relationships; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.GloballyEnabled; +import org.cloudfoundry.client.v3.securitygroups.Protocol; +import org.cloudfoundry.client.v3.securitygroups.Rule; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.reactor.client.AbstractClientApiTest; +import org.junit.Test; +import reactor.test.StepVerifier; +import org.cloudfoundry.client.v3.Link; +import org.cloudfoundry.client.v3.Relationship; + +import java.time.Duration; +import java.util.Collections; + +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.CREATED; + +public final class ReactorSecurityGroupsV3Test extends AbstractClientApiTest { + + private final ReactorSecurityGroupsV3 securityGroups = new ReactorSecurityGroupsV3(CONNECTION_CONTEXT, + this.root, + TOKEN_PROVIDER, Collections.emptyMap()); + + @Test + public void create() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(POST).path("/security_groups") + .payload("fixtures/client/v3/security_groups/POST_request.json") + .build()) + .response(TestResponse.builder() + .status(CREATED) + .payload("fixtures/client/v3/security_groups/POST_response.json") + .build()) + .build()); + this.securityGroups + .create(CreateSecurityGroupRequest.builder() + + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .name("my-group0") + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .build()) + .as(StepVerifier::create) + .expectNext(CreateSecurityGroupResponse.builder() + .name("my-group0") + .id("b85a788e-671f-4549-814d-e34cdb2f539a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .globallyEnabled(GloballyEnabled.builder() + .staging(false) + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship.builder() + .data(Relationship.builder() + .id("space-guid-1") + .build()) + .data(Relationship.builder() + .id("space-guid-2") + .build()) + .build()) + .runningSpaces(ToManyRelationship.builder().build()) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + + } + +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_request.json new file mode 100644 index 0000000000..35e74431db --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_request.json @@ -0,0 +1,17 @@ +{ + "name": "my-group0", + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_response.json new file mode 100644 index 0000000000..5c1290a8e3 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/POST_response.json @@ -0,0 +1,44 @@ +{ + "guid": "b85a788e-671f-4549-814d-e34cdb2f539a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group0", + "globally_enabled": { + "running": true, + "staging": false + }, + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ], + "relationships": { + "staging_spaces": { + "data": [ + { + "guid": "space-guid-1" + }, + { + "guid": "space-guid-2" + } + ] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a" + } + } +} \ No newline at end of file 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 04957c0d0c..b691c73958 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java @@ -63,6 +63,7 @@ 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.securitygroups.SecurityGroupsV3; import org.cloudfoundry.client.v3.serviceinstances.ServiceInstancesV3; import org.cloudfoundry.client.v3.servicebindings.ServiceBindingsV3; import org.cloudfoundry.client.v3.servicebrokers.ServiceBrokersV3; @@ -247,6 +248,11 @@ public interface CloudFoundryClient { */ SecurityGroups securityGroups(); + /** + * Main entry point to the Cloud Foundry Security Groups V3 Client API + */ + SecurityGroupsV3 securityGroupsV3(); + /** * Main entry point to the Cloud Foundry Service Bindings V2 Client API */ @@ -348,7 +354,8 @@ public interface CloudFoundryClient { Tasks tasks(); /** - * Main entry point to the Cloud Foundry User Provided Service Instances Client API + * Main entry point to the Cloud Foundry User Provided Service Instances Client + * API */ UserProvidedServiceInstances userProvidedServiceInstances(); diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java new file mode 100644 index 0000000000..eee396fec1 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -0,0 +1,33 @@ +/* + * 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.securitygroups; + +import reactor.core.publisher.Mono; + +public interface SecurityGroupsV3 { + + /** + * Makes the Creating + * a Security Group request. + * + * @param request the create security group request + * @return the response from the create security group request + */ + Mono create(CreateSecurityGroupRequest request); + +} From 20e6b29fb8d24268df0ca888375c01a4ee1350e9 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Fri, 7 Jul 2023 06:05:25 +0000 Subject: [PATCH 03/21] adding get security group api and tests --- .../_GetSecurityGroupRequest.java | 36 +++++++++++++++++++ .../_GetSecurityGroupResponse.java | 29 +++++++++++++++ .../GetSecurityGroupRequestTest.java | 19 ++++++++++ 3 files changed, 84 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java new file mode 100644 index 0000000000..9c91c51721 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java @@ -0,0 +1,36 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.immutables.value.Value; + +/** + * The request payload for the Get Security Group operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _GetSecurityGroupRequest { + + /** + * The Security Group id + */ + @JsonIgnore + abstract String getSecurityGroupId(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java new file mode 100644 index 0000000000..79271f7528 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java @@ -0,0 +1,29 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the get Security Group operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _GetSecurityGroupResponse extends SecurityGroup { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java new file mode 100644 index 0000000000..4435396786 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java @@ -0,0 +1,19 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class GetSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSecurityGroupId() { + GetSecurityGroupRequest.builder() + .build(); + } + + @Test + public void valid() { + GetSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .build(); + } +} \ No newline at end of file From 2d0bc0b3a8d2ca9c803c22e8ca45679b1341b524 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Fri, 7 Jul 2023 06:30:14 +0000 Subject: [PATCH 04/21] adding get security group impl + test --- .../ReactorSecurityGroupsV3.java | 10 +++ .../ReactorSecurityGroupsV3Test.java | 62 ++++++++++++++++++- .../v3/security_groups/GET_{id}_response.json | 44 +++++++++++++ .../v3/securitygroups/SecurityGroupsV3.java | 10 +++ 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_{id}_response.json diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index c3a7be1acb..ad472bb9ae 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -19,6 +19,8 @@ import org.cloudfoundry.client.v3.securitygroups.SecurityGroupsV3; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -54,4 +56,12 @@ public Mono create(CreateSecurityGroupRequest reque } + @Override + public Mono get(GetSecurityGroupRequest request) { + return get(request, GetSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); + + } + } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 453089a63e..78c2711ee4 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -25,7 +25,8 @@ import org.cloudfoundry.client.v3.securitygroups.GloballyEnabled; import org.cloudfoundry.client.v3.securitygroups.Protocol; import org.cloudfoundry.client.v3.securitygroups.Rule; -import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; import org.cloudfoundry.client.v3.ToManyRelationship; import org.cloudfoundry.reactor.client.AbstractClientApiTest; import org.junit.Test; @@ -36,9 +37,11 @@ import java.time.Duration; import java.util.Collections; +import static io.netty.handler.codec.http.HttpMethod.GET; import static io.netty.handler.codec.http.HttpMethod.POST; import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; import static io.netty.handler.codec.http.HttpResponseStatus.CREATED; +import static io.netty.handler.codec.http.HttpResponseStatus.OK; public final class ReactorSecurityGroupsV3Test extends AbstractClientApiTest { @@ -117,4 +120,61 @@ public void create() { } + @Test + public void get() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(GET) + .path("/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/security_groups/GET_{id}_response.json") + .build()) + .build()); + this.securityGroups + .get(GetSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .as(StepVerifier::create) + .expectNext(GetSecurityGroupResponse.builder() + .name("my-group0") + .id("b85a788e-671f-4549-814d-e34cdb2f539a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .globallyEnabled(GloballyEnabled.builder() + .staging(false) + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship.builder() + .data(Relationship.builder() + .id("space-guid-1") + .build()) + .data(Relationship.builder() + .id("space-guid-2") + .build()) + .build()) + .runningSpaces(ToManyRelationship.builder().build()) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + } \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_{id}_response.json new file mode 100644 index 0000000000..5c1290a8e3 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_{id}_response.json @@ -0,0 +1,44 @@ +{ + "guid": "b85a788e-671f-4549-814d-e34cdb2f539a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group0", + "globally_enabled": { + "running": true, + "staging": false + }, + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ], + "relationships": { + "staging_spaces": { + "data": [ + { + "guid": "space-guid-1" + }, + { + "guid": "space-guid-2" + } + ] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index eee396fec1..342368f105 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -30,4 +30,14 @@ public interface SecurityGroupsV3 { */ Mono create(CreateSecurityGroupRequest request); + /** + * Makes the Get + * a Security Group request. + * + * @param request the get security group request + * @return the response from the get security group request + */ + Mono get(GetSecurityGroupRequest request); + } From 696c8b0c06411ab2f45d18853cb64f47ea7ff086 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Fri, 7 Jul 2023 08:22:33 +0000 Subject: [PATCH 05/21] adding list security groups impl + api --- .../ReactorSecurityGroupsV3.java | 8 ++ .../ReactorSecurityGroupsV3Test.java | 90 ++++++++++++++++++- .../v3/security_groups/GET_response.json | 84 +++++++++++++++++ .../v3/securitygroups/SecurityGroup.java | 3 - .../v3/securitygroups/SecurityGroupsV3.java | 19 +++- .../_GetSecurityGroupRequest.java | 4 +- .../_ListSecurityGroupsRequest.java | 70 +++++++++++++++ .../_ListSecurityGroupsResponse.java | 31 +++++++ .../_SecurityGroupResource.java | 33 +++++++ .../ListSecurityGroupsRequestTest.java | 13 +++ 10 files changed, 345 insertions(+), 10 deletions(-) create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_response.json create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index ad472bb9ae..c6bc883185 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -21,6 +21,8 @@ import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -64,4 +66,10 @@ public Mono get(GetSecurityGroupRequest request) { } + @Override + public Mono list(ListSecurityGroupsRequest request) { + return get(request, ListSecurityGroupsResponse.class, + builder -> builder.pathSegment("security_groups")) + .checkpoint(); + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 78c2711ee4..5c19b35c64 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -16,13 +16,17 @@ package org.cloudfoundry.reactor.client.v3.securitygroups; +import org.cloudfoundry.client.v3.Pagination; import org.cloudfoundry.reactor.InteractionContext; import org.cloudfoundry.reactor.TestRequest; import org.cloudfoundry.reactor.TestResponse; import org.cloudfoundry.client.v3.securitygroups.Relationships; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.SecurityGroupResource; import org.cloudfoundry.client.v3.securitygroups.GloballyEnabled; +import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; import org.cloudfoundry.client.v3.securitygroups.Protocol; import org.cloudfoundry.client.v3.securitygroups.Rule; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; @@ -39,7 +43,6 @@ import static io.netty.handler.codec.http.HttpMethod.GET; import static io.netty.handler.codec.http.HttpMethod.POST; -import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; import static io.netty.handler.codec.http.HttpResponseStatus.CREATED; import static io.netty.handler.codec.http.HttpResponseStatus.OK; @@ -177,4 +180,89 @@ public void get() { .verify(Duration.ofSeconds(5)); } + @Test + public void list() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(GET).path("/security_groups") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/security_groups/GET_response.json") + .build()) + .build()); + + this.securityGroups.list(ListSecurityGroupsRequest.builder().build()) + .as(StepVerifier::create) + .expectNext(ListSecurityGroupsResponse.builder() + .pagination(Pagination.builder() + .totalResults(1) + .totalPages(1) + .first(Link.builder() + .href("https://api.example.org/v3/security_groups?page=1&per_page=50") + .build()) + .last(Link.builder() + .href("https://api.example.org/v3/security_groups?page=1&per_page=50") + .build()) + .build()) + .resource(SecurityGroupResource.builder() + .name("my-group0") + .id("b85a788e-671f-4549-814d-e34cdb2f539a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .globallyEnabled(GloballyEnabled + .builder() + .staging(false) + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship + .builder() + .data(Relationship + .builder() + .id("space-guid-1") + .build()) + .data(Relationship + .builder() + .id("space-guid-2") + .build()) + .build()) + .runningSpaces(ToManyRelationship + .builder() + .build()) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .build()) + .resource(SecurityGroupResource.builder() + .name("my-group1") + .id("a89a788e-671f-4549-814d-e34c1b2f533a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .globallyEnabled(GloballyEnabled + .builder() + .staging(true) + .running(true) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a") + .build()) + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } } \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_response.json new file mode 100644 index 0000000000..9e39d26c2a --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_response.json @@ -0,0 +1,84 @@ +{ + "pagination": { + "total_results": 1, + "total_pages": 1, + "first": { + "href": "https://api.example.org/v3/security_groups?page=1&per_page=50" + }, + "last": { + "href": "https://api.example.org/v3/security_groups?page=1&per_page=50" + }, + "next": null, + "previous": null + }, + "resources": [ + { + "guid": "b85a788e-671f-4549-814d-e34cdb2f539a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group0", + "globally_enabled": { + "running": true, + "staging": false + }, + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ], + "relationships": { + "staging_spaces": { + "data": [ + { + "guid": "space-guid-1" + }, + { + "guid": "space-guid-2" + } + ] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a" + } + } + }, + { + "guid": "a89a788e-671f-4549-814d-e34c1b2f533a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group1", + "globally_enabled": { + "running": true, + "staging": true + }, + "rules": [], + "relationships": { + "staging_spaces": { + "data": [] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a" + } + } + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java index 6dbda398a4..77b69a8875 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java @@ -39,21 +39,18 @@ public abstract class SecurityGroup extends Resource { * The globally enabled */ @JsonProperty("globally_enabled") - @Nullable abstract GloballyEnabled getGloballyEnabled(); /** * The rules */ @JsonProperty("rules") - @Nullable abstract List getRules(); /** * The space relationships */ @JsonProperty("relationships") - @Nullable abstract Relationships getRelationships(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index 342368f105..30760e332b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -25,8 +25,8 @@ public interface SecurityGroupsV3 { * "https://apidocs.cloudfoundry.org/latest-release/security_groups/creating_a_security_group.html">Creating * a Security Group request. * - * @param request the create security group request - * @return the response from the create security group request + * @param request the Create Security Group request + * @return the response from the Create Security Group request */ Mono create(CreateSecurityGroupRequest request); @@ -35,9 +35,20 @@ public interface SecurityGroupsV3 { * "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#get-a-security-group">Get * a Security Group request. * - * @param request the get security group request - * @return the response from the get security group request + * @param request the Get Security Group request + * @return the response from the Get Security Group request */ Mono get(GetSecurityGroupRequest request); + /** + * Makes the List + * Security Groups request + * + * @param request the List Security Group request + * @return the response from the List Security Group request + */ + Mono list(ListSecurityGroupsRequest request); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java index 9c91c51721..3861d945bf 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java @@ -16,14 +16,14 @@ package org.cloudfoundry.client.v3.securitygroups; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.annotation.JsonIgnore; import org.immutables.value.Value; /** * The request payload for the Get Security Group operation */ -@JsonDeserialize +@JsonSerialize @Value.Immutable abstract class _GetSecurityGroupRequest { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java new file mode 100644 index 0000000000..7945fe21ac --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java @@ -0,0 +1,70 @@ +/* + * 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.securitygroups; + +import org.cloudfoundry.client.v2.PaginatedRequest; +import org.immutables.value.Value; +import org.cloudfoundry.client.v3.FilterParameter; +import org.cloudfoundry.Nullable; +import java.util.List; +import com.fasterxml.jackson.databind.annotation.JsonSerialize;; + +/** + * The request payload for the List Security Group operation + */ +@JsonSerialize +@Value.Immutable +abstract class _ListSecurityGroupsRequest extends PaginatedRequest { + + /** + * The security group ids filter + */ + @FilterParameter("guids") + abstract List getSecurityGroupIds(); + + /** + * The security group names filter + */ + @FilterParameter("names") + abstract List getNames(); + + /** + * the security group globally enabled running filter + */ + @FilterParameter("globally_enabled_running") + @Nullable + abstract Boolean getGloballyEnabledRunning(); + + /** + * the security group globally enabled staging filter + */ + @FilterParameter("globally_enabled_staging") + @Nullable + abstract Boolean getGloballyEnabledStagingBoolean(); + + /** + * the security group running_space_guids filter + */ + @FilterParameter("running_space_guids") + abstract List getRunningSpaceIds(); + + /** + * the security group staging_space_guids filter + */ + @FilterParameter("staging_space_guids") + abstract List getStagingSpaceIds(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java new file mode 100644 index 0000000000..ea8427e71d --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java @@ -0,0 +1,31 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +import org.cloudfoundry.client.v3.PaginatedResponse; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +/** + * The response payload for the List Security Groups operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _ListSecurityGroupsResponse extends PaginatedResponse { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java new file mode 100644 index 0000000000..af4edc2e39 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java @@ -0,0 +1,33 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; +import org.cloudfoundry.client.v3.Resource; +import java.util.List; + +/** + * The Resource response payload for the List SecurityGroups operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _SecurityGroupResource extends SecurityGroup { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java new file mode 100644 index 0000000000..11356cfd81 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java @@ -0,0 +1,13 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class ListSecurityGroupsRequestTest { + + @Test + public void valid() { + ListSecurityGroupsRequest.builder() + .build(); + } + +} \ No newline at end of file From c4fe290fe256187220810e352f4ff13afce9778b Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Fri, 7 Jul 2023 08:54:43 +0000 Subject: [PATCH 06/21] adding update security group api --- .../ReactorSecurityGroupsV3Test.java | 1 + .../v3/securitygroups/SecurityGroupsV3.java | 10 ++++ .../v3/securitygroups/_GloballyEnabled.java | 4 ++ .../_UpdateSecurityGroupRequest.java | 48 +++++++++++++++++++ .../_UpdateSecurityGroupResponse.java | 29 +++++++++++ .../UpdateSecurityGroupRequestTest.java | 37 ++++++++++++++ 6 files changed, 129 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 5c19b35c64..9f28eb7539 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -252,6 +252,7 @@ public void list() { .id("a89a788e-671f-4549-814d-e34c1b2f533a") .createdAt("2020-02-20T17:42:08Z") .updatedAt("2020-02-20T17:42:08Z") + .relationships(Relationships.builder().build()) .globallyEnabled(GloballyEnabled .builder() .staging(true) diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index 30760e332b..1763e548f2 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -51,4 +51,14 @@ public interface SecurityGroupsV3 { */ Mono list(ListSecurityGroupsRequest request); + /** + * Makes the Update + * Security Groups request + * + * @param request the Update Security Group request + * @return the response from the List Security Group request + */ + Mono update(UpdateSecurityGroupRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java index 109bdf9d92..5cabbbe3f1 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import org.cloudfoundry.Nullable; import org.immutables.value.Value; /** @@ -17,6 +19,7 @@ abstract class _GloballyEnabled { * applications */ @JsonProperty("running") + @Nullable abstract Boolean getRunning(); /** @@ -24,6 +27,7 @@ abstract class _GloballyEnabled { * applications */ @JsonProperty("staging") + @Nullable abstract Boolean getStaging(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java new file mode 100644 index 0000000000..b3b34494c0 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java @@ -0,0 +1,48 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +import java.util.List; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The request payload for the Create a Security Group operation + */ +@JsonSerialize +@Value.Immutable +abstract class _UpdateSecurityGroupRequest { + /** + * Name of the security group + */ + @JsonProperty("name") + abstract String getName(); + + /** + * Object that controls if the group is applied globally to the lifecycle of all + * applications + */ + @JsonProperty("globally_enabled") + abstract GloballyEnabled getGloballyEnabled(); + + /** + * Rules that will be applied by this security group + */ + @JsonProperty("rules") + abstract List getRules(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java new file mode 100644 index 0000000000..a855711420 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java @@ -0,0 +1,29 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +/** + * The response payload for the Update a Security Group operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _UpdateSecurityGroupResponse extends SecurityGroup { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java new file mode 100644 index 0000000000..7af97fa34e --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java @@ -0,0 +1,37 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class UpdateSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noName() { + UpdateSecurityGroupRequest.builder() + .build(); + } + + @Test() + public void valid() { + UpdateSecurityGroupRequest.builder() + .name("my-group0") + .globallyEnabled(GloballyEnabled + .builder() + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .build(); + + } + +} \ No newline at end of file From 1a907f3f827d9a3ebb87d3e4a524c51a346a6cbe Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Fri, 7 Jul 2023 12:02:43 +0000 Subject: [PATCH 07/21] adding update security group api v3 impl --- .../ReactorSecurityGroupsV3.java | 9 ++ .../ReactorSecurityGroupsV3Test.java | 84 +++++++++++++++++++ .../security_groups/PATCH_{id}_request.json | 20 +++++ .../security_groups/PATCH_{id}_response.json | 44 ++++++++++ .../_UpdateSecurityGroupRequest.java | 8 ++ .../UpdateSecurityGroupRequestTest.java | 55 ++++++------ 6 files changed, 193 insertions(+), 27 deletions(-) create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_response.json diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index c6bc883185..af619079e9 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -20,7 +20,9 @@ import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; import org.cloudfoundry.reactor.ConnectionContext; @@ -72,4 +74,11 @@ public Mono list(ListSecurityGroupsRequest request) builder -> builder.pathSegment("security_groups")) .checkpoint(); } + + @Override + public Mono update(UpdateSecurityGroupRequest request) { + return patch(request, UpdateSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 9f28eb7539..fbb58c880d 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -30,6 +30,8 @@ import org.cloudfoundry.client.v3.securitygroups.Protocol; import org.cloudfoundry.client.v3.securitygroups.Rule; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; import org.cloudfoundry.client.v3.ToManyRelationship; import org.cloudfoundry.reactor.client.AbstractClientApiTest; @@ -42,6 +44,7 @@ import java.util.Collections; 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.CREATED; import static io.netty.handler.codec.http.HttpResponseStatus.OK; @@ -253,6 +256,11 @@ public void list() { .createdAt("2020-02-20T17:42:08Z") .updatedAt("2020-02-20T17:42:08Z") .relationships(Relationships.builder().build()) + .globallyEnabled(GloballyEnabled + .builder() + .staging(true) + .running(true) + .build()) .globallyEnabled(GloballyEnabled .builder() .staging(true) @@ -266,4 +274,80 @@ public void list() { .expectComplete() .verify(Duration.ofSeconds(5)); } + + @Test + public void update() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(PATCH).path("/security_groups") + .payload("fixtures/client/v3/security_groups/PATCH_{id}_request.json") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/security_groups/PATCH_{id}_response.json") + .build()) + .build()); + this.securityGroups + .update(UpdateSecurityGroupRequest.builder() + .name("my-group0") + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .globallyEnabled(GloballyEnabled.builder() + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + + .build()) + .as(StepVerifier::create) + .expectNext(UpdateSecurityGroupResponse.builder() + .name("my-group0") + .id("b85a788e-671f-4549-814d-e34cdb2f539a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .globallyEnabled(GloballyEnabled.builder() + .staging(false) + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship.builder() + .data(Relationship.builder() + .id("space-guid-1") + .build()) + .data(Relationship.builder() + .id("space-guid-2") + .build()) + .build()) + .runningSpaces(ToManyRelationship.builder().build()) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + + } } \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_request.json new file mode 100644 index 0000000000..7b146d9a9b --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_request.json @@ -0,0 +1,20 @@ +{ + "name": "my-group0", + "globally_enabled": { + "running": true + }, + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_response.json new file mode 100644 index 0000000000..5c1290a8e3 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/PATCH_{id}_response.json @@ -0,0 +1,44 @@ +{ + "guid": "b85a788e-671f-4549-814d-e34cdb2f539a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group0", + "globally_enabled": { + "running": true, + "staging": false + }, + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ], + "relationships": { + "staging_spaces": { + "data": [ + { + "guid": "space-guid-1" + }, + { + "guid": "space-guid-2" + } + ] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java index b3b34494c0..6c095fb492 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java @@ -20,6 +20,7 @@ import java.util.List; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; /** * The request payload for the Create a Security Group operation @@ -27,6 +28,13 @@ @JsonSerialize @Value.Immutable abstract class _UpdateSecurityGroupRequest { + + /** + * Id of the security group + */ + @JsonIgnore + abstract String getSecurityGroupId(); + /** * Name of the security group */ diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java index 7af97fa34e..90e6063606 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java @@ -4,34 +4,35 @@ public class UpdateSecurityGroupRequestTest { - @Test(expected = IllegalStateException.class) - public void noName() { - UpdateSecurityGroupRequest.builder() - .build(); - } + @Test(expected = IllegalStateException.class) + public void noName() { + UpdateSecurityGroupRequest.builder() + .build(); + } - @Test() - public void valid() { - UpdateSecurityGroupRequest.builder() - .name("my-group0") - .globallyEnabled(GloballyEnabled - .builder() - .running(true) - .build()) - .rules(Rule.builder() - .protocol(Protocol.TCP) - .destination("10.10.10.0/24") - .ports("443,80,8080") - .build()) - .rules(Rule.builder() - .protocol(Protocol.ICMP) - .destination("10.10.10.0/24") - .description("Allow ping requests to private services") - .type(8) - .code(0) - .build()) - .build(); + @Test() + public void valid() { + UpdateSecurityGroupRequest.builder() + .name("my-group0") + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .globallyEnabled(GloballyEnabled + .builder() + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .build(); - } + } } \ No newline at end of file From 53000cb9d10ac70b58ca343557d40c41e05d9fba Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Fri, 7 Jul 2023 12:44:37 +0000 Subject: [PATCH 08/21] adding security groups delete api v3 impl and tests --- .../ReactorSecurityGroupsV3.java | 9 +++++ .../ReactorSecurityGroupsV3Test.java | 27 ++++++++++++++ .../v3/securitygroups/SecurityGroupsV3.java | 12 +++++-- .../_DeleteSecurityGroupRequest.java | 36 +++++++++++++++++++ .../DeleteSecurityGroupRequestTest.java | 19 ++++++++++ 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index af619079e9..207468d290 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -20,6 +20,7 @@ import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.DeleteSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupResponse; @@ -81,4 +82,12 @@ public Mono update(UpdateSecurityGroupRequest reque builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) .checkpoint(); } + + @Override + public Mono delete(DeleteSecurityGroupRequest request) { + return delete(request, String.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); + + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index fbb58c880d..443e7e2ade 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -29,6 +29,7 @@ import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; import org.cloudfoundry.client.v3.securitygroups.Protocol; import org.cloudfoundry.client.v3.securitygroups.Rule; +import org.cloudfoundry.client.v3.securitygroups.DeleteSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupResponse; @@ -44,10 +45,12 @@ import java.util.Collections; import static io.netty.handler.codec.http.HttpMethod.GET; +import static io.netty.handler.codec.http.HttpMethod.DELETE;; 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.CREATED; import static io.netty.handler.codec.http.HttpResponseStatus.OK; +import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED;; public final class ReactorSecurityGroupsV3Test extends AbstractClientApiTest { @@ -350,4 +353,28 @@ public void update() { .verify(Duration.ofSeconds(5)); } + + @Test + public void delete() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(DELETE) + .path("/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .response(TestResponse.builder() + .status(ACCEPTED) + .header("Location", + "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .build()); + + this.securityGroups + .delete(DeleteSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .as(StepVerifier::create) + .expectNext("b85a788e-671f-4549-814d-e34cdb2f539a") + .expectComplete() + .verify(Duration.ofSeconds(5)); + } } \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index 1763e548f2..cc75c5d24f 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -42,7 +42,6 @@ public interface SecurityGroupsV3 { /** * Makes the List * Security Groups request * @@ -53,7 +52,6 @@ public interface SecurityGroupsV3 { /** * Makes the Update * Security Groups request * @@ -61,4 +59,14 @@ public interface SecurityGroupsV3 { * @return the response from the List Security Group request */ Mono update(UpdateSecurityGroupRequest request); + + /** + * Makes the Delete + * Security Groups request + * + * @param request the Delete Security Group request + * @return the response from the List Security Group request + */ + Mono delete(DeleteSecurityGroupRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java new file mode 100644 index 0000000000..812220b3f5 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java @@ -0,0 +1,36 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.immutables.value.Value; + +/** + * The request payload for the Delete Security Group operation + */ +@JsonSerialize +@Value.Immutable +abstract class _DeleteSecurityGroupRequest { + + /** + * The Security Group id + */ + @JsonIgnore + abstract String getSecurityGroupId(); + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java new file mode 100644 index 0000000000..a050d0fc32 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java @@ -0,0 +1,19 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class DeleteSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSecurityGroupId() { + DeleteSecurityGroupRequest.builder() + .build(); + } + + @Test + public void valid() { + DeleteSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .build(); + } +} \ No newline at end of file From 4f5437d12fe1e6b5baa4ca0d2c2c118eddd306b3 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov <49554804+radoslav-tomov@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:05:47 +0000 Subject: [PATCH 09/21] adding bind running/staging security group v3 api --- .../AbstractBindSecurityGroupRequest.java | 40 ++++++++++++++++++ .../AbstractBindSecurityGroupResponse.java | 41 +++++++++++++++++++ .../v3/securitygroups/SecurityGroupsV3.java | 20 +++++++++ .../_BindRunningSecurityGroupRequest.java | 24 +++++++++++ .../_BindRunningSecurityGroupResponse.java | 24 +++++++++++ .../_BindStagingSecurityGroupRequest.java | 24 +++++++++++ .../_BindStagingSecurityGroupResponse.java | 24 +++++++++++ .../BindRunningSecurityGroupRequestTest.java | 26 ++++++++++++ .../BindStagingSecurityGroupRequestTest.java | 26 ++++++++++++ 9 files changed, 249 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java new file mode 100644 index 0000000000..3e3fa620fc --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java @@ -0,0 +1,40 @@ +/* + * 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.securitygroups; + +import org.cloudfoundry.client.v3.ToManyRelationship; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize +public abstract class AbstractBindSecurityGroupRequest { + + /** + * The Security Group id + */ + @JsonIgnore + abstract String getSecurityGroupId(); + + /** + * A relationship to the spaces where the security_group is applied to + * applications during runtime + */ + @JsonProperty("data") + abstract ToManyRelationship getBoundSpaces(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java new file mode 100644 index 0000000000..e09532f8b5 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java @@ -0,0 +1,41 @@ +/* + * 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.securitygroups; + +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.ToManyRelationship; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize +public abstract class AbstractBindSecurityGroupResponse { + + /** + * A relationship to the spaces where the security_group is applied to + * applications during runtime + */ + @JsonProperty("data") + abstract ToManyRelationship getBoundSpaces(); + + /** + * When the resource was last updated + */ + @JsonProperty("updated_at") + @Nullable + public abstract String getUpdatedAt(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index cc75c5d24f..77a7cd4a54 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -69,4 +69,24 @@ public interface SecurityGroupsV3 { * @return the response from the List Security Group request */ Mono delete(DeleteSecurityGroupRequest request); + + /** + * Makes the Bind + * Staging Security Group request + * + * @param request the Bind Staging Security Group request + * @return the response from the Bind Staging Security Group request + */ + Mono bindStagingSecurityGroup(BindStagingSecurityGroupRequest request); + + /** + * Makes the Bind + * Running Security Group request + * + * @param request the Bind Running Security Group request + * @return the response from the Bind Running Security Group request + */ + Mono bindRunningSecurityGroup(BindStagingSecurityGroupRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java new file mode 100644 index 0000000000..cdb778207b --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java @@ -0,0 +1,24 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +@Value.Immutable +abstract class _BindRunningSecurityGroupRequest extends AbstractBindSecurityGroupRequest { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java new file mode 100644 index 0000000000..d504100af4 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java @@ -0,0 +1,24 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +@Value.Immutable +public abstract class _BindRunningSecurityGroupResponse extends AbstractBindSecurityGroupResponse { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java new file mode 100644 index 0000000000..07762e5bef --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java @@ -0,0 +1,24 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +@Value.Immutable +abstract class _BindStagingSecurityGroupRequest extends AbstractBindSecurityGroupRequest { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java new file mode 100644 index 0000000000..045c90096a --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java @@ -0,0 +1,24 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +@Value.Immutable +public abstract class _BindStagingSecurityGroupResponse extends AbstractBindSecurityGroupResponse { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java new file mode 100644 index 0000000000..cea1b74809 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java @@ -0,0 +1,26 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.Relationship; +import org.junit.Test; + +public class BindRunningSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSecurityGroupId() { + BindRunningSecurityGroupRequest.builder() + .build(); + } + + @Test + public void valid() { + BindRunningSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .boundSpaces(ToManyRelationship.builder() + .data(Relationship.builder() + .id("space-guid-1") + .build()) + .build()) + .build(); + } +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java new file mode 100644 index 0000000000..2bc79fad25 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java @@ -0,0 +1,26 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.Relationship; +import org.junit.Test; + +public class BindStagingSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSecurityGroupId() { + BindStagingSecurityGroupRequest.builder() + .build(); + } + + @Test + public void valid() { + BindStagingSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .boundSpaces(ToManyRelationship.builder() + .data(Relationship.builder() + .id("space-guid-1") + .build()) + .build()) + .build(); + } +} From a7867359c92fe5241a325135201707bda058141b Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Mon, 10 Jul 2023 19:36:44 +0000 Subject: [PATCH 10/21] adding bind impl --- .../ReactorSecurityGroupsV3.java | 20 +++++ .../ReactorSecurityGroupsV3Test.java | 81 +++++++++++++++++++ .../bind_staging/POST_request.json | 10 +++ .../bind_staging/POST_response.json | 18 +++++ .../AbstractBindSecurityGroupResponse.java | 12 ++- .../v3/securitygroups/SecurityGroupsV3.java | 2 +- 6 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_response.json diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index 207468d290..2ae6ddb31a 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -26,6 +26,10 @@ import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; +import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupResponse; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -90,4 +94,20 @@ public Mono delete(DeleteSecurityGroupRequest request) { .checkpoint(); } + + @Override + public Mono bindRunningSecurityGroup(BindRunningSecurityGroupRequest request) { + return post(request, BindRunningSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), "relationships", + "running_spaces")) + .checkpoint(); + } + + @Override + public Mono bindStagingSecurityGroup(BindStagingSecurityGroupRequest request) { + return post(request, BindStagingSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), "relationships", + "staging_spaces")) + .checkpoint(); + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 443e7e2ade..12d43f4fbc 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -21,6 +21,10 @@ import org.cloudfoundry.reactor.TestRequest; import org.cloudfoundry.reactor.TestResponse; import org.cloudfoundry.client.v3.securitygroups.Relationships; +import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.SecurityGroupResource; @@ -377,4 +381,81 @@ public void delete() { .expectComplete() .verify(Duration.ofSeconds(5)); } + + @Test + public void bindStagingSecurityGroup() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(POST) + .path("/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/staging_spaces") + .payload("fixtures/client/v3/security_groups/bind_staging/POST_request.json") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/security_groups/bind_staging/POST_response.json") + .build()) + .build()); + this.securityGroups.bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .boundSpaces(ToManyRelationship.builder() + .data(Relationship.builder().id("space-guid1").build()) + .data(Relationship.builder().id("space-guid2").build()) + .build()) + .build()) + .as(StepVerifier::create) + .expectNext(BindStagingSecurityGroupResponse.builder() + .boundSpaces(ToManyRelationship.builder() + .data(Relationship.builder().id("space-guid1").build()) + .data(Relationship.builder().id("space-guid2").build()) + .data(Relationship.builder().id("previous-space-guid") + .build()) + .build() + + ) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/staging_spaces") + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + public void bindRunningSecurityGroup() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(POST) + .path("/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/running_spaces") + .payload("fixtures/client/v3/security_groups/bind_running/POST_request.json") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/security_groups/bind_running/POST_response.json") + .build()) + .build()); + this.securityGroups.bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .boundSpaces(ToManyRelationship.builder() + .data(Relationship.builder().id("space-guid1").build()) + .data(Relationship.builder().id("space-guid2").build()) + .build()) + .build()) + .as(StepVerifier::create) + .expectNext(BindRunningSecurityGroupResponse.builder() + .boundSpaces(ToManyRelationship.builder() + .data(Relationship.builder().id("space-guid1").build()) + .data(Relationship.builder().id("space-guid2").build()) + .data(Relationship.builder().id("previous-space-guid") + .build()) + .build() + + ) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/running_spaces") + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + } \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_request.json new file mode 100644 index 0000000000..eaa31060ca --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_request.json @@ -0,0 +1,10 @@ +{ + "data": [ + { + "guid": "space-guid1" + }, + { + "guid": "space-guid2" + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_response.json new file mode 100644 index 0000000000..06b4b5914d --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_staging/POST_response.json @@ -0,0 +1,18 @@ +{ + "data": [ + { + "guid": "space-guid1" + }, + { + "guid": "space-guid2" + }, + { + "guid": "previous-space-guid" + } + ], + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/staging_spaces" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java index e09532f8b5..b484eca127 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java @@ -16,7 +16,11 @@ package org.cloudfoundry.client.v3.securitygroups; +import java.util.Map; + +import org.cloudfoundry.AllowNulls; import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Link; import org.cloudfoundry.client.v3.ToManyRelationship; import com.fasterxml.jackson.annotation.JsonProperty; @@ -33,9 +37,9 @@ public abstract class AbstractBindSecurityGroupResponse { abstract ToManyRelationship getBoundSpaces(); /** - * When the resource was last updated + * The links */ - @JsonProperty("updated_at") - @Nullable - public abstract String getUpdatedAt(); + @AllowNulls + @JsonProperty("links") + public abstract Map getLinks(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index 77a7cd4a54..ff2ef0f6e0 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -88,5 +88,5 @@ public interface SecurityGroupsV3 { * @param request the Bind Running Security Group request * @return the response from the Bind Running Security Group request */ - Mono bindRunningSecurityGroup(BindStagingSecurityGroupRequest request); + Mono bindRunningSecurityGroup(BindRunningSecurityGroupRequest request); } From 173a16939e0e3d86a93aa1bbfa5372995aab9eb7 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Mon, 10 Jul 2023 21:05:52 +0000 Subject: [PATCH 11/21] fixing test issues --- .../ReactorSecurityGroupsV3.java | 124 +++++++++--------- .../ReactorSecurityGroupsV3Test.java | 48 +++---- .../bind_running/POST_request.json | 10 ++ .../bind_running/POST_response.json | 18 +++ .../AbstractBindSecurityGroupRequest.java | 5 +- .../AbstractBindSecurityGroupResponse.java | 4 +- .../v3/securitygroups/SecurityGroupsV3.java | 2 +- .../_BindRunningSecurityGroupRequest.java | 3 + .../_BindRunningSecurityGroupResponse.java | 3 + .../_BindStagingSecurityGroupRequest.java | 2 + .../_BindStagingSecurityGroupResponse.java | 2 + .../_DeleteSecurityGroupRequest.java | 1 - .../_ListSecurityGroupsRequest.java | 2 + .../_ListSecurityGroupsResponse.java | 2 +- .../BindRunningSecurityGroupRequestTest.java | 6 +- .../BindStagingSecurityGroupRequestTest.java | 31 +++-- 16 files changed, 152 insertions(+), 111 deletions(-) create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_request.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_response.json diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index 2ae6ddb31a..a396d7b79e 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -41,73 +41,79 @@ */ public final class ReactorSecurityGroupsV3 extends AbstractClientV3Operations implements SecurityGroupsV3 { - /** - * 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 ReactorSecurityGroupsV3(ConnectionContext connectionContext, Mono root, TokenProvider tokenProvider, - Map requestTags) { - super(connectionContext, root, tokenProvider, requestTags); - } + /** + * 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 ReactorSecurityGroupsV3(ConnectionContext connectionContext, Mono root, + TokenProvider tokenProvider, + Map requestTags) { + super(connectionContext, root, tokenProvider, requestTags); + } - @Override - public Mono create(CreateSecurityGroupRequest request) { - return post(request, CreateSecurityGroupResponse.class, builder -> builder.pathSegment("security_groups")) - .checkpoint(); + @Override + public Mono create(CreateSecurityGroupRequest request) { + return post(request, CreateSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups")) + .checkpoint(); - } + } - @Override - public Mono get(GetSecurityGroupRequest request) { - return get(request, GetSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) - .checkpoint(); + @Override + public Mono get(GetSecurityGroupRequest request) { + return get(request, GetSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); - } + } - @Override - public Mono list(ListSecurityGroupsRequest request) { - return get(request, ListSecurityGroupsResponse.class, - builder -> builder.pathSegment("security_groups")) - .checkpoint(); - } + @Override + public Mono list(ListSecurityGroupsRequest request) { + return get(request, ListSecurityGroupsResponse.class, + builder -> builder.pathSegment("security_groups")) + .checkpoint(); + } - @Override - public Mono update(UpdateSecurityGroupRequest request) { - return patch(request, UpdateSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) - .checkpoint(); - } + @Override + public Mono update(UpdateSecurityGroupRequest request) { + return patch(request, UpdateSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); + } - @Override - public Mono delete(DeleteSecurityGroupRequest request) { - return delete(request, String.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) - .checkpoint(); + @Override + public Mono delete(DeleteSecurityGroupRequest request) { + return delete(request, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); - } + } - @Override - public Mono bindRunningSecurityGroup(BindRunningSecurityGroupRequest request) { - return post(request, BindRunningSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), "relationships", - "running_spaces")) - .checkpoint(); - } + @Override + public Mono bindRunningSecurityGroup( + BindRunningSecurityGroupRequest request) { + return post(request, BindRunningSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), + "relationships", + "running_spaces")) + .checkpoint(); + } - @Override - public Mono bindStagingSecurityGroup(BindStagingSecurityGroupRequest request) { - return post(request, BindStagingSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), "relationships", - "staging_spaces")) - .checkpoint(); - } + @Override + public Mono bindStagingSecurityGroup( + BindStagingSecurityGroupRequest request) { + return post(request, BindStagingSecurityGroupResponse.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), + "relationships", + "staging_spaces")) + .checkpoint(); + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 12d43f4fbc..7c268051ba 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -262,7 +262,13 @@ public void list() { .id("a89a788e-671f-4549-814d-e34c1b2f533a") .createdAt("2020-02-20T17:42:08Z") .updatedAt("2020-02-20T17:42:08Z") - .relationships(Relationships.builder().build()) + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship + .builder().build()) + .runningSpaces(ToManyRelationship + .builder().build()) + + .build()) .globallyEnabled(GloballyEnabled .builder() .staging(true) @@ -286,7 +292,8 @@ public void list() { public void update() { mockRequest(InteractionContext.builder() .request(TestRequest.builder() - .method(PATCH).path("/security_groups") + .method(PATCH) + .path("/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") .payload("fixtures/client/v3/security_groups/PATCH_{id}_request.json") .build()) .response(TestResponse.builder() @@ -368,7 +375,7 @@ public void delete() { .response(TestResponse.builder() .status(ACCEPTED) .header("Location", - "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + "https://api.example.org/v3/jobs/b85a788e-671f-4549-814d-e34cdb2f539a") .build()) .build()); @@ -397,21 +404,15 @@ public void bindStagingSecurityGroup() { .build()); this.securityGroups.bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .boundSpaces(ToManyRelationship.builder() - .data(Relationship.builder().id("space-guid1").build()) - .data(Relationship.builder().id("space-guid2").build()) - .build()) + .boundSpaces(Relationship.builder().id("space-guid1").build()) + .boundSpaces(Relationship.builder().id("space-guid2").build()) + .build()) .as(StepVerifier::create) .expectNext(BindStagingSecurityGroupResponse.builder() - .boundSpaces(ToManyRelationship.builder() - .data(Relationship.builder().id("space-guid1").build()) - .data(Relationship.builder().id("space-guid2").build()) - .data(Relationship.builder().id("previous-space-guid") - .build()) - .build() - - ) + .boundSpaces(Relationship.builder().id("space-guid1").build()) + .boundSpaces(Relationship.builder().id("space-guid2").build()) + .boundSpaces(Relationship.builder().id("previous-space-guid").build()) .link("self", Link.builder() .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/staging_spaces") .build()) @@ -435,21 +436,14 @@ public void bindRunningSecurityGroup() { .build()); this.securityGroups.bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .boundSpaces(ToManyRelationship.builder() - .data(Relationship.builder().id("space-guid1").build()) - .data(Relationship.builder().id("space-guid2").build()) - .build()) + .boundSpaces(Relationship.builder().id("space-guid1").build()) + .boundSpaces(Relationship.builder().id("space-guid2").build()) .build()) .as(StepVerifier::create) .expectNext(BindRunningSecurityGroupResponse.builder() - .boundSpaces(ToManyRelationship.builder() - .data(Relationship.builder().id("space-guid1").build()) - .data(Relationship.builder().id("space-guid2").build()) - .data(Relationship.builder().id("previous-space-guid") - .build()) - .build() - - ) + .boundSpaces(Relationship.builder().id("space-guid1").build()) + .boundSpaces(Relationship.builder().id("space-guid2").build()) + .boundSpaces(Relationship.builder().id("previous-space-guid").build()) .link("self", Link.builder() .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/running_spaces") .build()) diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_request.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_request.json new file mode 100644 index 0000000000..eaa31060ca --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_request.json @@ -0,0 +1,10 @@ +{ + "data": [ + { + "guid": "space-guid1" + }, + { + "guid": "space-guid2" + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_response.json new file mode 100644 index 0000000000..35ce11babf --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/bind_running/POST_response.json @@ -0,0 +1,18 @@ +{ + "data": [ + { + "guid": "space-guid1" + }, + { + "guid": "space-guid2" + }, + { + "guid": "previous-space-guid" + } + ], + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/running_spaces" + } + } +} \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java index 3e3fa620fc..aca1ce438e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java @@ -16,6 +16,9 @@ package org.cloudfoundry.client.v3.securitygroups; +import java.util.List; + +import org.cloudfoundry.client.v3.Relationship; import org.cloudfoundry.client.v3.ToManyRelationship; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -36,5 +39,5 @@ public abstract class AbstractBindSecurityGroupRequest { * applications during runtime */ @JsonProperty("data") - abstract ToManyRelationship getBoundSpaces(); + abstract List getBoundSpaces(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java index b484eca127..46cb4a2b26 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java @@ -16,11 +16,13 @@ package org.cloudfoundry.client.v3.securitygroups; +import java.util.List; import java.util.Map; import org.cloudfoundry.AllowNulls; import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.Link; +import org.cloudfoundry.client.v3.Relationship; import org.cloudfoundry.client.v3.ToManyRelationship; import com.fasterxml.jackson.annotation.JsonProperty; @@ -34,7 +36,7 @@ public abstract class AbstractBindSecurityGroupResponse { * applications during runtime */ @JsonProperty("data") - abstract ToManyRelationship getBoundSpaces(); + abstract List getBoundSpaces(); /** * The links diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index ff2ef0f6e0..a66fc07d1b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -62,7 +62,7 @@ public interface SecurityGroupsV3 { /** * Makes the Delete + * "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#delete-a-security-group">Delete * Security Groups request * * @param request the Delete Security Group request diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java index cdb778207b..1615113093 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java @@ -18,6 +18,9 @@ import org.immutables.value.Value; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonSerialize @Value.Immutable abstract class _BindRunningSecurityGroupRequest extends AbstractBindSecurityGroupRequest { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java index d504100af4..3650024de5 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java @@ -18,6 +18,9 @@ import org.immutables.value.Value; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize @Value.Immutable public abstract class _BindRunningSecurityGroupResponse extends AbstractBindSecurityGroupResponse { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java index 07762e5bef..9cd36ebe0e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java @@ -17,7 +17,9 @@ package org.cloudfoundry.client.v3.securitygroups; import org.immutables.value.Value; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +@JsonSerialize @Value.Immutable abstract class _BindStagingSecurityGroupRequest extends AbstractBindSecurityGroupRequest { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java index 045c90096a..5ffa11a648 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java @@ -17,7 +17,9 @@ package org.cloudfoundry.client.v3.securitygroups; import org.immutables.value.Value; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +@JsonDeserialize @Value.Immutable public abstract class _BindStagingSecurityGroupResponse extends AbstractBindSecurityGroupResponse { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java index 812220b3f5..765f581331 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java @@ -23,7 +23,6 @@ /** * The request payload for the Delete Security Group operation */ -@JsonSerialize @Value.Immutable abstract class _DeleteSecurityGroupRequest { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java index 7945fe21ac..5e640e50c9 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java @@ -60,11 +60,13 @@ abstract class _ListSecurityGroupsRequest extends PaginatedRequest { * the security group running_space_guids filter */ @FilterParameter("running_space_guids") + @Nullable abstract List getRunningSpaceIds(); /** * the security group staging_space_guids filter */ @FilterParameter("staging_space_guids") + @Nullable abstract List getStagingSpaceIds(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java index ea8427e71d..f19bfc7613 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsResponse.java @@ -26,6 +26,6 @@ */ @JsonDeserialize @Value.Immutable -abstract class _ListSecurityGroupsResponse extends PaginatedResponse { +abstract class _ListSecurityGroupsResponse extends PaginatedResponse { } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java index cea1b74809..a62f24214b 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java @@ -16,10 +16,8 @@ public void noSecurityGroupId() { public void valid() { BindRunningSecurityGroupRequest.builder() .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .boundSpaces(ToManyRelationship.builder() - .data(Relationship.builder() - .id("space-guid-1") - .build()) + .boundSpaces(Relationship.builder() + .id("space-guid-1") .build()) .build(); } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java index 2bc79fad25..24ef538685 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java @@ -6,21 +6,20 @@ public class BindStagingSecurityGroupRequestTest { - @Test(expected = IllegalStateException.class) - public void noSecurityGroupId() { - BindStagingSecurityGroupRequest.builder() - .build(); - } + @Test(expected = IllegalStateException.class) + public void noSecurityGroupId() { + BindStagingSecurityGroupRequest.builder() + .build(); + } - @Test - public void valid() { - BindStagingSecurityGroupRequest.builder() - .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .boundSpaces(ToManyRelationship.builder() - .data(Relationship.builder() - .id("space-guid-1") - .build()) - .build()) - .build(); - } + @Test + public void valid() { + BindStagingSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .boundSpaces(Relationship.builder() + .id("space-guid-1") + .build()) + + .build(); + } } From e9bac3ae69abdc081d180c4d5b9e348386228ff8 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Tue, 11 Jul 2023 07:31:43 +0000 Subject: [PATCH 12/21] adding unbind security group --- .../ReactorSecurityGroupsV3.java | 23 ++++++++++ .../ReactorSecurityGroupsV3Test.java | 46 ++++++++++++++++++- .../AbstractUnbindSecurityGroupRequest.java | 34 ++++++++++++++ .../v3/securitygroups/SecurityGroupsV3.java | 26 ++++++++++- .../_UnbindRunningSecurityGroupRequest.java | 27 +++++++++++ .../_UnbindStagingSecurityGroupRequest.java | 27 +++++++++++ ...UnbindRunningSecurityGroupRequestTest.java | 28 +++++++++++ ...UnbindStagingSecurityGroupRequestTest.java | 27 +++++++++++ 8 files changed, 235 insertions(+), 3 deletions(-) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index a396d7b79e..71561e5823 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -24,12 +24,15 @@ import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupResponse; +import org.cloudfoundry.client.v3.servicebindings.ServiceBindingsV3; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.UnbindRunningSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.UnbindStagingSecurityGroupRequest; import org.cloudfoundry.reactor.ConnectionContext; import org.cloudfoundry.reactor.TokenProvider; import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations; @@ -116,4 +119,24 @@ public Mono bindStagingSecurityGroup( "staging_spaces")) .checkpoint(); } + + @Override + public Mono unbindStagingSecurityGroup( + UnbindStagingSecurityGroupRequest request) { + return delete(request, Void.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), + "relationships", + "staging_spaces", request.getSpaceId())) + .checkpoint(); + } + + @Override + public Mono unbindRunningSecurityGroup( + UnbindRunningSecurityGroupRequest request) { + return delete(request, Void.class, + builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), + "relationships", + "running_spaces", request.getSpaceId())) + .checkpoint(); + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 7c268051ba..cd5151d11f 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -21,6 +21,8 @@ import org.cloudfoundry.reactor.TestRequest; import org.cloudfoundry.reactor.TestResponse; import org.cloudfoundry.client.v3.securitygroups.Relationships; +import org.cloudfoundry.client.v3.securitygroups.UnbindRunningSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.UnbindStagingSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; @@ -54,7 +56,8 @@ import static io.netty.handler.codec.http.HttpMethod.POST; import static io.netty.handler.codec.http.HttpResponseStatus.CREATED; import static io.netty.handler.codec.http.HttpResponseStatus.OK; -import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED;; +import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; +import static io.netty.handler.codec.http.HttpResponseStatus.NO_CONTENT;; public final class ReactorSecurityGroupsV3Test extends AbstractClientApiTest { @@ -452,4 +455,45 @@ public void bindRunningSecurityGroup() { .verify(Duration.ofSeconds(5)); } + @Test + public void unbindStagingSecurityGroup() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(DELETE) + .path("/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/staging_spaces/space-guid-1") + .build()) + .response(TestResponse.builder() + .status(NO_CONTENT) + .build()) + .build()); + this.securityGroups + .unbindStagingSecurityGroup(UnbindStagingSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .spaceId("space-guid-1") + .build()) + .as(StepVerifier::create) + .expectNextCount(0) + .verifyComplete(); + } + + @Test + public void unbindRunningSecurityGroup() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(DELETE) + .path("/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a/relationships/running_spaces/space-guid-1") + .build()) + .response(TestResponse.builder() + .status(NO_CONTENT) + .build()) + .build()); + this.securityGroups + .unbindRunningSecurityGroup(UnbindRunningSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .spaceId("space-guid-1") + .build()) + .as(StepVerifier::create) + .expectNextCount(0) + .verifyComplete(); + } } \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java new file mode 100644 index 0000000000..f2cf32a02b --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java @@ -0,0 +1,34 @@ +/* + * 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.securitygroups; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public abstract class AbstractUnbindSecurityGroupRequest { + + /** + * The Security Group id + */ + @JsonIgnore + abstract String getSecurityGroupId(); + + /** + * The Space id + */ + @JsonIgnore + abstract String getSpaceId(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index a66fc07d1b..defeedbe1b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -56,7 +56,7 @@ public interface SecurityGroupsV3 { * Security Groups request * * @param request the Update Security Group request - * @return the response from the List Security Group request + * @return the response from the Update Security Group request */ Mono update(UpdateSecurityGroupRequest request); @@ -66,7 +66,7 @@ public interface SecurityGroupsV3 { * Security Groups request * * @param request the Delete Security Group request - * @return the response from the List Security Group request + * @return the response from the Delete Security Group request */ Mono delete(DeleteSecurityGroupRequest request); @@ -89,4 +89,26 @@ public interface SecurityGroupsV3 { * @return the response from the Bind Running Security Group request */ Mono bindRunningSecurityGroup(BindRunningSecurityGroupRequest request); + + /** + * Makes the Unbind + * Staging + * Security Group request + * + * @param request the Unbind Staging Security Group request + * @return the response from the Unbind staging Security Group request + */ + Mono unbindStagingSecurityGroup(UnbindStagingSecurityGroupRequest request); + + /** + * Makes the Unbind + * Running + * Security Groups request + * + * @param request the Unbind Staging Running Security Group request + * @return the response from the Unbind Running Security Group request + */ + Mono unbindRunningSecurityGroup(UnbindRunningSecurityGroupRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java new file mode 100644 index 0000000000..0485627e43 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java @@ -0,0 +1,27 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +/** + * The request payload for the Unbind Running Security Group operation + */ +@Value.Immutable +abstract class _UnbindRunningSecurityGroupRequest extends AbstractUnbindSecurityGroupRequest { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java new file mode 100644 index 0000000000..768b02bdaa --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java @@ -0,0 +1,27 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +/** + * The request payload for the Unbind Staging Security Group operation + */ +@Value.Immutable +abstract class _UnbindStagingSecurityGroupRequest extends AbstractUnbindSecurityGroupRequest { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java new file mode 100644 index 0000000000..590305f9b1 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java @@ -0,0 +1,28 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class UnbindRunningSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSecurityGroupId() { + UnbindRunningSecurityGroupRequest.builder() + .build(); + } + + @Test(expected = IllegalStateException.class) + public void noSpaceId() { + UnbindRunningSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .build(); + } + + @Test + public void valid() { + UnbindRunningSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .spaceId("space-guid2") + .build(); + } + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java new file mode 100644 index 0000000000..b9f4d71da5 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java @@ -0,0 +1,27 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class UnbindStagingSecurityGroupRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSecurityGroupId() { + UnbindStagingSecurityGroupRequest.builder() + .build(); + } + + @Test(expected = IllegalStateException.class) + public void noSpaceId() { + UnbindStagingSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .build(); + } + + @Test + public void valid() { + UnbindStagingSecurityGroupRequest.builder() + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + .spaceId("space-guid2") + .build(); + } +} From 6cb276decc0936ba68d0260443c4cf9de7f40527 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Tue, 11 Jul 2023 08:41:20 +0000 Subject: [PATCH 13/21] adding list running/staging api and tests --- .../ReactorSecurityGroupsV3.java | 20 ++ .../ReactorSecurityGroupsV3Test.java | 208 ++++++++++++++++++ .../GET_running_{id}_response.json | 84 +++++++ .../GET_staging_{id}_response.json | 84 +++++++ .../AbstractListSecurityGroupRequest.java | 33 +++ .../v3/securitygroups/SecurityGroupsV3.java | 20 ++ .../_ListRunningSecurityGroupsRequest.java | 29 +++ .../_ListRunningSecurityGroupsResponse.java | 31 +++ .../_ListStagingSecurityGroupsRequest.java | 31 +++ .../_ListStagingSecurityGroupsResponse.java | 31 +++ .../ListRunningSecurityGroupsRequestTest.java | 20 ++ .../ListStagingSecurityGroupsRequestTest.java | 20 ++ 12 files changed, 611 insertions(+) create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_running_{id}_response.json create mode 100644 cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_staging_{id}_response.json create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java create mode 100644 cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index 71561e5823..1583f6a928 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -27,6 +27,10 @@ import org.cloudfoundry.client.v3.servicebindings.ServiceBindingsV3; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; +import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsResponse; +import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsResponse; import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; @@ -139,4 +143,20 @@ public Mono unbindRunningSecurityGroup( "running_spaces", request.getSpaceId())) .checkpoint(); } + + @Override + public Mono listRunning(ListRunningSecurityGroupsRequest request) { + return get(request, ListRunningSecurityGroupsResponse.class, + builder -> builder.pathSegment("spaces", request.getSpaceId(), + "running_security_groups")) + .checkpoint(); + } + + @Override + public Mono listStaging(ListStagingSecurityGroupsRequest request) { + return get(request, ListStagingSecurityGroupsResponse.class, + builder -> builder.pathSegment("spaces", request.getSpaceId(), + "staging_security_groups")) + .checkpoint(); + } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index cd5151d11f..018a50cb22 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -32,6 +32,10 @@ import org.cloudfoundry.client.v3.securitygroups.SecurityGroupResource; import org.cloudfoundry.client.v3.securitygroups.GloballyEnabled; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsResponse; +import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsResponse; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse; import org.cloudfoundry.client.v3.securitygroups.Protocol; import org.cloudfoundry.client.v3.securitygroups.Rule; @@ -496,4 +500,208 @@ public void unbindRunningSecurityGroup() { .expectNextCount(0) .verifyComplete(); } + + @Test + public void listRunning() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(GET) + .path("/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/running_security_groups") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/security_groups/GET_running_{id}_response.json") + .build()) + .build()); + + this.securityGroups + .listRunning(ListRunningSecurityGroupsRequest.builder() + .spaceId("c5048979-53b9-4d2a-9fca-78e6bc07c041").build()) + .as(StepVerifier::create) + .expectNext(ListRunningSecurityGroupsResponse.builder() + .pagination(Pagination.builder() + .totalResults(1) + .totalPages(1) + .first(Link.builder() + .href("https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/running_security_groups?page=1&per_page=50") + .build()) + .last(Link.builder() + .href("https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/running_security_groups?page=1&per_page=50") + .build()) + .build()) + .resource(SecurityGroupResource.builder() + .name("my-group0") + .id("b85a788e-671f-4549-814d-e34cdb2f539a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .globallyEnabled(GloballyEnabled + .builder() + .staging(false) + .running(true) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship + .builder() + + .build()) + .runningSpaces(ToManyRelationship + .builder() + .data(Relationship + .builder() + .id("space-guid-1") + .build()) + .data(Relationship + .builder() + .id("space-guid-2") + .build()) + .build()) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .build()) + .resource(SecurityGroupResource.builder() + .name("my-group1") + .id("a89a788e-671f-4549-814d-e34c1b2f533a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship + .builder().build()) + .runningSpaces(ToManyRelationship + .builder().build()) + + .build()) + .globallyEnabled(GloballyEnabled + .builder() + .staging(true) + .running(true) + .build()) + .globallyEnabled(GloballyEnabled + .builder() + .staging(true) + .running(true) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a") + .build()) + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } + + @Test + public void listStaging() { + mockRequest(InteractionContext.builder() + .request(TestRequest.builder() + .method(GET) + .path("/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/staging_security_groups") + .build()) + .response(TestResponse.builder() + .status(OK) + .payload("fixtures/client/v3/security_groups/GET_staging_{id}_response.json") + .build()) + .build()); + + this.securityGroups + .listStaging(ListStagingSecurityGroupsRequest.builder() + .spaceId("c5048979-53b9-4d2a-9fca-78e6bc07c041").build()) + .as(StepVerifier::create) + .expectNext(ListStagingSecurityGroupsResponse.builder() + .pagination(Pagination.builder() + .totalResults(1) + .totalPages(1) + .first(Link.builder() + .href("https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/staging_security_groups?page=1&per_page=50") + .build()) + .last(Link.builder() + .href("https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/staging_security_groups?page=1&per_page=50") + .build()) + .build()) + .resource(SecurityGroupResource.builder() + .name("my-group0") + .id("b85a788e-671f-4549-814d-e34cdb2f539a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .globallyEnabled(GloballyEnabled + .builder() + .staging(true) + .running(false) + .build()) + .rules(Rule.builder() + .protocol(Protocol.TCP) + .destination("10.10.10.0/24") + .ports("443,80,8080") + .build()) + .rules(Rule.builder() + .protocol(Protocol.ICMP) + .destination("10.10.10.0/24") + .description("Allow ping requests to private services") + .type(8) + .code(0) + .build()) + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship + .builder() + .data(Relationship + .builder() + .id("space-guid-1") + .build()) + .data(Relationship + .builder() + .id("space-guid-2") + .build()) + .build()) + .runningSpaces(ToManyRelationship + .builder() + + .build()) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a") + .build()) + .build()) + .resource(SecurityGroupResource.builder() + .name("my-group1") + .id("a89a788e-671f-4549-814d-e34c1b2f533a") + .createdAt("2020-02-20T17:42:08Z") + .updatedAt("2020-02-20T17:42:08Z") + .relationships(Relationships.builder() + .stagingSpaces(ToManyRelationship + .builder().build()) + .runningSpaces(ToManyRelationship + .builder().build()) + + .build()) + .globallyEnabled(GloballyEnabled + .builder() + .staging(true) + .running(true) + .build()) + .globallyEnabled(GloballyEnabled + .builder() + .staging(true) + .running(true) + .build()) + .link("self", Link.builder() + .href("https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a") + .build()) + .build()) + .build()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + } } \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_running_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_running_{id}_response.json new file mode 100644 index 0000000000..c02b6b9526 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_running_{id}_response.json @@ -0,0 +1,84 @@ +{ + "pagination": { + "total_results": 1, + "total_pages": 1, + "first": { + "href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/running_security_groups?page=1&per_page=50" + }, + "last": { + "href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/running_security_groups?page=1&per_page=50" + }, + "next": null, + "previous": null + }, + "resources": [ + { + "guid": "b85a788e-671f-4549-814d-e34cdb2f539a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group0", + "globally_enabled": { + "running": true, + "staging": false + }, + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ], + "relationships": { + "staging_spaces": { + "data": [] + }, + "running_spaces": { + "data": [ + { + "guid": "space-guid-1" + }, + { + "guid": "space-guid-2" + } + ] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a" + } + } + }, + { + "guid": "a89a788e-671f-4549-814d-e34c1b2f533a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group1", + "globally_enabled": { + "running": true, + "staging": true + }, + "rules": [], + "relationships": { + "staging_spaces": { + "data": [] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a" + } + } + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_staging_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_staging_{id}_response.json new file mode 100644 index 0000000000..b9dede1538 --- /dev/null +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/security_groups/GET_staging_{id}_response.json @@ -0,0 +1,84 @@ +{ + "pagination": { + "total_results": 1, + "total_pages": 1, + "first": { + "href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/staging_security_groups?page=1&per_page=50" + }, + "last": { + "href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/staging_security_groups?page=1&per_page=50" + }, + "next": null, + "previous": null + }, + "resources": [ + { + "guid": "b85a788e-671f-4549-814d-e34cdb2f539a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group0", + "globally_enabled": { + "running": false, + "staging": true + }, + "rules": [ + { + "protocol": "tcp", + "destination": "10.10.10.0/24", + "ports": "443,80,8080" + }, + { + "protocol": "icmp", + "destination": "10.10.10.0/24", + "type": 8, + "code": 0, + "description": "Allow ping requests to private services" + } + ], + "relationships": { + "staging_spaces": { + "data": [ + { + "guid": "space-guid-1" + }, + { + "guid": "space-guid-2" + } + ] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a" + } + } + }, + { + "guid": "a89a788e-671f-4549-814d-e34c1b2f533a", + "created_at": "2020-02-20T17:42:08Z", + "updated_at": "2020-02-20T17:42:08Z", + "name": "my-group1", + "globally_enabled": { + "running": true, + "staging": true + }, + "rules": [], + "relationships": { + "staging_spaces": { + "data": [] + }, + "running_spaces": { + "data": [] + } + }, + "links": { + "self": { + "href": "https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a" + } + } + } + ] +} \ No newline at end of file diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java new file mode 100644 index 0000000000..8d5aa91972 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java @@ -0,0 +1,33 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import java.util.List; + +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v2.PaginatedRequest; +import org.cloudfoundry.client.v3.FilterParameter; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public abstract class AbstractListSecurityGroupRequest extends PaginatedRequest { + + /** + * The Space id + */ + @JsonIgnore + abstract String getSpaceId(); + + /** + * The security group ids filter + */ + @FilterParameter("guids") + @Nullable + abstract List getSecurityGroupIds(); + + /** + * The security group names filter + */ + @FilterParameter("names") + @Nullable + abstract List getNames(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java index defeedbe1b..e90ca3f43e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java @@ -111,4 +111,24 @@ public interface SecurityGroupsV3 { * @return the response from the Unbind Running Security Group request */ Mono unbindRunningSecurityGroup(UnbindRunningSecurityGroupRequest request); + + /** + * Makes the List + * Running Security Groups request + * + * @param request the List Staging Security Group request + * @return the response from the List Staging Security Group request + */ + Mono listStaging(ListStagingSecurityGroupsRequest request); + + /** + * Makes the List + * Running Security Groups request + * + * @param request the List Staging Security Group request + * @return the response from the List Running Security Group request + */ + Mono listRunning(ListRunningSecurityGroupsRequest request); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java new file mode 100644 index 0000000000..d55296c97e --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java @@ -0,0 +1,29 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; +import com.fasterxml.jackson.databind.annotation.JsonSerialize;; + +/** + * The request payload for the List running Security Group operation + */ + +@Value.Immutable +abstract class _ListRunningSecurityGroupsRequest extends AbstractListSecurityGroupRequest { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java new file mode 100644 index 0000000000..e4cfb286f4 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java @@ -0,0 +1,31 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +import org.cloudfoundry.client.v3.PaginatedResponse; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +/** + * The response payload for the List Security Groups operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _ListRunningSecurityGroupsResponse extends PaginatedResponse { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java new file mode 100644 index 0000000000..7d3a343abc --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java @@ -0,0 +1,31 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize;; + +/** + * The request payload for the List staging Security Group operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _ListStagingSecurityGroupsRequest extends AbstractListSecurityGroupRequest { + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java new file mode 100644 index 0000000000..86fff12ad8 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java @@ -0,0 +1,31 @@ +/* + * 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.securitygroups; + +import org.immutables.value.Value; + +import org.cloudfoundry.client.v3.PaginatedResponse; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +/** + * The response payload for the List Security Groups operation + */ +@JsonDeserialize +@Value.Immutable +abstract class _ListStagingSecurityGroupsResponse extends PaginatedResponse { + +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java new file mode 100644 index 0000000000..824335c57f --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java @@ -0,0 +1,20 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class ListRunningSecurityGroupsRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSpaceID() { + ListRunningSecurityGroupsRequest.builder() + .build(); + } + + @Test + public void valid() { + ListRunningSecurityGroupsRequest.builder() + .spaceId("space-giud1") + .build(); + } + +} \ No newline at end of file diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java new file mode 100644 index 0000000000..ea1ab90f93 --- /dev/null +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java @@ -0,0 +1,20 @@ +package org.cloudfoundry.client.v3.securitygroups; + +import org.junit.Test; + +public class ListStagingSecurityGroupsRequestTest { + + @Test(expected = IllegalStateException.class) + public void noSpaceID() { + ListStagingSecurityGroupsRequest.builder() + .build(); + } + + @Test + public void valid() { + ListStagingSecurityGroupsRequest.builder() + .spaceId("space-giud1") + .build(); + } + +} \ No newline at end of file From bdc04f490b5e1b43b77b011eb75c98b354259ff8 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Wed, 12 Jul 2023 12:00:44 +0000 Subject: [PATCH 14/21] adding create security group test --- .../client/v3/SecurityGroupsTest.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java new file mode 100644 index 0000000000..c5991ee187 --- /dev/null +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -0,0 +1,66 @@ +/* + * 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.CloudFoundryVersion; +import org.cloudfoundry.IfCloudFoundryVersion; +import org.cloudfoundry.AbstractIntegrationTest; +import org.cloudfoundry.client.CloudFoundryClient; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; +import org.cloudfoundry.client.v3.securitygroups.Rule; +import org.cloudfoundry.util.JobUtils; +import org.cloudfoundry.util.PaginationUtils; +import org.cloudfoundry.util.ResourceUtils; +import org.junit.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.cloudfoundry.client.v3.securitygroups.Protocol.TCP; +import static org.cloudfoundry.util.tuple.TupleUtils.function; + +public final class SecurityGroupsTest extends AbstractIntegrationTest { + + @Autowired + private CloudFoundryClient cloudFoundryClient; + + @Test + public void create() { + String securityGroupName = this.nameFactory.getSecurityGroupName(); + + this.cloudFoundryClient.securityGroupsV3() + .create(CreateSecurityGroupRequest.builder() + .name(securityGroupName) + .rule(Rule.builder() + .destination("0.0.0.0/0") + .log(false) + .ports("2048-3000") + .protocol(TCP) + .build()) + .build()) + .map(response -> response.getName()) + .as(StepVerifier::create) + .expectNext(securityGroupName) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + +} From cb0dff512bd6e5874dbfb42a021ab0ffc43faef2 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Fri, 14 Jul 2023 08:32:53 +0000 Subject: [PATCH 15/21] adding integration tests --- .../client/v3/SecurityGroupsTest.java | 163 ++++++++++++++++-- 1 file changed, 153 insertions(+), 10 deletions(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java index c5991ee187..d5bb8023dd 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -16,35 +16,49 @@ package org.cloudfoundry.client.v3; -import org.cloudfoundry.CloudFoundryVersion; -import org.cloudfoundry.IfCloudFoundryVersion; import org.cloudfoundry.AbstractIntegrationTest; import org.cloudfoundry.client.CloudFoundryClient; +import org.cloudfoundry.client.v3.securitygroups.UnbindStagingSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.UnbindRunningSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; -import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.Rule; +import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.DeleteSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest; +import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest; import org.cloudfoundry.util.JobUtils; -import org.cloudfoundry.util.PaginationUtils; -import org.cloudfoundry.util.ResourceUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.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.cloudfoundry.client.v3.securitygroups.Protocol.TCP; -import static org.cloudfoundry.util.tuple.TupleUtils.function; public final class SecurityGroupsTest extends AbstractIntegrationTest { @Autowired private CloudFoundryClient cloudFoundryClient; - @Test - public void create() { - String securityGroupName = this.nameFactory.getSecurityGroupName(); + @Autowired + private Mono organizationId; + + private String securityGroupName; + private Mono securityGroupId; + + @Autowired + private Mono spaceId; + + @BeforeClass + public void settup() { + this.securityGroupName = this.nameFactory.getSecurityGroupName(); this.cloudFoundryClient.securityGroupsV3() .create(CreateSecurityGroupRequest.builder() @@ -56,6 +70,7 @@ public void create() { .protocol(TCP) .build()) .build()) + .doOnSuccess(response -> this.securityGroupId = Mono.just(response.getId())) .map(response -> response.getName()) .as(StepVerifier::create) .expectNext(securityGroupName) @@ -63,4 +78,132 @@ public void create() { .verify(Duration.ofMinutes(5)); } + @AfterClass + public void tearDown() { + this.cloudFoundryClient.securityGroupsV3().delete( + DeleteSecurityGroupRequest.builder() + .securityGroupId(this.securityGroupId.block()) + .build()) + .flatMap( + job -> JobUtils.waitForCompletion(this.cloudFoundryClient, + Duration.ofMinutes(5), job)) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void update() { + this.cloudFoundryClient.securityGroupsV3().update( + UpdateSecurityGroupRequest.builder() + .securityGroupId(securityGroupId.block()) + .rule(Rule.builder() + .destination("0.0.0.0/0") + .ports("8080") + .protocol(TCP) + .build()) + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + } + + @Test + public void get() { + this.cloudFoundryClient.securityGroupsV3().get( + GetSecurityGroupRequest.builder() + .securityGroupId(securityGroupId.block()) + .build()) + .map(securityGroup -> securityGroup.getName()) + .as(StepVerifier::create) + .expectNext(this.securityGroupName) + .expectComplete() + .verify(Duration.ofMinutes(5)); + + } + + @Test + public void list() { + this.cloudFoundryClient.securityGroupsV3().list( + ListSecurityGroupsRequest.builder() + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void listRunning() { + this.cloudFoundryClient.securityGroupsV3().listRunning( + ListRunningSecurityGroupsRequest.builder() + .spaceId(this.spaceId.block()) + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void listStaging() { + this.cloudFoundryClient.securityGroupsV3().listStaging( + ListStagingSecurityGroupsRequest.builder() + .spaceId(this.spaceId.block()) + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void bindStagingSecurityGroup() { + this.cloudFoundryClient.securityGroupsV3().bindStagingSecurityGroup( + BindStagingSecurityGroupRequest.builder() + .securityGroupId(this.securityGroupId.block()) + .boundSpaces(Relationship.builder() + .id(this.spaceId.block()) + .build()) + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void bindRunningSecurityGroup() { + this.cloudFoundryClient.securityGroupsV3().bindRunningSecurityGroup( + BindRunningSecurityGroupRequest.builder() + .securityGroupId(this.securityGroupId.block()) + .boundSpaces(Relationship.builder() + .id(this.spaceId.block()) + .build()) + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void unbindRunningSecurityGroup() { + this.cloudFoundryClient.securityGroupsV3().unbindRunningSecurityGroup( + UnbindRunningSecurityGroupRequest.builder() + .securityGroupId(this.securityGroupId.block()) + .spaceId(this.spaceId.block()) + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + + @Test + public void unbindStagingSecurityGroup() { + this.cloudFoundryClient.securityGroupsV3().unbindStagingSecurityGroup( + UnbindStagingSecurityGroupRequest.builder() + .securityGroupId(this.securityGroupId.block()) + .spaceId(this.spaceId.block()) + .build()) + .as(StepVerifier::create) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } } From f1e1b4ee5346c70cc3e349734e72c573e2c58805 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Fri, 14 Jul 2023 08:34:28 +0000 Subject: [PATCH 16/21] adding integration tests --- .../java/org/cloudfoundry/client/v3/SecurityGroupsTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java index d5bb8023dd..ecd7c50e99 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -47,9 +47,6 @@ public final class SecurityGroupsTest extends AbstractIntegrationTest { @Autowired private CloudFoundryClient cloudFoundryClient; - @Autowired - private Mono organizationId; - private String securityGroupName; private Mono securityGroupId; From 92b4dd2c8b31f1222de33865ca97f7927789d6e6 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Fri, 14 Jul 2023 09:53:51 +0000 Subject: [PATCH 17/21] small fixes --- .../cloudfoundry/client/v3/SecurityGroupsTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java index ecd7c50e99..1945a5b89f 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -31,8 +31,8 @@ import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest; import org.cloudfoundry.util.JobUtils; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; @@ -53,8 +53,8 @@ public final class SecurityGroupsTest extends AbstractIntegrationTest { @Autowired private Mono spaceId; - @BeforeClass - public void settup() { + @Before + void settup() { this.securityGroupName = this.nameFactory.getSecurityGroupName(); this.cloudFoundryClient.securityGroupsV3() @@ -75,8 +75,8 @@ public void settup() { .verify(Duration.ofMinutes(5)); } - @AfterClass - public void tearDown() { + @After + void tearDown() { this.cloudFoundryClient.securityGroupsV3().delete( DeleteSecurityGroupRequest.builder() .securityGroupId(this.securityGroupId.block()) From b1b90dfaa3b59b1d8d2abbbab2696fcf159bde85 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Fri, 14 Jul 2023 13:02:09 +0000 Subject: [PATCH 18/21] fixing setup/teardown --- .../java/org/cloudfoundry/client/v3/SecurityGroupsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java index 1945a5b89f..c7bf237f3c 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -54,7 +54,7 @@ public final class SecurityGroupsTest extends AbstractIntegrationTest { private Mono spaceId; @Before - void settup() { + prublic void settup() { this.securityGroupName = this.nameFactory.getSecurityGroupName(); this.cloudFoundryClient.securityGroupsV3() @@ -76,7 +76,7 @@ void settup() { } @After - void tearDown() { + public void tearDown() { this.cloudFoundryClient.securityGroupsV3().delete( DeleteSecurityGroupRequest.builder() .securityGroupId(this.securityGroupId.block()) From bc21c34591f439ba10e0b3d87c9aa8e6f3b51662 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Tue, 18 Jul 2023 07:02:10 +0000 Subject: [PATCH 19/21] fixing integration tests --- .../java/org/cloudfoundry/client/v3/SecurityGroupsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java index c7bf237f3c..6e8e8c1352 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -54,7 +54,7 @@ public final class SecurityGroupsTest extends AbstractIntegrationTest { private Mono spaceId; @Before - prublic void settup() { + public void settup() { this.securityGroupName = this.nameFactory.getSecurityGroupName(); this.cloudFoundryClient.securityGroupsV3() From eb9bb25a56bb09ef7a12f74d73b0a6f70319033c Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Wed, 19 Jul 2023 12:08:34 +0000 Subject: [PATCH 20/21] refactoring integration tests --- .../client/_ReactorCloudFoundryClient.java | 2 +- .../client/v3/SecurityGroupsTest.java | 199 +++++++++++------- 2 files changed, 124 insertions(+), 77 deletions(-) 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 d7e3747c2a..96183944c1 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 @@ -353,7 +353,7 @@ public SecurityGroups securityGroups() { @Override @Value.Derived public SecurityGroupsV3 securityGroupsV3() { - return new ReactorSecurityGroupsV3(getConnectionContext(), getRootV2(), getTokenProvider(), getRequestTags()); + return new ReactorSecurityGroupsV3(getConnectionContext(), getRootV3(), getTokenProvider(), getRequestTags()); } @Override diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java index 6e8e8c1352..700c9df32a 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -23,22 +23,30 @@ import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.Rule; +import org.cloudfoundry.client.v3.securitygroups.SecurityGroup; +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.securitygroups.Relationships; +import org.cloudfoundry.client.v3.securitygroups.GloballyEnabled; +import org.cloudfoundry.client.v3.securitygroups.SecurityGroup; import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.DeleteSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; +import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest; import org.cloudfoundry.util.JobUtils; -import org.junit.After; -import org.junit.Before; + import org.junit.Test; +import org.junit.Before; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; import java.time.Duration; +import java.util.Arrays; import static org.cloudfoundry.client.v3.securitygroups.Protocol.TCP; @@ -47,159 +55,198 @@ public final class SecurityGroupsTest extends AbstractIntegrationTest { @Autowired private CloudFoundryClient cloudFoundryClient; - private String securityGroupName; - private Mono securityGroupId; - @Autowired private Mono spaceId; + private Mono securityGroup; + private String securityGroupName; @Before public void settup() { this.securityGroupName = this.nameFactory.getSecurityGroupName(); - - this.cloudFoundryClient.securityGroupsV3() + String spaceID = this.spaceId.block(); + this.securityGroup = this.cloudFoundryClient.securityGroupsV3() .create(CreateSecurityGroupRequest.builder() - .name(securityGroupName) + .name(this.securityGroupName) + .globallyEnabled(GloballyEnabled.builder() + .staging(true) + .running(true) + .build()) .rule(Rule.builder() .destination("0.0.0.0/0") .log(false) .ports("2048-3000") .protocol(TCP) .build()) - .build()) - .doOnSuccess(response -> this.securityGroupId = Mono.just(response.getId())) - .map(response -> response.getName()) + .build()); + } + + @Test + public void create() { + this.securityGroup + .map(securityGroup -> securityGroup.getName()) .as(StepVerifier::create) - .expectNext(securityGroupName) + .expectNext(this.securityGroupName) .expectComplete() .verify(Duration.ofMinutes(5)); } - @After - public void tearDown() { - this.cloudFoundryClient.securityGroupsV3().delete( - DeleteSecurityGroupRequest.builder() - .securityGroupId(this.securityGroupId.block()) - .build()) - .flatMap( - job -> JobUtils.waitForCompletion(this.cloudFoundryClient, - Duration.ofMinutes(5), job)) + @Test + public void get() { + this.securityGroup + .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3() + .get(GetSecurityGroupRequest.builder() + .securityGroupId(securityGroup.getId()) + .build()) + .map(sg -> sg.getName())) .as(StepVerifier::create) + .expectNext(this.securityGroupName) .expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void update() { - this.cloudFoundryClient.securityGroupsV3().update( - UpdateSecurityGroupRequest.builder() - .securityGroupId(securityGroupId.block()) - .rule(Rule.builder() - .destination("0.0.0.0/0") - .ports("8080") - .protocol(TCP) - .build()) - .build()) + String newSecurityGroupName = this.nameFactory.getSecurityGroupName(); + this.securityGroup + .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3().update( + UpdateSecurityGroupRequest.builder() + .securityGroupId(securityGroup.getId()) + .name(newSecurityGroupName) + .build())) + .map(securityGroup -> securityGroup.getName()) .as(StepVerifier::create) + .expectNext(newSecurityGroupName) .expectComplete() .verify(Duration.ofMinutes(5)); - } @Test - public void get() { - this.cloudFoundryClient.securityGroupsV3().get( - GetSecurityGroupRequest.builder() - .securityGroupId(securityGroupId.block()) - .build()) - .map(securityGroup -> securityGroup.getName()) + public void delete() { + this.securityGroup + .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3().delete( + DeleteSecurityGroupRequest.builder() + .securityGroupId(securityGroup.getId()) + .build()) + .map(id -> Arrays.asList(id))) .as(StepVerifier::create) - .expectNext(this.securityGroupName) + .expectNextCount(1) .expectComplete() .verify(Duration.ofMinutes(5)); - } @Test public void list() { - this.cloudFoundryClient.securityGroupsV3().list( - ListSecurityGroupsRequest.builder() - .build()) + this.securityGroup.map( + securityGroup -> this.cloudFoundryClient.securityGroupsV3() + .list(ListSecurityGroupsRequest.builder() + .names(Arrays.asList(securityGroup.getName())) + .build())) .as(StepVerifier::create) + .expectNextCount(1) .expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void listRunning() { - this.cloudFoundryClient.securityGroupsV3().listRunning( - ListRunningSecurityGroupsRequest.builder() - .spaceId(this.spaceId.block()) - .build()) + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + .listRunning(ListRunningSecurityGroupsRequest.builder() + .spaceId(v.getT2()) + .names(Arrays.asList(v.getT1().getName())).build())) .as(StepVerifier::create) + .expectNextCount(1) .expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void listStaging() { - this.cloudFoundryClient.securityGroupsV3().listStaging( - ListStagingSecurityGroupsRequest.builder() - .spaceId(this.spaceId.block()) - .build()) + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + .listStaging(ListStagingSecurityGroupsRequest.builder() + .spaceId(v.getT2()) + .names(Arrays.asList(v.getT1().getName())).build())) .as(StepVerifier::create) + .expectNextCount(1) .expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void bindStagingSecurityGroup() { - this.cloudFoundryClient.securityGroupsV3().bindStagingSecurityGroup( - BindStagingSecurityGroupRequest.builder() - .securityGroupId(this.securityGroupId.block()) - .boundSpaces(Relationship.builder() - .id(this.spaceId.block()) - .build()) - .build()) + Mono.zip(this.securityGroup, this.spaceId) + .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + .bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder() + .id(v.getT2()).build()) + .build())) .as(StepVerifier::create) + .expectNextCount(1) .expectComplete() .verify(Duration.ofMinutes(5)); } @Test - public void bindRunningSecurityGroup() { - this.cloudFoundryClient.securityGroupsV3().bindRunningSecurityGroup( - BindRunningSecurityGroupRequest.builder() - .securityGroupId(this.securityGroupId.block()) - .boundSpaces(Relationship.builder() - .id(this.spaceId.block()) + public void unbindStagingSecurityGroup() { + Mono.zip(this.securityGroup, this.spaceId) + .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + .bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder().id(v.getT2()) + .build()) .build()) - .build()) + .then(this.cloudFoundryClient.securityGroupsV3() + .unbindStagingSecurityGroup( + UnbindStagingSecurityGroupRequest + .builder() + .securityGroupId(v + .getT1() + .getId()) + .spaceId(v.getT2()) + .build()))) + .as(StepVerifier::create) + .expectNextCount(0) .expectComplete() .verify(Duration.ofMinutes(5)); } @Test - public void unbindRunningSecurityGroup() { - this.cloudFoundryClient.securityGroupsV3().unbindRunningSecurityGroup( - UnbindRunningSecurityGroupRequest.builder() - .securityGroupId(this.securityGroupId.block()) - .spaceId(this.spaceId.block()) - .build()) + public void bindRunningSecurityGroup() { + Mono.zip(this.securityGroup, this.spaceId) + .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + .bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder().id(v.getT2()) + .build()) + .build())) .as(StepVerifier::create) + .expectNextCount(1) .expectComplete() .verify(Duration.ofMinutes(5)); } @Test - public void unbindStagingSecurityGroup() { - this.cloudFoundryClient.securityGroupsV3().unbindStagingSecurityGroup( - UnbindStagingSecurityGroupRequest.builder() - .securityGroupId(this.securityGroupId.block()) - .spaceId(this.spaceId.block()) - .build()) + public void unbindRunnungSecurityGroup() { + Mono.zip(this.securityGroup, this.spaceId) + .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + .bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder().id(v.getT2()) + .build()) + .build()) + .then(this.cloudFoundryClient.securityGroupsV3() + .unbindRunningSecurityGroup( + UnbindRunningSecurityGroupRequest + .builder() + .securityGroupId(v + .getT1() + .getId()) + .spaceId(v.getT2()) + .build()))) + .as(StepVerifier::create) + .expectNextCount(0) .expectComplete() .verify(Duration.ofMinutes(5)); } From d6b4a409e0a55b05dcc05c23b4636959e5350153 Mon Sep 17 00:00:00 2001 From: Radoslav Tomov Date: Mon, 16 Oct 2023 12:42:01 +0000 Subject: [PATCH 21/21] imports and formating --- .../ReactorSecurityGroupsV3.java | 105 ++++----- .../ReactorSecurityGroupsV3Test.java | 4 +- .../AbstractBindSecurityGroupRequest.java | 21 +- .../AbstractBindSecurityGroupResponse.java | 26 +-- .../AbstractListSecurityGroupRequest.java | 14 +- .../AbstractUnbindSecurityGroupRequest.java | 18 +- .../client/v3/securitygroups/Protocol.java | 20 +- .../v3/securitygroups/SecurityGroup.java | 20 +- .../_BindRunningSecurityGroupRequest.java | 18 +- .../_BindRunningSecurityGroupResponse.java | 18 +- .../_BindStagingSecurityGroupRequest.java | 18 +- .../_BindStagingSecurityGroupResponse.java | 18 +- .../_CreateSecurityGroupResponse.java | 18 +- .../_DeleteSecurityGroupRequest.java | 19 +- .../_GetSecurityGroupRequest.java | 18 +- .../_GetSecurityGroupResponse.java | 18 +- .../v3/securitygroups/_GloballyEnabled.java | 22 +- .../_ListRunningSecurityGroupsRequest.java | 18 +- .../_ListRunningSecurityGroupsResponse.java | 18 +- .../_ListSecurityGroupsRequest.java | 20 +- .../_ListStagingSecurityGroupsRequest.java | 21 +- .../_ListStagingSecurityGroupsResponse.java | 18 +- .../v3/securitygroups/_Relationships.java | 14 ++ .../client/v3/securitygroups/_Rule.java | 18 +- .../_SecurityGroupResource.java | 7 +- .../_UnbindRunningSecurityGroupRequest.java | 18 +- .../_UnbindStagingSecurityGroupRequest.java | 18 +- .../_UpdateSecurityGroupRequest.java | 21 +- .../_UpdateSecurityGroupResponse.java | 19 +- .../BindRunningSecurityGroupRequestTest.java | 21 +- .../BindStagingSecurityGroupRequestTest.java | 21 +- .../CreateSecurityGroupRequestTest.java | 24 +- .../DeleteSecurityGroupRequestTest.java | 21 +- .../GetSecurityGroupRequestTest.java | 22 +- .../ListRunningSecurityGroupsRequestTest.java | 22 +- .../ListSecurityGroupsRequestTest.java | 18 +- .../ListStagingSecurityGroupsRequestTest.java | 22 +- ...UnbindRunningSecurityGroupRequestTest.java | 22 +- ...UnbindStagingSecurityGroupRequestTest.java | 22 +- .../UpdateSecurityGroupRequestTest.java | 39 ++-- .../client/v3/SecurityGroupsTest.java | 218 ++++++++---------- 41 files changed, 554 insertions(+), 523 deletions(-) diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java index 1583f6a928..23d64c3425 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; @@ -46,61 +44,56 @@ /** * The Reactor-based implementation of {@link ServiceBindingsV3} */ -public final class ReactorSecurityGroupsV3 extends AbstractClientV3Operations implements SecurityGroupsV3 { +public final class ReactorSecurityGroupsV3 extends AbstractClientV3Operations + implements SecurityGroupsV3 { /** * 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 + * @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 ReactorSecurityGroupsV3(ConnectionContext connectionContext, Mono root, - TokenProvider tokenProvider, - Map requestTags) { + TokenProvider tokenProvider, Map requestTags) { super(connectionContext, root, tokenProvider, requestTags); } @Override public Mono create(CreateSecurityGroupRequest request) { return post(request, CreateSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups")) - .checkpoint(); + builder -> builder.pathSegment("security_groups")).checkpoint(); } @Override public Mono get(GetSecurityGroupRequest request) { - return get(request, GetSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) - .checkpoint(); + return get(request, GetSecurityGroupResponse.class, builder -> builder + .pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); } @Override public Mono list(ListSecurityGroupsRequest request) { return get(request, ListSecurityGroupsResponse.class, - builder -> builder.pathSegment("security_groups")) - .checkpoint(); + builder -> builder.pathSegment("security_groups")).checkpoint(); } @Override public Mono update(UpdateSecurityGroupRequest request) { - return patch(request, UpdateSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) - .checkpoint(); + return patch(request, UpdateSecurityGroupResponse.class, builder -> builder + .pathSegment("security_groups", request.getSecurityGroupId())) + .checkpoint(); } @Override public Mono delete(DeleteSecurityGroupRequest request) { - return delete(request, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId())) - .checkpoint(); + return delete(request, builder -> builder.pathSegment("security_groups", + request.getSecurityGroupId())).checkpoint(); } @@ -108,55 +101,51 @@ public Mono delete(DeleteSecurityGroupRequest request) { public Mono bindRunningSecurityGroup( BindRunningSecurityGroupRequest request) { return post(request, BindRunningSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), - "relationships", - "running_spaces")) - .checkpoint(); + builder -> builder.pathSegment("security_groups", + request.getSecurityGroupId(), "relationships", + "running_spaces")).checkpoint(); } @Override public Mono bindStagingSecurityGroup( BindStagingSecurityGroupRequest request) { return post(request, BindStagingSecurityGroupResponse.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), - "relationships", - "staging_spaces")) - .checkpoint(); + builder -> builder.pathSegment("security_groups", + request.getSecurityGroupId(), "relationships", + "staging_spaces")).checkpoint(); } @Override - public Mono unbindStagingSecurityGroup( - UnbindStagingSecurityGroupRequest request) { + public Mono unbindStagingSecurityGroup(UnbindStagingSecurityGroupRequest request) { return delete(request, Void.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), - "relationships", + builder -> builder.pathSegment("security_groups", + request.getSecurityGroupId(), "relationships", "staging_spaces", request.getSpaceId())) - .checkpoint(); + .checkpoint(); } @Override - public Mono unbindRunningSecurityGroup( - UnbindRunningSecurityGroupRequest request) { + public Mono unbindRunningSecurityGroup(UnbindRunningSecurityGroupRequest request) { return delete(request, Void.class, - builder -> builder.pathSegment("security_groups", request.getSecurityGroupId(), - "relationships", + builder -> builder.pathSegment("security_groups", + request.getSecurityGroupId(), "relationships", "running_spaces", request.getSpaceId())) - .checkpoint(); + .checkpoint(); } @Override - public Mono listRunning(ListRunningSecurityGroupsRequest request) { + public Mono listRunning( + ListRunningSecurityGroupsRequest request) { return get(request, ListRunningSecurityGroupsResponse.class, builder -> builder.pathSegment("spaces", request.getSpaceId(), - "running_security_groups")) - .checkpoint(); + "running_security_groups")).checkpoint(); } @Override - public Mono listStaging(ListStagingSecurityGroupsRequest request) { + public Mono listStaging( + ListStagingSecurityGroupsRequest request) { return get(request, ListStagingSecurityGroupsResponse.class, builder -> builder.pathSegment("spaces", request.getSpaceId(), - "staging_security_groups")) - .checkpoint(); + "staging_security_groups")).checkpoint(); } } diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java index 018a50cb22..efe402f6a2 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java @@ -55,13 +55,13 @@ import java.util.Collections; import static io.netty.handler.codec.http.HttpMethod.GET; -import static io.netty.handler.codec.http.HttpMethod.DELETE;; +import static io.netty.handler.codec.http.HttpMethod.DELETE; 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.CREATED; import static io.netty.handler.codec.http.HttpResponseStatus.OK; import static io.netty.handler.codec.http.HttpResponseStatus.ACCEPTED; -import static io.netty.handler.codec.http.HttpResponseStatus.NO_CONTENT;; +import static io.netty.handler.codec.http.HttpResponseStatus.NO_CONTENT; public final class ReactorSecurityGroupsV3Test extends AbstractClientApiTest { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java index aca1ce438e..1979a6812e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupRequest.java @@ -1,26 +1,21 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; import java.util.List; - import org.cloudfoundry.client.v3.Relationship; -import org.cloudfoundry.client.v3.ToManyRelationship; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java index 46cb4a2b26..effa617eae 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractBindSecurityGroupResponse.java @@ -1,29 +1,25 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; import java.util.List; import java.util.Map; - import org.cloudfoundry.AllowNulls; -import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.Link; import org.cloudfoundry.client.v3.Relationship; -import org.cloudfoundry.client.v3.ToManyRelationship; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -32,8 +28,8 @@ public abstract class AbstractBindSecurityGroupResponse { /** - * A relationship to the spaces where the security_group is applied to - * applications during runtime + * A relationship to the spaces where the security_group is applied to applications during + * runtime */ @JsonProperty("data") abstract List getBoundSpaces(); diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java index 8d5aa91972..b0d6e8e573 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractListSecurityGroupRequest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import java.util.List; @@ -5,7 +18,6 @@ import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v2.PaginatedRequest; import org.cloudfoundry.client.v3.FilterParameter; - import com.fasterxml.jackson.annotation.JsonIgnore; public abstract class AbstractListSecurityGroupRequest extends PaginatedRequest { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java index f2cf32a02b..7903a2bdac 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/AbstractUnbindSecurityGroupRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java index 74b2aec1fe..d855b130e1 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/Protocol.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; @@ -20,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonValue; /** - * The protocol of a {@link RuleEntity} + * The protocol of a Security Group */ public enum Protocol { diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java index 77b69a8875..348e84500b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroup.java @@ -1,25 +1,21 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.cloudfoundry.Nullable; -import org.immutables.value.Value; import org.cloudfoundry.client.v3.Resource; import java.util.List; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java index 1615113093..0e14195fc7 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java index 3650024de5..e299671f9a 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindRunningSecurityGroupResponse.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java index 9cd36ebe0e..36ce1fcada 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java index 5ffa11a648..920c3eee7d 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_BindStagingSecurityGroupResponse.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java index f3f7c3d080..5b7f6f8ccd 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_CreateSecurityGroupResponse.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java index 765f581331..48b0e7d20e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_DeleteSecurityGroupRequest.java @@ -1,22 +1,19 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.annotation.JsonIgnore; import org.immutables.value.Value; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java index 3861d945bf..e001a6dbf9 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java index 79271f7528..aab7d9d91e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GetSecurityGroupResponse.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java index 5cabbbe3f1..bf89201cbb 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import com.fasterxml.jackson.annotation.JsonProperty; @@ -7,24 +20,21 @@ import org.immutables.value.Value; /** - * Controls if the group is applied globally to the lifecycle of all - * applications + * Controls if the group is applied globally to the lifecycle of all applications */ @JsonDeserialize @Value.Immutable abstract class _GloballyEnabled { /** - * Specifies whether the group should be applied globally to all running - * applications + * Specifies whether the group should be applied globally to all running applications */ @JsonProperty("running") @Nullable abstract Boolean getRunning(); /** - * Specifies whether the group should be applied globally to all staging - * applications + * Specifies whether the group should be applied globally to all staging applications */ @JsonProperty("staging") @Nullable diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java index d55296c97e..45e37d9a8f 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsRequest.java @@ -1,23 +1,21 @@ /* * 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 + * 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 + * 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. + * 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.securitygroups; import org.immutables.value.Value; -import com.fasterxml.jackson.databind.annotation.JsonSerialize;; + /** * The request payload for the List running Security Group operation diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java index e4cfb286f4..0a6ec345a2 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListRunningSecurityGroupsResponse.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java index 5e640e50c9..2ec1c16369 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListSecurityGroupsRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2023 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 + * 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 + * 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. + * 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.securitygroups; @@ -21,7 +19,7 @@ import org.cloudfoundry.client.v3.FilterParameter; import org.cloudfoundry.Nullable; import java.util.List; -import com.fasterxml.jackson.databind.annotation.JsonSerialize;; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; /** * The request payload for the List Security Group operation diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java index 7d3a343abc..d85b8c9c01 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsRequest.java @@ -1,25 +1,22 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; import org.immutables.value.Value; - import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize;; + /** * The request payload for the List staging Security Group operation diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java index 86fff12ad8..1109b7a60a 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_ListStagingSecurityGroupsResponse.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java index 8f0a5112e1..e9d782cbac 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Relationships.java @@ -1,3 +1,17 @@ +/* + * Copyright 2013-2023 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.securitygroups; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java index 73938c6c03..b24119e0f8 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_Rule.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java index af4edc2e39..339559f111 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_SecurityGroupResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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. @@ -16,12 +16,9 @@ package org.cloudfoundry.client.v3.securitygroups; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.cloudfoundry.Nullable; import org.immutables.value.Value; -import org.cloudfoundry.client.v3.Resource; -import java.util.List; + /** * The Resource response payload for the List SecurityGroups operation diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java index 0485627e43..b9666f9042 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindRunningSecurityGroupRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java index 768b02bdaa..7c0f3a34b8 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UnbindStagingSecurityGroupRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java index 6c095fb492..a5ce3eed99 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupRequest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; @@ -42,8 +40,7 @@ abstract class _UpdateSecurityGroupRequest { abstract String getName(); /** - * Object that controls if the group is applied globally to the lifecycle of all - * applications + * Object that controls if the group is applied globally to the lifecycle of all applications */ @JsonProperty("globally_enabled") abstract GloballyEnabled getGloballyEnabled(); diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java index a855711420..42f5dfa05e 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_UpdateSecurityGroupResponse.java @@ -1,19 +1,16 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java index a62f24214b..32d7335b89 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindRunningSecurityGroupRequestTest.java @@ -1,6 +1,18 @@ +/* + * Copyright 2013-2023 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.securitygroups; -import org.cloudfoundry.client.v3.ToManyRelationship; import org.cloudfoundry.client.v3.Relationship; import org.junit.Test; @@ -8,17 +20,14 @@ public class BindRunningSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noSecurityGroupId() { - BindRunningSecurityGroupRequest.builder() - .build(); + BindRunningSecurityGroupRequest.builder().build(); } @Test public void valid() { BindRunningSecurityGroupRequest.builder() .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .boundSpaces(Relationship.builder() - .id("space-guid-1") - .build()) + .boundSpaces(Relationship.builder().id("space-guid-1").build()) .build(); } } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java index 24ef538685..5a8ec2589b 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/BindStagingSecurityGroupRequestTest.java @@ -1,6 +1,18 @@ +/* + * Copyright 2013-2023 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.securitygroups; -import org.cloudfoundry.client.v3.ToManyRelationship; import org.cloudfoundry.client.v3.Relationship; import org.junit.Test; @@ -8,17 +20,14 @@ public class BindStagingSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noSecurityGroupId() { - BindStagingSecurityGroupRequest.builder() - .build(); + BindStagingSecurityGroupRequest.builder().build(); } @Test public void valid() { BindStagingSecurityGroupRequest.builder() .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .boundSpaces(Relationship.builder() - .id("space-guid-1") - .build()) + .boundSpaces(Relationship.builder().id("space-guid-1").build()) .build(); } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java index ad9f6a1d4c..7cf4e23066 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/CreateSecurityGroupRequestTest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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.securitygroups; @@ -22,9 +20,7 @@ public class CreateSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noName() { - CreateSecurityGroupRequest.builder() - .rule(Rule.builder().build()) - .build(); + CreateSecurityGroupRequest.builder().rule(Rule.builder().build()).build(); } -} \ No newline at end of file +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java index a050d0fc32..9a2b95c3d5 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/DeleteSecurityGroupRequestTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,14 +19,12 @@ public class DeleteSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noSecurityGroupId() { - DeleteSecurityGroupRequest.builder() - .build(); + DeleteSecurityGroupRequest.builder().build(); } @Test public void valid() { - DeleteSecurityGroupRequest.builder() - .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + DeleteSecurityGroupRequest.builder().securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") .build(); } -} \ No newline at end of file +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java index 4435396786..d086d9196b 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/GetSecurityGroupRequestTest.java @@ -1,3 +1,17 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,14 +20,12 @@ public class GetSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noSecurityGroupId() { - GetSecurityGroupRequest.builder() - .build(); + GetSecurityGroupRequest.builder().build(); } @Test public void valid() { - GetSecurityGroupRequest.builder() - .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") + GetSecurityGroupRequest.builder().securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") .build(); } -} \ No newline at end of file +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java index 824335c57f..f9aeb74f36 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListRunningSecurityGroupsRequestTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,15 +19,12 @@ public class ListRunningSecurityGroupsRequestTest { @Test(expected = IllegalStateException.class) public void noSpaceID() { - ListRunningSecurityGroupsRequest.builder() - .build(); + ListRunningSecurityGroupsRequest.builder().build(); } @Test public void valid() { - ListRunningSecurityGroupsRequest.builder() - .spaceId("space-giud1") - .build(); + ListRunningSecurityGroupsRequest.builder().spaceId("space-giud1").build(); } -} \ No newline at end of file +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java index 11356cfd81..0c8e498dc0 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListSecurityGroupsRequestTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,8 +19,7 @@ public class ListSecurityGroupsRequestTest { @Test public void valid() { - ListSecurityGroupsRequest.builder() - .build(); + ListSecurityGroupsRequest.builder().build(); } -} \ No newline at end of file +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java index ea1ab90f93..fa591d8121 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/ListStagingSecurityGroupsRequestTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,15 +19,12 @@ public class ListStagingSecurityGroupsRequestTest { @Test(expected = IllegalStateException.class) public void noSpaceID() { - ListStagingSecurityGroupsRequest.builder() - .build(); + ListStagingSecurityGroupsRequest.builder().build(); } @Test public void valid() { - ListStagingSecurityGroupsRequest.builder() - .spaceId("space-giud1") - .build(); + ListStagingSecurityGroupsRequest.builder().spaceId("space-giud1").build(); } -} \ No newline at end of file +} diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java index 590305f9b1..362f88403b 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindRunningSecurityGroupRequestTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,23 +19,20 @@ public class UnbindRunningSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noSecurityGroupId() { - UnbindRunningSecurityGroupRequest.builder() - .build(); + UnbindRunningSecurityGroupRequest.builder().build(); } @Test(expected = IllegalStateException.class) public void noSpaceId() { UnbindRunningSecurityGroupRequest.builder() - .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .build(); + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a").build(); } @Test public void valid() { UnbindRunningSecurityGroupRequest.builder() .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .spaceId("space-guid2") - .build(); + .spaceId("space-guid2").build(); } } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java index b9f4d71da5..6396fce0a1 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UnbindStagingSecurityGroupRequestTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,22 +19,19 @@ public class UnbindStagingSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noSecurityGroupId() { - UnbindStagingSecurityGroupRequest.builder() - .build(); + UnbindStagingSecurityGroupRequest.builder().build(); } @Test(expected = IllegalStateException.class) public void noSpaceId() { UnbindStagingSecurityGroupRequest.builder() - .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .build(); + .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a").build(); } @Test public void valid() { UnbindStagingSecurityGroupRequest.builder() .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .spaceId("space-guid2") - .build(); + .spaceId("space-guid2").build(); } } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java index 90e6063606..e3493e3cf7 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/securitygroups/UpdateSecurityGroupRequestTest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2013-2023 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.securitygroups; import org.junit.Test; @@ -6,33 +19,23 @@ public class UpdateSecurityGroupRequestTest { @Test(expected = IllegalStateException.class) public void noName() { - UpdateSecurityGroupRequest.builder() - .build(); + UpdateSecurityGroupRequest.builder().build(); } @Test() public void valid() { - UpdateSecurityGroupRequest.builder() - .name("my-group0") + UpdateSecurityGroupRequest.builder().name("my-group0") .securityGroupId("b85a788e-671f-4549-814d-e34cdb2f539a") - .globallyEnabled(GloballyEnabled - .builder() - .running(true) - .build()) - .rules(Rule.builder() - .protocol(Protocol.TCP) - .destination("10.10.10.0/24") - .ports("443,80,8080") + .globallyEnabled(GloballyEnabled.builder().running(true).build()) + .rules(Rule.builder().protocol(Protocol.TCP) + .destination("10.10.10.0/24").ports("443,80,8080") .build()) - .rules(Rule.builder() - .protocol(Protocol.ICMP) + .rules(Rule.builder().protocol(Protocol.ICMP) .destination("10.10.10.0/24") .description("Allow ping requests to private services") - .type(8) - .code(0) - .build()) + .type(8).code(0).build()) .build(); } -} \ No newline at end of file +} diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java index 700c9df32a..9ff8b69d6b 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/SecurityGroupsTest.java @@ -1,17 +1,15 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 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 + * 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 + * 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. + * 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; @@ -25,19 +23,16 @@ import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.CreateSecurityGroupResponse; import org.cloudfoundry.client.v3.securitygroups.Rule; -import org.cloudfoundry.client.v3.securitygroups.SecurityGroup; -import org.cloudfoundry.client.v3.ToManyRelationship; -import org.cloudfoundry.client.v3.securitygroups.Relationships; + import org.cloudfoundry.client.v3.securitygroups.GloballyEnabled; -import org.cloudfoundry.client.v3.securitygroups.SecurityGroup; + import org.cloudfoundry.client.v3.securitygroups.UpdateSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.DeleteSecurityGroupRequest; import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupRequest; -import org.cloudfoundry.client.v3.securitygroups.GetSecurityGroupResponse; + import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest; import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest; -import org.cloudfoundry.util.JobUtils; import org.junit.Test; import org.junit.Before; @@ -61,33 +56,26 @@ public final class SecurityGroupsTest extends AbstractIntegrationTest { private String securityGroupName; @Before - public void settup() { + public void setup() { this.securityGroupName = this.nameFactory.getSecurityGroupName(); - String spaceID = this.spaceId.block(); + this.securityGroup = this.cloudFoundryClient.securityGroupsV3() .create(CreateSecurityGroupRequest.builder() .name(this.securityGroupName) .globallyEnabled(GloballyEnabled.builder() - .staging(true) - .running(true) - .build()) - .rule(Rule.builder() - .destination("0.0.0.0/0") - .log(false) - .ports("2048-3000") - .protocol(TCP) + .staging(true).running(true) .build()) + .rule(Rule.builder().destination("0.0.0.0/0") + .log(false).ports("2048-3000") + .protocol(TCP).build()) .build()); } @Test public void create() { - this.securityGroup - .map(securityGroup -> securityGroup.getName()) - .as(StepVerifier::create) - .expectNext(this.securityGroupName) - .expectComplete() - .verify(Duration.ofMinutes(5)); + this.securityGroup.map(securityGroup -> securityGroup.getName()) + .as(StepVerifier::create).expectNext(this.securityGroupName) + .expectComplete().verify(Duration.ofMinutes(5)); } @Test @@ -95,159 +83,145 @@ public void get() { this.securityGroup .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3() .get(GetSecurityGroupRequest.builder() - .securityGroupId(securityGroup.getId()) + .securityGroupId(securityGroup + .getId()) .build()) .map(sg -> sg.getName())) - .as(StepVerifier::create) - .expectNext(this.securityGroupName) - .expectComplete() - .verify(Duration.ofMinutes(5)); + .as(StepVerifier::create).expectNext(this.securityGroupName) + .expectComplete().verify(Duration.ofMinutes(5)); } @Test public void update() { String newSecurityGroupName = this.nameFactory.getSecurityGroupName(); this.securityGroup - .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3().update( - UpdateSecurityGroupRequest.builder() - .securityGroupId(securityGroup.getId()) + .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3() + .update(UpdateSecurityGroupRequest.builder() + .securityGroupId(securityGroup + .getId()) .name(newSecurityGroupName) .build())) .map(securityGroup -> securityGroup.getName()) - .as(StepVerifier::create) - .expectNext(newSecurityGroupName) - .expectComplete() - .verify(Duration.ofMinutes(5)); + .as(StepVerifier::create).expectNext(newSecurityGroupName) + .expectComplete().verify(Duration.ofMinutes(5)); } @Test public void delete() { this.securityGroup - .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3().delete( - DeleteSecurityGroupRequest.builder() - .securityGroupId(securityGroup.getId()) + .flatMap(securityGroup -> this.cloudFoundryClient.securityGroupsV3() + .delete(DeleteSecurityGroupRequest.builder() + .securityGroupId(securityGroup + .getId()) .build()) .map(id -> Arrays.asList(id))) - .as(StepVerifier::create) - .expectNextCount(1) - .expectComplete() + .as(StepVerifier::create).expectNextCount(1).expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void list() { - this.securityGroup.map( - securityGroup -> this.cloudFoundryClient.securityGroupsV3() + this.securityGroup + .map(securityGroup -> this.cloudFoundryClient.securityGroupsV3() .list(ListSecurityGroupsRequest.builder() - .names(Arrays.asList(securityGroup.getName())) + .names(Arrays.asList(securityGroup + .getName())) .build())) - .as(StepVerifier::create) - .expectNextCount(1) - .expectComplete() + .as(StepVerifier::create).expectNextCount(1).expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void listRunning() { - Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient + .securityGroupsV3() .listRunning(ListRunningSecurityGroupsRequest.builder() .spaceId(v.getT2()) .names(Arrays.asList(v.getT1().getName())).build())) - .as(StepVerifier::create) - .expectNextCount(1) - .expectComplete() + .as(StepVerifier::create).expectNextCount(1).expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void listStaging() { - Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient.securityGroupsV3() + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient + .securityGroupsV3() .listStaging(ListStagingSecurityGroupsRequest.builder() .spaceId(v.getT2()) .names(Arrays.asList(v.getT1().getName())).build())) - .as(StepVerifier::create) - .expectNextCount(1) - .expectComplete() + .as(StepVerifier::create).expectNextCount(1).expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void bindStagingSecurityGroup() { - Mono.zip(this.securityGroup, this.spaceId) - .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() - .bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() - .securityGroupId(v.getT1().getId()) - .boundSpaces(Relationship.builder() - .id(v.getT2()).build()) - .build())) - .as(StepVerifier::create) - .expectNextCount(1) - .expectComplete() + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient + .securityGroupsV3() + .bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder().id(v.getT2()) + .build()) + .build())) + .as(StepVerifier::create).expectNextCount(1).expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void unbindStagingSecurityGroup() { - Mono.zip(this.securityGroup, this.spaceId) - .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() - .bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() - .securityGroupId(v.getT1().getId()) - .boundSpaces(Relationship.builder().id(v.getT2()) - .build()) + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient + .securityGroupsV3() + .bindStagingSecurityGroup(BindStagingSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder().id(v.getT2()) .build()) - .then(this.cloudFoundryClient.securityGroupsV3() - .unbindStagingSecurityGroup( - UnbindStagingSecurityGroupRequest - .builder() - .securityGroupId(v - .getT1() - .getId()) - .spaceId(v.getT2()) - .build()))) - - .as(StepVerifier::create) - .expectNextCount(0) - .expectComplete() + .build()) + .then(this.cloudFoundryClient.securityGroupsV3() + .unbindStagingSecurityGroup( + UnbindStagingSecurityGroupRequest + .builder() + .securityGroupId(v + .getT1() + .getId()) + .spaceId(v.getT2()) + .build()))) + + .as(StepVerifier::create).expectNextCount(0).expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void bindRunningSecurityGroup() { - Mono.zip(this.securityGroup, this.spaceId) - .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() - .bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() - .securityGroupId(v.getT1().getId()) - .boundSpaces(Relationship.builder().id(v.getT2()) - .build()) - .build())) - .as(StepVerifier::create) - .expectNextCount(1) - .expectComplete() + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient + .securityGroupsV3() + .bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder().id(v.getT2()) + .build()) + .build())) + .as(StepVerifier::create).expectNextCount(1).expectComplete() .verify(Duration.ofMinutes(5)); } @Test public void unbindRunnungSecurityGroup() { - Mono.zip(this.securityGroup, this.spaceId) - .flatMap(v -> this.cloudFoundryClient.securityGroupsV3() - .bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() - .securityGroupId(v.getT1().getId()) - .boundSpaces(Relationship.builder().id(v.getT2()) - .build()) + Mono.zip(this.securityGroup, this.spaceId).flatMap(v -> this.cloudFoundryClient + .securityGroupsV3() + .bindRunningSecurityGroup(BindRunningSecurityGroupRequest.builder() + .securityGroupId(v.getT1().getId()) + .boundSpaces(Relationship.builder().id(v.getT2()) .build()) - .then(this.cloudFoundryClient.securityGroupsV3() - .unbindRunningSecurityGroup( - UnbindRunningSecurityGroupRequest - .builder() - .securityGroupId(v - .getT1() - .getId()) - .spaceId(v.getT2()) - .build()))) - - .as(StepVerifier::create) - .expectNextCount(0) - .expectComplete() + .build()) + .then(this.cloudFoundryClient.securityGroupsV3() + .unbindRunningSecurityGroup( + UnbindRunningSecurityGroupRequest + .builder() + .securityGroupId(v + .getT1() + .getId()) + .spaceId(v.getT2()) + .build()))) + + .as(StepVerifier::create).expectNextCount(0).expectComplete() .verify(Duration.ofMinutes(5)); } }