Skip to content

Commit c4fe290

Browse files
adding update security group api
1 parent 696c8b0 commit c4fe290

File tree

6 files changed

+129
-0
lines changed

6 files changed

+129
-0
lines changed

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ public void list() {
252252
.id("a89a788e-671f-4549-814d-e34c1b2f533a")
253253
.createdAt("2020-02-20T17:42:08Z")
254254
.updatedAt("2020-02-20T17:42:08Z")
255+
.relationships(Relationships.builder().build())
255256
.globallyEnabled(GloballyEnabled
256257
.builder()
257258
.staging(true)

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/SecurityGroupsV3.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@ public interface SecurityGroupsV3 {
5151
*/
5252
Mono<ListSecurityGroupsResponse> list(ListSecurityGroupsRequest request);
5353

54+
/**
55+
* Makes the <a href=
56+
*
57+
* "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#update-a-security-group">Update
58+
* Security Groups</a> request
59+
*
60+
* @param request the Update Security Group request
61+
* @return the response from the List Security Group request
62+
*/
63+
Mono<UpdateSecurityGroupResponse> update(UpdateSecurityGroupRequest request);
5464
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/securitygroups/_GloballyEnabled.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
5+
6+
import org.cloudfoundry.Nullable;
57
import org.immutables.value.Value;
68

79
/**
@@ -17,13 +19,15 @@ abstract class _GloballyEnabled {
1719
* applications
1820
*/
1921
@JsonProperty("running")
22+
@Nullable
2023
abstract Boolean getRunning();
2124

2225
/**
2326
* Specifies whether the group should be applied globally to all staging
2427
* applications
2528
*/
2629
@JsonProperty("staging")
30+
@Nullable
2731
abstract Boolean getStaging();
2832

2933
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2013-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.cloudfoundry.client.v3.securitygroups;
17+
18+
import org.immutables.value.Value;
19+
20+
import java.util.List;
21+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
22+
import com.fasterxml.jackson.annotation.JsonProperty;
23+
24+
/**
25+
* The request payload for the Create a Security Group operation
26+
*/
27+
@JsonSerialize
28+
@Value.Immutable
29+
abstract class _UpdateSecurityGroupRequest {
30+
/**
31+
* Name of the security group
32+
*/
33+
@JsonProperty("name")
34+
abstract String getName();
35+
36+
/**
37+
* Object that controls if the group is applied globally to the lifecycle of all
38+
* applications
39+
*/
40+
@JsonProperty("globally_enabled")
41+
abstract GloballyEnabled getGloballyEnabled();
42+
43+
/**
44+
* Rules that will be applied by this security group
45+
*/
46+
@JsonProperty("rules")
47+
abstract List<Rule> getRules();
48+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2013-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.cloudfoundry.client.v3.securitygroups;
18+
19+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
20+
import org.immutables.value.Value;
21+
22+
/**
23+
* The response payload for the Update a Security Group operation
24+
*/
25+
@JsonDeserialize
26+
@Value.Immutable
27+
abstract class _UpdateSecurityGroupResponse extends SecurityGroup {
28+
29+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.cloudfoundry.client.v3.securitygroups;
2+
3+
import org.junit.Test;
4+
5+
public class UpdateSecurityGroupRequestTest {
6+
7+
@Test(expected = IllegalStateException.class)
8+
public void noName() {
9+
UpdateSecurityGroupRequest.builder()
10+
.build();
11+
}
12+
13+
@Test()
14+
public void valid() {
15+
UpdateSecurityGroupRequest.builder()
16+
.name("my-group0")
17+
.globallyEnabled(GloballyEnabled
18+
.builder()
19+
.running(true)
20+
.build())
21+
.rules(Rule.builder()
22+
.protocol(Protocol.TCP)
23+
.destination("10.10.10.0/24")
24+
.ports("443,80,8080")
25+
.build())
26+
.rules(Rule.builder()
27+
.protocol(Protocol.ICMP)
28+
.destination("10.10.10.0/24")
29+
.description("Allow ping requests to private services")
30+
.type(8)
31+
.code(0)
32+
.build())
33+
.build();
34+
35+
}
36+
37+
}

0 commit comments

Comments
 (0)