software.amazon.awssdk.services.securityhub.model.AwsIamAccessKeyDetails 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.securityhub.model;
import java.io.Serializable;
import java.util.Arrays;
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 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;
/**
*
* IAM access key details related to a finding.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AwsIamAccessKeyDetails implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField USER_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("UserName").getter(getter(AwsIamAccessKeyDetails::userName)).setter(setter(Builder::userName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UserName").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(AwsIamAccessKeyDetails::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField CREATED_AT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("CreatedAt").getter(getter(AwsIamAccessKeyDetails::createdAt)).setter(setter(Builder::createdAt))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedAt").build()).build();
private static final SdkField PRINCIPAL_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrincipalId").getter(getter(AwsIamAccessKeyDetails::principalId)).setter(setter(Builder::principalId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrincipalId").build()).build();
private static final SdkField PRINCIPAL_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrincipalType").getter(getter(AwsIamAccessKeyDetails::principalType))
.setter(setter(Builder::principalType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrincipalType").build()).build();
private static final SdkField PRINCIPAL_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PrincipalName").getter(getter(AwsIamAccessKeyDetails::principalName))
.setter(setter(Builder::principalName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PrincipalName").build()).build();
private static final SdkField ACCOUNT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccountId").getter(getter(AwsIamAccessKeyDetails::accountId)).setter(setter(Builder::accountId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccountId").build()).build();
private static final SdkField ACCESS_KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AccessKeyId").getter(getter(AwsIamAccessKeyDetails::accessKeyId)).setter(setter(Builder::accessKeyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AccessKeyId").build()).build();
private static final SdkField SESSION_CONTEXT_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("SessionContext")
.getter(getter(AwsIamAccessKeyDetails::sessionContext)).setter(setter(Builder::sessionContext))
.constructor(AwsIamAccessKeySessionContext::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SessionContext").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(USER_NAME_FIELD, STATUS_FIELD,
CREATED_AT_FIELD, PRINCIPAL_ID_FIELD, PRINCIPAL_TYPE_FIELD, PRINCIPAL_NAME_FIELD, ACCOUNT_ID_FIELD,
ACCESS_KEY_ID_FIELD, SESSION_CONTEXT_FIELD));
private static final long serialVersionUID = 1L;
private final String userName;
private final String status;
private final String createdAt;
private final String principalId;
private final String principalType;
private final String principalName;
private final String accountId;
private final String accessKeyId;
private final AwsIamAccessKeySessionContext sessionContext;
private AwsIamAccessKeyDetails(BuilderImpl builder) {
this.userName = builder.userName;
this.status = builder.status;
this.createdAt = builder.createdAt;
this.principalId = builder.principalId;
this.principalType = builder.principalType;
this.principalName = builder.principalName;
this.accountId = builder.accountId;
this.accessKeyId = builder.accessKeyId;
this.sessionContext = builder.sessionContext;
}
/**
*
* The user associated with the IAM access key related to a finding.
*
*
* The UserName parameter has been replaced with the PrincipalName parameter because
* access keys can also be assigned to principals that are not IAM users.
*
*
* @return The user associated with the IAM access key related to a finding.
*
* The UserName parameter has been replaced with the PrincipalName parameter
* because access keys can also be assigned to principals that are not IAM users.
* @deprecated This filter is deprecated. Instead, use PrincipalName.
*/
@Deprecated
public final String userName() {
return userName;
}
/**
*
* The status of the IAM access key related to a finding.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AwsIamAccessKeyStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the IAM access key related to a finding.
* @see AwsIamAccessKeyStatus
*/
public final AwsIamAccessKeyStatus status() {
return AwsIamAccessKeyStatus.fromValue(status);
}
/**
*
* The status of the IAM access key related to a finding.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link AwsIamAccessKeyStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the IAM access key related to a finding.
* @see AwsIamAccessKeyStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* Indicates when the IAM access key was created.
*
*
* Uses the date-time format specified in RFC
* 3339 section 5.6, Internet Date/Time Format. The value cannot contain spaces, and date and time should be
* separated by T. For example, 2020-03-22T13:22:13.933Z.
*
*
* @return Indicates when the IAM access key was created.
*
* Uses the date-time format specified in RFC 3339 section 5.6, Internet Date/Time
* Format. The value cannot contain spaces, and date and time should be separated by T. For
* example, 2020-03-22T13:22:13.933Z.
*/
public final String createdAt() {
return createdAt;
}
/**
*
* The ID of the principal associated with an access key.
*
*
* @return The ID of the principal associated with an access key.
*/
public final String principalId() {
return principalId;
}
/**
*
* The type of principal associated with an access key.
*
*
* @return The type of principal associated with an access key.
*/
public final String principalType() {
return principalType;
}
/**
*
* The name of the principal.
*
*
* @return The name of the principal.
*/
public final String principalName() {
return principalName;
}
/**
*
* The Amazon Web Services account ID of the account for the key.
*
*
* @return The Amazon Web Services account ID of the account for the key.
*/
public final String accountId() {
return accountId;
}
/**
*
* The identifier of the access key.
*
*
* @return The identifier of the access key.
*/
public final String accessKeyId() {
return accessKeyId;
}
/**
*
* Information about the session that the key was used for.
*
*
* @return Information about the session that the key was used for.
*/
public final AwsIamAccessKeySessionContext sessionContext() {
return sessionContext;
}
@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(userName());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(createdAt());
hashCode = 31 * hashCode + Objects.hashCode(principalId());
hashCode = 31 * hashCode + Objects.hashCode(principalType());
hashCode = 31 * hashCode + Objects.hashCode(principalName());
hashCode = 31 * hashCode + Objects.hashCode(accountId());
hashCode = 31 * hashCode + Objects.hashCode(accessKeyId());
hashCode = 31 * hashCode + Objects.hashCode(sessionContext());
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 AwsIamAccessKeyDetails)) {
return false;
}
AwsIamAccessKeyDetails other = (AwsIamAccessKeyDetails) obj;
return Objects.equals(userName(), other.userName()) && Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(createdAt(), other.createdAt()) && Objects.equals(principalId(), other.principalId())
&& Objects.equals(principalType(), other.principalType())
&& Objects.equals(principalName(), other.principalName()) && Objects.equals(accountId(), other.accountId())
&& Objects.equals(accessKeyId(), other.accessKeyId()) && Objects.equals(sessionContext(), other.sessionContext());
}
/**
* 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("AwsIamAccessKeyDetails").add("UserName", userName()).add("Status", statusAsString())
.add("CreatedAt", createdAt()).add("PrincipalId", principalId()).add("PrincipalType", principalType())
.add("PrincipalName", principalName()).add("AccountId", accountId()).add("AccessKeyId", accessKeyId())
.add("SessionContext", sessionContext()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "UserName":
return Optional.ofNullable(clazz.cast(userName()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "CreatedAt":
return Optional.ofNullable(clazz.cast(createdAt()));
case "PrincipalId":
return Optional.ofNullable(clazz.cast(principalId()));
case "PrincipalType":
return Optional.ofNullable(clazz.cast(principalType()));
case "PrincipalName":
return Optional.ofNullable(clazz.cast(principalName()));
case "AccountId":
return Optional.ofNullable(clazz.cast(accountId()));
case "AccessKeyId":
return Optional.ofNullable(clazz.cast(accessKeyId()));
case "SessionContext":
return Optional.ofNullable(clazz.cast(sessionContext()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function