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

software.amazon.awssdk.services.redshift.model.SnapshotSchedule Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon Redshift module holds the client classes that are used for communicating with Amazon Redshift Service

There is a newer version: 2.29.15
Show newest version
/*
 * 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.redshift.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 a snapshot schedule. You can set a regular interval for creating snapshots of a cluster. You can also * schedule snapshots for specific dates. *

*/ @Generated("software.amazon.awssdk:codegen") public final class SnapshotSchedule implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> SCHEDULE_DEFINITIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("ScheduleDefinitions") .getter(getter(SnapshotSchedule::scheduleDefinitions)) .setter(setter(Builder::scheduleDefinitions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleDefinitions").build(), ListTrait .builder() .memberLocationName("ScheduleDefinition") .memberFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("ScheduleDefinition").build()).build()).build()).build(); private static final SdkField SCHEDULE_IDENTIFIER_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ScheduleIdentifier").getter(getter(SnapshotSchedule::scheduleIdentifier)) .setter(setter(Builder::scheduleIdentifier)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleIdentifier").build()) .build(); private static final SdkField SCHEDULE_DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ScheduleDescription").getter(getter(SnapshotSchedule::scheduleDescription)) .setter(setter(Builder::scheduleDescription)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScheduleDescription").build()) .build(); private static final SdkField> TAGS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Tags") .getter(getter(SnapshotSchedule::tags)) .setter(setter(Builder::tags)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(), ListTrait .builder() .memberLocationName("Tag") .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Tag::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("Tag").build()).build()).build()).build(); private static final SdkField> NEXT_INVOCATIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("NextInvocations") .getter(getter(SnapshotSchedule::nextInvocations)) .setter(setter(Builder::nextInvocations)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NextInvocations").build(), ListTrait .builder() .memberLocationName("SnapshotTime") .memberFieldInfo( SdkField. builder(MarshallingType.INSTANT) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("SnapshotTime").build()).build()).build()).build(); private static final SdkField ASSOCIATED_CLUSTER_COUNT_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("AssociatedClusterCount").getter(getter(SnapshotSchedule::associatedClusterCount)) .setter(setter(Builder::associatedClusterCount)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociatedClusterCount").build()) .build(); private static final SdkField> ASSOCIATED_CLUSTERS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("AssociatedClusters") .getter(getter(SnapshotSchedule::associatedClusters)) .setter(setter(Builder::associatedClusters)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AssociatedClusters").build(), ListTrait .builder() .memberLocationName("ClusterAssociatedToSchedule") .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(ClusterAssociatedToSchedule::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("ClusterAssociatedToSchedule").build()).build()).build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SCHEDULE_DEFINITIONS_FIELD, SCHEDULE_IDENTIFIER_FIELD, SCHEDULE_DESCRIPTION_FIELD, TAGS_FIELD, NEXT_INVOCATIONS_FIELD, ASSOCIATED_CLUSTER_COUNT_FIELD, ASSOCIATED_CLUSTERS_FIELD)); private static final long serialVersionUID = 1L; private final List scheduleDefinitions; private final String scheduleIdentifier; private final String scheduleDescription; private final List tags; private final List nextInvocations; private final Integer associatedClusterCount; private final List associatedClusters; private SnapshotSchedule(BuilderImpl builder) { this.scheduleDefinitions = builder.scheduleDefinitions; this.scheduleIdentifier = builder.scheduleIdentifier; this.scheduleDescription = builder.scheduleDescription; this.tags = builder.tags; this.nextInvocations = builder.nextInvocations; this.associatedClusterCount = builder.associatedClusterCount; this.associatedClusters = builder.associatedClusters; } /** * Returns true if the ScheduleDefinitions 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 final boolean hasScheduleDefinitions() { return scheduleDefinitions != null && !(scheduleDefinitions instanceof SdkAutoConstructList); } /** *

* A list of ScheduleDefinitions. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasScheduleDefinitions()} to see if a value was sent in this field. *

* * @return A list of ScheduleDefinitions. */ public final List scheduleDefinitions() { return scheduleDefinitions; } /** *

* A unique identifier for the schedule. *

* * @return A unique identifier for the schedule. */ public final String scheduleIdentifier() { return scheduleIdentifier; } /** *

* The description of the schedule. *

* * @return The description of the schedule. */ public final String scheduleDescription() { return scheduleDescription; } /** * Returns true if the Tags 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 final boolean hasTags() { return tags != null && !(tags instanceof SdkAutoConstructList); } /** *

* An optional set of tags describing the schedule. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasTags()} to see if a value was sent in this field. *

* * @return An optional set of tags describing the schedule. */ public final List tags() { return tags; } /** * Returns true if the NextInvocations 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 final boolean hasNextInvocations() { return nextInvocations != null && !(nextInvocations instanceof SdkAutoConstructList); } /** *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasNextInvocations()} to see if a value was sent in this field. *

* * @return */ public final List nextInvocations() { return nextInvocations; } /** *

* The number of clusters associated with the schedule. *

* * @return The number of clusters associated with the schedule. */ public final Integer associatedClusterCount() { return associatedClusterCount; } /** * Returns true if the AssociatedClusters 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 final boolean hasAssociatedClusters() { return associatedClusters != null && !(associatedClusters instanceof SdkAutoConstructList); } /** *

* A list of clusters associated with the schedule. A maximum of 100 clusters is returned. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasAssociatedClusters()} to see if a value was sent in this field. *

* * @return A list of clusters associated with the schedule. A maximum of 100 clusters is returned. */ public final List associatedClusters() { return associatedClusters; } @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(hasScheduleDefinitions() ? scheduleDefinitions() : null); hashCode = 31 * hashCode + Objects.hashCode(scheduleIdentifier()); hashCode = 31 * hashCode + Objects.hashCode(scheduleDescription()); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null); hashCode = 31 * hashCode + Objects.hashCode(hasNextInvocations() ? nextInvocations() : null); hashCode = 31 * hashCode + Objects.hashCode(associatedClusterCount()); hashCode = 31 * hashCode + Objects.hashCode(hasAssociatedClusters() ? associatedClusters() : 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 SnapshotSchedule)) { return false; } SnapshotSchedule other = (SnapshotSchedule) obj; return hasScheduleDefinitions() == other.hasScheduleDefinitions() && Objects.equals(scheduleDefinitions(), other.scheduleDefinitions()) && Objects.equals(scheduleIdentifier(), other.scheduleIdentifier()) && Objects.equals(scheduleDescription(), other.scheduleDescription()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()) && hasNextInvocations() == other.hasNextInvocations() && Objects.equals(nextInvocations(), other.nextInvocations()) && Objects.equals(associatedClusterCount(), other.associatedClusterCount()) && hasAssociatedClusters() == other.hasAssociatedClusters() && Objects.equals(associatedClusters(), other.associatedClusters()); } /** * 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("SnapshotSchedule") .add("ScheduleDefinitions", hasScheduleDefinitions() ? scheduleDefinitions() : null) .add("ScheduleIdentifier", scheduleIdentifier()).add("ScheduleDescription", scheduleDescription()) .add("Tags", hasTags() ? tags() : null).add("NextInvocations", hasNextInvocations() ? nextInvocations() : null) .add("AssociatedClusterCount", associatedClusterCount()) .add("AssociatedClusters", hasAssociatedClusters() ? associatedClusters() : null).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ScheduleDefinitions": return Optional.ofNullable(clazz.cast(scheduleDefinitions())); case "ScheduleIdentifier": return Optional.ofNullable(clazz.cast(scheduleIdentifier())); case "ScheduleDescription": return Optional.ofNullable(clazz.cast(scheduleDescription())); case "Tags": return Optional.ofNullable(clazz.cast(tags())); case "NextInvocations": return Optional.ofNullable(clazz.cast(nextInvocations())); case "AssociatedClusterCount": return Optional.ofNullable(clazz.cast(associatedClusterCount())); case "AssociatedClusters": return Optional.ofNullable(clazz.cast(associatedClusters())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((SnapshotSchedule) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* A list of ScheduleDefinitions. *

* * @param scheduleDefinitions * A list of ScheduleDefinitions. * @return Returns a reference to this object so that method calls can be chained together. */ Builder scheduleDefinitions(Collection scheduleDefinitions); /** *

* A list of ScheduleDefinitions. *

* * @param scheduleDefinitions * A list of ScheduleDefinitions. * @return Returns a reference to this object so that method calls can be chained together. */ Builder scheduleDefinitions(String... scheduleDefinitions); /** *

* A unique identifier for the schedule. *

* * @param scheduleIdentifier * A unique identifier for the schedule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder scheduleIdentifier(String scheduleIdentifier); /** *

* The description of the schedule. *

* * @param scheduleDescription * The description of the schedule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder scheduleDescription(String scheduleDescription); /** *

* An optional set of tags describing the schedule. *

* * @param tags * An optional set of tags describing the schedule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Collection tags); /** *

* An optional set of tags describing the schedule. *

* * @param tags * An optional set of tags describing the schedule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

* An optional set of tags describing the schedule. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the need to create * one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately and its result * is passed to {@link #tags(List)}. * * @param tags * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tags(List) */ Builder tags(Consumer... tags); /** *

* * @param nextInvocations * @return Returns a reference to this object so that method calls can be chained together. */ Builder nextInvocations(Collection nextInvocations); /** *

* * @param nextInvocations * @return Returns a reference to this object so that method calls can be chained together. */ Builder nextInvocations(Instant... nextInvocations); /** *

* The number of clusters associated with the schedule. *

* * @param associatedClusterCount * The number of clusters associated with the schedule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder associatedClusterCount(Integer associatedClusterCount); /** *

* A list of clusters associated with the schedule. A maximum of 100 clusters is returned. *

* * @param associatedClusters * A list of clusters associated with the schedule. A maximum of 100 clusters is returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder associatedClusters(Collection associatedClusters); /** *

* A list of clusters associated with the schedule. A maximum of 100 clusters is returned. *

* * @param associatedClusters * A list of clusters associated with the schedule. A maximum of 100 clusters is returned. * @return Returns a reference to this object so that method calls can be chained together. */ Builder associatedClusters(ClusterAssociatedToSchedule... associatedClusters); /** *

* A list of clusters associated with the schedule. A maximum of 100 clusters is returned. *

* This is a convenience that creates an instance of the {@link List.Builder} * avoiding the need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called * immediately and its result is passed to {@link #associatedClusters(List)}. * * @param associatedClusters * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #associatedClusters(List) */ Builder associatedClusters(Consumer... associatedClusters); } static final class BuilderImpl implements Builder { private List scheduleDefinitions = DefaultSdkAutoConstructList.getInstance(); private String scheduleIdentifier; private String scheduleDescription; private List tags = DefaultSdkAutoConstructList.getInstance(); private List nextInvocations = DefaultSdkAutoConstructList.getInstance(); private Integer associatedClusterCount; private List associatedClusters = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(SnapshotSchedule model) { scheduleDefinitions(model.scheduleDefinitions); scheduleIdentifier(model.scheduleIdentifier); scheduleDescription(model.scheduleDescription); tags(model.tags); nextInvocations(model.nextInvocations); associatedClusterCount(model.associatedClusterCount); associatedClusters(model.associatedClusters); } public final Collection getScheduleDefinitions() { if (scheduleDefinitions instanceof SdkAutoConstructList) { return null; } return scheduleDefinitions; } @Override public final Builder scheduleDefinitions(Collection scheduleDefinitions) { this.scheduleDefinitions = ScheduleDefinitionListCopier.copy(scheduleDefinitions); return this; } @Override @SafeVarargs public final Builder scheduleDefinitions(String... scheduleDefinitions) { scheduleDefinitions(Arrays.asList(scheduleDefinitions)); return this; } public final void setScheduleDefinitions(Collection scheduleDefinitions) { this.scheduleDefinitions = ScheduleDefinitionListCopier.copy(scheduleDefinitions); } public final String getScheduleIdentifier() { return scheduleIdentifier; } @Override public final Builder scheduleIdentifier(String scheduleIdentifier) { this.scheduleIdentifier = scheduleIdentifier; return this; } public final void setScheduleIdentifier(String scheduleIdentifier) { this.scheduleIdentifier = scheduleIdentifier; } public final String getScheduleDescription() { return scheduleDescription; } @Override public final Builder scheduleDescription(String scheduleDescription) { this.scheduleDescription = scheduleDescription; return this; } public final void setScheduleDescription(String scheduleDescription) { this.scheduleDescription = scheduleDescription; } public final Collection getTags() { if (tags instanceof SdkAutoConstructList) { return null; } return tags != null ? tags.stream().map(Tag::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder tags(Collection tags) { this.tags = TagListCopier.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; } public final void setTags(Collection tags) { this.tags = TagListCopier.copyFromBuilder(tags); } public final Collection getNextInvocations() { if (nextInvocations instanceof SdkAutoConstructList) { return null; } return nextInvocations; } @Override public final Builder nextInvocations(Collection nextInvocations) { this.nextInvocations = ScheduledSnapshotTimeListCopier.copy(nextInvocations); return this; } @Override @SafeVarargs public final Builder nextInvocations(Instant... nextInvocations) { nextInvocations(Arrays.asList(nextInvocations)); return this; } public final void setNextInvocations(Collection nextInvocations) { this.nextInvocations = ScheduledSnapshotTimeListCopier.copy(nextInvocations); } public final Integer getAssociatedClusterCount() { return associatedClusterCount; } @Override public final Builder associatedClusterCount(Integer associatedClusterCount) { this.associatedClusterCount = associatedClusterCount; return this; } public final void setAssociatedClusterCount(Integer associatedClusterCount) { this.associatedClusterCount = associatedClusterCount; } public final Collection getAssociatedClusters() { if (associatedClusters instanceof SdkAutoConstructList) { return null; } return associatedClusters != null ? associatedClusters.stream().map(ClusterAssociatedToSchedule::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder associatedClusters(Collection associatedClusters) { this.associatedClusters = AssociatedClusterListCopier.copy(associatedClusters); return this; } @Override @SafeVarargs public final Builder associatedClusters(ClusterAssociatedToSchedule... associatedClusters) { associatedClusters(Arrays.asList(associatedClusters)); return this; } @Override @SafeVarargs public final Builder associatedClusters(Consumer... associatedClusters) { associatedClusters(Stream.of(associatedClusters) .map(c -> ClusterAssociatedToSchedule.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final void setAssociatedClusters(Collection associatedClusters) { this.associatedClusters = AssociatedClusterListCopier.copyFromBuilder(associatedClusters); } @Override public SnapshotSchedule build() { return new SnapshotSchedule(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy