software.amazon.awssdk.services.iam.model.PolicyGrantingServiceAccess 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.iam.model;
import java.io.Serializable;
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.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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains details about the permissions policies that are attached to the specified identity (user, group, or role).
*
*
* This data type is an element of the ListPoliciesGrantingServiceAccessEntry object.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PolicyGrantingServiceAccess implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField POLICY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PolicyName").getter(getter(PolicyGrantingServiceAccess::policyName)).setter(setter(Builder::policyName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolicyName").build()).build();
private static final SdkField POLICY_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PolicyType").getter(getter(PolicyGrantingServiceAccess::policyTypeAsString))
.setter(setter(Builder::policyType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolicyType").build()).build();
private static final SdkField POLICY_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PolicyArn").getter(getter(PolicyGrantingServiceAccess::policyArn)).setter(setter(Builder::policyArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolicyArn").build()).build();
private static final SdkField ENTITY_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EntityType").getter(getter(PolicyGrantingServiceAccess::entityTypeAsString))
.setter(setter(Builder::entityType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EntityType").build()).build();
private static final SdkField ENTITY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("EntityName").getter(getter(PolicyGrantingServiceAccess::entityName)).setter(setter(Builder::entityName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EntityName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(POLICY_NAME_FIELD,
POLICY_TYPE_FIELD, POLICY_ARN_FIELD, ENTITY_TYPE_FIELD, ENTITY_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final String policyName;
private final String policyType;
private final String policyArn;
private final String entityType;
private final String entityName;
private PolicyGrantingServiceAccess(BuilderImpl builder) {
this.policyName = builder.policyName;
this.policyType = builder.policyType;
this.policyArn = builder.policyArn;
this.entityType = builder.entityType;
this.entityName = builder.entityName;
}
/**
*
* The policy name.
*
*
* @return The policy name.
*/
public String policyName() {
return policyName;
}
/**
*
* The policy type. For more information about these policy types, see Managed Policies
* and Inline Policies in the IAM User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #policyType} will
* return {@link PolicyType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #policyTypeAsString}.
*
*
* @return The policy type. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
* @see PolicyType
*/
public PolicyType policyType() {
return PolicyType.fromValue(policyType);
}
/**
*
* The policy type. For more information about these policy types, see Managed Policies
* and Inline Policies in the IAM User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #policyType} will
* return {@link PolicyType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #policyTypeAsString}.
*
*
* @return The policy type. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
* @see PolicyType
*/
public String policyTypeAsString() {
return policyType;
}
/**
* Returns the value of the PolicyArn property for this object.
*
* @return The value of the PolicyArn property for this object.
*/
public String policyArn() {
return policyArn;
}
/**
*
* The type of entity (user or role) that used the policy to access the service to which the inline policy is
* attached.
*
*
* This field is null for managed policies. For more information about these policy types, see Managed Policies
* and Inline Policies in the IAM User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #entityType} will
* return {@link PolicyOwnerEntityType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #entityTypeAsString}.
*
*
* @return The type of entity (user or role) that used the policy to access the service to which the inline policy
* is attached.
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
* @see PolicyOwnerEntityType
*/
public PolicyOwnerEntityType entityType() {
return PolicyOwnerEntityType.fromValue(entityType);
}
/**
*
* The type of entity (user or role) that used the policy to access the service to which the inline policy is
* attached.
*
*
* This field is null for managed policies. For more information about these policy types, see Managed Policies
* and Inline Policies in the IAM User Guide.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #entityType} will
* return {@link PolicyOwnerEntityType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #entityTypeAsString}.
*
*
* @return The type of entity (user or role) that used the policy to access the service to which the inline policy
* is attached.
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
* @see PolicyOwnerEntityType
*/
public String entityTypeAsString() {
return entityType;
}
/**
*
* The name of the entity (user or role) to which the inline policy is attached.
*
*
* This field is null for managed policies. For more information about these policy types, see Managed Policies
* and Inline Policies in the IAM User Guide.
*
*
* @return The name of the entity (user or role) to which the inline policy is attached.
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
*/
public String entityName() {
return entityName;
}
@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(policyName());
hashCode = 31 * hashCode + Objects.hashCode(policyTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(policyArn());
hashCode = 31 * hashCode + Objects.hashCode(entityTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(entityName());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PolicyGrantingServiceAccess)) {
return false;
}
PolicyGrantingServiceAccess other = (PolicyGrantingServiceAccess) obj;
return Objects.equals(policyName(), other.policyName())
&& Objects.equals(policyTypeAsString(), other.policyTypeAsString())
&& Objects.equals(policyArn(), other.policyArn())
&& Objects.equals(entityTypeAsString(), other.entityTypeAsString())
&& Objects.equals(entityName(), other.entityName());
}
/**
* 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 String toString() {
return ToString.builder("PolicyGrantingServiceAccess").add("PolicyName", policyName())
.add("PolicyType", policyTypeAsString()).add("PolicyArn", policyArn()).add("EntityType", entityTypeAsString())
.add("EntityName", entityName()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "PolicyName":
return Optional.ofNullable(clazz.cast(policyName()));
case "PolicyType":
return Optional.ofNullable(clazz.cast(policyTypeAsString()));
case "PolicyArn":
return Optional.ofNullable(clazz.cast(policyArn()));
case "EntityType":
return Optional.ofNullable(clazz.cast(entityTypeAsString()));
case "EntityName":
return Optional.ofNullable(clazz.cast(entityName()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
* @see PolicyOwnerEntityType
* @return Returns a reference to this object so that method calls can be chained together.
* @see PolicyOwnerEntityType
*/
Builder entityType(String entityType);
/**
*
* The type of entity (user or role) that used the policy to access the service to which the inline policy is
* attached.
*
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
*
*
* @param entityType
* The type of entity (user or role) that used the policy to access the service to which the inline
* policy is attached.
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
* @see PolicyOwnerEntityType
* @return Returns a reference to this object so that method calls can be chained together.
* @see PolicyOwnerEntityType
*/
Builder entityType(PolicyOwnerEntityType entityType);
/**
*
* The name of the entity (user or role) to which the inline policy is attached.
*
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
*
*
* @param entityName
* The name of the entity (user or role) to which the inline policy is attached.
*
* This field is null for managed policies. For more information about these policy types, see Managed
* Policies and Inline Policies in the IAM User Guide.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder entityName(String entityName);
}
static final class BuilderImpl implements Builder {
private String policyName;
private String policyType;
private String policyArn;
private String entityType;
private String entityName;
private BuilderImpl() {
}
private BuilderImpl(PolicyGrantingServiceAccess model) {
policyName(model.policyName);
policyType(model.policyType);
policyArn(model.policyArn);
entityType(model.entityType);
entityName(model.entityName);
}
public final String getPolicyName() {
return policyName;
}
@Override
public final Builder policyName(String policyName) {
this.policyName = policyName;
return this;
}
public final void setPolicyName(String policyName) {
this.policyName = policyName;
}
public final String getPolicyType() {
return policyType;
}
@Override
public final Builder policyType(String policyType) {
this.policyType = policyType;
return this;
}
@Override
public final Builder policyType(PolicyType policyType) {
this.policyType(policyType == null ? null : policyType.toString());
return this;
}
public final void setPolicyType(String policyType) {
this.policyType = policyType;
}
public final String getPolicyArn() {
return policyArn;
}
@Override
public final Builder policyArn(String policyArn) {
this.policyArn = policyArn;
return this;
}
public final void setPolicyArn(String policyArn) {
this.policyArn = policyArn;
}
public final String getEntityType() {
return entityType;
}
@Override
public final Builder entityType(String entityType) {
this.entityType = entityType;
return this;
}
@Override
public final Builder entityType(PolicyOwnerEntityType entityType) {
this.entityType(entityType == null ? null : entityType.toString());
return this;
}
public final void setEntityType(String entityType) {
this.entityType = entityType;
}
public final String getEntityName() {
return entityName;
}
@Override
public final Builder entityName(String entityName) {
this.entityName = entityName;
return this;
}
public final void setEntityName(String entityName) {
this.entityName = entityName;
}
@Override
public PolicyGrantingServiceAccess build() {
return new PolicyGrantingServiceAccess(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}