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

software.amazon.awssdk.services.iam.model.GetMfaDeviceResponse 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.time.Instant;
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.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.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class GetMfaDeviceResponse extends IamResponse implements
        ToCopyableBuilder {
    private static final SdkField USER_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("UserName").getter(getter(GetMfaDeviceResponse::userName)).setter(setter(Builder::userName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UserName").build()).build();

    private static final SdkField SERIAL_NUMBER_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("SerialNumber").getter(getter(GetMfaDeviceResponse::serialNumber)).setter(setter(Builder::serialNumber))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SerialNumber").build()).build();

    private static final SdkField ENABLE_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
            .memberName("EnableDate").getter(getter(GetMfaDeviceResponse::enableDate)).setter(setter(Builder::enableDate))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnableDate").build()).build();

    private static final SdkField> CERTIFICATIONS_FIELD = SdkField
            .> builder(MarshallingType.MAP)
            .memberName("Certifications")
            .getter(getter(GetMfaDeviceResponse::certifications))
            .setter(setter(Builder::certifications))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Certifications").build(),
                    MapTrait.builder()
                            .keyLocationName("key")
                            .valueLocationName("value")
                            .valueFieldInfo(
                                    SdkField. builder(MarshallingType.STRING)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("value").build()).build()).build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(USER_NAME_FIELD,
            SERIAL_NUMBER_FIELD, ENABLE_DATE_FIELD, CERTIFICATIONS_FIELD));

    private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();

    private final String userName;

    private final String serialNumber;

    private final Instant enableDate;

    private final Map certifications;

    private GetMfaDeviceResponse(BuilderImpl builder) {
        super(builder);
        this.userName = builder.userName;
        this.serialNumber = builder.serialNumber;
        this.enableDate = builder.enableDate;
        this.certifications = builder.certifications;
    }

    /**
     * 

* The friendly name identifying the user. *

* * @return The friendly name identifying the user. */ public final String userName() { return userName; } /** *

* Serial number that uniquely identifies the MFA device. For this API, we only accept FIDO security key ARNs. *

* * @return Serial number that uniquely identifies the MFA device. For this API, we only accept FIDO security key ARNs. */ public final String serialNumber() { return serialNumber; } /** *

* The date that a specified user's MFA device was first enabled. *

* * @return The date that a specified user's MFA device was first enabled. */ public final Instant enableDate() { return enableDate; } /** * For responses, this returns true if the service returned a value for the Certifications 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 hasCertifications() { return certifications != null && !(certifications instanceof SdkAutoConstructMap); } /** *

* The certifications of a specified user's MFA device. We currently provide FIPS-140-2, FIPS-140-3, and FIDO * certification levels obtained from FIDO Alliance Metadata Service * (MDS). *

*

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

* * @return The certifications of a specified user's MFA device. We currently provide FIPS-140-2, FIPS-140-3, and * FIDO certification levels obtained from FIDO Alliance * Metadata Service (MDS). */ public final Map certifications() { return certifications; } @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 + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(userName()); hashCode = 31 * hashCode + Objects.hashCode(serialNumber()); hashCode = 31 * hashCode + Objects.hashCode(enableDate()); hashCode = 31 * hashCode + Objects.hashCode(hasCertifications() ? certifications() : null); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof GetMfaDeviceResponse)) { return false; } GetMfaDeviceResponse other = (GetMfaDeviceResponse) obj; return Objects.equals(userName(), other.userName()) && Objects.equals(serialNumber(), other.serialNumber()) && Objects.equals(enableDate(), other.enableDate()) && hasCertifications() == other.hasCertifications() && Objects.equals(certifications(), other.certifications()); } /** * 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("GetMfaDeviceResponse").add("UserName", userName()).add("SerialNumber", serialNumber()) .add("EnableDate", enableDate()).add("Certifications", hasCertifications() ? certifications() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "UserName": return Optional.ofNullable(clazz.cast(userName())); case "SerialNumber": return Optional.ofNullable(clazz.cast(serialNumber())); case "EnableDate": return Optional.ofNullable(clazz.cast(enableDate())); case "Certifications": return Optional.ofNullable(clazz.cast(certifications())); 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("UserName", USER_NAME_FIELD); map.put("SerialNumber", SERIAL_NUMBER_FIELD); map.put("EnableDate", ENABLE_DATE_FIELD); map.put("Certifications", CERTIFICATIONS_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((GetMfaDeviceResponse) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends IamResponse.Builder, SdkPojo, CopyableBuilder { /** *

* The friendly name identifying the user. *

* * @param userName * The friendly name identifying the user. * @return Returns a reference to this object so that method calls can be chained together. */ Builder userName(String userName); /** *

* Serial number that uniquely identifies the MFA device. For this API, we only accept FIDO security key ARNs. *

* * @param serialNumber * Serial number that uniquely identifies the MFA device. For this API, we only accept FIDO security key * ARNs. * @return Returns a reference to this object so that method calls can be chained together. */ Builder serialNumber(String serialNumber); /** *

* The date that a specified user's MFA device was first enabled. *

* * @param enableDate * The date that a specified user's MFA device was first enabled. * @return Returns a reference to this object so that method calls can be chained together. */ Builder enableDate(Instant enableDate); /** *

* The certifications of a specified user's MFA device. We currently provide FIPS-140-2, FIPS-140-3, and FIDO * certification levels obtained from FIDO Alliance Metadata * Service (MDS). *

* * @param certifications * The certifications of a specified user's MFA device. We currently provide FIPS-140-2, FIPS-140-3, and * FIDO certification levels obtained from FIDO Alliance * Metadata Service (MDS). * @return Returns a reference to this object so that method calls can be chained together. */ Builder certifications(Map certifications); } static final class BuilderImpl extends IamResponse.BuilderImpl implements Builder { private String userName; private String serialNumber; private Instant enableDate; private Map certifications = DefaultSdkAutoConstructMap.getInstance(); private BuilderImpl() { } private BuilderImpl(GetMfaDeviceResponse model) { super(model); userName(model.userName); serialNumber(model.serialNumber); enableDate(model.enableDate); certifications(model.certifications); } public final String getUserName() { return userName; } public final void setUserName(String userName) { this.userName = userName; } @Override public final Builder userName(String userName) { this.userName = userName; return this; } 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 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 Map getCertifications() { if (certifications instanceof SdkAutoConstructMap) { return null; } return certifications; } public final void setCertifications(Map certifications) { this.certifications = CertificationMapTypeCopier.copy(certifications); } @Override public final Builder certifications(Map certifications) { this.certifications = CertificationMapTypeCopier.copy(certifications); return this; } @Override public GetMfaDeviceResponse build() { return new GetMfaDeviceResponse(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy