All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.services.lambda.model.Cors Maven / Gradle / Ivy

/*
 * Copyright 2019-2024 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.lambda.model;

import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;

/**
 * 

* The cross-origin resource sharing (CORS) * settings for your Lambda function URL. Use CORS to grant access to your function URL from any origin. You can also * use CORS to control access for specific HTTP headers and methods in requests to your function URL. *

* * @see AWS API Documentation */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class Cors implements Serializable, Cloneable, StructuredPojo { /** *

* Whether to allow cookies or other credentials in requests to your function URL. The default is false * . *

*/ private Boolean allowCredentials; /** *

* The HTTP headers that origins can include in requests to your function URL. For example: Date, * Keep-Alive, X-Custom-Header. *

*/ private com.amazonaws.internal.SdkInternalList allowHeaders; /** *

* The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). *

*/ private com.amazonaws.internal.SdkInternalList allowMethods; /** *

* The origins that can access your function URL. You can list any number of specific origins, separated by a comma. * For example: https://www.example.com, http://localhost:60905. *

*

* Alternatively, you can grant access to all origins using the wildcard character (*). *

*/ private com.amazonaws.internal.SdkInternalList allowOrigins; /** *

* The HTTP headers in your function response that you want to expose to origins that call your function URL. For * example: Date, Keep-Alive, X-Custom-Header. *

*/ private com.amazonaws.internal.SdkInternalList exposeHeaders; /** *

* The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, * this is set to 0, which means that the browser doesn't cache results. *

*/ private Integer maxAge; /** *

* Whether to allow cookies or other credentials in requests to your function URL. The default is false * . *

* * @param allowCredentials * Whether to allow cookies or other credentials in requests to your function URL. The default is * false. */ public void setAllowCredentials(Boolean allowCredentials) { this.allowCredentials = allowCredentials; } /** *

* Whether to allow cookies or other credentials in requests to your function URL. The default is false * . *

* * @return Whether to allow cookies or other credentials in requests to your function URL. The default is * false. */ public Boolean getAllowCredentials() { return this.allowCredentials; } /** *

* Whether to allow cookies or other credentials in requests to your function URL. The default is false * . *

* * @param allowCredentials * Whether to allow cookies or other credentials in requests to your function URL. The default is * false. * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withAllowCredentials(Boolean allowCredentials) { setAllowCredentials(allowCredentials); return this; } /** *

* Whether to allow cookies or other credentials in requests to your function URL. The default is false * . *

* * @return Whether to allow cookies or other credentials in requests to your function URL. The default is * false. */ public Boolean isAllowCredentials() { return this.allowCredentials; } /** *

* The HTTP headers that origins can include in requests to your function URL. For example: Date, * Keep-Alive, X-Custom-Header. *

* * @return The HTTP headers that origins can include in requests to your function URL. For example: * Date, Keep-Alive, X-Custom-Header. */ public java.util.List getAllowHeaders() { if (allowHeaders == null) { allowHeaders = new com.amazonaws.internal.SdkInternalList(); } return allowHeaders; } /** *

* The HTTP headers that origins can include in requests to your function URL. For example: Date, * Keep-Alive, X-Custom-Header. *

* * @param allowHeaders * The HTTP headers that origins can include in requests to your function URL. For example: Date * , Keep-Alive, X-Custom-Header. */ public void setAllowHeaders(java.util.Collection allowHeaders) { if (allowHeaders == null) { this.allowHeaders = null; return; } this.allowHeaders = new com.amazonaws.internal.SdkInternalList(allowHeaders); } /** *

* The HTTP headers that origins can include in requests to your function URL. For example: Date, * Keep-Alive, X-Custom-Header. *

*

* NOTE: This method appends the values to the existing list (if any). Use * {@link #setAllowHeaders(java.util.Collection)} or {@link #withAllowHeaders(java.util.Collection)} if you want to * override the existing values. *

* * @param allowHeaders * The HTTP headers that origins can include in requests to your function URL. For example: Date * , Keep-Alive, X-Custom-Header. * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withAllowHeaders(String... allowHeaders) { if (this.allowHeaders == null) { setAllowHeaders(new com.amazonaws.internal.SdkInternalList(allowHeaders.length)); } for (String ele : allowHeaders) { this.allowHeaders.add(ele); } return this; } /** *

* The HTTP headers that origins can include in requests to your function URL. For example: Date, * Keep-Alive, X-Custom-Header. *

* * @param allowHeaders * The HTTP headers that origins can include in requests to your function URL. For example: Date * , Keep-Alive, X-Custom-Header. * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withAllowHeaders(java.util.Collection allowHeaders) { setAllowHeaders(allowHeaders); return this; } /** *

* The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). *

* * @return The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). */ public java.util.List getAllowMethods() { if (allowMethods == null) { allowMethods = new com.amazonaws.internal.SdkInternalList(); } return allowMethods; } /** *

* The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). *

* * @param allowMethods * The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). */ public void setAllowMethods(java.util.Collection allowMethods) { if (allowMethods == null) { this.allowMethods = null; return; } this.allowMethods = new com.amazonaws.internal.SdkInternalList(allowMethods); } /** *

* The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). *

*

* NOTE: This method appends the values to the existing list (if any). Use * {@link #setAllowMethods(java.util.Collection)} or {@link #withAllowMethods(java.util.Collection)} if you want to * override the existing values. *

* * @param allowMethods * The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withAllowMethods(String... allowMethods) { if (this.allowMethods == null) { setAllowMethods(new com.amazonaws.internal.SdkInternalList(allowMethods.length)); } for (String ele : allowMethods) { this.allowMethods.add(ele); } return this; } /** *

* The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). *

* * @param allowMethods * The HTTP methods that are allowed when calling your function URL. For example: GET, * POST, DELETE, or the wildcard character (*). * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withAllowMethods(java.util.Collection allowMethods) { setAllowMethods(allowMethods); return this; } /** *

* The origins that can access your function URL. You can list any number of specific origins, separated by a comma. * For example: https://www.example.com, http://localhost:60905. *

*

* Alternatively, you can grant access to all origins using the wildcard character (*). *

* * @return The origins that can access your function URL. You can list any number of specific origins, separated by * a comma. For example: https://www.example.com, http://localhost:60905.

*

* Alternatively, you can grant access to all origins using the wildcard character (*). */ public java.util.List getAllowOrigins() { if (allowOrigins == null) { allowOrigins = new com.amazonaws.internal.SdkInternalList(); } return allowOrigins; } /** *

* The origins that can access your function URL. You can list any number of specific origins, separated by a comma. * For example: https://www.example.com, http://localhost:60905. *

*

* Alternatively, you can grant access to all origins using the wildcard character (*). *

* * @param allowOrigins * The origins that can access your function URL. You can list any number of specific origins, separated by a * comma. For example: https://www.example.com, http://localhost:60905.

*

* Alternatively, you can grant access to all origins using the wildcard character (*). */ public void setAllowOrigins(java.util.Collection allowOrigins) { if (allowOrigins == null) { this.allowOrigins = null; return; } this.allowOrigins = new com.amazonaws.internal.SdkInternalList(allowOrigins); } /** *

* The origins that can access your function URL. You can list any number of specific origins, separated by a comma. * For example: https://www.example.com, http://localhost:60905. *

*

* Alternatively, you can grant access to all origins using the wildcard character (*). *

*

* NOTE: This method appends the values to the existing list (if any). Use * {@link #setAllowOrigins(java.util.Collection)} or {@link #withAllowOrigins(java.util.Collection)} if you want to * override the existing values. *

* * @param allowOrigins * The origins that can access your function URL. You can list any number of specific origins, separated by a * comma. For example: https://www.example.com, http://localhost:60905.

*

* Alternatively, you can grant access to all origins using the wildcard character (*). * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withAllowOrigins(String... allowOrigins) { if (this.allowOrigins == null) { setAllowOrigins(new com.amazonaws.internal.SdkInternalList(allowOrigins.length)); } for (String ele : allowOrigins) { this.allowOrigins.add(ele); } return this; } /** *

* The origins that can access your function URL. You can list any number of specific origins, separated by a comma. * For example: https://www.example.com, http://localhost:60905. *

*

* Alternatively, you can grant access to all origins using the wildcard character (*). *

* * @param allowOrigins * The origins that can access your function URL. You can list any number of specific origins, separated by a * comma. For example: https://www.example.com, http://localhost:60905.

*

* Alternatively, you can grant access to all origins using the wildcard character (*). * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withAllowOrigins(java.util.Collection allowOrigins) { setAllowOrigins(allowOrigins); return this; } /** *

* The HTTP headers in your function response that you want to expose to origins that call your function URL. For * example: Date, Keep-Alive, X-Custom-Header. *

* * @return The HTTP headers in your function response that you want to expose to origins that call your function * URL. For example: Date, Keep-Alive, X-Custom-Header. */ public java.util.List getExposeHeaders() { if (exposeHeaders == null) { exposeHeaders = new com.amazonaws.internal.SdkInternalList(); } return exposeHeaders; } /** *

* The HTTP headers in your function response that you want to expose to origins that call your function URL. For * example: Date, Keep-Alive, X-Custom-Header. *

* * @param exposeHeaders * The HTTP headers in your function response that you want to expose to origins that call your function URL. * For example: Date, Keep-Alive, X-Custom-Header. */ public void setExposeHeaders(java.util.Collection exposeHeaders) { if (exposeHeaders == null) { this.exposeHeaders = null; return; } this.exposeHeaders = new com.amazonaws.internal.SdkInternalList(exposeHeaders); } /** *

* The HTTP headers in your function response that you want to expose to origins that call your function URL. For * example: Date, Keep-Alive, X-Custom-Header. *

*

* NOTE: This method appends the values to the existing list (if any). Use * {@link #setExposeHeaders(java.util.Collection)} or {@link #withExposeHeaders(java.util.Collection)} if you want * to override the existing values. *

* * @param exposeHeaders * The HTTP headers in your function response that you want to expose to origins that call your function URL. * For example: Date, Keep-Alive, X-Custom-Header. * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withExposeHeaders(String... exposeHeaders) { if (this.exposeHeaders == null) { setExposeHeaders(new com.amazonaws.internal.SdkInternalList(exposeHeaders.length)); } for (String ele : exposeHeaders) { this.exposeHeaders.add(ele); } return this; } /** *

* The HTTP headers in your function response that you want to expose to origins that call your function URL. For * example: Date, Keep-Alive, X-Custom-Header. *

* * @param exposeHeaders * The HTTP headers in your function response that you want to expose to origins that call your function URL. * For example: Date, Keep-Alive, X-Custom-Header. * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withExposeHeaders(java.util.Collection exposeHeaders) { setExposeHeaders(exposeHeaders); return this; } /** *

* The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, * this is set to 0, which means that the browser doesn't cache results. *

* * @param maxAge * The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By * default, this is set to 0, which means that the browser doesn't cache results. */ public void setMaxAge(Integer maxAge) { this.maxAge = maxAge; } /** *

* The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, * this is set to 0, which means that the browser doesn't cache results. *

* * @return The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By * default, this is set to 0, which means that the browser doesn't cache results. */ public Integer getMaxAge() { return this.maxAge; } /** *

* The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By default, * this is set to 0, which means that the browser doesn't cache results. *

* * @param maxAge * The maximum amount of time, in seconds, that web browsers can cache results of a preflight request. By * default, this is set to 0, which means that the browser doesn't cache results. * @return Returns a reference to this object so that method calls can be chained together. */ public Cors withMaxAge(Integer maxAge) { setMaxAge(maxAge); return this; } /** * 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. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getAllowCredentials() != null) sb.append("AllowCredentials: ").append(getAllowCredentials()).append(","); if (getAllowHeaders() != null) sb.append("AllowHeaders: ").append(getAllowHeaders()).append(","); if (getAllowMethods() != null) sb.append("AllowMethods: ").append(getAllowMethods()).append(","); if (getAllowOrigins() != null) sb.append("AllowOrigins: ").append(getAllowOrigins()).append(","); if (getExposeHeaders() != null) sb.append("ExposeHeaders: ").append(getExposeHeaders()).append(","); if (getMaxAge() != null) sb.append("MaxAge: ").append(getMaxAge()); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Cors == false) return false; Cors other = (Cors) obj; if (other.getAllowCredentials() == null ^ this.getAllowCredentials() == null) return false; if (other.getAllowCredentials() != null && other.getAllowCredentials().equals(this.getAllowCredentials()) == false) return false; if (other.getAllowHeaders() == null ^ this.getAllowHeaders() == null) return false; if (other.getAllowHeaders() != null && other.getAllowHeaders().equals(this.getAllowHeaders()) == false) return false; if (other.getAllowMethods() == null ^ this.getAllowMethods() == null) return false; if (other.getAllowMethods() != null && other.getAllowMethods().equals(this.getAllowMethods()) == false) return false; if (other.getAllowOrigins() == null ^ this.getAllowOrigins() == null) return false; if (other.getAllowOrigins() != null && other.getAllowOrigins().equals(this.getAllowOrigins()) == false) return false; if (other.getExposeHeaders() == null ^ this.getExposeHeaders() == null) return false; if (other.getExposeHeaders() != null && other.getExposeHeaders().equals(this.getExposeHeaders()) == false) return false; if (other.getMaxAge() == null ^ this.getMaxAge() == null) return false; if (other.getMaxAge() != null && other.getMaxAge().equals(this.getMaxAge()) == false) return false; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getAllowCredentials() == null) ? 0 : getAllowCredentials().hashCode()); hashCode = prime * hashCode + ((getAllowHeaders() == null) ? 0 : getAllowHeaders().hashCode()); hashCode = prime * hashCode + ((getAllowMethods() == null) ? 0 : getAllowMethods().hashCode()); hashCode = prime * hashCode + ((getAllowOrigins() == null) ? 0 : getAllowOrigins().hashCode()); hashCode = prime * hashCode + ((getExposeHeaders() == null) ? 0 : getExposeHeaders().hashCode()); hashCode = prime * hashCode + ((getMaxAge() == null) ? 0 : getMaxAge().hashCode()); return hashCode; } @Override public Cors clone() { try { return (Cors) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); } } @com.amazonaws.annotation.SdkInternalApi @Override public void marshall(ProtocolMarshaller protocolMarshaller) { com.amazonaws.services.lambda.model.transform.CorsMarshaller.getInstance().marshall(this, protocolMarshaller); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy