
software.amazon.awssdk.services.imagebuilder.model.LaunchPermissionConfiguration 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.imagebuilder.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;
/**
*
* Describes the configuration for a launch permission. The launch permission modification request is sent to the Amazon EC2
* ModifyImageAttribute API on behalf of the user for each Region they have selected to distribute the AMI. To make
* an AMI public, set the launch permission authorized accounts to all
. See the examples for making an AMI
* public at Amazon EC2
* ModifyImageAttribute.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class LaunchPermissionConfiguration implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField> USER_IDS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("userIds")
.getter(getter(LaunchPermissionConfiguration::userIds))
.setter(setter(Builder::userIds))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("userIds").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> USER_GROUPS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("userGroups")
.getter(getter(LaunchPermissionConfiguration::userGroups))
.setter(setter(Builder::userGroups))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("userGroups").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> ORGANIZATION_ARNS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("organizationArns")
.getter(getter(LaunchPermissionConfiguration::organizationArns))
.setter(setter(Builder::organizationArns))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("organizationArns").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> ORGANIZATIONAL_UNIT_ARNS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("organizationalUnitArns")
.getter(getter(LaunchPermissionConfiguration::organizationalUnitArns))
.setter(setter(Builder::organizationalUnitArns))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("organizationalUnitArns").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(USER_IDS_FIELD,
USER_GROUPS_FIELD, ORGANIZATION_ARNS_FIELD, ORGANIZATIONAL_UNIT_ARNS_FIELD));
private static final long serialVersionUID = 1L;
private final List userIds;
private final List userGroups;
private final List organizationArns;
private final List organizationalUnitArns;
private LaunchPermissionConfiguration(BuilderImpl builder) {
this.userIds = builder.userIds;
this.userGroups = builder.userGroups;
this.organizationArns = builder.organizationArns;
this.organizationalUnitArns = builder.organizationalUnitArns;
}
/**
* For responses, this returns true if the service returned a value for the UserIds 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 hasUserIds() {
return userIds != null && !(userIds instanceof SdkAutoConstructList);
}
/**
*
* The Amazon Web Services account ID.
*
*
* 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 #hasUserIds} method.
*
*
* @return The Amazon Web Services account ID.
*/
public final List userIds() {
return userIds;
}
/**
* For responses, this returns true if the service returned a value for the UserGroups 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 hasUserGroups() {
return userGroups != null && !(userGroups instanceof SdkAutoConstructList);
}
/**
*
* The name of the group.
*
*
* 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 #hasUserGroups} method.
*
*
* @return The name of the group.
*/
public final List userGroups() {
return userGroups;
}
/**
* For responses, this returns true if the service returned a value for the OrganizationArns 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 hasOrganizationArns() {
return organizationArns != null && !(organizationArns instanceof SdkAutoConstructList);
}
/**
*
* The ARN for an Amazon Web Services Organization that you want to share your AMI with. For more information, see
* What is
* Organizations?.
*
*
* 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 #hasOrganizationArns} method.
*
*
* @return The ARN for an Amazon Web Services Organization that you want to share your AMI with. For more
* information, see What is
* Organizations?.
*/
public final List organizationArns() {
return organizationArns;
}
/**
* For responses, this returns true if the service returned a value for the OrganizationalUnitArns 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 hasOrganizationalUnitArns() {
return organizationalUnitArns != null && !(organizationalUnitArns instanceof SdkAutoConstructList);
}
/**
*
* The ARN for an Organizations organizational unit (OU) that you want to share your AMI with. For more information
* about key concepts for Organizations, see Organizations terminology and concepts.
*
*
* 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 #hasOrganizationalUnitArns} method.
*
*
* @return The ARN for an Organizations organizational unit (OU) that you want to share your AMI with. For more
* information about key concepts for Organizations, see Organizations terminology and concepts.
*/
public final List organizationalUnitArns() {
return organizationalUnitArns;
}
@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(hasUserIds() ? userIds() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasUserGroups() ? userGroups() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasOrganizationArns() ? organizationArns() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasOrganizationalUnitArns() ? organizationalUnitArns() : 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 LaunchPermissionConfiguration)) {
return false;
}
LaunchPermissionConfiguration other = (LaunchPermissionConfiguration) obj;
return hasUserIds() == other.hasUserIds() && Objects.equals(userIds(), other.userIds())
&& hasUserGroups() == other.hasUserGroups() && Objects.equals(userGroups(), other.userGroups())
&& hasOrganizationArns() == other.hasOrganizationArns()
&& Objects.equals(organizationArns(), other.organizationArns())
&& hasOrganizationalUnitArns() == other.hasOrganizationalUnitArns()
&& Objects.equals(organizationalUnitArns(), other.organizationalUnitArns());
}
/**
* 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("LaunchPermissionConfiguration").add("UserIds", hasUserIds() ? userIds() : null)
.add("UserGroups", hasUserGroups() ? userGroups() : null)
.add("OrganizationArns", hasOrganizationArns() ? organizationArns() : null)
.add("OrganizationalUnitArns", hasOrganizationalUnitArns() ? organizationalUnitArns() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "userIds":
return Optional.ofNullable(clazz.cast(userIds()));
case "userGroups":
return Optional.ofNullable(clazz.cast(userGroups()));
case "organizationArns":
return Optional.ofNullable(clazz.cast(organizationArns()));
case "organizationalUnitArns":
return Optional.ofNullable(clazz.cast(organizationalUnitArns()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function