Skip to content

Commit b358b25

Browse files
committed
Merge branch 'v3-spaces' into 3.x
2 parents 9bbebe6 + c9da9ec commit b358b25

File tree

6 files changed

+113
-2
lines changed

6 files changed

+113
-2
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentResponse;
2121
import org.cloudfoundry.client.v3.spaces.CreateSpaceRequest;
2222
import org.cloudfoundry.client.v3.spaces.CreateSpaceResponse;
23+
import org.cloudfoundry.client.v3.spaces.DeleteSpaceRequest;
2324
import org.cloudfoundry.client.v3.spaces.DeleteUnmappedRoutesRequest;
2425
import org.cloudfoundry.client.v3.spaces.GetSpaceIsolationSegmentRequest;
2526
import org.cloudfoundry.client.v3.spaces.GetSpaceIsolationSegmentResponse;
@@ -66,6 +67,12 @@ public Mono<CreateSpaceResponse> create(CreateSpaceRequest request) {
6667
.checkpoint();
6768
}
6869

70+
@Override
71+
public Mono<String> delete(DeleteSpaceRequest request) {
72+
return delete(request, builder -> builder.pathSegment("spaces", request.getSpaceId()))
73+
.checkpoint();
74+
}
75+
6976
@Override
7077
public Mono<String> deleteUnmappedRoutes(DeleteUnmappedRoutesRequest request) {
7178
return delete(request, builder -> builder.pathSegment("spaces", request.getSpaceId(), "routes").query("unmapped=true"))

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/spaces/ReactorSpacesV3Test.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentResponse;
2626
import org.cloudfoundry.client.v3.spaces.CreateSpaceRequest;
2727
import org.cloudfoundry.client.v3.spaces.CreateSpaceResponse;
28+
import org.cloudfoundry.client.v3.spaces.DeleteSpaceRequest;
2829
import org.cloudfoundry.client.v3.spaces.DeleteUnmappedRoutesRequest;
2930
import org.cloudfoundry.client.v3.spaces.GetSpaceIsolationSegmentRequest;
3031
import org.cloudfoundry.client.v3.spaces.GetSpaceIsolationSegmentResponse;
@@ -141,6 +142,28 @@ public void create() {
141142
.verify(Duration.ofSeconds(5));
142143
}
143144

145+
@Test
146+
public void delete() {
147+
mockRequest(InteractionContext.builder()
148+
.request(TestRequest.builder()
149+
.method(DELETE).path("/spaces/test-space-id")
150+
.build())
151+
.response(TestResponse.builder()
152+
.status(ACCEPTED)
153+
.header("Location", "https://api.example.org/v3/jobs/test-job-id")
154+
.build())
155+
.build());
156+
157+
this.spaces
158+
.delete(DeleteSpaceRequest.builder()
159+
.spaceId("test-space-id")
160+
.build())
161+
.as(StepVerifier::create)
162+
.expectNext("test-job-id")
163+
.expectComplete()
164+
.verify(Duration.ofSeconds(5));
165+
}
166+
144167
@Test
145168
public void deleteUnmappedRoutes() {
146169
mockRequest(InteractionContext.builder()
@@ -149,7 +172,7 @@ public void deleteUnmappedRoutes() {
149172
.build())
150173
.response(TestResponse.builder()
151174
.status(ACCEPTED)
152-
.header("Location", "https://api.example.org/v3/jobs/test-space-id")
175+
.header("Location", "https://api.example.org/v3/jobs/test-job-id")
153176
.build())
154177
.build());
155178

@@ -158,7 +181,7 @@ public void deleteUnmappedRoutes() {
158181
.spaceId("test-space-id")
159182
.build())
160183
.as(StepVerifier::create)
161-
.expectNext("test-space-id")
184+
.expectNext("test-job-id")
162185
.expectComplete()
163186
.verify(Duration.ofSeconds(5));
164187
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/spaces/SpacesV3.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public interface SpacesV3 {
3939
*/
4040
Mono<CreateSpaceResponse> create(CreateSpaceRequest request);
4141

42+
/**
43+
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.87.0/index.html#delete-a-space">Delete Space</a> request
44+
*
45+
* @param request the Delete Space request
46+
* @return the response from the Delete Space request
47+
*/
48+
Mono<String> delete(DeleteSpaceRequest request);
49+
4250
/**
4351
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.77.0/index.html#delete-unmapped-routes-for-a-space">Delete Unmapped Routes</a> request
4452
*
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.cloudfoundry.client.v3.spaces;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import org.immutables.value.Value;
5+
6+
/**
7+
* The request payload for the Delete Unmapped Routes operation
8+
*/
9+
@Value.Immutable
10+
abstract class _DeleteSpaceRequest {
11+
12+
/**
13+
* The space id
14+
*/
15+
@JsonIgnore
16+
abstract String getSpaceId();
17+
18+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2013-2020 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.spaces;
18+
19+
import org.junit.Test;
20+
21+
public class DeleteSpaceRequestTest {
22+
23+
@Test(expected = IllegalStateException.class)
24+
public void noSpaceId() {
25+
DeleteSpaceRequest.builder()
26+
.build();
27+
}
28+
29+
@Test
30+
public void valid() {
31+
DeleteSpaceRequest.builder()
32+
.spaceId("test-space-id")
33+
.build();
34+
}
35+
36+
}

integration-test/src/test/java/org/cloudfoundry/client/v3/SpacesTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.cloudfoundry.client.v3.spaces.AssignSpaceIsolationSegmentResponse;
3737
import org.cloudfoundry.client.v3.spaces.CreateSpaceRequest;
3838
import org.cloudfoundry.client.v3.spaces.CreateSpaceResponse;
39+
import org.cloudfoundry.client.v3.spaces.DeleteSpaceRequest;
3940
import org.cloudfoundry.client.v3.spaces.DeleteUnmappedRoutesRequest;
4041
import org.cloudfoundry.client.v3.spaces.GetSpaceIsolationSegmentRequest;
4142
import org.cloudfoundry.client.v3.spaces.ListSpacesRequest;
@@ -115,6 +116,24 @@ public void create() {
115116
.verify(Duration.ofMinutes(5));
116117
}
117118

119+
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_8)
120+
@Test
121+
public void delete() {
122+
String spaceName = this.nameFactory.getSpaceName();
123+
124+
this.organizationId
125+
.flatMap(organizationId -> createSpaceId(this.cloudFoundryClient, organizationId, spaceName))
126+
.flatMap(spaceId -> this.cloudFoundryClient.spacesV3()
127+
.delete(DeleteSpaceRequest.builder()
128+
.spaceId(spaceId)
129+
.build())
130+
.flatMap(job -> JobUtils.waitForCompletion(this.cloudFoundryClient, Duration.ofMinutes(5), job)))
131+
.thenMany(requestListSpaces(this.cloudFoundryClient, spaceName))
132+
.as(StepVerifier::create)
133+
.expectComplete()
134+
.verify(Duration.ofMinutes(5));
135+
}
136+
118137
//TODO: Test has not been validated
119138
@IfCloudFoundryVersion(greaterThan = CloudFoundryVersion.PCF_2_9)
120139
@Test

0 commit comments

Comments
 (0)