software.amazon.awssdk.services.apigateway.model.UpdateAuthorizerResponse 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.apigateway.model;
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.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;
/**
*
* Represents an authorization layer for methods. If enabled on a method, API Gateway will activate the authorizer when
* a client calls the method.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class UpdateAuthorizerResponse extends ApiGatewayResponse implements
ToCopyableBuilder {
private static final SdkField ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("id")
.getter(getter(UpdateAuthorizerResponse::id)).setter(setter(Builder::id))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("id").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(UpdateAuthorizerResponse::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("type")
.getter(getter(UpdateAuthorizerResponse::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("type").build()).build();
private static final SdkField> PROVIDER_AR_NS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("providerARNs")
.getter(getter(UpdateAuthorizerResponse::providerARNs))
.setter(setter(Builder::providerARNs))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("providerARNs").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 AUTH_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("authType").getter(getter(UpdateAuthorizerResponse::authType)).setter(setter(Builder::authType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("authType").build()).build();
private static final SdkField AUTHORIZER_URI_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("authorizerUri").getter(getter(UpdateAuthorizerResponse::authorizerUri))
.setter(setter(Builder::authorizerUri))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("authorizerUri").build()).build();
private static final SdkField AUTHORIZER_CREDENTIALS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("authorizerCredentials").getter(getter(UpdateAuthorizerResponse::authorizerCredentials))
.setter(setter(Builder::authorizerCredentials))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("authorizerCredentials").build())
.build();
private static final SdkField IDENTITY_SOURCE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("identitySource").getter(getter(UpdateAuthorizerResponse::identitySource))
.setter(setter(Builder::identitySource))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("identitySource").build()).build();
private static final SdkField IDENTITY_VALIDATION_EXPRESSION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("identityValidationExpression")
.getter(getter(UpdateAuthorizerResponse::identityValidationExpression))
.setter(setter(Builder::identityValidationExpression))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("identityValidationExpression")
.build()).build();
private static final SdkField AUTHORIZER_RESULT_TTL_IN_SECONDS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.memberName("authorizerResultTtlInSeconds")
.getter(getter(UpdateAuthorizerResponse::authorizerResultTtlInSeconds))
.setter(setter(Builder::authorizerResultTtlInSeconds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("authorizerResultTtlInSeconds")
.build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ID_FIELD, NAME_FIELD,
TYPE_FIELD, PROVIDER_AR_NS_FIELD, AUTH_TYPE_FIELD, AUTHORIZER_URI_FIELD, AUTHORIZER_CREDENTIALS_FIELD,
IDENTITY_SOURCE_FIELD, IDENTITY_VALIDATION_EXPRESSION_FIELD, AUTHORIZER_RESULT_TTL_IN_SECONDS_FIELD));
private final String id;
private final String name;
private final String type;
private final List providerARNs;
private final String authType;
private final String authorizerUri;
private final String authorizerCredentials;
private final String identitySource;
private final String identityValidationExpression;
private final Integer authorizerResultTtlInSeconds;
private UpdateAuthorizerResponse(BuilderImpl builder) {
super(builder);
this.id = builder.id;
this.name = builder.name;
this.type = builder.type;
this.providerARNs = builder.providerARNs;
this.authType = builder.authType;
this.authorizerUri = builder.authorizerUri;
this.authorizerCredentials = builder.authorizerCredentials;
this.identitySource = builder.identitySource;
this.identityValidationExpression = builder.identityValidationExpression;
this.authorizerResultTtlInSeconds = builder.authorizerResultTtlInSeconds;
}
/**
*
* The identifier for the authorizer resource.
*
*
* @return The identifier for the authorizer resource.
*/
public final String id() {
return id;
}
/**
*
* The name of the authorizer.
*
*
* @return The name of the authorizer.
*/
public final String name() {
return name;
}
/**
*
* The authorizer type. Valid values are TOKEN
for a Lambda function using a single authorization token
* submitted in a custom header, REQUEST
for a Lambda function using incoming request parameters, and
* COGNITO_USER_POOLS
for using an Amazon Cognito user pool.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link AuthorizerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The authorizer type. Valid values are TOKEN
for a Lambda function using a single
* authorization token submitted in a custom header, REQUEST
for a Lambda function using
* incoming request parameters, and COGNITO_USER_POOLS
for using an Amazon Cognito user pool.
* @see AuthorizerType
*/
public final AuthorizerType type() {
return AuthorizerType.fromValue(type);
}
/**
*
* The authorizer type. Valid values are TOKEN
for a Lambda function using a single authorization token
* submitted in a custom header, REQUEST
for a Lambda function using incoming request parameters, and
* COGNITO_USER_POOLS
for using an Amazon Cognito user pool.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link AuthorizerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The authorizer type. Valid values are TOKEN
for a Lambda function using a single
* authorization token submitted in a custom header, REQUEST
for a Lambda function using
* incoming request parameters, and COGNITO_USER_POOLS
for using an Amazon Cognito user pool.
* @see AuthorizerType
*/
public final String typeAsString() {
return type;
}
/**
* For responses, this returns true if the service returned a value for the ProviderARNs 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 hasProviderARNs() {
return providerARNs != null && !(providerARNs instanceof SdkAutoConstructList);
}
/**
*
* A list of the Amazon Cognito user pool ARNs for the COGNITO_USER_POOLS
authorizer. Each element is
* of this format: arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
. For a
* TOKEN
or REQUEST
authorizer, this is not defined.
*
*
* 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 #hasProviderARNs} method.
*
*
* @return A list of the Amazon Cognito user pool ARNs for the COGNITO_USER_POOLS
authorizer. Each
* element is of this format: arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}
* . For a TOKEN
or REQUEST
authorizer, this is not defined.
*/
public final List providerARNs() {
return providerARNs;
}
/**
*
* Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
*
*
* @return Optional customer-defined field, used in OpenAPI imports and exports without functional impact.
*/
public final String authType() {
return authType;
}
/**
*
* Specifies the authorizer's Uniform Resource Identifier (URI). For TOKEN
or REQUEST
* authorizers, this must be a well-formed Lambda function URI, for example,
* arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
* . In general, the URI has this form arn:aws:apigateway:{region}:lambda:path/{service_api}
, where
* {region}
is the same as the region hosting the Lambda function, path
indicates that the
* remaining substring in the URI should be treated as the path to the resource, including the initial
* /
. For Lambda functions, this is usually of the form
* /2015-03-31/functions/[FunctionARN]/invocations
.
*
*
* @return Specifies the authorizer's Uniform Resource Identifier (URI). For TOKEN
or
* REQUEST
authorizers, this must be a well-formed Lambda function URI, for example,
* arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations
* . In general, the URI has this form arn:aws:apigateway:{region}:lambda:path/{service_api}
,
* where {region}
is the same as the region hosting the Lambda function, path
* indicates that the remaining substring in the URI should be treated as the path to the resource,
* including the initial /
. For Lambda functions, this is usually of the form
* /2015-03-31/functions/[FunctionARN]/invocations
.
*/
public final String authorizerUri() {
return authorizerUri;
}
/**
*
* Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer. To specify an IAM
* role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based permissions on
* the Lambda function, specify null.
*
*
* @return Specifies the required credentials as an IAM role for API Gateway to invoke the authorizer. To specify an
* IAM role for API Gateway to assume, use the role's Amazon Resource Name (ARN). To use resource-based
* permissions on the Lambda function, specify null.
*/
public final String authorizerCredentials() {
return authorizerCredentials;
}
/**
*
* The identity source for which authorization is requested. For a TOKEN
or
* COGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping expression
* for the custom header holding the authorization token submitted by the client. For example, if the token header
* name is Auth
, the header mapping expression is method.request.header.Auth
. For the
* REQUEST
authorizer, this is required when authorization caching is enabled. The value is a
* comma-separated string of one or more mapping expressions of the specified request parameters. For example, if an
* Auth
header, a Name
query string parameter are defined as identity sources, this value
* is method.request.header.Auth
, method.request.querystring.Name
. These parameters will
* be used to derive the authorization caching key and to perform runtime validation of the REQUEST
* authorizer by verifying all of the identity-related request parameters are present, not null and non-empty. Only
* when this is true does the authorizer invoke the authorizer Lambda function, otherwise, it returns a 401
* Unauthorized response without calling the Lambda function. The valid value is a string of comma-separated mapping
* expressions of the specified request parameters. When the authorization caching is not enabled, this property is
* optional.
*
*
* @return The identity source for which authorization is requested. For a TOKEN
or
* COGNITO_USER_POOLS
authorizer, this is required and specifies the request header mapping
* expression for the custom header holding the authorization token submitted by the client. For example, if
* the token header name is Auth
, the header mapping expression is
* method.request.header.Auth
. For the REQUEST
authorizer, this is required when
* authorization caching is enabled. The value is a comma-separated string of one or more mapping
* expressions of the specified request parameters. For example, if an Auth
header, a
* Name
query string parameter are defined as identity sources, this value is
* method.request.header.Auth
, method.request.querystring.Name
. These parameters
* will be used to derive the authorization caching key and to perform runtime validation of the
* REQUEST
authorizer by verifying all of the identity-related request parameters are present,
* not null and non-empty. Only when this is true does the authorizer invoke the authorizer Lambda function,
* otherwise, it returns a 401 Unauthorized response without calling the Lambda function. The valid value is
* a string of comma-separated mapping expressions of the specified request parameters. When the
* authorization caching is not enabled, this property is optional.
*/
public final String identitySource() {
return identitySource;
}
/**
*
* A validation expression for the incoming identity token. For TOKEN
authorizers, this value is a
* regular expression. For COGNITO_USER_POOLS
authorizers, API Gateway will match the aud
* field of the incoming token from the client against the specified regular expression. It will invoke the
* authorizer's Lambda function when there is a match. Otherwise, it will return a 401 Unauthorized response without
* calling the Lambda function. The validation expression does not apply to the REQUEST
authorizer.
*
*
* @return A validation expression for the incoming identity token. For TOKEN
authorizers, this value
* is a regular expression. For COGNITO_USER_POOLS
authorizers, API Gateway will match the
* aud
field of the incoming token from the client against the specified regular expression. It
* will invoke the authorizer's Lambda function when there is a match. Otherwise, it will return a 401
* Unauthorized response without calling the Lambda function. The validation expression does not apply to
* the REQUEST
authorizer.
*/
public final String identityValidationExpression() {
return identityValidationExpression;
}
/**
*
* The TTL in seconds of cached authorizer results. If it equals 0, authorization caching is disabled. If it is
* greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default value is 300.
* The maximum value is 3600, or 1 hour.
*
*
* @return The TTL in seconds of cached authorizer results. If it equals 0, authorization caching is disabled. If it
* is greater than 0, API Gateway will cache authorizer responses. If this field is not set, the default
* value is 300. The maximum value is 3600, or 1 hour.
*/
public final Integer authorizerResultTtlInSeconds() {
return authorizerResultTtlInSeconds;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(id());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasProviderARNs() ? providerARNs() : null);
hashCode = 31 * hashCode + Objects.hashCode(authType());
hashCode = 31 * hashCode + Objects.hashCode(authorizerUri());
hashCode = 31 * hashCode + Objects.hashCode(authorizerCredentials());
hashCode = 31 * hashCode + Objects.hashCode(identitySource());
hashCode = 31 * hashCode + Objects.hashCode(identityValidationExpression());
hashCode = 31 * hashCode + Objects.hashCode(authorizerResultTtlInSeconds());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof UpdateAuthorizerResponse)) {
return false;
}
UpdateAuthorizerResponse other = (UpdateAuthorizerResponse) obj;
return Objects.equals(id(), other.id()) && Objects.equals(name(), other.name())
&& Objects.equals(typeAsString(), other.typeAsString()) && hasProviderARNs() == other.hasProviderARNs()
&& Objects.equals(providerARNs(), other.providerARNs()) && Objects.equals(authType(), other.authType())
&& Objects.equals(authorizerUri(), other.authorizerUri())
&& Objects.equals(authorizerCredentials(), other.authorizerCredentials())
&& Objects.equals(identitySource(), other.identitySource())
&& Objects.equals(identityValidationExpression(), other.identityValidationExpression())
&& Objects.equals(authorizerResultTtlInSeconds(), other.authorizerResultTtlInSeconds());
}
/**
* 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("UpdateAuthorizerResponse").add("Id", id()).add("Name", name()).add("Type", typeAsString())
.add("ProviderARNs", hasProviderARNs() ? providerARNs() : null).add("AuthType", authType())
.add("AuthorizerUri", authorizerUri()).add("AuthorizerCredentials", authorizerCredentials())
.add("IdentitySource", identitySource()).add("IdentityValidationExpression", identityValidationExpression())
.add("AuthorizerResultTtlInSeconds", authorizerResultTtlInSeconds()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "id":
return Optional.ofNullable(clazz.cast(id()));
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "providerARNs":
return Optional.ofNullable(clazz.cast(providerARNs()));
case "authType":
return Optional.ofNullable(clazz.cast(authType()));
case "authorizerUri":
return Optional.ofNullable(clazz.cast(authorizerUri()));
case "authorizerCredentials":
return Optional.ofNullable(clazz.cast(authorizerCredentials()));
case "identitySource":
return Optional.ofNullable(clazz.cast(identitySource()));
case "identityValidationExpression":
return Optional.ofNullable(clazz.cast(identityValidationExpression()));
case "authorizerResultTtlInSeconds":
return Optional.ofNullable(clazz.cast(authorizerResultTtlInSeconds()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function