software.amazon.awssdk.services.chime.model.Account Maven / Gradle / Ivy
/*
* 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.chime.model;
import java.io.Serializable;
import java.time.Instant;
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.traits.TimestampFormatTrait;
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;
/**
*
* The Amazon Chime account details. An AWS account can have multiple Amazon Chime accounts.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Account implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField AWS_ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AwsAccountId").getter(getter(Account::awsAccountId)).setter(setter(Builder::awsAccountId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AwsAccountId").build()).build();
private static final SdkField ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccountId").getter(getter(Account::accountId)).setter(setter(Builder::accountId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountId").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(Account::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField ACCOUNT_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccountType").getter(getter(Account::accountTypeAsString)).setter(setter(Builder::accountType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountType").build()).build();
private static final SdkField CREATED_TIMESTAMP_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("CreatedTimestamp")
.getter(getter(Account::createdTimestamp))
.setter(setter(Builder::createdTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTimestamp").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField DEFAULT_LICENSE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DefaultLicense").getter(getter(Account::defaultLicenseAsString)).setter(setter(Builder::defaultLicense))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DefaultLicense").build()).build();
private static final SdkField> SUPPORTED_LICENSES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SupportedLicenses")
.getter(getter(Account::supportedLicensesAsStrings))
.setter(setter(Builder::supportedLicensesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SupportedLicenses").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField ACCOUNT_STATUS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccountStatus").getter(getter(Account::accountStatusAsString)).setter(setter(Builder::accountStatus))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountStatus").build()).build();
private static final SdkField> SIGNIN_DELEGATE_GROUPS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("SigninDelegateGroups")
.getter(getter(Account::signinDelegateGroups))
.setter(setter(Builder::signinDelegateGroups))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SigninDelegateGroups").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(SigninDelegateGroup::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AWS_ACCOUNT_ID_FIELD,
ACCOUNT_ID_FIELD, NAME_FIELD, ACCOUNT_TYPE_FIELD, CREATED_TIMESTAMP_FIELD, DEFAULT_LICENSE_FIELD,
SUPPORTED_LICENSES_FIELD, ACCOUNT_STATUS_FIELD, SIGNIN_DELEGATE_GROUPS_FIELD));
private static final long serialVersionUID = 1L;
private final String awsAccountId;
private final String accountId;
private final String name;
private final String accountType;
private final Instant createdTimestamp;
private final String defaultLicense;
private final List supportedLicenses;
private final String accountStatus;
private final List signinDelegateGroups;
private Account(BuilderImpl builder) {
this.awsAccountId = builder.awsAccountId;
this.accountId = builder.accountId;
this.name = builder.name;
this.accountType = builder.accountType;
this.createdTimestamp = builder.createdTimestamp;
this.defaultLicense = builder.defaultLicense;
this.supportedLicenses = builder.supportedLicenses;
this.accountStatus = builder.accountStatus;
this.signinDelegateGroups = builder.signinDelegateGroups;
}
/**
*
* The AWS account ID.
*
*
* @return The AWS account ID.
*/
public final String awsAccountId() {
return awsAccountId;
}
/**
*
* The Amazon Chime account ID.
*
*
* @return The Amazon Chime account ID.
*/
public final String accountId() {
return accountId;
}
/**
*
* The Amazon Chime account name.
*
*
* @return The Amazon Chime account name.
*/
public final String name() {
return name;
}
/**
*
* The Amazon Chime account type. For more information about different account types, see Managing Your Amazon Chime
* Accounts in the Amazon Chime Administration Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #accountType} will
* return {@link AccountType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #accountTypeAsString}.
*
*
* @return The Amazon Chime account type. For more information about different account types, see Managing Your Amazon Chime
* Accounts in the Amazon Chime Administration Guide.
* @see AccountType
*/
public final AccountType accountType() {
return AccountType.fromValue(accountType);
}
/**
*
* The Amazon Chime account type. For more information about different account types, see Managing Your Amazon Chime
* Accounts in the Amazon Chime Administration Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #accountType} will
* return {@link AccountType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #accountTypeAsString}.
*
*
* @return The Amazon Chime account type. For more information about different account types, see Managing Your Amazon Chime
* Accounts in the Amazon Chime Administration Guide.
* @see AccountType
*/
public final String accountTypeAsString() {
return accountType;
}
/**
*
* The Amazon Chime account creation timestamp, in ISO 8601 format.
*
*
* @return The Amazon Chime account creation timestamp, in ISO 8601 format.
*/
public final Instant createdTimestamp() {
return createdTimestamp;
}
/**
*
* The default license for the Amazon Chime account.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #defaultLicense}
* will return {@link License#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #defaultLicenseAsString}.
*
*
* @return The default license for the Amazon Chime account.
* @see License
*/
public final License defaultLicense() {
return License.fromValue(defaultLicense);
}
/**
*
* The default license for the Amazon Chime account.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #defaultLicense}
* will return {@link License#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #defaultLicenseAsString}.
*
*
* @return The default license for the Amazon Chime account.
* @see License
*/
public final String defaultLicenseAsString() {
return defaultLicense;
}
/**
*
* Supported licenses for the Amazon Chime account.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasSupportedLicenses} method.
*
*
* @return Supported licenses for the Amazon Chime account.
*/
public final List supportedLicenses() {
return LicenseListCopier.copyStringToEnum(supportedLicenses);
}
/**
* For responses, this returns true if the service returned a value for the SupportedLicenses property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasSupportedLicenses() {
return supportedLicenses != null && !(supportedLicenses instanceof SdkAutoConstructList);
}
/**
*
* Supported licenses for the Amazon Chime account.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasSupportedLicenses} method.
*
*
* @return Supported licenses for the Amazon Chime account.
*/
public final List supportedLicensesAsStrings() {
return supportedLicenses;
}
/**
*
* The status of the account.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #accountStatus}
* will return {@link AccountStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #accountStatusAsString}.
*
*
* @return The status of the account.
* @see AccountStatus
*/
public final AccountStatus accountStatus() {
return AccountStatus.fromValue(accountStatus);
}
/**
*
* The status of the account.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #accountStatus}
* will return {@link AccountStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #accountStatusAsString}.
*
*
* @return The status of the account.
* @see AccountStatus
*/
public final String accountStatusAsString() {
return accountStatus;
}
/**
* For responses, this returns true if the service returned a value for the SigninDelegateGroups property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasSigninDelegateGroups() {
return signinDelegateGroups != null && !(signinDelegateGroups instanceof SdkAutoConstructList);
}
/**
*
* The sign-in delegate groups associated with the account.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasSigninDelegateGroups} method.
*
*
* @return The sign-in delegate groups associated with the account.
*/
public final List signinDelegateGroups() {
return signinDelegateGroups;
}
@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 final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(awsAccountId());
hashCode = 31 * hashCode + Objects.hashCode(accountId());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(accountTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(createdTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(defaultLicenseAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasSupportedLicenses() ? supportedLicensesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(accountStatusAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasSigninDelegateGroups() ? signinDelegateGroups() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Account)) {
return false;
}
Account other = (Account) obj;
return Objects.equals(awsAccountId(), other.awsAccountId()) && Objects.equals(accountId(), other.accountId())
&& Objects.equals(name(), other.name()) && Objects.equals(accountTypeAsString(), other.accountTypeAsString())
&& Objects.equals(createdTimestamp(), other.createdTimestamp())
&& Objects.equals(defaultLicenseAsString(), other.defaultLicenseAsString())
&& hasSupportedLicenses() == other.hasSupportedLicenses()
&& Objects.equals(supportedLicensesAsStrings(), other.supportedLicensesAsStrings())
&& Objects.equals(accountStatusAsString(), other.accountStatusAsString())
&& hasSigninDelegateGroups() == other.hasSigninDelegateGroups()
&& Objects.equals(signinDelegateGroups(), other.signinDelegateGroups());
}
/**
* 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 final String toString() {
return ToString.builder("Account").add("AwsAccountId", awsAccountId()).add("AccountId", accountId()).add("Name", name())
.add("AccountType", accountTypeAsString()).add("CreatedTimestamp", createdTimestamp())
.add("DefaultLicense", defaultLicenseAsString())
.add("SupportedLicenses", hasSupportedLicenses() ? supportedLicensesAsStrings() : null)
.add("AccountStatus", accountStatusAsString())
.add("SigninDelegateGroups", hasSigninDelegateGroups() ? signinDelegateGroups() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AwsAccountId":
return Optional.ofNullable(clazz.cast(awsAccountId()));
case "AccountId":
return Optional.ofNullable(clazz.cast(accountId()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "AccountType":
return Optional.ofNullable(clazz.cast(accountTypeAsString()));
case "CreatedTimestamp":
return Optional.ofNullable(clazz.cast(createdTimestamp()));
case "DefaultLicense":
return Optional.ofNullable(clazz.cast(defaultLicenseAsString()));
case "SupportedLicenses":
return Optional.ofNullable(clazz.cast(supportedLicensesAsStrings()));
case "AccountStatus":
return Optional.ofNullable(clazz.cast(accountStatusAsString()));
case "SigninDelegateGroups":
return Optional.ofNullable(clazz.cast(signinDelegateGroups()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function