software.amazon.awssdk.services.amplifybackend.model.CreateBackendAuthUserPoolConfig Maven / Gradle / Ivy
Show all versions of amplifybackend 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.amplifybackend.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
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;
/**
*
* Describes the Amazon Cognito user pool configuration for the auth resource to be configured for your Amplify project.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class CreateBackendAuthUserPoolConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField FORGOT_PASSWORD_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ForgotPassword")
.getter(getter(CreateBackendAuthUserPoolConfig::forgotPassword)).setter(setter(Builder::forgotPassword))
.constructor(CreateBackendAuthForgotPasswordConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("forgotPassword").build()).build();
private static final SdkField MFA_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Mfa")
.getter(getter(CreateBackendAuthUserPoolConfig::mfa)).setter(setter(Builder::mfa))
.constructor(CreateBackendAuthMFAConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("mfa").build()).build();
private static final SdkField O_AUTH_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("OAuth")
.getter(getter(CreateBackendAuthUserPoolConfig::oAuth)).setter(setter(Builder::oAuth))
.constructor(CreateBackendAuthOAuthConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("oAuth").build()).build();
private static final SdkField PASSWORD_POLICY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("PasswordPolicy")
.getter(getter(CreateBackendAuthUserPoolConfig::passwordPolicy)).setter(setter(Builder::passwordPolicy))
.constructor(CreateBackendAuthPasswordPolicyConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("passwordPolicy").build()).build();
private static final SdkField> REQUIRED_SIGN_UP_ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("RequiredSignUpAttributes")
.getter(getter(CreateBackendAuthUserPoolConfig::requiredSignUpAttributesAsStrings))
.setter(setter(Builder::requiredSignUpAttributesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("requiredSignUpAttributes").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 SIGN_IN_METHOD_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SignInMethod").getter(getter(CreateBackendAuthUserPoolConfig::signInMethodAsString))
.setter(setter(Builder::signInMethod))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("signInMethod").build()).build();
private static final SdkField USER_POOL_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("UserPoolName").getter(getter(CreateBackendAuthUserPoolConfig::userPoolName))
.setter(setter(Builder::userPoolName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("userPoolName").build()).build();
private static final SdkField VERIFICATION_MESSAGE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("VerificationMessage")
.getter(getter(CreateBackendAuthUserPoolConfig::verificationMessage)).setter(setter(Builder::verificationMessage))
.constructor(CreateBackendAuthVerificationMessageConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("verificationMessage").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FORGOT_PASSWORD_FIELD,
MFA_FIELD, O_AUTH_FIELD, PASSWORD_POLICY_FIELD, REQUIRED_SIGN_UP_ATTRIBUTES_FIELD, SIGN_IN_METHOD_FIELD,
USER_POOL_NAME_FIELD, VERIFICATION_MESSAGE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("forgotPassword", FORGOT_PASSWORD_FIELD);
put("mfa", MFA_FIELD);
put("oAuth", O_AUTH_FIELD);
put("passwordPolicy", PASSWORD_POLICY_FIELD);
put("requiredSignUpAttributes", REQUIRED_SIGN_UP_ATTRIBUTES_FIELD);
put("signInMethod", SIGN_IN_METHOD_FIELD);
put("userPoolName", USER_POOL_NAME_FIELD);
put("verificationMessage", VERIFICATION_MESSAGE_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final CreateBackendAuthForgotPasswordConfig forgotPassword;
private final CreateBackendAuthMFAConfig mfa;
private final CreateBackendAuthOAuthConfig oAuth;
private final CreateBackendAuthPasswordPolicyConfig passwordPolicy;
private final List requiredSignUpAttributes;
private final String signInMethod;
private final String userPoolName;
private final CreateBackendAuthVerificationMessageConfig verificationMessage;
private CreateBackendAuthUserPoolConfig(BuilderImpl builder) {
this.forgotPassword = builder.forgotPassword;
this.mfa = builder.mfa;
this.oAuth = builder.oAuth;
this.passwordPolicy = builder.passwordPolicy;
this.requiredSignUpAttributes = builder.requiredSignUpAttributes;
this.signInMethod = builder.signInMethod;
this.userPoolName = builder.userPoolName;
this.verificationMessage = builder.verificationMessage;
}
/**
*
* (DEPRECATED) Describes the forgotten password policy for your Amazon Cognito user pool, configured as a
* part of your Amplify project.
*
*
* @return (DEPRECATED)
*/
public final CreateBackendAuthForgotPasswordConfig forgotPassword() {
return forgotPassword;
}
/**
*
* Describes whether to apply multi-factor authentication policies for your Amazon Cognito user pool configured as a
* part of your Amplify project.
*
*
* @return Describes whether to apply multi-factor authentication policies for your Amazon Cognito user pool
* configured as a part of your Amplify project.
*/
public final CreateBackendAuthMFAConfig mfa() {
return mfa;
}
/**
*
* Describes the OAuth policy and rules for your Amazon Cognito user pool, configured as a part of your Amplify
* project.
*
*
* @return Describes the OAuth policy and rules for your Amazon Cognito user pool, configured as a part of your
* Amplify project.
*/
public final CreateBackendAuthOAuthConfig oAuth() {
return oAuth;
}
/**
*
* Describes the password policy for your Amazon Cognito user pool, configured as a part of your Amplify project.
*
*
* @return Describes the password policy for your Amazon Cognito user pool, configured as a part of your Amplify
* project.
*/
public final CreateBackendAuthPasswordPolicyConfig passwordPolicy() {
return passwordPolicy;
}
/**
*
* The required attributes to sign up new users in the user pool.
*
*
* 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 #hasRequiredSignUpAttributes} method.
*
*
* @return The required attributes to sign up new users in the user pool.
*/
public final List requiredSignUpAttributes() {
return ListOfRequiredSignUpAttributesElementCopier.copyStringToEnum(requiredSignUpAttributes);
}
/**
* For responses, this returns true if the service returned a value for the RequiredSignUpAttributes 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 hasRequiredSignUpAttributes() {
return requiredSignUpAttributes != null && !(requiredSignUpAttributes instanceof SdkAutoConstructList);
}
/**
*
* The required attributes to sign up new users in the user pool.
*
*
* 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 #hasRequiredSignUpAttributes} method.
*
*
* @return The required attributes to sign up new users in the user pool.
*/
public final List requiredSignUpAttributesAsStrings() {
return requiredSignUpAttributes;
}
/**
*
* Describes the sign-in methods that your Amplify app users use to log in using the Amazon Cognito user pool,
* configured as a part of your Amplify project.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #signInMethod} will
* return {@link SignInMethod#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #signInMethodAsString}.
*
*
* @return Describes the sign-in methods that your Amplify app users use to log in using the Amazon Cognito user
* pool, configured as a part of your Amplify project.
* @see SignInMethod
*/
public final SignInMethod signInMethod() {
return SignInMethod.fromValue(signInMethod);
}
/**
*
* Describes the sign-in methods that your Amplify app users use to log in using the Amazon Cognito user pool,
* configured as a part of your Amplify project.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #signInMethod} will
* return {@link SignInMethod#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #signInMethodAsString}.
*
*
* @return Describes the sign-in methods that your Amplify app users use to log in using the Amazon Cognito user
* pool, configured as a part of your Amplify project.
* @see SignInMethod
*/
public final String signInMethodAsString() {
return signInMethod;
}
/**
*
* The Amazon Cognito user pool name.
*
*
* @return The Amazon Cognito user pool name.
*/
public final String userPoolName() {
return userPoolName;
}
/**
*
* Describes the email or SMS verification message for your Amazon Cognito user pool, configured as a part of your
* Amplify project.
*
*
* @return Describes the email or SMS verification message for your Amazon Cognito user pool, configured as a part
* of your Amplify project.
*/
public final CreateBackendAuthVerificationMessageConfig verificationMessage() {
return verificationMessage;
}
@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(forgotPassword());
hashCode = 31 * hashCode + Objects.hashCode(mfa());
hashCode = 31 * hashCode + Objects.hashCode(oAuth());
hashCode = 31 * hashCode + Objects.hashCode(passwordPolicy());
hashCode = 31 * hashCode + Objects.hashCode(hasRequiredSignUpAttributes() ? requiredSignUpAttributesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(signInMethodAsString());
hashCode = 31 * hashCode + Objects.hashCode(userPoolName());
hashCode = 31 * hashCode + Objects.hashCode(verificationMessage());
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 CreateBackendAuthUserPoolConfig)) {
return false;
}
CreateBackendAuthUserPoolConfig other = (CreateBackendAuthUserPoolConfig) obj;
return Objects.equals(forgotPassword(), other.forgotPassword()) && Objects.equals(mfa(), other.mfa())
&& Objects.equals(oAuth(), other.oAuth()) && Objects.equals(passwordPolicy(), other.passwordPolicy())
&& hasRequiredSignUpAttributes() == other.hasRequiredSignUpAttributes()
&& Objects.equals(requiredSignUpAttributesAsStrings(), other.requiredSignUpAttributesAsStrings())
&& Objects.equals(signInMethodAsString(), other.signInMethodAsString())
&& Objects.equals(userPoolName(), other.userPoolName())
&& Objects.equals(verificationMessage(), other.verificationMessage());
}
/**
* 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("CreateBackendAuthUserPoolConfig").add("ForgotPassword", forgotPassword()).add("Mfa", mfa())
.add("OAuth", oAuth()).add("PasswordPolicy", passwordPolicy())
.add("RequiredSignUpAttributes", hasRequiredSignUpAttributes() ? requiredSignUpAttributesAsStrings() : null)
.add("SignInMethod", signInMethodAsString()).add("UserPoolName", userPoolName())
.add("VerificationMessage", verificationMessage()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ForgotPassword":
return Optional.ofNullable(clazz.cast(forgotPassword()));
case "Mfa":
return Optional.ofNullable(clazz.cast(mfa()));
case "OAuth":
return Optional.ofNullable(clazz.cast(oAuth()));
case "PasswordPolicy":
return Optional.ofNullable(clazz.cast(passwordPolicy()));
case "RequiredSignUpAttributes":
return Optional.ofNullable(clazz.cast(requiredSignUpAttributesAsStrings()));
case "SignInMethod":
return Optional.ofNullable(clazz.cast(signInMethodAsString()));
case "UserPoolName":
return Optional.ofNullable(clazz.cast(userPoolName()));
case "VerificationMessage":
return Optional.ofNullable(clazz.cast(verificationMessage()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function