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

software.amazon.awssdk.services.workmail.model.Permission Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon WorkMail module holds the client classes that are used for communicating with Amazon WorkMail Service

There is a newer version: 2.28.3
Show newest version
/*
 * 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.workmail.model;

import java.io.Serializable;
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.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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* Permission granted to a user, group, or resource to access a certain aspect of another user, group, or resource * mailbox. *

*/ @Generated("software.amazon.awssdk:codegen") public final class Permission implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField GRANTEE_ID_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("GranteeId").getter(getter(Permission::granteeId)).setter(setter(Builder::granteeId)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GranteeId").build()).build(); private static final SdkField GRANTEE_TYPE_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("GranteeType").getter(getter(Permission::granteeTypeAsString)).setter(setter(Builder::granteeType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("GranteeType").build()).build(); private static final SdkField> PERMISSION_VALUES_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("PermissionValues") .getter(getter(Permission::permissionValuesAsStrings)) .setter(setter(Builder::permissionValuesWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PermissionValues").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 List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(GRANTEE_ID_FIELD, GRANTEE_TYPE_FIELD, PERMISSION_VALUES_FIELD)); private static final long serialVersionUID = 1L; private final String granteeId; private final String granteeType; private final List permissionValues; private Permission(BuilderImpl builder) { this.granteeId = builder.granteeId; this.granteeType = builder.granteeType; this.permissionValues = builder.permissionValues; } /** *

* The identifier of the user, group, or resource to which the permissions are granted. *

* * @return The identifier of the user, group, or resource to which the permissions are granted. */ public final String granteeId() { return granteeId; } /** *

* The type of user, group, or resource referred to in GranteeId. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #granteeType} will * return {@link MemberType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #granteeTypeAsString}. *

* * @return The type of user, group, or resource referred to in GranteeId. * @see MemberType */ public final MemberType granteeType() { return MemberType.fromValue(granteeType); } /** *

* The type of user, group, or resource referred to in GranteeId. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #granteeType} will * return {@link MemberType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #granteeTypeAsString}. *

* * @return The type of user, group, or resource referred to in GranteeId. * @see MemberType */ public final String granteeTypeAsString() { return granteeType; } /** *

* The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the mailbox (the * grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email on behalf of the owner * of the mailbox (the grantee is not mentioned as the physical sender of these emails). FULL_ACCESS allows the * grantee full access to the mailbox, irrespective of other folder-level permissions set on the mailbox. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasPermissionValues} method. *

* * @return The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the * mailbox (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email * on behalf of the owner of the mailbox (the grantee is not mentioned as the physical sender of these * emails). FULL_ACCESS allows the grantee full access to the mailbox, irrespective of other folder-level * permissions set on the mailbox. */ public final List permissionValues() { return PermissionValuesCopier.copyStringToEnum(permissionValues); } /** * For responses, this returns true if the service returned a value for the PermissionValues property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasPermissionValues() { return permissionValues != null && !(permissionValues instanceof SdkAutoConstructList); } /** *

* The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the mailbox (the * grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email on behalf of the owner * of the mailbox (the grantee is not mentioned as the physical sender of these emails). FULL_ACCESS allows the * grantee full access to the mailbox, irrespective of other folder-level permissions set on the mailbox. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasPermissionValues} method. *

* * @return The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the * mailbox (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email * on behalf of the owner of the mailbox (the grantee is not mentioned as the physical sender of these * emails). FULL_ACCESS allows the grantee full access to the mailbox, irrespective of other folder-level * permissions set on the mailbox. */ public final List permissionValuesAsStrings() { return permissionValues; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(granteeId()); hashCode = 31 * hashCode + Objects.hashCode(granteeTypeAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasPermissionValues() ? permissionValuesAsStrings() : null); 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 Permission)) { return false; } Permission other = (Permission) obj; return Objects.equals(granteeId(), other.granteeId()) && Objects.equals(granteeTypeAsString(), other.granteeTypeAsString()) && hasPermissionValues() == other.hasPermissionValues() && Objects.equals(permissionValuesAsStrings(), other.permissionValuesAsStrings()); } /** * 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("Permission").add("GranteeId", granteeId()).add("GranteeType", granteeTypeAsString()) .add("PermissionValues", hasPermissionValues() ? permissionValuesAsStrings() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "GranteeId": return Optional.ofNullable(clazz.cast(granteeId())); case "GranteeType": return Optional.ofNullable(clazz.cast(granteeTypeAsString())); case "PermissionValues": return Optional.ofNullable(clazz.cast(permissionValuesAsStrings())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((Permission) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The identifier of the user, group, or resource to which the permissions are granted. *

* * @param granteeId * The identifier of the user, group, or resource to which the permissions are granted. * @return Returns a reference to this object so that method calls can be chained together. */ Builder granteeId(String granteeId); /** *

* The type of user, group, or resource referred to in GranteeId. *

* * @param granteeType * The type of user, group, or resource referred to in GranteeId. * @see MemberType * @return Returns a reference to this object so that method calls can be chained together. * @see MemberType */ Builder granteeType(String granteeType); /** *

* The type of user, group, or resource referred to in GranteeId. *

* * @param granteeType * The type of user, group, or resource referred to in GranteeId. * @see MemberType * @return Returns a reference to this object so that method calls can be chained together. * @see MemberType */ Builder granteeType(MemberType granteeType); /** *

* The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the mailbox * (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email on behalf of * the owner of the mailbox (the grantee is not mentioned as the physical sender of these emails). FULL_ACCESS * allows the grantee full access to the mailbox, irrespective of other folder-level permissions set on the * mailbox. *

* * @param permissionValues * The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the * mailbox (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send * email on behalf of the owner of the mailbox (the grantee is not mentioned as the physical sender of * these emails). FULL_ACCESS allows the grantee full access to the mailbox, irrespective of other * folder-level permissions set on the mailbox. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permissionValuesWithStrings(Collection permissionValues); /** *

* The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the mailbox * (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email on behalf of * the owner of the mailbox (the grantee is not mentioned as the physical sender of these emails). FULL_ACCESS * allows the grantee full access to the mailbox, irrespective of other folder-level permissions set on the * mailbox. *

* * @param permissionValues * The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the * mailbox (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send * email on behalf of the owner of the mailbox (the grantee is not mentioned as the physical sender of * these emails). FULL_ACCESS allows the grantee full access to the mailbox, irrespective of other * folder-level permissions set on the mailbox. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permissionValuesWithStrings(String... permissionValues); /** *

* The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the mailbox * (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email on behalf of * the owner of the mailbox (the grantee is not mentioned as the physical sender of these emails). FULL_ACCESS * allows the grantee full access to the mailbox, irrespective of other folder-level permissions set on the * mailbox. *

* * @param permissionValues * The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the * mailbox (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send * email on behalf of the owner of the mailbox (the grantee is not mentioned as the physical sender of * these emails). FULL_ACCESS allows the grantee full access to the mailbox, irrespective of other * folder-level permissions set on the mailbox. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permissionValues(Collection permissionValues); /** *

* The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the mailbox * (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send email on behalf of * the owner of the mailbox (the grantee is not mentioned as the physical sender of these emails). FULL_ACCESS * allows the grantee full access to the mailbox, irrespective of other folder-level permissions set on the * mailbox. *

* * @param permissionValues * The permissions granted to the grantee. SEND_AS allows the grantee to send email as the owner of the * mailbox (the grantee is not mentioned on these emails). SEND_ON_BEHALF allows the grantee to send * email on behalf of the owner of the mailbox (the grantee is not mentioned as the physical sender of * these emails). FULL_ACCESS allows the grantee full access to the mailbox, irrespective of other * folder-level permissions set on the mailbox. * @return Returns a reference to this object so that method calls can be chained together. */ Builder permissionValues(PermissionType... permissionValues); } static final class BuilderImpl implements Builder { private String granteeId; private String granteeType; private List permissionValues = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(Permission model) { granteeId(model.granteeId); granteeType(model.granteeType); permissionValuesWithStrings(model.permissionValues); } public final String getGranteeId() { return granteeId; } public final void setGranteeId(String granteeId) { this.granteeId = granteeId; } @Override public final Builder granteeId(String granteeId) { this.granteeId = granteeId; return this; } public final String getGranteeType() { return granteeType; } public final void setGranteeType(String granteeType) { this.granteeType = granteeType; } @Override public final Builder granteeType(String granteeType) { this.granteeType = granteeType; return this; } @Override public final Builder granteeType(MemberType granteeType) { this.granteeType(granteeType == null ? null : granteeType.toString()); return this; } public final Collection getPermissionValues() { if (permissionValues instanceof SdkAutoConstructList) { return null; } return permissionValues; } public final void setPermissionValues(Collection permissionValues) { this.permissionValues = PermissionValuesCopier.copy(permissionValues); } @Override public final Builder permissionValuesWithStrings(Collection permissionValues) { this.permissionValues = PermissionValuesCopier.copy(permissionValues); return this; } @Override @SafeVarargs public final Builder permissionValuesWithStrings(String... permissionValues) { permissionValuesWithStrings(Arrays.asList(permissionValues)); return this; } @Override public final Builder permissionValues(Collection permissionValues) { this.permissionValues = PermissionValuesCopier.copyEnumToString(permissionValues); return this; } @Override @SafeVarargs public final Builder permissionValues(PermissionType... permissionValues) { permissionValues(Arrays.asList(permissionValues)); return this; } @Override public Permission build() { return new Permission(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy