software.amazon.awssdk.services.iam.model.SimulatePrincipalPolicyRequest Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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.iam.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.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
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 SimulatePrincipalPolicyRequest extends IamRequest implements
ToCopyableBuilder {
private static final SdkField POLICY_SOURCE_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SimulatePrincipalPolicyRequest::policySourceArn)).setter(setter(Builder::policySourceArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolicySourceArn").build()).build();
private static final SdkField> POLICY_INPUT_LIST_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(SimulatePrincipalPolicyRequest::policyInputList))
.setter(setter(Builder::policyInputList))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolicyInputList").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> ACTION_NAMES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(SimulatePrincipalPolicyRequest::actionNames))
.setter(setter(Builder::actionNames))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ActionNames").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> RESOURCE_ARNS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(SimulatePrincipalPolicyRequest::resourceArns))
.setter(setter(Builder::resourceArns))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceArns").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 RESOURCE_POLICY_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SimulatePrincipalPolicyRequest::resourcePolicy)).setter(setter(Builder::resourcePolicy))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourcePolicy").build()).build();
private static final SdkField RESOURCE_OWNER_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SimulatePrincipalPolicyRequest::resourceOwner)).setter(setter(Builder::resourceOwner))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceOwner").build()).build();
private static final SdkField CALLER_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SimulatePrincipalPolicyRequest::callerArn)).setter(setter(Builder::callerArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CallerArn").build()).build();
private static final SdkField> CONTEXT_ENTRIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(SimulatePrincipalPolicyRequest::contextEntries))
.setter(setter(Builder::contextEntries))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ContextEntries").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ContextEntry::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField RESOURCE_HANDLING_OPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SimulatePrincipalPolicyRequest::resourceHandlingOption))
.setter(setter(Builder::resourceHandlingOption))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ResourceHandlingOption").build())
.build();
private static final SdkField MAX_ITEMS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.getter(getter(SimulatePrincipalPolicyRequest::maxItems)).setter(setter(Builder::maxItems))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MaxItems").build()).build();
private static final SdkField MARKER_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(SimulatePrincipalPolicyRequest::marker)).setter(setter(Builder::marker))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Marker").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(POLICY_SOURCE_ARN_FIELD,
POLICY_INPUT_LIST_FIELD, ACTION_NAMES_FIELD, RESOURCE_ARNS_FIELD, RESOURCE_POLICY_FIELD, RESOURCE_OWNER_FIELD,
CALLER_ARN_FIELD, CONTEXT_ENTRIES_FIELD, RESOURCE_HANDLING_OPTION_FIELD, MAX_ITEMS_FIELD, MARKER_FIELD));
private final String policySourceArn;
private final List policyInputList;
private final List actionNames;
private final List resourceArns;
private final String resourcePolicy;
private final String resourceOwner;
private final String callerArn;
private final List contextEntries;
private final String resourceHandlingOption;
private final Integer maxItems;
private final String marker;
private SimulatePrincipalPolicyRequest(BuilderImpl builder) {
super(builder);
this.policySourceArn = builder.policySourceArn;
this.policyInputList = builder.policyInputList;
this.actionNames = builder.actionNames;
this.resourceArns = builder.resourceArns;
this.resourcePolicy = builder.resourcePolicy;
this.resourceOwner = builder.resourceOwner;
this.callerArn = builder.callerArn;
this.contextEntries = builder.contextEntries;
this.resourceHandlingOption = builder.resourceHandlingOption;
this.maxItems = builder.maxItems;
this.marker = builder.marker;
}
/**
*
* The Amazon Resource Name (ARN) of a user, group, or role whose policies you want to include in the simulation. If
* you specify a user, group, or role, the simulation includes all policies that are associated with that entity. If
* you specify a user, the simulation also includes all policies that are attached to any groups the user belongs
* to.
*
*
* For more information about ARNs, see Amazon Resource Names (ARNs) and
* AWS Service Namespaces in the AWS General Reference.
*
*
* @return The Amazon Resource Name (ARN) of a user, group, or role whose policies you want to include in the
* simulation. If you specify a user, group, or role, the simulation includes all policies that are
* associated with that entity. If you specify a user, the simulation also includes all policies that are
* attached to any groups the user belongs to.
*
* For more information about ARNs, see Amazon Resource Names
* (ARNs) and AWS Service Namespaces in the AWS General Reference.
*/
public String policySourceArn() {
return policySourceArn;
}
/**
*
* An optional list of additional policy documents to include in the simulation. Each document is specified as a
* string containing the complete, valid JSON text of an IAM policy.
*
*
* The regex pattern used to validate this parameter is a string of
* characters consisting of the following:
*
*
* -
*
* Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character range
*
*
* -
*
* The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
*
*
* -
*
* The special characters tab ( ), line feed ( ), and carriage return ( )
*
*
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return An optional list of additional policy documents to include in the simulation. Each document is specified
* as a string containing the complete, valid JSON text of an IAM policy.
*
* The regex pattern used to validate this parameter is a
* string of characters consisting of the following:
*
*
* -
*
* Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character
* range
*
*
* -
*
* The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
*
*
* -
*
* The special characters tab ( ), line feed ( ), and carriage return ( )
*
*
*/
public List policyInputList() {
return policyInputList;
}
/**
*
* A list of names of API operations to evaluate in the simulation. Each operation is evaluated for each resource.
* Each operation must include the service identifier, such as iam:CreateUser
.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of names of API operations to evaluate in the simulation. Each operation is evaluated for each
* resource. Each operation must include the service identifier, such as iam:CreateUser
.
*/
public List actionNames() {
return actionNames;
}
/**
*
* A list of ARNs of AWS resources to include in the simulation. If this parameter is not provided, then the value
* defaults to *
(all resources). Each API in the ActionNames
parameter is evaluated for
* each resource in this list. The simulation determines the access result (allowed or denied) of each combination
* and reports it in the response.
*
*
* The simulation does not automatically retrieve policies for the specified resources. If you want to include a
* resource policy in the simulation, then you must include the policy as a string in the
* ResourcePolicy
parameter.
*
*
* For more information about ARNs, see Amazon Resource Names (ARNs) and
* AWS Service Namespaces in the AWS General Reference.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of ARNs of AWS resources to include in the simulation. If this parameter is not provided, then the
* value defaults to *
(all resources). Each API in the ActionNames
parameter is
* evaluated for each resource in this list. The simulation determines the access result (allowed or denied)
* of each combination and reports it in the response.
*
* The simulation does not automatically retrieve policies for the specified resources. If you want to
* include a resource policy in the simulation, then you must include the policy as a string in the
* ResourcePolicy
parameter.
*
*
* For more information about ARNs, see Amazon Resource Names
* (ARNs) and AWS Service Namespaces in the AWS General Reference.
*/
public List resourceArns() {
return resourceArns;
}
/**
*
* A resource-based policy to include in the simulation provided as a string. Each resource in the simulation is
* treated as if it had this policy attached. You can include only one resource-based policy in a simulation.
*
*
* The regex pattern used to validate this parameter is a string of
* characters consisting of the following:
*
*
* -
*
* Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character range
*
*
* -
*
* The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
*
*
* -
*
* The special characters tab ( ), line feed ( ), and carriage return ( )
*
*
*
*
* @return A resource-based policy to include in the simulation provided as a string. Each resource in the
* simulation is treated as if it had this policy attached. You can include only one resource-based policy
* in a simulation.
*
* The regex pattern used to validate this parameter is a
* string of characters consisting of the following:
*
*
* -
*
* Any printable ASCII character ranging from the space character ( ) through the end of the ASCII character
* range
*
*
* -
*
* The printable characters in the Basic Latin and Latin-1 Supplement character set (through \u00FF)
*
*
* -
*
* The special characters tab ( ), line feed ( ), and carriage return ( )
*
*
*/
public String resourcePolicy() {
return resourcePolicy;
}
/**
*
* An AWS account ID that specifies the owner of any simulated resource that does not identify its owner in the
* resource ARN, such as an S3 bucket or object. If ResourceOwner
is specified, it is also used as the
* account owner of any ResourcePolicy
included in the simulation. If the ResourceOwner
* parameter is not specified, then the owner of the resources and the resource policy defaults to the account of
* the identity provided in CallerArn
. This parameter is required only if you specify a resource-based
* policy and account that owns the resource is different from the account that owns the simulated calling user
* CallerArn
.
*
*
* @return An AWS account ID that specifies the owner of any simulated resource that does not identify its owner in
* the resource ARN, such as an S3 bucket or object. If ResourceOwner
is specified, it is also
* used as the account owner of any ResourcePolicy
included in the simulation. If the
* ResourceOwner
parameter is not specified, then the owner of the resources and the resource
* policy defaults to the account of the identity provided in CallerArn
. This parameter is
* required only if you specify a resource-based policy and account that owns the resource is different from
* the account that owns the simulated calling user CallerArn
.
*/
public String resourceOwner() {
return resourceOwner;
}
/**
*
* The ARN of the IAM user that you want to specify as the simulated caller of the API operations. If you do not
* specify a CallerArn
, it defaults to the ARN of the user that you specify in
* PolicySourceArn
, if you specified a user. If you include both a PolicySourceArn
(for
* example, arn:aws:iam::123456789012:user/David
) and a CallerArn
(for example,
* arn:aws:iam::123456789012:user/Bob
), the result is that you simulate calling the API operations as
* Bob, as if Bob had David's policies.
*
*
* You can specify only the ARN of an IAM user. You cannot specify the ARN of an assumed role, federated user, or a
* service principal.
*
*
* CallerArn
is required if you include a ResourcePolicy
and the
* PolicySourceArn
is not the ARN for an IAM user. This is required so that the resource-based policy's
* Principal
element has a value to use in evaluating the policy.
*
*
* For more information about ARNs, see Amazon Resource Names (ARNs) and
* AWS Service Namespaces in the AWS General Reference.
*
*
* @return The ARN of the IAM user that you want to specify as the simulated caller of the API operations. If you do
* not specify a CallerArn
, it defaults to the ARN of the user that you specify in
* PolicySourceArn
, if you specified a user. If you include both a PolicySourceArn
* (for example, arn:aws:iam::123456789012:user/David
) and a CallerArn
(for
* example, arn:aws:iam::123456789012:user/Bob
), the result is that you simulate calling the
* API operations as Bob, as if Bob had David's policies.
*
* You can specify only the ARN of an IAM user. You cannot specify the ARN of an assumed role, federated
* user, or a service principal.
*
*
* CallerArn
is required if you include a ResourcePolicy
and the
* PolicySourceArn
is not the ARN for an IAM user. This is required so that the resource-based
* policy's Principal
element has a value to use in evaluating the policy.
*
*
* For more information about ARNs, see Amazon Resource Names
* (ARNs) and AWS Service Namespaces in the AWS General Reference.
*/
public String callerArn() {
return callerArn;
}
/**
*
* A list of context keys and corresponding values for the simulation to use. Whenever a context key is evaluated in
* one of the simulated IAM permission policies, the corresponding value is supplied.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A list of context keys and corresponding values for the simulation to use. Whenever a context key is
* evaluated in one of the simulated IAM permission policies, the corresponding value is supplied.
*/
public List contextEntries() {
return contextEntries;
}
/**
*
* Specifies the type of simulation to run. Different API operations that support resource-based policies require
* different combinations of resources. By specifying the type of simulation to run, you enable the policy simulator
* to enforce the presence of the required resources to ensure reliable simulation results. If your simulation does
* not match one of the following scenarios, then you can omit this parameter. The following list shows each of the
* supported scenario values and the resources that you must define to run the simulation.
*
*
* Each of the EC2 scenarios requires that you specify instance, image, and security group resources. If your
* scenario includes an EBS volume, then you must specify that volume as a resource. If the EC2 scenario includes
* VPC, then you must supply the network interface resource. If it includes an IP subnet, then you must specify the
* subnet resource. For more information on the EC2 scenario options, see Supported Platforms in
* the Amazon EC2 User Guide.
*
*
* -
*
* EC2-Classic-InstanceStore
*
*
* instance, image, security group
*
*
* -
*
* EC2-Classic-EBS
*
*
* instance, image, security group, volume
*
*
* -
*
* EC2-VPC-InstanceStore
*
*
* instance, image, security group, network interface
*
*
* -
*
* EC2-VPC-InstanceStore-Subnet
*
*
* instance, image, security group, network interface, subnet
*
*
* -
*
* EC2-VPC-EBS
*
*
* instance, image, security group, network interface, volume
*
*
* -
*
* EC2-VPC-EBS-Subnet
*
*
* instance, image, security group, network interface, subnet, volume
*
*
*
*
* @return Specifies the type of simulation to run. Different API operations that support resource-based policies
* require different combinations of resources. By specifying the type of simulation to run, you enable the
* policy simulator to enforce the presence of the required resources to ensure reliable simulation results.
* If your simulation does not match one of the following scenarios, then you can omit this parameter. The
* following list shows each of the supported scenario values and the resources that you must define to run
* the simulation.
*
* Each of the EC2 scenarios requires that you specify instance, image, and security group resources. If
* your scenario includes an EBS volume, then you must specify that volume as a resource. If the EC2
* scenario includes VPC, then you must supply the network interface resource. If it includes an IP subnet,
* then you must specify the subnet resource. For more information on the EC2 scenario options, see Supported
* Platforms in the Amazon EC2 User Guide.
*
*
* -
*
* EC2-Classic-InstanceStore
*
*
* instance, image, security group
*
*
* -
*
* EC2-Classic-EBS
*
*
* instance, image, security group, volume
*
*
* -
*
* EC2-VPC-InstanceStore
*
*
* instance, image, security group, network interface
*
*
* -
*
* EC2-VPC-InstanceStore-Subnet
*
*
* instance, image, security group, network interface, subnet
*
*
* -
*
* EC2-VPC-EBS
*
*
* instance, image, security group, network interface, volume
*
*
* -
*
* EC2-VPC-EBS-Subnet
*
*
* instance, image, security group, network interface, subnet, volume
*
*
*/
public String resourceHandlingOption() {
return resourceHandlingOption;
}
/**
*
* Use this only when paginating results to indicate the maximum number of items you want in the response. If
* additional items exist beyond the maximum you specify, the IsTruncated
response element is
* true
.
*
*
* If you do not include this parameter, the number of items defaults to 100. Note that IAM might return fewer
* results, even when there are more results available. In that case, the IsTruncated
response element
* returns true
, and Marker
contains a value to include in the subsequent call that tells
* the service where to continue from.
*
*
* @return Use this only when paginating results to indicate the maximum number of items you want in the response.
* If additional items exist beyond the maximum you specify, the IsTruncated
response element
* is true
.
*
* If you do not include this parameter, the number of items defaults to 100. Note that IAM might return
* fewer results, even when there are more results available. In that case, the IsTruncated
* response element returns true
, and Marker
contains a value to include in the
* subsequent call that tells the service where to continue from.
*/
public Integer maxItems() {
return maxItems;
}
/**
*
* Use this parameter only when paginating results and only after you receive a response indicating that the results
* are truncated. Set it to the value of the Marker
element in the response that you received to
* indicate where the next call should start.
*
*
* @return Use this parameter only when paginating results and only after you receive a response indicating that the
* results are truncated. Set it to the value of the Marker
element in the response that you
* received to indicate where the next call should start.
*/
public String marker() {
return marker;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(policySourceArn());
hashCode = 31 * hashCode + Objects.hashCode(policyInputList());
hashCode = 31 * hashCode + Objects.hashCode(actionNames());
hashCode = 31 * hashCode + Objects.hashCode(resourceArns());
hashCode = 31 * hashCode + Objects.hashCode(resourcePolicy());
hashCode = 31 * hashCode + Objects.hashCode(resourceOwner());
hashCode = 31 * hashCode + Objects.hashCode(callerArn());
hashCode = 31 * hashCode + Objects.hashCode(contextEntries());
hashCode = 31 * hashCode + Objects.hashCode(resourceHandlingOption());
hashCode = 31 * hashCode + Objects.hashCode(maxItems());
hashCode = 31 * hashCode + Objects.hashCode(marker());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SimulatePrincipalPolicyRequest)) {
return false;
}
SimulatePrincipalPolicyRequest other = (SimulatePrincipalPolicyRequest) obj;
return Objects.equals(policySourceArn(), other.policySourceArn())
&& Objects.equals(policyInputList(), other.policyInputList())
&& Objects.equals(actionNames(), other.actionNames()) && Objects.equals(resourceArns(), other.resourceArns())
&& Objects.equals(resourcePolicy(), other.resourcePolicy())
&& Objects.equals(resourceOwner(), other.resourceOwner()) && Objects.equals(callerArn(), other.callerArn())
&& Objects.equals(contextEntries(), other.contextEntries())
&& Objects.equals(resourceHandlingOption(), other.resourceHandlingOption())
&& Objects.equals(maxItems(), other.maxItems()) && Objects.equals(marker(), other.marker());
}
@Override
public String toString() {
return ToString.builder("SimulatePrincipalPolicyRequest").add("PolicySourceArn", policySourceArn())
.add("PolicyInputList", policyInputList()).add("ActionNames", actionNames()).add("ResourceArns", resourceArns())
.add("ResourcePolicy", resourcePolicy()).add("ResourceOwner", resourceOwner()).add("CallerArn", callerArn())
.add("ContextEntries", contextEntries()).add("ResourceHandlingOption", resourceHandlingOption())
.add("MaxItems", maxItems()).add("Marker", marker()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PolicySourceArn":
return Optional.ofNullable(clazz.cast(policySourceArn()));
case "PolicyInputList":
return Optional.ofNullable(clazz.cast(policyInputList()));
case "ActionNames":
return Optional.ofNullable(clazz.cast(actionNames()));
case "ResourceArns":
return Optional.ofNullable(clazz.cast(resourceArns()));
case "ResourcePolicy":
return Optional.ofNullable(clazz.cast(resourcePolicy()));
case "ResourceOwner":
return Optional.ofNullable(clazz.cast(resourceOwner()));
case "CallerArn":
return Optional.ofNullable(clazz.cast(callerArn()));
case "ContextEntries":
return Optional.ofNullable(clazz.cast(contextEntries()));
case "ResourceHandlingOption":
return Optional.ofNullable(clazz.cast(resourceHandlingOption()));
case "MaxItems":
return Optional.ofNullable(clazz.cast(maxItems()));
case "Marker":
return Optional.ofNullable(clazz.cast(marker()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function