software.amazon.awssdk.services.organizations.model.Organization Maven / Gradle / Ivy
Show all versions of organizations Show documentation
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.services.organizations.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains details about an organization. An organization is a collection of accounts that are centrally managed
* together using consolidated billing, organized hierarchically with organizational units (OUs), and controlled with
* policies .
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Organization implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Organization::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Id").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Organization::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();
private static final SdkField FEATURE_SET_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Organization::featureSetAsString)).setter(setter(Builder::featureSet))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FeatureSet").build()).build();
private static final SdkField MASTER_ACCOUNT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Organization::masterAccountArn)).setter(setter(Builder::masterAccountArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MasterAccountArn").build()).build();
private static final SdkField MASTER_ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Organization::masterAccountId)).setter(setter(Builder::masterAccountId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MasterAccountId").build()).build();
private static final SdkField MASTER_ACCOUNT_EMAIL_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Organization::masterAccountEmail)).setter(setter(Builder::masterAccountEmail))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MasterAccountEmail").build())
.build();
private static final SdkField> AVAILABLE_POLICY_TYPES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(Organization::availablePolicyTypes))
.setter(setter(Builder::availablePolicyTypes))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AvailablePolicyTypes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(PolicyTypeSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, ARN_FIELD,
FEATURE_SET_FIELD, MASTER_ACCOUNT_ARN_FIELD, MASTER_ACCOUNT_ID_FIELD, MASTER_ACCOUNT_EMAIL_FIELD,
AVAILABLE_POLICY_TYPES_FIELD));
private static final long serialVersionUID = 1L;
private final String id;
private final String arn;
private final String featureSet;
private final String masterAccountArn;
private final String masterAccountId;
private final String masterAccountEmail;
private final List availablePolicyTypes;
private Organization(BuilderImpl builder) {
this.id = builder.id;
this.arn = builder.arn;
this.featureSet = builder.featureSet;
this.masterAccountArn = builder.masterAccountArn;
this.masterAccountId = builder.masterAccountId;
this.masterAccountEmail = builder.masterAccountEmail;
this.availablePolicyTypes = builder.availablePolicyTypes;
}
/**
*
* The unique identifier (ID) of an organization.
*
*
* The regex pattern for an organization ID string requires "o-"
* followed by from 10 to 32 lower-case letters or digits.
*
*
* @return The unique identifier (ID) of an organization.
*
* The regex pattern for an organization ID string requires
* "o-" followed by from 10 to 32 lower-case letters or digits.
*/
public String id() {
return id;
}
/**
*
* The Amazon Resource Name (ARN) of an organization.
*
*
* For more information about ARNs in Organizations, see ARN
* Formats Supported by Organizations in the AWS Organizations User Guide.
*
*
* @return The Amazon Resource Name (ARN) of an organization.
*
* For more information about ARNs in Organizations, see ARN Formats Supported by Organizations in the AWS Organizations User Guide.
*/
public String arn() {
return arn;
}
/**
*
* Specifies the functionality that currently is available to the organization. If set to "ALL", then all features
* are enabled and policies can be applied to accounts in the organization. If set to "CONSOLIDATED_BILLING", then
* only consolidated billing functionality is available. For more information, see Enabling All Features in Your Organization in the AWS Organizations User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #featureSet} will
* return {@link OrganizationFeatureSet#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #featureSetAsString}.
*
*
* @return Specifies the functionality that currently is available to the organization. If set to "ALL", then all
* features are enabled and policies can be applied to accounts in the organization. If set to
* "CONSOLIDATED_BILLING", then only consolidated billing functionality is available. For more information,
* see Enabling All Features in Your Organization in the AWS Organizations User Guide.
* @see OrganizationFeatureSet
*/
public OrganizationFeatureSet featureSet() {
return OrganizationFeatureSet.fromValue(featureSet);
}
/**
*
* Specifies the functionality that currently is available to the organization. If set to "ALL", then all features
* are enabled and policies can be applied to accounts in the organization. If set to "CONSOLIDATED_BILLING", then
* only consolidated billing functionality is available. For more information, see Enabling All Features in Your Organization in the AWS Organizations User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #featureSet} will
* return {@link OrganizationFeatureSet#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #featureSetAsString}.
*
*
* @return Specifies the functionality that currently is available to the organization. If set to "ALL", then all
* features are enabled and policies can be applied to accounts in the organization. If set to
* "CONSOLIDATED_BILLING", then only consolidated billing functionality is available. For more information,
* see Enabling All Features in Your Organization in the AWS Organizations User Guide.
* @see OrganizationFeatureSet
*/
public String featureSetAsString() {
return featureSet;
}
/**
*
* The Amazon Resource Name (ARN) of the account that is designated as the master account for the organization.
*
*
* For more information about ARNs in Organizations, see ARN
* Formats Supported by Organizations in the AWS Organizations User Guide.
*
*
* @return The Amazon Resource Name (ARN) of the account that is designated as the master account for the
* organization.
*
* For more information about ARNs in Organizations, see ARN Formats Supported by Organizations in the AWS Organizations User Guide.
*/
public String masterAccountArn() {
return masterAccountArn;
}
/**
*
* The unique identifier (ID) of the master account of an organization.
*
*
* The regex pattern for an account ID string requires exactly 12
* digits.
*
*
* @return The unique identifier (ID) of the master account of an organization.
*
* The regex pattern for an account ID string requires exactly
* 12 digits.
*/
public String masterAccountId() {
return masterAccountId;
}
/**
*
* The email address that is associated with the AWS account that is designated as the master account for the
* organization.
*
*
* @return The email address that is associated with the AWS account that is designated as the master account for
* the organization.
*/
public String masterAccountEmail() {
return masterAccountEmail;
}
/**
* Returns true if the AvailablePolicyTypes property was specified by the sender (it may be empty), or false if the
* sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS
* service.
*/
public boolean hasAvailablePolicyTypes() {
return availablePolicyTypes != null && !(availablePolicyTypes instanceof SdkAutoConstructList);
}
/**
*
* A list of policy types that are enabled for this organization. For example, if your organization has all features
* enabled, then service control policies (SCPs) are included in the list.
*
*
*
* Even if a policy type is shown as available in the organization, you can separately enable and disable them at
* the root level by using EnablePolicyType and DisablePolicyType. Use ListRoots to see the
* status of a policy type in that root.
*
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasAvailablePolicyTypes()} to see if a value was sent in this field.
*
*
* @return A list of policy types that are enabled for this organization. For example, if your organization has all
* features enabled, then service control policies (SCPs) are included in the list.
*
* Even if a policy type is shown as available in the organization, you can separately enable and disable
* them at the root level by using EnablePolicyType and DisablePolicyType. Use
* ListRoots to see the status of a policy type in that root.
*
*/
public List availablePolicyTypes() {
return availablePolicyTypes;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(featureSetAsString());
hashCode = 31 * hashCode + Objects.hashCode(masterAccountArn());
hashCode = 31 * hashCode + Objects.hashCode(masterAccountId());
hashCode = 31 * hashCode + Objects.hashCode(masterAccountEmail());
hashCode = 31 * hashCode + Objects.hashCode(availablePolicyTypes());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Organization)) {
return false;
}
Organization other = (Organization) obj;
return Objects.equals(id(), other.id()) && Objects.equals(arn(), other.arn())
&& Objects.equals(featureSetAsString(), other.featureSetAsString())
&& Objects.equals(masterAccountArn(), other.masterAccountArn())
&& Objects.equals(masterAccountId(), other.masterAccountId())
&& Objects.equals(masterAccountEmail(), other.masterAccountEmail())
&& Objects.equals(availablePolicyTypes(), other.availablePolicyTypes());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public String toString() {
return ToString.builder("Organization").add("Id", id()).add("Arn", arn()).add("FeatureSet", featureSetAsString())
.add("MasterAccountArn", masterAccountArn()).add("MasterAccountId", masterAccountId())
.add("MasterAccountEmail", masterAccountEmail() == null ? null : "*** Sensitive Data Redacted ***")
.add("AvailablePolicyTypes", availablePolicyTypes()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Id":
return Optional.ofNullable(clazz.cast(id()));
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
case "FeatureSet":
return Optional.ofNullable(clazz.cast(featureSetAsString()));
case "MasterAccountArn":
return Optional.ofNullable(clazz.cast(masterAccountArn()));
case "MasterAccountId":
return Optional.ofNullable(clazz.cast(masterAccountId()));
case "MasterAccountEmail":
return Optional.ofNullable(clazz.cast(masterAccountEmail()));
case "AvailablePolicyTypes":
return Optional.ofNullable(clazz.cast(availablePolicyTypes()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function