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

software.amazon.awssdk.services.iam.model.VirtualMFADevice 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.nio.ByteBuffer;
import java.time.Instant;
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.core.SdkBytes;
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;

/**
 * 

* Contains information about a virtual MFA device. *

*/ @Generated("software.amazon.awssdk:codegen") public final class VirtualMFADevice implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField SERIAL_NUMBER_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("SerialNumber").getter(getter(VirtualMFADevice::serialNumber)).setter(setter(Builder::serialNumber)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SerialNumber").build()).build(); private static final SdkField BASE32_STRING_SEED_FIELD = SdkField. builder(MarshallingType.SDK_BYTES) .memberName("Base32StringSeed").getter(getter(VirtualMFADevice::base32StringSeed)) .setter(setter(Builder::base32StringSeed)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Base32StringSeed").build()).build(); private static final SdkField QR_CODE_PNG_FIELD = SdkField. builder(MarshallingType.SDK_BYTES) .memberName("QRCodePNG").getter(getter(VirtualMFADevice::qrCodePNG)).setter(setter(Builder::qrCodePNG)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("QRCodePNG").build()).build(); private static final SdkField USER_FIELD = SdkField. builder(MarshallingType.SDK_POJO).memberName("User") .getter(getter(VirtualMFADevice::user)).setter(setter(Builder::user)).constructor(User::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("User").build()).build(); private static final SdkField ENABLE_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("EnableDate").getter(getter(VirtualMFADevice::enableDate)).setter(setter(Builder::enableDate)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnableDate").build()).build(); private static final SdkField> TAGS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Tags") .getter(getter(VirtualMFADevice::tags)) .setter(setter(Builder::tags)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Tag::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SERIAL_NUMBER_FIELD, BASE32_STRING_SEED_FIELD, QR_CODE_PNG_FIELD, USER_FIELD, ENABLE_DATE_FIELD, TAGS_FIELD)); private static final long serialVersionUID = 1L; private final String serialNumber; private final SdkBytes base32StringSeed; private final SdkBytes qrCodePNG; private final User user; private final Instant enableDate; private final List tags; private VirtualMFADevice(BuilderImpl builder) { this.serialNumber = builder.serialNumber; this.base32StringSeed = builder.base32StringSeed; this.qrCodePNG = builder.qrCodePNG; this.user = builder.user; this.enableDate = builder.enableDate; this.tags = builder.tags; } /** *

* The serial number associated with VirtualMFADevice. *

* * @return The serial number associated with VirtualMFADevice. */ public final String serialNumber() { return serialNumber; } /** *

* The base32 seed defined as specified in RFC3548. The * Base32StringSeed is base32-encoded. *

* * @return The base32 seed defined as specified in RFC3548. * The Base32StringSeed is base32-encoded. */ public final SdkBytes base32StringSeed() { return base32StringSeed; } /** *

* A QR code PNG image that encodes * otpauth://totp/$virtualMFADeviceName@$AccountName?secret=$Base32String where * $virtualMFADeviceName is one of the create call arguments. AccountName is the user name * if set (otherwise, the account ID otherwise), and Base32String is the seed in base32 format. The * Base32String value is base64-encoded. *

* * @return A QR code PNG image that encodes * otpauth://totp/$virtualMFADeviceName@$AccountName?secret=$Base32String where * $virtualMFADeviceName is one of the create call arguments. AccountName is the * user name if set (otherwise, the account ID otherwise), and Base32String is the seed in * base32 format. The Base32String value is base64-encoded. */ public final SdkBytes qrCodePNG() { return qrCodePNG; } /** *

* The IAM user associated with this virtual MFA device. *

* * @return The IAM user associated with this virtual MFA device. */ public final User user() { return user; } /** *

* The date and time on which the virtual MFA device was enabled. *

* * @return The date and time on which the virtual MFA device was enabled. */ public final Instant enableDate() { return enableDate; } /** * For responses, this returns true if the service returned a value for the Tags 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 hasTags() { return tags != null && !(tags instanceof SdkAutoConstructList); } /** *

* A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources in the IAM User * Guide. *

*

* 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 #hasTags} method. *

* * @return A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources in the * IAM User Guide. */ public final List tags() { return tags; } @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(serialNumber()); hashCode = 31 * hashCode + Objects.hashCode(base32StringSeed()); hashCode = 31 * hashCode + Objects.hashCode(qrCodePNG()); hashCode = 31 * hashCode + Objects.hashCode(user()); hashCode = 31 * hashCode + Objects.hashCode(enableDate()); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : 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 VirtualMFADevice)) { return false; } VirtualMFADevice other = (VirtualMFADevice) obj; return Objects.equals(serialNumber(), other.serialNumber()) && Objects.equals(base32StringSeed(), other.base32StringSeed()) && Objects.equals(qrCodePNG(), other.qrCodePNG()) && Objects.equals(user(), other.user()) && Objects.equals(enableDate(), other.enableDate()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()); } /** * 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("VirtualMFADevice").add("SerialNumber", serialNumber()) .add("Base32StringSeed", base32StringSeed() == null ? null : "*** Sensitive Data Redacted ***") .add("QRCodePNG", qrCodePNG() == null ? null : "*** Sensitive Data Redacted ***").add("User", user()) .add("EnableDate", enableDate()).add("Tags", hasTags() ? tags() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "SerialNumber": return Optional.ofNullable(clazz.cast(serialNumber())); case "Base32StringSeed": return Optional.ofNullable(clazz.cast(base32StringSeed())); case "QRCodePNG": return Optional.ofNullable(clazz.cast(qrCodePNG())); case "User": return Optional.ofNullable(clazz.cast(user())); case "EnableDate": return Optional.ofNullable(clazz.cast(enableDate())); case "Tags": return Optional.ofNullable(clazz.cast(tags())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((VirtualMFADevice) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The serial number associated with VirtualMFADevice. *

* * @param serialNumber * The serial number associated with VirtualMFADevice. * @return Returns a reference to this object so that method calls can be chained together. */ Builder serialNumber(String serialNumber); /** *

* The base32 seed defined as specified in RFC3548. The * Base32StringSeed is base32-encoded. *

* * @param base32StringSeed * The base32 seed defined as specified in RFC3548. * The Base32StringSeed is base32-encoded. * @return Returns a reference to this object so that method calls can be chained together. */ Builder base32StringSeed(SdkBytes base32StringSeed); /** *

* A QR code PNG image that encodes * otpauth://totp/$virtualMFADeviceName@$AccountName?secret=$Base32String where * $virtualMFADeviceName is one of the create call arguments. AccountName is the user * name if set (otherwise, the account ID otherwise), and Base32String is the seed in base32 * format. The Base32String value is base64-encoded. *

* * @param qrCodePNG * A QR code PNG image that encodes * otpauth://totp/$virtualMFADeviceName@$AccountName?secret=$Base32String where * $virtualMFADeviceName is one of the create call arguments. AccountName is * the user name if set (otherwise, the account ID otherwise), and Base32String is the seed * in base32 format. The Base32String value is base64-encoded. * @return Returns a reference to this object so that method calls can be chained together. */ Builder qrCodePNG(SdkBytes qrCodePNG); /** *

* The IAM user associated with this virtual MFA device. *

* * @param user * The IAM user associated with this virtual MFA device. * @return Returns a reference to this object so that method calls can be chained together. */ Builder user(User user); /** *

* The IAM user associated with this virtual MFA device. *

* This is a convenience method that creates an instance of the {@link User.Builder} avoiding the need to create * one manually via {@link User#builder()}. * *

* When the {@link Consumer} completes, {@link User.Builder#build()} is called immediately and its result is * passed to {@link #user(User)}. * * @param user * a consumer that will call methods on {@link User.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #user(User) */ default Builder user(Consumer user) { return user(User.builder().applyMutation(user).build()); } /** *

* The date and time on which the virtual MFA device was enabled. *

* * @param enableDate * The date and time on which the virtual MFA device was enabled. * @return Returns a reference to this object so that method calls can be chained together. */ Builder enableDate(Instant enableDate); /** *

* A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources in the IAM * User Guide. *

* * @param tags * A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources in the * IAM User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Collection tags); /** *

* A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources in the IAM * User Guide. *

* * @param tags * A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources in the * IAM User Guide. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

* A list of tags that are attached to the virtual MFA device. For more information about tagging, see Tagging IAM resources in the IAM * User Guide. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.iam.model.Tag.Builder} avoiding the need to create one manually via * {@link software.amazon.awssdk.services.iam.model.Tag#builder()}. * *

* When the {@link Consumer} completes, {@link software.amazon.awssdk.services.iam.model.Tag.Builder#build()} is * called immediately and its result is passed to {@link #tags(List)}. * * @param tags * a consumer that will call methods on {@link software.amazon.awssdk.services.iam.model.Tag.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tags(java.util.Collection) */ Builder tags(Consumer... tags); } static final class BuilderImpl implements Builder { private String serialNumber; private SdkBytes base32StringSeed; private SdkBytes qrCodePNG; private User user; private Instant enableDate; private List tags = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(VirtualMFADevice model) { serialNumber(model.serialNumber); base32StringSeed(model.base32StringSeed); qrCodePNG(model.qrCodePNG); user(model.user); enableDate(model.enableDate); tags(model.tags); } public final String getSerialNumber() { return serialNumber; } public final void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } @Override public final Builder serialNumber(String serialNumber) { this.serialNumber = serialNumber; return this; } public final ByteBuffer getBase32StringSeed() { return base32StringSeed == null ? null : base32StringSeed.asByteBuffer(); } public final void setBase32StringSeed(ByteBuffer base32StringSeed) { base32StringSeed(base32StringSeed == null ? null : SdkBytes.fromByteBuffer(base32StringSeed)); } @Override public final Builder base32StringSeed(SdkBytes base32StringSeed) { this.base32StringSeed = base32StringSeed; return this; } public final ByteBuffer getQrCodePNG() { return qrCodePNG == null ? null : qrCodePNG.asByteBuffer(); } public final void setQrCodePNG(ByteBuffer qrCodePNG) { qrCodePNG(qrCodePNG == null ? null : SdkBytes.fromByteBuffer(qrCodePNG)); } @Override public final Builder qrCodePNG(SdkBytes qrCodePNG) { this.qrCodePNG = qrCodePNG; return this; } public final User.Builder getUser() { return user != null ? user.toBuilder() : null; } public final void setUser(User.BuilderImpl user) { this.user = user != null ? user.build() : null; } @Override public final Builder user(User user) { this.user = user; return this; } public final Instant getEnableDate() { return enableDate; } public final void setEnableDate(Instant enableDate) { this.enableDate = enableDate; } @Override public final Builder enableDate(Instant enableDate) { this.enableDate = enableDate; return this; } public final List getTags() { List result = _tagListTypeCopier.copyToBuilder(this.tags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTags(Collection tags) { this.tags = _tagListTypeCopier.copyFromBuilder(tags); } @Override public final Builder tags(Collection tags) { this.tags = _tagListTypeCopier.copy(tags); return this; } @Override @SafeVarargs public final Builder tags(Tag... tags) { tags(Arrays.asList(tags)); return this; } @Override @SafeVarargs public final Builder tags(Consumer... tags) { tags(Stream.of(tags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } @Override public VirtualMFADevice build() { return new VirtualMFADevice(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy