software.amazon.awssdk.services.lambda.model.AddPermissionRequest Maven / Gradle / Ivy
Show all versions of lambda 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.lambda.model;
import java.util.Arrays;
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 software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class AddPermissionRequest extends LambdaRequest implements
ToCopyableBuilder {
private static final SdkField FUNCTION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FunctionName").getter(getter(AddPermissionRequest::functionName)).setter(setter(Builder::functionName))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("FunctionName").build()).build();
private static final SdkField STATEMENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StatementId").getter(getter(AddPermissionRequest::statementId)).setter(setter(Builder::statementId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatementId").build()).build();
private static final SdkField ACTION_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Action")
.getter(getter(AddPermissionRequest::action)).setter(setter(Builder::action))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Action").build()).build();
private static final SdkField PRINCIPAL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Principal").getter(getter(AddPermissionRequest::principal)).setter(setter(Builder::principal))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Principal").build()).build();
private static final SdkField SOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SourceArn").getter(getter(AddPermissionRequest::sourceArn)).setter(setter(Builder::sourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceArn").build()).build();
private static final SdkField SOURCE_ACCOUNT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SourceAccount").getter(getter(AddPermissionRequest::sourceAccount))
.setter(setter(Builder::sourceAccount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceAccount").build()).build();
private static final SdkField EVENT_SOURCE_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EventSourceToken").getter(getter(AddPermissionRequest::eventSourceToken))
.setter(setter(Builder::eventSourceToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EventSourceToken").build()).build();
private static final SdkField QUALIFIER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Qualifier").getter(getter(AddPermissionRequest::qualifier)).setter(setter(Builder::qualifier))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("Qualifier").build()).build();
private static final SdkField REVISION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("RevisionId").getter(getter(AddPermissionRequest::revisionId)).setter(setter(Builder::revisionId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RevisionId").build()).build();
private static final SdkField PRINCIPAL_ORG_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrincipalOrgID").getter(getter(AddPermissionRequest::principalOrgID))
.setter(setter(Builder::principalOrgID))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrincipalOrgID").build()).build();
private static final SdkField FUNCTION_URL_AUTH_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FunctionUrlAuthType").getter(getter(AddPermissionRequest::functionUrlAuthTypeAsString))
.setter(setter(Builder::functionUrlAuthType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionUrlAuthType").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FUNCTION_NAME_FIELD,
STATEMENT_ID_FIELD, ACTION_FIELD, PRINCIPAL_FIELD, SOURCE_ARN_FIELD, SOURCE_ACCOUNT_FIELD, EVENT_SOURCE_TOKEN_FIELD,
QUALIFIER_FIELD, REVISION_ID_FIELD, PRINCIPAL_ORG_ID_FIELD, FUNCTION_URL_AUTH_TYPE_FIELD));
private final String functionName;
private final String statementId;
private final String action;
private final String principal;
private final String sourceArn;
private final String sourceAccount;
private final String eventSourceToken;
private final String qualifier;
private final String revisionId;
private final String principalOrgID;
private final String functionUrlAuthType;
private AddPermissionRequest(BuilderImpl builder) {
super(builder);
this.functionName = builder.functionName;
this.statementId = builder.statementId;
this.action = builder.action;
this.principal = builder.principal;
this.sourceArn = builder.sourceArn;
this.sourceAccount = builder.sourceAccount;
this.eventSourceToken = builder.eventSourceToken;
this.qualifier = builder.qualifier;
this.revisionId = builder.revisionId;
this.principalOrgID = builder.principalOrgID;
this.functionUrlAuthType = builder.functionUrlAuthType;
}
/**
*
* The name or ARN of the Lambda function, version, or alias.
*
*
* Name formats
*
*
* -
*
* Function name – my-function
(name-only), my-function:v1
(with alias).
*
*
* -
*
* Function ARN – arn:aws:lambda:us-west-2:123456789012:function:my-function
.
*
*
* -
*
* Partial ARN – 123456789012:function:my-function
.
*
*
*
*
* You can append a version number or alias to any of the formats. The length constraint applies only to the full
* ARN. If you specify only the function name, it is limited to 64 characters in length.
*
*
* @return The name or ARN of the Lambda function, version, or alias.
*
* Name formats
*
*
* -
*
* Function name – my-function
(name-only), my-function:v1
(with alias).
*
*
* -
*
* Function ARN – arn:aws:lambda:us-west-2:123456789012:function:my-function
.
*
*
* -
*
* Partial ARN – 123456789012:function:my-function
.
*
*
*
*
* You can append a version number or alias to any of the formats. The length constraint applies only to the
* full ARN. If you specify only the function name, it is limited to 64 characters in length.
*/
public final String functionName() {
return functionName;
}
/**
*
* A statement identifier that differentiates the statement from others in the same policy.
*
*
* @return A statement identifier that differentiates the statement from others in the same policy.
*/
public final String statementId() {
return statementId;
}
/**
*
* The action that the principal can use on the function. For example, lambda:InvokeFunction
or
* lambda:GetFunction
.
*
*
* @return The action that the principal can use on the function. For example, lambda:InvokeFunction
or
* lambda:GetFunction
.
*/
public final String action() {
return action;
}
/**
*
* The Amazon Web Services service, Amazon Web Services account, IAM user, or IAM role that invokes the function. If
* you specify a service, use SourceArn
or SourceAccount
to limit who can invoke the
* function through that service.
*
*
* @return The Amazon Web Services service, Amazon Web Services account, IAM user, or IAM role that invokes the
* function. If you specify a service, use SourceArn
or SourceAccount
to limit who
* can invoke the function through that service.
*/
public final String principal() {
return principal;
}
/**
*
* For Amazon Web Services services, the ARN of the Amazon Web Services resource that invokes the function. For
* example, an Amazon S3 bucket or Amazon SNS topic.
*
*
* Note that Lambda configures the comparison using the StringLike
operator.
*
*
* @return For Amazon Web Services services, the ARN of the Amazon Web Services resource that invokes the function.
* For example, an Amazon S3 bucket or Amazon SNS topic.
*
* Note that Lambda configures the comparison using the StringLike
operator.
*/
public final String sourceArn() {
return sourceArn;
}
/**
*
* For Amazon Web Services service, the ID of the Amazon Web Services account that owns the resource. Use this
* together with SourceArn
to ensure that the specified account owns the resource. It is possible for
* an Amazon S3 bucket to be deleted by its owner and recreated by another account.
*
*
* @return For Amazon Web Services service, the ID of the Amazon Web Services account that owns the resource. Use
* this together with SourceArn
to ensure that the specified account owns the resource. It is
* possible for an Amazon S3 bucket to be deleted by its owner and recreated by another account.
*/
public final String sourceAccount() {
return sourceAccount;
}
/**
*
* For Alexa Smart Home functions, a token that the invoker must supply.
*
*
* @return For Alexa Smart Home functions, a token that the invoker must supply.
*/
public final String eventSourceToken() {
return eventSourceToken;
}
/**
*
* Specify a version or alias to add permissions to a published version of the function.
*
*
* @return Specify a version or alias to add permissions to a published version of the function.
*/
public final String qualifier() {
return qualifier;
}
/**
*
* Update the policy only if the revision ID matches the ID that's specified. Use this option to avoid modifying a
* policy that has changed since you last read it.
*
*
* @return Update the policy only if the revision ID matches the ID that's specified. Use this option to avoid
* modifying a policy that has changed since you last read it.
*/
public final String revisionId() {
return revisionId;
}
/**
*
* The identifier for your organization in Organizations. Use this to grant permissions to all the Amazon Web
* Services accounts under this organization.
*
*
* @return The identifier for your organization in Organizations. Use this to grant permissions to all the Amazon
* Web Services accounts under this organization.
*/
public final String principalOrgID() {
return principalOrgID;
}
/**
*
* The type of authentication that your function URL uses. Set to AWS_IAM
if you want to restrict
* access to authenticated users only. Set to NONE
if you want to bypass IAM authentication to create a
* public endpoint. For more information, see Security and auth model for Lambda function
* URLs.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #functionUrlAuthType} will return {@link FunctionUrlAuthType#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #functionUrlAuthTypeAsString}.
*
*
* @return The type of authentication that your function URL uses. Set to AWS_IAM
if you want to
* restrict access to authenticated users only. Set to NONE
if you want to bypass IAM
* authentication to create a public endpoint. For more information, see Security and auth model for Lambda
* function URLs.
* @see FunctionUrlAuthType
*/
public final FunctionUrlAuthType functionUrlAuthType() {
return FunctionUrlAuthType.fromValue(functionUrlAuthType);
}
/**
*
* The type of authentication that your function URL uses. Set to AWS_IAM
if you want to restrict
* access to authenticated users only. Set to NONE
if you want to bypass IAM authentication to create a
* public endpoint. For more information, see Security and auth model for Lambda function
* URLs.
*
*
* If the service returns an enum value that is not available in the current SDK version,
* {@link #functionUrlAuthType} will return {@link FunctionUrlAuthType#UNKNOWN_TO_SDK_VERSION}. The raw value
* returned by the service is available from {@link #functionUrlAuthTypeAsString}.
*
*
* @return The type of authentication that your function URL uses. Set to AWS_IAM
if you want to
* restrict access to authenticated users only. Set to NONE
if you want to bypass IAM
* authentication to create a public endpoint. For more information, see Security and auth model for Lambda
* function URLs.
* @see FunctionUrlAuthType
*/
public final String functionUrlAuthTypeAsString() {
return functionUrlAuthType;
}
@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(functionName());
hashCode = 31 * hashCode + Objects.hashCode(statementId());
hashCode = 31 * hashCode + Objects.hashCode(action());
hashCode = 31 * hashCode + Objects.hashCode(principal());
hashCode = 31 * hashCode + Objects.hashCode(sourceArn());
hashCode = 31 * hashCode + Objects.hashCode(sourceAccount());
hashCode = 31 * hashCode + Objects.hashCode(eventSourceToken());
hashCode = 31 * hashCode + Objects.hashCode(qualifier());
hashCode = 31 * hashCode + Objects.hashCode(revisionId());
hashCode = 31 * hashCode + Objects.hashCode(principalOrgID());
hashCode = 31 * hashCode + Objects.hashCode(functionUrlAuthTypeAsString());
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 AddPermissionRequest)) {
return false;
}
AddPermissionRequest other = (AddPermissionRequest) obj;
return Objects.equals(functionName(), other.functionName()) && Objects.equals(statementId(), other.statementId())
&& Objects.equals(action(), other.action()) && Objects.equals(principal(), other.principal())
&& Objects.equals(sourceArn(), other.sourceArn()) && Objects.equals(sourceAccount(), other.sourceAccount())
&& Objects.equals(eventSourceToken(), other.eventSourceToken()) && Objects.equals(qualifier(), other.qualifier())
&& Objects.equals(revisionId(), other.revisionId()) && Objects.equals(principalOrgID(), other.principalOrgID())
&& Objects.equals(functionUrlAuthTypeAsString(), other.functionUrlAuthTypeAsString());
}
/**
* 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("AddPermissionRequest").add("FunctionName", functionName()).add("StatementId", statementId())
.add("Action", action()).add("Principal", principal()).add("SourceArn", sourceArn())
.add("SourceAccount", sourceAccount()).add("EventSourceToken", eventSourceToken()).add("Qualifier", qualifier())
.add("RevisionId", revisionId()).add("PrincipalOrgID", principalOrgID())
.add("FunctionUrlAuthType", functionUrlAuthTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FunctionName":
return Optional.ofNullable(clazz.cast(functionName()));
case "StatementId":
return Optional.ofNullable(clazz.cast(statementId()));
case "Action":
return Optional.ofNullable(clazz.cast(action()));
case "Principal":
return Optional.ofNullable(clazz.cast(principal()));
case "SourceArn":
return Optional.ofNullable(clazz.cast(sourceArn()));
case "SourceAccount":
return Optional.ofNullable(clazz.cast(sourceAccount()));
case "EventSourceToken":
return Optional.ofNullable(clazz.cast(eventSourceToken()));
case "Qualifier":
return Optional.ofNullable(clazz.cast(qualifier()));
case "RevisionId":
return Optional.ofNullable(clazz.cast(revisionId()));
case "PrincipalOrgID":
return Optional.ofNullable(clazz.cast(principalOrgID()));
case "FunctionUrlAuthType":
return Optional.ofNullable(clazz.cast(functionUrlAuthTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function