
software.amazon.awssdk.services.ssm.model.Association 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;
/**
*
* Describes an association of a Systems Manager document and an instance.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Association implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Association::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField INSTANCE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Association::instanceId)).setter(setter(Builder::instanceId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("InstanceId").build()).build();
private static final SdkField ASSOCIATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Association::associationId)).setter(setter(Builder::associationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociationId").build()).build();
private static final SdkField ASSOCIATION_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Association::associationVersion)).setter(setter(Builder::associationVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociationVersion").build())
.build();
private static final SdkField DOCUMENT_VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Association::documentVersion)).setter(setter(Builder::documentVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DocumentVersion").build()).build();
private static final SdkField> TARGETS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.getter(getter(Association::targets))
.setter(setter(Builder::targets))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Targets").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(Target::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField LAST_EXECUTION_DATE_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(Association::lastExecutionDate)).setter(setter(Builder::lastExecutionDate))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastExecutionDate").build()).build();
private static final SdkField OVERVIEW_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).getter(getter(Association::overview))
.setter(setter(Builder::overview)).constructor(AssociationOverview::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Overview").build()).build();
private static final SdkField SCHEDULE_EXPRESSION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Association::scheduleExpression)).setter(setter(Builder::scheduleExpression))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleExpression").build())
.build();
private static final SdkField ASSOCIATION_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Association::associationName)).setter(setter(Builder::associationName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociationName").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, INSTANCE_ID_FIELD,
ASSOCIATION_ID_FIELD, ASSOCIATION_VERSION_FIELD, DOCUMENT_VERSION_FIELD, TARGETS_FIELD, LAST_EXECUTION_DATE_FIELD,
OVERVIEW_FIELD, SCHEDULE_EXPRESSION_FIELD, ASSOCIATION_NAME_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String instanceId;
private final String associationId;
private final String associationVersion;
private final String documentVersion;
private final List targets;
private final Instant lastExecutionDate;
private final AssociationOverview overview;
private final String scheduleExpression;
private final String associationName;
private Association(BuilderImpl builder) {
this.name = builder.name;
this.instanceId = builder.instanceId;
this.associationId = builder.associationId;
this.associationVersion = builder.associationVersion;
this.documentVersion = builder.documentVersion;
this.targets = builder.targets;
this.lastExecutionDate = builder.lastExecutionDate;
this.overview = builder.overview;
this.scheduleExpression = builder.scheduleExpression;
this.associationName = builder.associationName;
}
/**
*
* The name of the Systems Manager document.
*
*
* @return The name of the Systems Manager document.
*/
public String name() {
return name;
}
/**
*
* The ID of the instance.
*
*
* @return The ID of the instance.
*/
public String instanceId() {
return instanceId;
}
/**
*
* The ID created by the system when you create an association. An association is a binding between a document and a
* set of targets with a schedule.
*
*
* @return The ID created by the system when you create an association. An association is a binding between a
* document and a set of targets with a schedule.
*/
public String associationId() {
return associationId;
}
/**
*
* The association version.
*
*
* @return The association version.
*/
public String associationVersion() {
return associationVersion;
}
/**
*
* The version of the document used in the association.
*
*
* @return The version of the document used in the association.
*/
public String documentVersion() {
return documentVersion;
}
/**
* Returns true if the Targets 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 hasTargets() {
return targets != null && !(targets instanceof SdkAutoConstructList);
}
/**
*
* The instances targeted by the request to create an association.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasTargets()} to see if a value was sent in this field.
*
*
* @return The instances targeted by the request to create an association.
*/
public List targets() {
return targets;
}
/**
*
* The date on which the association was last run.
*
*
* @return The date on which the association was last run.
*/
public Instant lastExecutionDate() {
return lastExecutionDate;
}
/**
*
* Information about the association.
*
*
* @return Information about the association.
*/
public AssociationOverview overview() {
return overview;
}
/**
*
* A cron expression that specifies a schedule when the association runs.
*
*
* @return A cron expression that specifies a schedule when the association runs.
*/
public String scheduleExpression() {
return scheduleExpression;
}
/**
*
* The association name.
*
*
* @return The association name.
*/
public String associationName() {
return associationName;
}
@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(instanceId());
hashCode = 31 * hashCode + Objects.hashCode(associationId());
hashCode = 31 * hashCode + Objects.hashCode(associationVersion());
hashCode = 31 * hashCode + Objects.hashCode(documentVersion());
hashCode = 31 * hashCode + Objects.hashCode(targets());
hashCode = 31 * hashCode + Objects.hashCode(lastExecutionDate());
hashCode = 31 * hashCode + Objects.hashCode(overview());
hashCode = 31 * hashCode + Objects.hashCode(scheduleExpression());
hashCode = 31 * hashCode + Objects.hashCode(associationName());
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 Association)) {
return false;
}
Association other = (Association) obj;
return Objects.equals(name(), other.name()) && Objects.equals(instanceId(), other.instanceId())
&& Objects.equals(associationId(), other.associationId())
&& Objects.equals(associationVersion(), other.associationVersion())
&& Objects.equals(documentVersion(), other.documentVersion()) && Objects.equals(targets(), other.targets())
&& Objects.equals(lastExecutionDate(), other.lastExecutionDate()) && Objects.equals(overview(), other.overview())
&& Objects.equals(scheduleExpression(), other.scheduleExpression())
&& Objects.equals(associationName(), other.associationName());
}
/**
* 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("Association").add("Name", name()).add("InstanceId", instanceId())
.add("AssociationId", associationId()).add("AssociationVersion", associationVersion())
.add("DocumentVersion", documentVersion()).add("Targets", targets())
.add("LastExecutionDate", lastExecutionDate()).add("Overview", overview())
.add("ScheduleExpression", scheduleExpression()).add("AssociationName", associationName()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "InstanceId":
return Optional.ofNullable(clazz.cast(instanceId()));
case "AssociationId":
return Optional.ofNullable(clazz.cast(associationId()));
case "AssociationVersion":
return Optional.ofNullable(clazz.cast(associationVersion()));
case "DocumentVersion":
return Optional.ofNullable(clazz.cast(documentVersion()));
case "Targets":
return Optional.ofNullable(clazz.cast(targets()));
case "LastExecutionDate":
return Optional.ofNullable(clazz.cast(lastExecutionDate()));
case "Overview":
return Optional.ofNullable(clazz.cast(overview()));
case "ScheduleExpression":
return Optional.ofNullable(clazz.cast(scheduleExpression()));
case "AssociationName":
return Optional.ofNullable(clazz.cast(associationName()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function