Skip to content

Commit 6cb276d

Browse files
adding list running/staging api and tests
1 parent e9bac3a commit 6cb276d

File tree

12 files changed

+611
-0
lines changed

12 files changed

+611
-0
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/securitygroups/ReactorSecurityGroupsV3.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
import org.cloudfoundry.client.v3.servicebindings.ServiceBindingsV3;
2828
import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsRequest;
2929
import org.cloudfoundry.client.v3.securitygroups.ListSecurityGroupsResponse;
30+
import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsRequest;
31+
import org.cloudfoundry.client.v3.securitygroups.ListRunningSecurityGroupsResponse;
32+
import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsRequest;
33+
import org.cloudfoundry.client.v3.securitygroups.ListStagingSecurityGroupsResponse;
3034
import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupRequest;
3135
import org.cloudfoundry.client.v3.securitygroups.BindRunningSecurityGroupResponse;
3236
import org.cloudfoundry.client.v3.securitygroups.BindStagingSecurityGroupRequest;
@@ -139,4 +143,20 @@ public Mono<Void> unbindRunningSecurityGroup(
139143
"running_spaces", request.getSpaceId()))
140144
.checkpoint();
141145
}
146+
147+
@Override
148+
public Mono<ListRunningSecurityGroupsResponse> listRunning(ListRunningSecurityGroupsRequest request) {
149+
return get(request, ListRunningSecurityGroupsResponse.class,
150+
builder -> builder.pathSegment("spaces", request.getSpaceId(),
151+
"running_security_groups"))
152+
.checkpoint();
153+
}
154+
155+
@Override
156+
public Mono<ListStagingSecurityGroupsResponse> listStaging(ListStagingSecurityGroupsRequest request) {
157+
return get(request, ListStagingSecurityGroupsResponse.class,
158+
builder -> builder.pathSegment("spaces", request.getSpaceId(),
159+
"staging_security_groups"))
160+
.checkpoint();
161+
}
142162
}

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

Lines changed: 208 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"pagination": {
3+
"total_results": 1,
4+
"total_pages": 1,
5+
"first": {
6+
"href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/running_security_groups?page=1&per_page=50"
7+
},
8+
"last": {
9+
"href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/running_security_groups?page=1&per_page=50"
10+
},
11+
"next": null,
12+
"previous": null
13+
},
14+
"resources": [
15+
{
16+
"guid": "b85a788e-671f-4549-814d-e34cdb2f539a",
17+
"created_at": "2020-02-20T17:42:08Z",
18+
"updated_at": "2020-02-20T17:42:08Z",
19+
"name": "my-group0",
20+
"globally_enabled": {
21+
"running": true,
22+
"staging": false
23+
},
24+
"rules": [
25+
{
26+
"protocol": "tcp",
27+
"destination": "10.10.10.0/24",
28+
"ports": "443,80,8080"
29+
},
30+
{
31+
"protocol": "icmp",
32+
"destination": "10.10.10.0/24",
33+
"type": 8,
34+
"code": 0,
35+
"description": "Allow ping requests to private services"
36+
}
37+
],
38+
"relationships": {
39+
"staging_spaces": {
40+
"data": []
41+
},
42+
"running_spaces": {
43+
"data": [
44+
{
45+
"guid": "space-guid-1"
46+
},
47+
{
48+
"guid": "space-guid-2"
49+
}
50+
]
51+
}
52+
},
53+
"links": {
54+
"self": {
55+
"href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a"
56+
}
57+
}
58+
},
59+
{
60+
"guid": "a89a788e-671f-4549-814d-e34c1b2f533a",
61+
"created_at": "2020-02-20T17:42:08Z",
62+
"updated_at": "2020-02-20T17:42:08Z",
63+
"name": "my-group1",
64+
"globally_enabled": {
65+
"running": true,
66+
"staging": true
67+
},
68+
"rules": [],
69+
"relationships": {
70+
"staging_spaces": {
71+
"data": []
72+
},
73+
"running_spaces": {
74+
"data": []
75+
}
76+
},
77+
"links": {
78+
"self": {
79+
"href": "https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a"
80+
}
81+
}
82+
}
83+
]
84+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"pagination": {
3+
"total_results": 1,
4+
"total_pages": 1,
5+
"first": {
6+
"href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/staging_security_groups?page=1&per_page=50"
7+
},
8+
"last": {
9+
"href": "https://api.example.org/v3/spaces/c5048979-53b9-4d2a-9fca-78e6bc07c041/staging_security_groups?page=1&per_page=50"
10+
},
11+
"next": null,
12+
"previous": null
13+
},
14+
"resources": [
15+
{
16+
"guid": "b85a788e-671f-4549-814d-e34cdb2f539a",
17+
"created_at": "2020-02-20T17:42:08Z",
18+
"updated_at": "2020-02-20T17:42:08Z",
19+
"name": "my-group0",
20+
"globally_enabled": {
21+
"running": false,
22+
"staging": true
23+
},
24+
"rules": [
25+
{
26+
"protocol": "tcp",
27+
"destination": "10.10.10.0/24",
28+
"ports": "443,80,8080"
29+
},
30+
{
31+
"protocol": "icmp",
32+
"destination": "10.10.10.0/24",
33+
"type": 8,
34+
"code": 0,
35+
"description": "Allow ping requests to private services"
36+
}
37+
],
38+
"relationships": {
39+
"staging_spaces": {
40+
"data": [
41+
{
42+
"guid": "space-guid-1"
43+
},
44+
{
45+
"guid": "space-guid-2"
46+
}
47+
]
48+
},
49+
"running_spaces": {
50+
"data": []
51+
}
52+
},
53+
"links": {
54+
"self": {
55+
"href": "https://api.example.org/v3/security_groups/b85a788e-671f-4549-814d-e34cdb2f539a"
56+
}
57+
}
58+
},
59+
{
60+
"guid": "a89a788e-671f-4549-814d-e34c1b2f533a",
61+
"created_at": "2020-02-20T17:42:08Z",
62+
"updated_at": "2020-02-20T17:42:08Z",
63+
"name": "my-group1",
64+
"globally_enabled": {
65+
"running": true,
66+
"staging": true
67+
},
68+
"rules": [],
69+
"relationships": {
70+
"staging_spaces": {
71+
"data": []
72+
},
73+
"running_spaces": {
74+
"data": []
75+
}
76+
},
77+
"links": {
78+
"self": {
79+
"href": "https://api.example.org/v3/security_groups/a89a788e-671f-4549-814d-e34c1b2f533a"
80+
}
81+
}
82+
}
83+
]
84+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.cloudfoundry.client.v3.securitygroups;
2+
3+
import java.util.List;
4+
5+
import org.cloudfoundry.Nullable;
6+
import org.cloudfoundry.client.v2.PaginatedRequest;
7+
import org.cloudfoundry.client.v3.FilterParameter;
8+
9+
import com.fasterxml.jackson.annotation.JsonIgnore;
10+
11+
public abstract class AbstractListSecurityGroupRequest extends PaginatedRequest {
12+
13+
/**
14+
* The Space id
15+
*/
16+
@JsonIgnore
17+
abstract String getSpaceId();
18+
19+
/**
20+
* The security group ids filter
21+
*/
22+
@FilterParameter("guids")
23+
@Nullable
24+
abstract List<String> getSecurityGroupIds();
25+
26+
/**
27+
* The security group names filter
28+
*/
29+
@FilterParameter("names")
30+
@Nullable
31+
abstract List<String> getNames();
32+
33+
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,24 @@ public interface SecurityGroupsV3 {
111111
* @return the response from the Unbind Running Security Group request
112112
*/
113113
Mono<Void> unbindRunningSecurityGroup(UnbindRunningSecurityGroupRequest request);
114+
115+
/**
116+
* Makes the <a href=
117+
* "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#list-staging-security-groups-for-a-space">List
118+
* Running Security Groups</a> request
119+
*
120+
* @param request the List Staging Security Group request
121+
* @return the response from the List Staging Security Group request
122+
*/
123+
Mono<ListStagingSecurityGroupsResponse> listStaging(ListStagingSecurityGroupsRequest request);
124+
125+
/**
126+
* Makes the <a href=
127+
* "https://v3-apidocs.cloudfoundry.org/version/3.140.0/index.html#list-running-security-groups-for-a-space">List
128+
* Running Security Groups</a> request
129+
*
130+
* @param request the List Staging Security Group request
131+
* @return the response from the List Running Security Group request
132+
*/
133+
Mono<ListRunningSecurityGroupsResponse> listRunning(ListRunningSecurityGroupsRequest request);
114134
}
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 org.immutables.value.Value;
20+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;;
21+
22+
/**
23+
* The request payload for the List running Security Group operation
24+
*/
25+
26+
@Value.Immutable
27+
abstract class _ListRunningSecurityGroupsRequest extends AbstractListSecurityGroupRequest {
28+
29+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 org.immutables.value.Value;
20+
21+
import org.cloudfoundry.client.v3.PaginatedResponse;
22+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
23+
24+
/**
25+
* The response payload for the List Security Groups operation
26+
*/
27+
@JsonDeserialize
28+
@Value.Immutable
29+
abstract class _ListRunningSecurityGroupsResponse extends PaginatedResponse<SecurityGroupResource> {
30+
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 org.immutables.value.Value;
20+
21+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
22+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;;
23+
24+
/**
25+
* The request payload for the List staging Security Group operation
26+
*/
27+
@JsonDeserialize
28+
@Value.Immutable
29+
abstract class _ListStagingSecurityGroupsRequest extends AbstractListSecurityGroupRequest {
30+
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 org.immutables.value.Value;
20+
21+
import org.cloudfoundry.client.v3.PaginatedResponse;
22+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
23+
24+
/**
25+
* The response payload for the List Security Groups operation
26+
*/
27+
@JsonDeserialize
28+
@Value.Immutable
29+
abstract class _ListStagingSecurityGroupsResponse extends PaginatedResponse<SecurityGroupResource> {
30+
31+
}

0 commit comments

Comments
 (0)