Skip to content

Commit c148115

Browse files
committed
Merge branch '1007-default-domain' into 3.x
2 parents 8f84bb3 + 5c94bc9 commit c148115

File tree

9 files changed

+191
-9
lines changed

9 files changed

+191
-9
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentResponse;
2121
import org.cloudfoundry.client.v3.organizations.CreateOrganizationRequest;
2222
import org.cloudfoundry.client.v3.organizations.CreateOrganizationResponse;
23+
import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainRequest;
24+
import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainResponse;
2325
import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultIsolationSegmentRequest;
2426
import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultIsolationSegmentResponse;
2527
import org.cloudfoundry.client.v3.organizations.GetOrganizationRequest;
@@ -74,6 +76,12 @@ public Mono<GetOrganizationResponse> get(GetOrganizationRequest request) {
7476
.checkpoint();
7577
}
7678

79+
@Override
80+
public Mono<GetOrganizationDefaultDomainResponse> getDefaultDomain(GetOrganizationDefaultDomainRequest request) {
81+
return get(request, GetOrganizationDefaultDomainResponse.class, builder -> builder.pathSegment("organizations", request.getOrganizationId(), "domains", "default"))
82+
.checkpoint();
83+
}
84+
7785
@Override
7886
public Mono<GetOrganizationDefaultIsolationSegmentResponse> getDefaultIsolationSegment(GetOrganizationDefaultIsolationSegmentRequest request) {
7987
return get(request, GetOrganizationDefaultIsolationSegmentResponse.class, builder ->

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_ToOneRelationship.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
import org.cloudfoundry.Nullable;
2122
import org.immutables.value.Value;
2223

2324
/**
@@ -30,6 +31,7 @@ abstract class _ToOneRelationship {
3031
/**
3132
* The relationship data
3233
*/
34+
@Nullable
3335
@JsonProperty("data")
3436
abstract Relationship getData();
3537

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2013-2019 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.domains;
18+
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import org.cloudfoundry.Nullable;
21+
import org.cloudfoundry.client.v3.Metadata;
22+
import org.cloudfoundry.client.v3.Resource;
23+
24+
public abstract class Domain extends Resource {
25+
26+
/**
27+
* Metadata applied to the domain.
28+
*/
29+
@JsonProperty("metadata")
30+
@Nullable
31+
public abstract Metadata getMetadata();
32+
33+
/**
34+
* The name of the domain.
35+
* Must be between 3 ~ 253 characters and follow <a href="https://tools.ietf.org/html/rfc1035">RFC 1035</a>.
36+
*/
37+
@JsonProperty("name")
38+
public abstract String getName();
39+
40+
/**
41+
* Relationships of the domain.
42+
*/
43+
@JsonProperty("relationships")
44+
public abstract DomainRelationships getRelationships();
45+
46+
/**
47+
* Whether the domain is used for internal (container-to-container) traffic.
48+
*/
49+
@JsonProperty("internal")
50+
public abstract boolean isInternal();
51+
52+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2013-2019 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.domains;
18+
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
import org.cloudfoundry.client.v3.ToManyRelationship;
22+
import org.cloudfoundry.client.v3.ToOneRelationship;
23+
import org.immutables.value.Value;
24+
25+
@JsonDeserialize
26+
@Value.Immutable
27+
abstract class _DomainRelationships {
28+
29+
/**
30+
* The organization the domain is scoped to. If set, the domain will only be available in that organization.
31+
* Otherwise, the domain will be globally available.
32+
*/
33+
@JsonProperty("organization")
34+
abstract ToOneRelationship getOrganization();
35+
36+
/**
37+
* Organizations the domain is shared with. If set, the domain will be available in these organizations in addition
38+
* to the organization the domain is scoped to.
39+
*/
40+
@JsonProperty("shared_organizations")
41+
abstract ToManyRelationship getSharedOrganizations();
42+
43+
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ public interface OrganizationsV3 {
4747
*/
4848
Mono<GetOrganizationResponse> get(GetOrganizationRequest request);
4949

50+
/**
51+
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.76.0/index.html#get-default-domain">List Organizations</a> request
52+
*
53+
* @param request the List Organizations request
54+
* @return the response from the List Organizations request
55+
*/
56+
Mono<GetOrganizationDefaultDomainResponse> getDefaultDomain(GetOrganizationDefaultDomainRequest request);
57+
5058
/**
5159
* Makes the <a href="https://v3-apidocs.cloudfoundry.org/version/3.27.0/index.html#get-default-isolation-segment">Get Default Isolation Segment</a> request
5260
*
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2013-2019 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.organizations;
18+
19+
import com.fasterxml.jackson.annotation.JsonIgnore;
20+
import org.immutables.value.Value;
21+
22+
@Value.Immutable
23+
abstract class _GetOrganizationDefaultDomainRequest {
24+
25+
/**
26+
* The organization id
27+
*/
28+
@JsonIgnore
29+
abstract String getOrganizationId();
30+
31+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2013-2019 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.organizations;
18+
19+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
20+
import org.cloudfoundry.client.v3.domains.Domain;
21+
import org.immutables.value.Value;
22+
23+
@JsonDeserialize
24+
@Value.Immutable
25+
abstract class _GetOrganizationDefaultDomainResponse extends Domain {
26+
27+
}

cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/ToOneRelationshipTest.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,10 @@
2020

2121
public final class ToOneRelationshipTest {
2222

23-
@Test(expected = IllegalStateException.class)
24-
public void noData() {
25-
ToOneRelationship.builder()
26-
.build();
27-
}
28-
2923
@Test
3024
public void valid() {
3125
ToOneRelationship.builder()
32-
.data(Relationship.builder()
33-
.id("test-id")
34-
.build())
3526
.build();
3627
}
28+
3729
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentResponse;
2929
import org.cloudfoundry.client.v3.organizations.CreateOrganizationRequest;
3030
import org.cloudfoundry.client.v3.organizations.CreateOrganizationResponse;
31+
import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainRequest;
32+
import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainResponse;
3133
import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultIsolationSegmentRequest;
3234
import org.cloudfoundry.client.v3.organizations.GetOrganizationRequest;
3335
import org.cloudfoundry.client.v3.organizations.GetOrganizationResponse;
@@ -110,6 +112,23 @@ public void get() {
110112
.verify(Duration.ofMinutes(5));
111113
}
112114

115+
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_7)
116+
@Test
117+
public void getDefaultDomain() {
118+
String organizationName = this.nameFactory.getOrganizationName();
119+
120+
createOrganizationId(this.cloudFoundryClient, organizationName)
121+
.flatMap(organizationId -> this.cloudFoundryClient.organizationsV3()
122+
.getDefaultDomain(GetOrganizationDefaultDomainRequest.builder()
123+
.organizationId(organizationId)
124+
.build()))
125+
.map(GetOrganizationDefaultDomainResponse::getName)
126+
.as(StepVerifier::create)
127+
.consumeNextWith(name -> assertThat(name).contains("apps.", ".springapps.io"))
128+
.expectComplete()
129+
.verify(Duration.ofMinutes(5));
130+
}
131+
113132
@Test
114133
public void getDefaultIsolationSegment() {
115134
String isolationSegmentName = this.nameFactory.getIsolationSegmentName();

0 commit comments

Comments
 (0)