
software.amazon.awssdk.services.ssm.model.ParameterMetadata 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.ssm.model;
import java.io.Serializable;
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.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;
/**
*
* Metadata includes information like the ARN of the last user and the date/time the parameter was last used.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ParameterMetadata implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(ParameterMetadata::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField TYPE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Type")
.getter(getter(ParameterMetadata::typeAsString)).setter(setter(Builder::type))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Type").build()).build();
private static final SdkField KEY_ID_FIELD = SdkField. builder(MarshallingType.STRING).memberName("KeyId")
.getter(getter(ParameterMetadata::keyId)).setter(setter(Builder::keyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("KeyId").build()).build();
private static final SdkField LAST_MODIFIED_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("LastModifiedDate").getter(getter(ParameterMetadata::lastModifiedDate))
.setter(setter(Builder::lastModifiedDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastModifiedDate").build()).build();
private static final SdkField LAST_MODIFIED_USER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("LastModifiedUser").getter(getter(ParameterMetadata::lastModifiedUser))
.setter(setter(Builder::lastModifiedUser))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastModifiedUser").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(ParameterMetadata::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField ALLOWED_PATTERN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("AllowedPattern").getter(getter(ParameterMetadata::allowedPattern))
.setter(setter(Builder::allowedPattern))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AllowedPattern").build()).build();
private static final SdkField VERSION_FIELD = SdkField. builder(MarshallingType.LONG).memberName("Version")
.getter(getter(ParameterMetadata::version)).setter(setter(Builder::version))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Version").build()).build();
private static final SdkField TIER_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Tier")
.getter(getter(ParameterMetadata::tierAsString)).setter(setter(Builder::tier))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tier").build()).build();
private static final SdkField> POLICIES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("Policies")
.getter(getter(ParameterMetadata::policies))
.setter(setter(Builder::policies))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Policies").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ParameterInlinePolicy::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField DATA_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DataType").getter(getter(ParameterMetadata::dataType)).setter(setter(Builder::dataType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DataType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, TYPE_FIELD,
KEY_ID_FIELD, LAST_MODIFIED_DATE_FIELD, LAST_MODIFIED_USER_FIELD, DESCRIPTION_FIELD, ALLOWED_PATTERN_FIELD,
VERSION_FIELD, TIER_FIELD, POLICIES_FIELD, DATA_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String type;
private final String keyId;
private final Instant lastModifiedDate;
private final String lastModifiedUser;
private final String description;
private final String allowedPattern;
private final Long version;
private final String tier;
private final List policies;
private final String dataType;
private ParameterMetadata(BuilderImpl builder) {
this.name = builder.name;
this.type = builder.type;
this.keyId = builder.keyId;
this.lastModifiedDate = builder.lastModifiedDate;
this.lastModifiedUser = builder.lastModifiedUser;
this.description = builder.description;
this.allowedPattern = builder.allowedPattern;
this.version = builder.version;
this.tier = builder.tier;
this.policies = builder.policies;
this.dataType = builder.dataType;
}
/**
*
* The parameter name.
*
*
* @return The parameter name.
*/
public String name() {
return name;
}
/**
*
* The type of parameter. Valid parameter types include the following: String
, StringList
,
* and SecureString
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ParameterType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of parameter. Valid parameter types include the following: String
,
* StringList
, and SecureString
.
* @see ParameterType
*/
public ParameterType type() {
return ParameterType.fromValue(type);
}
/**
*
* The type of parameter. Valid parameter types include the following: String
, StringList
,
* and SecureString
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #type} will return
* {@link ParameterType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #typeAsString}.
*
*
* @return The type of parameter. Valid parameter types include the following: String
,
* StringList
, and SecureString
.
* @see ParameterType
*/
public String typeAsString() {
return type;
}
/**
*
* The ID of the query key used for this parameter.
*
*
* @return The ID of the query key used for this parameter.
*/
public String keyId() {
return keyId;
}
/**
*
* Date the parameter was last changed or updated.
*
*
* @return Date the parameter was last changed or updated.
*/
public Instant lastModifiedDate() {
return lastModifiedDate;
}
/**
*
* Amazon Resource Name (ARN) of the AWS user who last changed the parameter.
*
*
* @return Amazon Resource Name (ARN) of the AWS user who last changed the parameter.
*/
public String lastModifiedUser() {
return lastModifiedUser;
}
/**
*
* Description of the parameter actions.
*
*
* @return Description of the parameter actions.
*/
public String description() {
return description;
}
/**
*
* A parameter name can include only the following letters and symbols.
*
*
* a-zA-Z0-9_.-
*
*
* @return A parameter name can include only the following letters and symbols.
*
* a-zA-Z0-9_.-
*/
public String allowedPattern() {
return allowedPattern;
}
/**
*
* The parameter version.
*
*
* @return The parameter version.
*/
public Long version() {
return version;
}
/**
*
* The parameter tier.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #tier} will return
* {@link ParameterTier#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #tierAsString}.
*
*
* @return The parameter tier.
* @see ParameterTier
*/
public ParameterTier tier() {
return ParameterTier.fromValue(tier);
}
/**
*
* The parameter tier.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #tier} will return
* {@link ParameterTier#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #tierAsString}.
*
*
* @return The parameter tier.
* @see ParameterTier
*/
public String tierAsString() {
return tier;
}
/**
* Returns true if the Policies property was specified by the sender (it may be empty), or false if the sender did
* not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service.
*/
public boolean hasPolicies() {
return policies != null && !(policies instanceof SdkAutoConstructList);
}
/**
*
* A list of policies associated with a parameter.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasPolicies()} to see if a value was sent in this field.
*
*
* @return A list of policies associated with a parameter.
*/
public List policies() {
return policies;
}
/**
*
* The data type of the parameter, such as text
or aws:ec2:image
. The default is
* text
.
*
*
* @return The data type of the parameter, such as text
or aws:ec2:image
. The default is
* text
.
*/
public String dataType() {
return dataType;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(typeAsString());
hashCode = 31 * hashCode + Objects.hashCode(keyId());
hashCode = 31 * hashCode + Objects.hashCode(lastModifiedDate());
hashCode = 31 * hashCode + Objects.hashCode(lastModifiedUser());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(allowedPattern());
hashCode = 31 * hashCode + Objects.hashCode(version());
hashCode = 31 * hashCode + Objects.hashCode(tierAsString());
hashCode = 31 * hashCode + Objects.hashCode(policies());
hashCode = 31 * hashCode + Objects.hashCode(dataType());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ParameterMetadata)) {
return false;
}
ParameterMetadata other = (ParameterMetadata) obj;
return Objects.equals(name(), other.name()) && Objects.equals(typeAsString(), other.typeAsString())
&& Objects.equals(keyId(), other.keyId()) && Objects.equals(lastModifiedDate(), other.lastModifiedDate())
&& Objects.equals(lastModifiedUser(), other.lastModifiedUser())
&& Objects.equals(description(), other.description()) && Objects.equals(allowedPattern(), other.allowedPattern())
&& Objects.equals(version(), other.version()) && Objects.equals(tierAsString(), other.tierAsString())
&& Objects.equals(policies(), other.policies()) && Objects.equals(dataType(), other.dataType());
}
/**
* 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 String toString() {
return ToString.builder("ParameterMetadata").add("Name", name()).add("Type", typeAsString()).add("KeyId", keyId())
.add("LastModifiedDate", lastModifiedDate()).add("LastModifiedUser", lastModifiedUser())
.add("Description", description()).add("AllowedPattern", allowedPattern()).add("Version", version())
.add("Tier", tierAsString()).add("Policies", policies()).add("DataType", dataType()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Type":
return Optional.ofNullable(clazz.cast(typeAsString()));
case "KeyId":
return Optional.ofNullable(clazz.cast(keyId()));
case "LastModifiedDate":
return Optional.ofNullable(clazz.cast(lastModifiedDate()));
case "LastModifiedUser":
return Optional.ofNullable(clazz.cast(lastModifiedUser()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "AllowedPattern":
return Optional.ofNullable(clazz.cast(allowedPattern()));
case "Version":
return Optional.ofNullable(clazz.cast(version()));
case "Tier":
return Optional.ofNullable(clazz.cast(tierAsString()));
case "Policies":
return Optional.ofNullable(clazz.cast(policies()));
case "DataType":
return Optional.ofNullable(clazz.cast(dataType()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function