
com.amazonaws.services.apigateway.model.Authorizer Maven / Gradle / Ivy
Show all versions of aws-java-sdk-api-gateway Show documentation
/*
* Copyright 2011-2016 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 com.amazonaws.services.apigateway.model;
import java.io.Serializable;
/**
*
* Represents an authorization layer for methods. If enabled on a method, API
* Gateway will activate the authorizer when a client calls the method.
*
*/
public class Authorizer implements Serializable, Cloneable {
/**
*
* The identifier for the authorizer resource.
*
*/
private String id;
/**
*
* [Required] The name of the authorizer.
*
*/
private String name;
/**
*
* [Required] The type of the authorizer. Currently, the only valid type is
* TOKEN.
*
*/
private String type;
private java.util.List providerARNs;
/**
*
* Optional customer-defined field, used in Swagger imports/exports. Has no
* functional impact.
*
*/
private String authType;
/**
*
* [Required] Specifies the authorizer's Uniform Resource Identifier (URI).
* For TOKEN authorizers, this must be a well-formed Lambda function URI.
* The URI should be of the form
* arn:aws:apigateway:{region}:lambda:path/{service_api}
.
* Region
is used to determine the right endpoint. In this
* case, path
is used to indicate 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
*
*/
private String authorizerUri;
/**
*
* Specifies the credentials required for the authorizer, if any. Two
* options are available. To specify an IAM Role for Amazon API Gateway to
* assume, use the role's Amazon Resource Name (ARN). To use resource-based
* permissions on the Lambda function, specify null.
*
*/
private String authorizerCredentials;
/**
*
* [Required] The source of the identity in an incoming request. For TOKEN
* authorizers, this value is a mapping expression with the same syntax as
* integration parameter mappings. The only valid source for tokens is
* 'header', so the expression should match
* 'method.request.header.[headerName]'. The value of the header
* '[headerName]' will be interpreted as the incoming token.
*
*/
private String identitySource;
/**
*
* A validation expression for the incoming identity. For TOKEN authorizers,
* this value should be a regular expression. The incoming token from the
* client is matched against this expression, and will proceed if the token
* matches. If the token doesn't match, the client receives a 401
* Unauthorized response.
*
*/
private String identityValidationExpression;
/**
*
* The TTL in seconds of cached authorizer results. If 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.
*
*/
private Integer authorizerResultTtlInSeconds;
/**
*
* The identifier for the authorizer resource.
*
*
* @param id
* The identifier for the authorizer resource.
*/
public void setId(String id) {
this.id = id;
}
/**
*
* The identifier for the authorizer resource.
*
*
* @return The identifier for the authorizer resource.
*/
public String getId() {
return this.id;
}
/**
*
* The identifier for the authorizer resource.
*
*
* @param id
* The identifier for the authorizer resource.
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withId(String id) {
setId(id);
return this;
}
/**
*
* [Required] The name of the authorizer.
*
*
* @param name
* [Required] The name of the authorizer.
*/
public void setName(String name) {
this.name = name;
}
/**
*
* [Required] The name of the authorizer.
*
*
* @return [Required] The name of the authorizer.
*/
public String getName() {
return this.name;
}
/**
*
* [Required] The name of the authorizer.
*
*
* @param name
* [Required] The name of the authorizer.
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withName(String name) {
setName(name);
return this;
}
/**
*
* [Required] The type of the authorizer. Currently, the only valid type is
* TOKEN.
*
*
* @param type
* [Required] The type of the authorizer. Currently, the only valid
* type is TOKEN.
* @see AuthorizerType
*/
public void setType(String type) {
this.type = type;
}
/**
*
* [Required] The type of the authorizer. Currently, the only valid type is
* TOKEN.
*
*
* @return [Required] The type of the authorizer. Currently, the only valid
* type is TOKEN.
* @see AuthorizerType
*/
public String getType() {
return this.type;
}
/**
*
* [Required] The type of the authorizer. Currently, the only valid type is
* TOKEN.
*
*
* @param type
* [Required] The type of the authorizer. Currently, the only valid
* type is TOKEN.
* @return Returns a reference to this object so that method calls can be
* chained together.
* @see AuthorizerType
*/
public Authorizer withType(String type) {
setType(type);
return this;
}
/**
*
* [Required] The type of the authorizer. Currently, the only valid type is
* TOKEN.
*
*
* @param type
* [Required] The type of the authorizer. Currently, the only valid
* type is TOKEN.
* @see AuthorizerType
*/
public void setType(AuthorizerType type) {
this.type = type.toString();
}
/**
*
* [Required] The type of the authorizer. Currently, the only valid type is
* TOKEN.
*
*
* @param type
* [Required] The type of the authorizer. Currently, the only valid
* type is TOKEN.
* @return Returns a reference to this object so that method calls can be
* chained together.
* @see AuthorizerType
*/
public Authorizer withType(AuthorizerType type) {
setType(type);
return this;
}
/**
* @return
*/
public java.util.List getProviderARNs() {
return providerARNs;
}
/**
* @param providerARNs
*/
public void setProviderARNs(java.util.Collection providerARNs) {
if (providerARNs == null) {
this.providerARNs = null;
return;
}
this.providerARNs = new java.util.ArrayList(providerARNs);
}
/**
*
* NOTE: This method appends the values to the existing list (if
* any). Use {@link #setProviderARNs(java.util.Collection)} or
* {@link #withProviderARNs(java.util.Collection)} if you want to override
* the existing values.
*
*
* @param providerARNs
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withProviderARNs(String... providerARNs) {
if (this.providerARNs == null) {
setProviderARNs(new java.util.ArrayList(providerARNs.length));
}
for (String ele : providerARNs) {
this.providerARNs.add(ele);
}
return this;
}
/**
* @param providerARNs
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withProviderARNs(java.util.Collection providerARNs) {
setProviderARNs(providerARNs);
return this;
}
/**
*
* Optional customer-defined field, used in Swagger imports/exports. Has no
* functional impact.
*
*
* @param authType
* Optional customer-defined field, used in Swagger imports/exports.
* Has no functional impact.
*/
public void setAuthType(String authType) {
this.authType = authType;
}
/**
*
* Optional customer-defined field, used in Swagger imports/exports. Has no
* functional impact.
*
*
* @return Optional customer-defined field, used in Swagger imports/exports.
* Has no functional impact.
*/
public String getAuthType() {
return this.authType;
}
/**
*
* Optional customer-defined field, used in Swagger imports/exports. Has no
* functional impact.
*
*
* @param authType
* Optional customer-defined field, used in Swagger imports/exports.
* Has no functional impact.
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withAuthType(String authType) {
setAuthType(authType);
return this;
}
/**
*
* [Required] Specifies the authorizer's Uniform Resource Identifier (URI).
* For TOKEN authorizers, this must be a well-formed Lambda function URI.
* The URI should be of the form
* arn:aws:apigateway:{region}:lambda:path/{service_api}
.
* Region
is used to determine the right endpoint. In this
* case, path
is used to indicate 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
*
*
* @param authorizerUri
* [Required] Specifies the authorizer's Uniform Resource Identifier
* (URI). For TOKEN authorizers, this must be a well-formed Lambda
* function URI. The URI should be of the form
* arn:aws:apigateway:{region}:lambda:path/{service_api}
* . Region
is used to determine the right endpoint. In
* this case, path
is used to indicate 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 void setAuthorizerUri(String authorizerUri) {
this.authorizerUri = authorizerUri;
}
/**
*
* [Required] Specifies the authorizer's Uniform Resource Identifier (URI).
* For TOKEN authorizers, this must be a well-formed Lambda function URI.
* The URI should be of the form
* arn:aws:apigateway:{region}:lambda:path/{service_api}
.
* Region
is used to determine the right endpoint. In this
* case, path
is used to indicate 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 [Required] Specifies the authorizer's Uniform Resource Identifier
* (URI). For TOKEN authorizers, this must be a well-formed Lambda
* function URI. The URI should be of the form
* arn:aws:apigateway:{region}:lambda:path/{service_api}
* . Region
is used to determine the right endpoint. In
* this case, path
is used to indicate 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 String getAuthorizerUri() {
return this.authorizerUri;
}
/**
*
* [Required] Specifies the authorizer's Uniform Resource Identifier (URI).
* For TOKEN authorizers, this must be a well-formed Lambda function URI.
* The URI should be of the form
* arn:aws:apigateway:{region}:lambda:path/{service_api}
.
* Region
is used to determine the right endpoint. In this
* case, path
is used to indicate 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
*
*
* @param authorizerUri
* [Required] Specifies the authorizer's Uniform Resource Identifier
* (URI). For TOKEN authorizers, this must be a well-formed Lambda
* function URI. The URI should be of the form
* arn:aws:apigateway:{region}:lambda:path/{service_api}
* . Region
is used to determine the right endpoint. In
* this case, path
is used to indicate 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 Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withAuthorizerUri(String authorizerUri) {
setAuthorizerUri(authorizerUri);
return this;
}
/**
*
* Specifies the credentials required for the authorizer, if any. Two
* options are available. To specify an IAM Role for Amazon API Gateway to
* assume, use the role's Amazon Resource Name (ARN). To use resource-based
* permissions on the Lambda function, specify null.
*
*
* @param authorizerCredentials
* Specifies the credentials required for the authorizer, if any. Two
* options are available. To specify an IAM Role for Amazon API
* Gateway to assume, use the role's Amazon Resource Name (ARN). To
* use resource-based permissions on the Lambda function, specify
* null.
*/
public void setAuthorizerCredentials(String authorizerCredentials) {
this.authorizerCredentials = authorizerCredentials;
}
/**
*
* Specifies the credentials required for the authorizer, if any. Two
* options are available. To specify an IAM Role for Amazon 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 credentials required for the authorizer, if any.
* Two options are available. To specify an IAM Role for Amazon API
* Gateway to assume, use the role's Amazon Resource Name (ARN). To
* use resource-based permissions on the Lambda function, specify
* null.
*/
public String getAuthorizerCredentials() {
return this.authorizerCredentials;
}
/**
*
* Specifies the credentials required for the authorizer, if any. Two
* options are available. To specify an IAM Role for Amazon API Gateway to
* assume, use the role's Amazon Resource Name (ARN). To use resource-based
* permissions on the Lambda function, specify null.
*
*
* @param authorizerCredentials
* Specifies the credentials required for the authorizer, if any. Two
* options are available. To specify an IAM Role for Amazon API
* Gateway to assume, use the role's Amazon Resource Name (ARN). To
* use resource-based permissions on the Lambda function, specify
* null.
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withAuthorizerCredentials(String authorizerCredentials) {
setAuthorizerCredentials(authorizerCredentials);
return this;
}
/**
*
* [Required] The source of the identity in an incoming request. For TOKEN
* authorizers, this value is a mapping expression with the same syntax as
* integration parameter mappings. The only valid source for tokens is
* 'header', so the expression should match
* 'method.request.header.[headerName]'. The value of the header
* '[headerName]' will be interpreted as the incoming token.
*
*
* @param identitySource
* [Required] The source of the identity in an incoming request. For
* TOKEN authorizers, this value is a mapping expression with the
* same syntax as integration parameter mappings. The only valid
* source for tokens is 'header', so the expression should match
* 'method.request.header.[headerName]'. The value of the header
* '[headerName]' will be interpreted as the incoming token.
*/
public void setIdentitySource(String identitySource) {
this.identitySource = identitySource;
}
/**
*
* [Required] The source of the identity in an incoming request. For TOKEN
* authorizers, this value is a mapping expression with the same syntax as
* integration parameter mappings. The only valid source for tokens is
* 'header', so the expression should match
* 'method.request.header.[headerName]'. The value of the header
* '[headerName]' will be interpreted as the incoming token.
*
*
* @return [Required] The source of the identity in an incoming request. For
* TOKEN authorizers, this value is a mapping expression with the
* same syntax as integration parameter mappings. The only valid
* source for tokens is 'header', so the expression should match
* 'method.request.header.[headerName]'. The value of the header
* '[headerName]' will be interpreted as the incoming token.
*/
public String getIdentitySource() {
return this.identitySource;
}
/**
*
* [Required] The source of the identity in an incoming request. For TOKEN
* authorizers, this value is a mapping expression with the same syntax as
* integration parameter mappings. The only valid source for tokens is
* 'header', so the expression should match
* 'method.request.header.[headerName]'. The value of the header
* '[headerName]' will be interpreted as the incoming token.
*
*
* @param identitySource
* [Required] The source of the identity in an incoming request. For
* TOKEN authorizers, this value is a mapping expression with the
* same syntax as integration parameter mappings. The only valid
* source for tokens is 'header', so the expression should match
* 'method.request.header.[headerName]'. The value of the header
* '[headerName]' will be interpreted as the incoming token.
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withIdentitySource(String identitySource) {
setIdentitySource(identitySource);
return this;
}
/**
*
* A validation expression for the incoming identity. For TOKEN authorizers,
* this value should be a regular expression. The incoming token from the
* client is matched against this expression, and will proceed if the token
* matches. If the token doesn't match, the client receives a 401
* Unauthorized response.
*
*
* @param identityValidationExpression
* A validation expression for the incoming identity. For TOKEN
* authorizers, this value should be a regular expression. The
* incoming token from the client is matched against this expression,
* and will proceed if the token matches. If the token doesn't match,
* the client receives a 401 Unauthorized response.
*/
public void setIdentityValidationExpression(
String identityValidationExpression) {
this.identityValidationExpression = identityValidationExpression;
}
/**
*
* A validation expression for the incoming identity. For TOKEN authorizers,
* this value should be a regular expression. The incoming token from the
* client is matched against this expression, and will proceed if the token
* matches. If the token doesn't match, the client receives a 401
* Unauthorized response.
*
*
* @return A validation expression for the incoming identity. For TOKEN
* authorizers, this value should be a regular expression. The
* incoming token from the client is matched against this
* expression, and will proceed if the token matches. If the token
* doesn't match, the client receives a 401 Unauthorized response.
*/
public String getIdentityValidationExpression() {
return this.identityValidationExpression;
}
/**
*
* A validation expression for the incoming identity. For TOKEN authorizers,
* this value should be a regular expression. The incoming token from the
* client is matched against this expression, and will proceed if the token
* matches. If the token doesn't match, the client receives a 401
* Unauthorized response.
*
*
* @param identityValidationExpression
* A validation expression for the incoming identity. For TOKEN
* authorizers, this value should be a regular expression. The
* incoming token from the client is matched against this expression,
* and will proceed if the token matches. If the token doesn't match,
* the client receives a 401 Unauthorized response.
* @return Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withIdentityValidationExpression(
String identityValidationExpression) {
setIdentityValidationExpression(identityValidationExpression);
return this;
}
/**
*
* The TTL in seconds of cached authorizer results. If 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.
*
*
* @param authorizerResultTtlInSeconds
* The TTL in seconds of cached authorizer results. If 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 void setAuthorizerResultTtlInSeconds(
Integer authorizerResultTtlInSeconds) {
this.authorizerResultTtlInSeconds = authorizerResultTtlInSeconds;
}
/**
*
* The TTL in seconds of cached authorizer results. If 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 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 Integer getAuthorizerResultTtlInSeconds() {
return this.authorizerResultTtlInSeconds;
}
/**
*
* The TTL in seconds of cached authorizer results. If 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.
*
*
* @param authorizerResultTtlInSeconds
* The TTL in seconds of cached authorizer results. If 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 Returns a reference to this object so that method calls can be
* chained together.
*/
public Authorizer withAuthorizerResultTtlInSeconds(
Integer authorizerResultTtlInSeconds) {
setAuthorizerResultTtlInSeconds(authorizerResultTtlInSeconds);
return this;
}
/**
* Returns a string representation of this object; useful for testing and
* debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getId() != null)
sb.append("Id: " + getId() + ",");
if (getName() != null)
sb.append("Name: " + getName() + ",");
if (getType() != null)
sb.append("Type: " + getType() + ",");
if (getProviderARNs() != null)
sb.append("ProviderARNs: " + getProviderARNs() + ",");
if (getAuthType() != null)
sb.append("AuthType: " + getAuthType() + ",");
if (getAuthorizerUri() != null)
sb.append("AuthorizerUri: " + getAuthorizerUri() + ",");
if (getAuthorizerCredentials() != null)
sb.append("AuthorizerCredentials: " + getAuthorizerCredentials()
+ ",");
if (getIdentitySource() != null)
sb.append("IdentitySource: " + getIdentitySource() + ",");
if (getIdentityValidationExpression() != null)
sb.append("IdentityValidationExpression: "
+ getIdentityValidationExpression() + ",");
if (getAuthorizerResultTtlInSeconds() != null)
sb.append("AuthorizerResultTtlInSeconds: "
+ getAuthorizerResultTtlInSeconds());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Authorizer == false)
return false;
Authorizer other = (Authorizer) obj;
if (other.getId() == null ^ this.getId() == null)
return false;
if (other.getId() != null
&& other.getId().equals(this.getId()) == false)
return false;
if (other.getName() == null ^ this.getName() == null)
return false;
if (other.getName() != null
&& other.getName().equals(this.getName()) == false)
return false;
if (other.getType() == null ^ this.getType() == null)
return false;
if (other.getType() != null
&& other.getType().equals(this.getType()) == false)
return false;
if (other.getProviderARNs() == null ^ this.getProviderARNs() == null)
return false;
if (other.getProviderARNs() != null
&& other.getProviderARNs().equals(this.getProviderARNs()) == false)
return false;
if (other.getAuthType() == null ^ this.getAuthType() == null)
return false;
if (other.getAuthType() != null
&& other.getAuthType().equals(this.getAuthType()) == false)
return false;
if (other.getAuthorizerUri() == null ^ this.getAuthorizerUri() == null)
return false;
if (other.getAuthorizerUri() != null
&& other.getAuthorizerUri().equals(this.getAuthorizerUri()) == false)
return false;
if (other.getAuthorizerCredentials() == null
^ this.getAuthorizerCredentials() == null)
return false;
if (other.getAuthorizerCredentials() != null
&& other.getAuthorizerCredentials().equals(
this.getAuthorizerCredentials()) == false)
return false;
if (other.getIdentitySource() == null
^ this.getIdentitySource() == null)
return false;
if (other.getIdentitySource() != null
&& other.getIdentitySource().equals(this.getIdentitySource()) == false)
return false;
if (other.getIdentityValidationExpression() == null
^ this.getIdentityValidationExpression() == null)
return false;
if (other.getIdentityValidationExpression() != null
&& other.getIdentityValidationExpression().equals(
this.getIdentityValidationExpression()) == false)
return false;
if (other.getAuthorizerResultTtlInSeconds() == null
^ this.getAuthorizerResultTtlInSeconds() == null)
return false;
if (other.getAuthorizerResultTtlInSeconds() != null
&& other.getAuthorizerResultTtlInSeconds().equals(
this.getAuthorizerResultTtlInSeconds()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode
+ ((getId() == null) ? 0 : getId().hashCode());
hashCode = prime * hashCode
+ ((getName() == null) ? 0 : getName().hashCode());
hashCode = prime * hashCode
+ ((getType() == null) ? 0 : getType().hashCode());
hashCode = prime
* hashCode
+ ((getProviderARNs() == null) ? 0 : getProviderARNs()
.hashCode());
hashCode = prime * hashCode
+ ((getAuthType() == null) ? 0 : getAuthType().hashCode());
hashCode = prime
* hashCode
+ ((getAuthorizerUri() == null) ? 0 : getAuthorizerUri()
.hashCode());
hashCode = prime
* hashCode
+ ((getAuthorizerCredentials() == null) ? 0
: getAuthorizerCredentials().hashCode());
hashCode = prime
* hashCode
+ ((getIdentitySource() == null) ? 0 : getIdentitySource()
.hashCode());
hashCode = prime
* hashCode
+ ((getIdentityValidationExpression() == null) ? 0
: getIdentityValidationExpression().hashCode());
hashCode = prime
* hashCode
+ ((getAuthorizerResultTtlInSeconds() == null) ? 0
: getAuthorizerResultTtlInSeconds().hashCode());
return hashCode;
}
@Override
public Authorizer clone() {
try {
return (Authorizer) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(
"Got a CloneNotSupportedException from Object.clone() "
+ "even though we're Cloneable!", e);
}
}
}