software.amazon.awssdk.services.verifiedpermissions.model.TemplateLinkedPolicyDefinition 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.verifiedpermissions.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.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 information about a policy created by instantiating a policy template.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TemplateLinkedPolicyDefinition implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField POLICY_TEMPLATE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("policyTemplateId").getter(getter(TemplateLinkedPolicyDefinition::policyTemplateId))
.setter(setter(Builder::policyTemplateId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("policyTemplateId").build()).build();
private static final SdkField PRINCIPAL_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("principal")
.getter(getter(TemplateLinkedPolicyDefinition::principal)).setter(setter(Builder::principal))
.constructor(EntityIdentifier::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("principal").build()).build();
private static final SdkField RESOURCE_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("resource")
.getter(getter(TemplateLinkedPolicyDefinition::resource)).setter(setter(Builder::resource))
.constructor(EntityIdentifier::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resource").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(POLICY_TEMPLATE_ID_FIELD,
PRINCIPAL_FIELD, RESOURCE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String policyTemplateId;
private final EntityIdentifier principal;
private final EntityIdentifier resource;
private TemplateLinkedPolicyDefinition(BuilderImpl builder) {
this.policyTemplateId = builder.policyTemplateId;
this.principal = builder.principal;
this.resource = builder.resource;
}
/**
*
* The unique identifier of the policy template used to create this policy.
*
*
* @return The unique identifier of the policy template used to create this policy.
*/
public final String policyTemplateId() {
return policyTemplateId;
}
/**
*
* The principal associated with this template-linked policy. Verified Permissions substitutes this principal for
* the ?principal
placeholder in the policy template when it evaluates an authorization request.
*
*
* @return The principal associated with this template-linked policy. Verified Permissions substitutes this
* principal for the ?principal
placeholder in the policy template when it evaluates an
* authorization request.
*/
public final EntityIdentifier principal() {
return principal;
}
/**
*
* The resource associated with this template-linked policy. Verified Permissions substitutes this resource for the
* ?resource
placeholder in the policy template when it evaluates an authorization request.
*
*
* @return The resource associated with this template-linked policy. Verified Permissions substitutes this resource
* for the ?resource
placeholder in the policy template when it evaluates an authorization
* request.
*/
public final EntityIdentifier resource() {
return resource;
}
@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 + Objects.hashCode(policyTemplateId());
hashCode = 31 * hashCode + Objects.hashCode(principal());
hashCode = 31 * hashCode + Objects.hashCode(resource());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TemplateLinkedPolicyDefinition)) {
return false;
}
TemplateLinkedPolicyDefinition other = (TemplateLinkedPolicyDefinition) obj;
return Objects.equals(policyTemplateId(), other.policyTemplateId()) && Objects.equals(principal(), other.principal())
&& Objects.equals(resource(), other.resource());
}
/**
* 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("TemplateLinkedPolicyDefinition").add("PolicyTemplateId", policyTemplateId())
.add("Principal", principal()).add("Resource", resource()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "policyTemplateId":
return Optional.ofNullable(clazz.cast(policyTemplateId()));
case "principal":
return Optional.ofNullable(clazz.cast(principal()));
case "resource":
return Optional.ofNullable(clazz.cast(resource()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("policyTemplateId", POLICY_TEMPLATE_ID_FIELD);
map.put("principal", PRINCIPAL_FIELD);
map.put("resource", RESOURCE_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy