From bfa64f351dc7365febe94164c813c2b9bf57058a Mon Sep 17 00:00:00 2001 From: Alexander Tsvetkov Date: Tue, 8 Oct 2019 14:45:31 +0300 Subject: [PATCH 1/2] Make data in relationships nullable --- .../java/org/cloudfoundry/client/v3/_ToOneRelationship.java | 3 +++ .../java/org/cloudfoundry/client/v3/ToOneRelationshipTest.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_ToOneRelationship.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_ToOneRelationship.java index 1b84bcd2e1f..81adacc4c94 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_ToOneRelationship.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_ToOneRelationship.java @@ -18,6 +18,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import org.cloudfoundry.Nullable; import org.immutables.value.Value; /** @@ -30,6 +32,7 @@ abstract class _ToOneRelationship { /** * The relationship data */ + @Nullable @JsonProperty("data") abstract Relationship getData(); diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/ToOneRelationshipTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/ToOneRelationshipTest.java index b26ec2276fd..061dfc5a7e6 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/ToOneRelationshipTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/ToOneRelationshipTest.java @@ -20,7 +20,7 @@ public final class ToOneRelationshipTest { - @Test(expected = IllegalStateException.class) + @Test public void noData() { ToOneRelationship.builder() .build(); From ff6d3c96be5649963c8ce0698776931e5ba2384b Mon Sep 17 00:00:00 2001 From: Alexander Tsvetkov Date: Tue, 8 Oct 2019 16:49:57 +0300 Subject: [PATCH 2/2] Implement retrieval of default domain --- .../organizations/ReactorOrganizationsV3.java | 8 +++ .../client/v3/domains/Domain.java | 53 +++++++++++++++++++ .../v3/domains/_DomainRelationships.java | 44 +++++++++++++++ .../v3/organizations/OrganizationsV3.java | 8 +++ .../_GetOrganizationDefaultDomainRequest.java | 32 +++++++++++ ..._GetOrganizationDefaultDomainResponse.java | 28 ++++++++++ 6 files changed, 173 insertions(+) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/Domain.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/_DomainRelationships.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainRequest.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainResponse.java diff --git a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java index 56e0a0d0a12..eb02edce148 100644 --- a/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java +++ b/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/organizations/ReactorOrganizationsV3.java @@ -20,6 +20,8 @@ import org.cloudfoundry.client.v3.organizations.AssignOrganizationDefaultIsolationSegmentResponse; import org.cloudfoundry.client.v3.organizations.CreateOrganizationRequest; import org.cloudfoundry.client.v3.organizations.CreateOrganizationResponse; +import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainRequest; +import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultDomainResponse; import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultIsolationSegmentRequest; import org.cloudfoundry.client.v3.organizations.GetOrganizationDefaultIsolationSegmentResponse; import org.cloudfoundry.client.v3.organizations.GetOrganizationRequest; @@ -85,4 +87,10 @@ public Mono list(ListOrganizationsRequest request) { .checkpoint(); } + @Override + public Mono getDefaultDomain(GetOrganizationDefaultDomainRequest request) { + return get(request, GetOrganizationDefaultDomainResponse.class, builder -> builder.pathSegment("organizations", request.getOrganizationId(), "domains", "default")) + .checkpoint(); + } + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/Domain.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/Domain.java new file mode 100644 index 00000000000..9657b4089a4 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/Domain.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013-2019 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.domains; + +import org.cloudfoundry.Nullable; +import org.cloudfoundry.client.v3.Metadata; +import org.cloudfoundry.client.v3.Resource; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public abstract class Domain extends Resource { + + /** + * The name of the domain. + * Must be between 3 ~ 253 characters and follow RFC 1035. + */ + @JsonProperty("name") + public abstract String getName(); + + /** + * Metadata applied to the domain. + */ + @JsonProperty("metadata") + @Nullable + public abstract Metadata getMetadata(); + + /** + * Whether the domain is used for internal (container-to-container) traffic. + */ + @JsonProperty("internal") + public abstract boolean isInternal(); + + /** + * Relationships of the domain. + */ + @JsonProperty("relationships") + public abstract DomainRelationships getRelationships(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/_DomainRelationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/_DomainRelationships.java new file mode 100644 index 00000000000..e373321724e --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/domains/_DomainRelationships.java @@ -0,0 +1,44 @@ +/* + * Copyright 2013-2019 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.domains; + +import org.cloudfoundry.client.v3.ToManyRelationship; +import org.cloudfoundry.client.v3.ToOneRelationship; +import org.immutables.value.Value; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize +@Value.Immutable +abstract class _DomainRelationships { + + /** + * The organization the domain is scoped to. If set, the domain will only be available in that organization. + * Otherwise, the domain will be globally available. + */ + @JsonProperty("organization") + abstract ToOneRelationship getOrganization(); + + /** + * Organizations the domain is shared with. If set, the domain will be available in these organizations in addition + * to the organization the domain is scoped to. + */ + @JsonProperty("shared_organizations") + abstract ToManyRelationship getSharedOrganizations(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java index 799dac4c648..513f1b92fd9 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/OrganizationsV3.java @@ -63,4 +63,12 @@ public interface OrganizationsV3 { */ Mono list(ListOrganizationsRequest request); + /** + * Makes the List Organizations request + * + * @param request the List Organizations request + * @return the response from the List Organizations request + */ + Mono getDefaultDomain(GetOrganizationDefaultDomainRequest request); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainRequest.java new file mode 100644 index 00000000000..713d96dce10 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainRequest.java @@ -0,0 +1,32 @@ +/* + * Copyright 2013-2019 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.organizations; + +import org.immutables.value.Value; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +@Value.Immutable +abstract class _GetOrganizationDefaultDomainRequest { + + /** + * The organization id + */ + @JsonIgnore + abstract String getOrganizationId(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainResponse.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainResponse.java new file mode 100644 index 00000000000..0cef55f8ed7 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/organizations/_GetOrganizationDefaultDomainResponse.java @@ -0,0 +1,28 @@ +/* + * Copyright 2013-2019 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.organizations; + +import org.cloudfoundry.client.v3.domains.Domain; +import org.immutables.value.Value; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize +@Value.Immutable +abstract class _GetOrganizationDefaultDomainResponse extends Domain { + +}