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

software.amazon.awssdk.services.s3.model.LifecycleRule Maven / Gradle / Ivy

Go to download

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

There is a newer version: 2.29.39
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.s3.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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.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.traits.RequiredTrait;
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;

/**
 * 

* A lifecycle rule for individual objects in an Amazon S3 bucket. *

*

* For more information see, Managing your storage * lifecycle in the Amazon S3 User Guide. *

*/ @Generated("software.amazon.awssdk:codegen") public final class LifecycleRule implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField EXPIRATION_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("Expiration") .getter(getter(LifecycleRule::expiration)) .setter(setter(Builder::expiration)) .constructor(LifecycleExpiration::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Expiration") .unmarshallLocationName("Expiration").build()).build(); private static final SdkField ID_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("ID") .getter(getter(LifecycleRule::id)) .setter(setter(Builder::id)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ID").unmarshallLocationName("ID") .build()).build(); private static final SdkField PREFIX_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("Prefix") .getter(getter(LifecycleRule::prefix)) .setter(setter(Builder::prefix)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Prefix") .unmarshallLocationName("Prefix").build()).build(); private static final SdkField FILTER_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("Filter") .getter(getter(LifecycleRule::filter)) .setter(setter(Builder::filter)) .constructor(LifecycleRuleFilter::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Filter") .unmarshallLocationName("Filter").build()).build(); private static final SdkField STATUS_FIELD = SdkField . builder(MarshallingType.STRING) .memberName("Status") .getter(getter(LifecycleRule::statusAsString)) .setter(setter(Builder::status)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status") .unmarshallLocationName("Status").build(), RequiredTrait.create()).build(); private static final SdkField> TRANSITIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("Transitions") .getter(getter(LifecycleRule::transitions)) .setter(setter(Builder::transitions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Transition") .unmarshallLocationName("Transition").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Transition::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").unmarshallLocationName("member").build()).build()) .isFlattened(true).build()).build(); private static final SdkField> NONCURRENT_VERSION_TRANSITIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("NoncurrentVersionTransitions") .getter(getter(LifecycleRule::noncurrentVersionTransitions)) .setter(setter(Builder::noncurrentVersionTransitions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NoncurrentVersionTransition") .unmarshallLocationName("NoncurrentVersionTransition").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(NoncurrentVersionTransition::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").unmarshallLocationName("member").build()).build()) .isFlattened(true).build()).build(); private static final SdkField NONCURRENT_VERSION_EXPIRATION_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("NoncurrentVersionExpiration") .getter(getter(LifecycleRule::noncurrentVersionExpiration)) .setter(setter(Builder::noncurrentVersionExpiration)) .constructor(NoncurrentVersionExpiration::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NoncurrentVersionExpiration") .unmarshallLocationName("NoncurrentVersionExpiration").build()).build(); private static final SdkField ABORT_INCOMPLETE_MULTIPART_UPLOAD_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("AbortIncompleteMultipartUpload") .getter(getter(LifecycleRule::abortIncompleteMultipartUpload)) .setter(setter(Builder::abortIncompleteMultipartUpload)) .constructor(AbortIncompleteMultipartUpload::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AbortIncompleteMultipartUpload") .unmarshallLocationName("AbortIncompleteMultipartUpload").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(EXPIRATION_FIELD, ID_FIELD, PREFIX_FIELD, FILTER_FIELD, STATUS_FIELD, TRANSITIONS_FIELD, NONCURRENT_VERSION_TRANSITIONS_FIELD, NONCURRENT_VERSION_EXPIRATION_FIELD, ABORT_INCOMPLETE_MULTIPART_UPLOAD_FIELD)); private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer(); private static final long serialVersionUID = 1L; private final LifecycleExpiration expiration; private final String id; private final String prefix; private final LifecycleRuleFilter filter; private final String status; private final List transitions; private final List noncurrentVersionTransitions; private final NoncurrentVersionExpiration noncurrentVersionExpiration; private final AbortIncompleteMultipartUpload abortIncompleteMultipartUpload; private LifecycleRule(BuilderImpl builder) { this.expiration = builder.expiration; this.id = builder.id; this.prefix = builder.prefix; this.filter = builder.filter; this.status = builder.status; this.transitions = builder.transitions; this.noncurrentVersionTransitions = builder.noncurrentVersionTransitions; this.noncurrentVersionExpiration = builder.noncurrentVersionExpiration; this.abortIncompleteMultipartUpload = builder.abortIncompleteMultipartUpload; } /** *

* Specifies the expiration for the lifecycle of the object in the form of date, days and, whether the object has a * delete marker. *

* * @return Specifies the expiration for the lifecycle of the object in the form of date, days and, whether the * object has a delete marker. */ public final LifecycleExpiration expiration() { return expiration; } /** *

* Unique identifier for the rule. The value cannot be longer than 255 characters. *

* * @return Unique identifier for the rule. The value cannot be longer than 255 characters. */ public final String id() { return id; } /** *

* Prefix identifying one or more objects to which the rule applies. This is no longer used; use Filter * instead. *

* *

* Replacement must be made for object keys containing special characters (such as carriage returns) when using XML * requests. For more information, see XML * related object key constraints. *

*
* * @return Prefix identifying one or more objects to which the rule applies. This is no longer used; use * Filter instead.

*

* Replacement must be made for object keys containing special characters (such as carriage returns) when * using XML requests. For more information, see XML related object key constraints. *

* @deprecated */ @Deprecated public final String prefix() { return prefix; } /** *

* The Filter is used to identify objects that a Lifecycle Rule applies to. A Filter must * have exactly one of Prefix, Tag, or And specified. Filter is * required if the LifecycleRule does not contain a Prefix element. *

* *

* Tag filters are not supported for directory buckets. *

*
* * @return The Filter is used to identify objects that a Lifecycle Rule applies to. A * Filter must have exactly one of Prefix, Tag, or And * specified. Filter is required if the LifecycleRule does not contain a * Prefix element.

*

* Tag filters are not supported for directory buckets. *

*/ public final LifecycleRuleFilter filter() { return filter; } /** *

* If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link ExpirationStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusAsString}. *

* * @return If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being * applied. * @see ExpirationStatus */ public final ExpirationStatus status() { return ExpirationStatus.fromValue(status); } /** *

* If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied. *

*

* If the service returns an enum value that is not available in the current SDK version, {@link #status} will * return {@link ExpirationStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #statusAsString}. *

* * @return If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being * applied. * @see ExpirationStatus */ public final String statusAsString() { return status; } /** * For responses, this returns true if the service returned a value for the Transitions 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 hasTransitions() { return transitions != null && !(transitions instanceof SdkAutoConstructList); } /** *

* Specifies when an Amazon S3 object transitions to a specified storage class. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
*

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

* * @return Specifies when an Amazon S3 object transitions to a specified storage class.

*

* This parameter applies to general purpose buckets only. It is not supported for directory bucket * lifecycle configurations. *

*/ public final List transitions() { return transitions; } /** * For responses, this returns true if the service returned a value for the NoncurrentVersionTransitions 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 hasNoncurrentVersionTransitions() { return noncurrentVersionTransitions != null && !(noncurrentVersionTransitions instanceof SdkAutoConstructList); } /** *

* Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition to a * specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set this * action to request that Amazon S3 transition noncurrent object versions to a specific storage class at a set * period in the object's lifetime. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
*

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

* * @return Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition to * a specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set * this action to request that Amazon S3 transition noncurrent object versions to a specific storage class * at a set period in the object's lifetime.

*

* This parameter applies to general purpose buckets only. It is not supported for directory bucket * lifecycle configurations. *

*/ public final List noncurrentVersionTransitions() { return noncurrentVersionTransitions; } /** * Returns the value of the NoncurrentVersionExpiration property for this object. * * @return The value of the NoncurrentVersionExpiration property for this object. */ public final NoncurrentVersionExpiration noncurrentVersionExpiration() { return noncurrentVersionExpiration; } /** * Returns the value of the AbortIncompleteMultipartUpload property for this object. * * @return The value of the AbortIncompleteMultipartUpload property for this object. */ public final AbortIncompleteMultipartUpload abortIncompleteMultipartUpload() { return abortIncompleteMultipartUpload; } @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(expiration()); hashCode = 31 * hashCode + Objects.hashCode(id()); hashCode = 31 * hashCode + Objects.hashCode(prefix()); hashCode = 31 * hashCode + Objects.hashCode(filter()); hashCode = 31 * hashCode + Objects.hashCode(statusAsString()); hashCode = 31 * hashCode + Objects.hashCode(hasTransitions() ? transitions() : null); hashCode = 31 * hashCode + Objects.hashCode(hasNoncurrentVersionTransitions() ? noncurrentVersionTransitions() : null); hashCode = 31 * hashCode + Objects.hashCode(noncurrentVersionExpiration()); hashCode = 31 * hashCode + Objects.hashCode(abortIncompleteMultipartUpload()); 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 LifecycleRule)) { return false; } LifecycleRule other = (LifecycleRule) obj; return Objects.equals(expiration(), other.expiration()) && Objects.equals(id(), other.id()) && Objects.equals(prefix(), other.prefix()) && Objects.equals(filter(), other.filter()) && Objects.equals(statusAsString(), other.statusAsString()) && hasTransitions() == other.hasTransitions() && Objects.equals(transitions(), other.transitions()) && hasNoncurrentVersionTransitions() == other.hasNoncurrentVersionTransitions() && Objects.equals(noncurrentVersionTransitions(), other.noncurrentVersionTransitions()) && Objects.equals(noncurrentVersionExpiration(), other.noncurrentVersionExpiration()) && Objects.equals(abortIncompleteMultipartUpload(), other.abortIncompleteMultipartUpload()); } /** * 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("LifecycleRule").add("Expiration", expiration()).add("ID", id()).add("Prefix", prefix()) .add("Filter", filter()).add("Status", statusAsString()) .add("Transitions", hasTransitions() ? transitions() : null) .add("NoncurrentVersionTransitions", hasNoncurrentVersionTransitions() ? noncurrentVersionTransitions() : null) .add("NoncurrentVersionExpiration", noncurrentVersionExpiration()) .add("AbortIncompleteMultipartUpload", abortIncompleteMultipartUpload()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Expiration": return Optional.ofNullable(clazz.cast(expiration())); case "ID": return Optional.ofNullable(clazz.cast(id())); case "Prefix": return Optional.ofNullable(clazz.cast(prefix())); case "Filter": return Optional.ofNullable(clazz.cast(filter())); case "Status": return Optional.ofNullable(clazz.cast(statusAsString())); case "Transitions": return Optional.ofNullable(clazz.cast(transitions())); case "NoncurrentVersionTransitions": return Optional.ofNullable(clazz.cast(noncurrentVersionTransitions())); case "NoncurrentVersionExpiration": return Optional.ofNullable(clazz.cast(noncurrentVersionExpiration())); case "AbortIncompleteMultipartUpload": return Optional.ofNullable(clazz.cast(abortIncompleteMultipartUpload())); 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("Expiration", EXPIRATION_FIELD); map.put("ID", ID_FIELD); map.put("Prefix", PREFIX_FIELD); map.put("Filter", FILTER_FIELD); map.put("Status", STATUS_FIELD); map.put("Transition", TRANSITIONS_FIELD); map.put("NoncurrentVersionTransition", NONCURRENT_VERSION_TRANSITIONS_FIELD); map.put("NoncurrentVersionExpiration", NONCURRENT_VERSION_EXPIRATION_FIELD); map.put("AbortIncompleteMultipartUpload", ABORT_INCOMPLETE_MULTIPART_UPLOAD_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((LifecycleRule) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* Specifies the expiration for the lifecycle of the object in the form of date, days and, whether the object * has a delete marker. *

* * @param expiration * Specifies the expiration for the lifecycle of the object in the form of date, days and, whether the * object has a delete marker. * @return Returns a reference to this object so that method calls can be chained together. */ Builder expiration(LifecycleExpiration expiration); /** *

* Specifies the expiration for the lifecycle of the object in the form of date, days and, whether the object * has a delete marker. *

* This is a convenience method that creates an instance of the {@link LifecycleExpiration.Builder} avoiding the * need to create one manually via {@link LifecycleExpiration#builder()}. * *

* When the {@link Consumer} completes, {@link LifecycleExpiration.Builder#build()} is called immediately and * its result is passed to {@link #expiration(LifecycleExpiration)}. * * @param expiration * a consumer that will call methods on {@link LifecycleExpiration.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #expiration(LifecycleExpiration) */ default Builder expiration(Consumer expiration) { return expiration(LifecycleExpiration.builder().applyMutation(expiration).build()); } /** *

* Unique identifier for the rule. The value cannot be longer than 255 characters. *

* * @param id * Unique identifier for the rule. The value cannot be longer than 255 characters. * @return Returns a reference to this object so that method calls can be chained together. */ Builder id(String id); /** *

* Prefix identifying one or more objects to which the rule applies. This is no longer used; use * Filter instead. *

* *

* Replacement must be made for object keys containing special characters (such as carriage returns) when using * XML requests. For more information, see * XML related object key constraints. *

*
* * @param prefix * Prefix identifying one or more objects to which the rule applies. This is no longer used; use * Filter instead.

*

* Replacement must be made for object keys containing special characters (such as carriage returns) when * using XML requests. For more information, see XML related object key constraints. *

* @return Returns a reference to this object so that method calls can be chained together. * @deprecated */ @Deprecated Builder prefix(String prefix); /** *

* The Filter is used to identify objects that a Lifecycle Rule applies to. A Filter * must have exactly one of Prefix, Tag, or And specified. * Filter is required if the LifecycleRule does not contain a Prefix * element. *

* *

* Tag filters are not supported for directory buckets. *

*
* * @param filter * The Filter is used to identify objects that a Lifecycle Rule applies to. A * Filter must have exactly one of Prefix, Tag, or * And specified. Filter is required if the LifecycleRule does not * contain a Prefix element.

*

* Tag filters are not supported for directory buckets. *

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

* The Filter is used to identify objects that a Lifecycle Rule applies to. A Filter * must have exactly one of Prefix, Tag, or And specified. * Filter is required if the LifecycleRule does not contain a Prefix * element. *

* *

* Tag filters are not supported for directory buckets. *

*
This is a convenience method that creates an instance of the {@link LifecycleRuleFilter.Builder} * avoiding the need to create one manually via {@link LifecycleRuleFilter#builder()}. * *

* When the {@link Consumer} completes, {@link LifecycleRuleFilter.Builder#build()} is called immediately and * its result is passed to {@link #filter(LifecycleRuleFilter)}. * * @param filter * a consumer that will call methods on {@link LifecycleRuleFilter.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #filter(LifecycleRuleFilter) */ default Builder filter(Consumer filter) { return filter(LifecycleRuleFilter.builder().applyMutation(filter).build()); } /** *

* If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied. *

* * @param status * If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being * applied. * @see ExpirationStatus * @return Returns a reference to this object so that method calls can be chained together. * @see ExpirationStatus */ Builder status(String status); /** *

* If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied. *

* * @param status * If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being * applied. * @see ExpirationStatus * @return Returns a reference to this object so that method calls can be chained together. * @see ExpirationStatus */ Builder status(ExpirationStatus status); /** *

* Specifies when an Amazon S3 object transitions to a specified storage class. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
* * @param transitions * Specifies when an Amazon S3 object transitions to a specified storage class.

*

* This parameter applies to general purpose buckets only. It is not supported for directory bucket * lifecycle configurations. *

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

* Specifies when an Amazon S3 object transitions to a specified storage class. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
* * @param transitions * Specifies when an Amazon S3 object transitions to a specified storage class.

*

* This parameter applies to general purpose buckets only. It is not supported for directory bucket * lifecycle configurations. *

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

* Specifies when an Amazon S3 object transitions to a specified storage class. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.s3.model.Transition.Builder} avoiding the need to create one manually * via {@link software.amazon.awssdk.services.s3.model.Transition#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.s3.model.Transition.Builder#build()} is called immediately and its * result is passed to {@link #transitions(List)}. * * @param transitions * a consumer that will call methods on * {@link software.amazon.awssdk.services.s3.model.Transition.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #transitions(java.util.Collection) */ Builder transitions(Consumer... transitions); /** *

* Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition to a * specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set this * action to request that Amazon S3 transition noncurrent object versions to a specific storage class at a set * period in the object's lifetime. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
* * @param noncurrentVersionTransitions * Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition * to a specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you * can set this action to request that Amazon S3 transition noncurrent object versions to a specific * storage class at a set period in the object's lifetime.

*

* This parameter applies to general purpose buckets only. It is not supported for directory bucket * lifecycle configurations. *

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

* Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition to a * specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set this * action to request that Amazon S3 transition noncurrent object versions to a specific storage class at a set * period in the object's lifetime. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
* * @param noncurrentVersionTransitions * Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition * to a specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you * can set this action to request that Amazon S3 transition noncurrent object versions to a specific * storage class at a set period in the object's lifetime.

*

* This parameter applies to general purpose buckets only. It is not supported for directory bucket * lifecycle configurations. *

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

* Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition to a * specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set this * action to request that Amazon S3 transition noncurrent object versions to a specific storage class at a set * period in the object's lifetime. *

* *

* This parameter applies to general purpose buckets only. It is not supported for directory bucket lifecycle * configurations. *

*
This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.s3.model.NoncurrentVersionTransition.Builder} avoiding the need to * create one manually via * {@link software.amazon.awssdk.services.s3.model.NoncurrentVersionTransition#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.s3.model.NoncurrentVersionTransition.Builder#build()} is called * immediately and its result is passed to {@link * #noncurrentVersionTransitions(List)}. * * @param noncurrentVersionTransitions * a consumer that will call methods on * {@link software.amazon.awssdk.services.s3.model.NoncurrentVersionTransition.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #noncurrentVersionTransitions(java.util.Collection) */ Builder noncurrentVersionTransitions(Consumer... noncurrentVersionTransitions); /** * Sets the value of the NoncurrentVersionExpiration property for this object. * * @param noncurrentVersionExpiration * The new value for the NoncurrentVersionExpiration property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder noncurrentVersionExpiration(NoncurrentVersionExpiration noncurrentVersionExpiration); /** * Sets the value of the NoncurrentVersionExpiration property for this object. * * This is a convenience method that creates an instance of the {@link NoncurrentVersionExpiration.Builder} * avoiding the need to create one manually via {@link NoncurrentVersionExpiration#builder()}. * *

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

* When the {@link Consumer} completes, {@link AbortIncompleteMultipartUpload.Builder#build()} is called * immediately and its result is passed to * {@link #abortIncompleteMultipartUpload(AbortIncompleteMultipartUpload)}. * * @param abortIncompleteMultipartUpload * a consumer that will call methods on {@link AbortIncompleteMultipartUpload.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #abortIncompleteMultipartUpload(AbortIncompleteMultipartUpload) */ default Builder abortIncompleteMultipartUpload( Consumer abortIncompleteMultipartUpload) { return abortIncompleteMultipartUpload(AbortIncompleteMultipartUpload.builder() .applyMutation(abortIncompleteMultipartUpload).build()); } } static final class BuilderImpl implements Builder { private LifecycleExpiration expiration; private String id; private String prefix; private LifecycleRuleFilter filter; private String status; private List transitions = DefaultSdkAutoConstructList.getInstance(); private List noncurrentVersionTransitions = DefaultSdkAutoConstructList.getInstance(); private NoncurrentVersionExpiration noncurrentVersionExpiration; private AbortIncompleteMultipartUpload abortIncompleteMultipartUpload; private BuilderImpl() { } private BuilderImpl(LifecycleRule model) { expiration(model.expiration); id(model.id); prefix(model.prefix); filter(model.filter); status(model.status); transitions(model.transitions); noncurrentVersionTransitions(model.noncurrentVersionTransitions); noncurrentVersionExpiration(model.noncurrentVersionExpiration); abortIncompleteMultipartUpload(model.abortIncompleteMultipartUpload); } public final LifecycleExpiration.Builder getExpiration() { return expiration != null ? expiration.toBuilder() : null; } public final void setExpiration(LifecycleExpiration.BuilderImpl expiration) { this.expiration = expiration != null ? expiration.build() : null; } @Override public final Builder expiration(LifecycleExpiration expiration) { this.expiration = expiration; return this; } public final String getId() { return id; } public final void setId(String id) { this.id = id; } @Override public final Builder id(String id) { this.id = id; return this; } @Deprecated public final String getPrefix() { return prefix; } @Deprecated public final void setPrefix(String prefix) { this.prefix = prefix; } @Override @Deprecated public final Builder prefix(String prefix) { this.prefix = prefix; return this; } public final LifecycleRuleFilter.Builder getFilter() { return filter != null ? filter.toBuilder() : null; } public final void setFilter(LifecycleRuleFilter.BuilderImpl filter) { this.filter = filter != null ? filter.build() : null; } @Override public final Builder filter(LifecycleRuleFilter filter) { this.filter = filter; return this; } public final String getStatus() { return status; } public final void setStatus(String status) { this.status = status; } @Override public final Builder status(String status) { this.status = status; return this; } @Override public final Builder status(ExpirationStatus status) { this.status(status == null ? null : status.toString()); return this; } public final List getTransitions() { List result = TransitionListCopier.copyToBuilder(this.transitions); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTransitions(Collection transitions) { this.transitions = TransitionListCopier.copyFromBuilder(transitions); } @Override public final Builder transitions(Collection transitions) { this.transitions = TransitionListCopier.copy(transitions); return this; } @Override @SafeVarargs public final Builder transitions(Transition... transitions) { transitions(Arrays.asList(transitions)); return this; } @Override @SafeVarargs public final Builder transitions(Consumer... transitions) { transitions(Stream.of(transitions).map(c -> Transition.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final List getNoncurrentVersionTransitions() { List result = NoncurrentVersionTransitionListCopier .copyToBuilder(this.noncurrentVersionTransitions); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setNoncurrentVersionTransitions( Collection noncurrentVersionTransitions) { this.noncurrentVersionTransitions = NoncurrentVersionTransitionListCopier .copyFromBuilder(noncurrentVersionTransitions); } @Override public final Builder noncurrentVersionTransitions(Collection noncurrentVersionTransitions) { this.noncurrentVersionTransitions = NoncurrentVersionTransitionListCopier.copy(noncurrentVersionTransitions); return this; } @Override @SafeVarargs public final Builder noncurrentVersionTransitions(NoncurrentVersionTransition... noncurrentVersionTransitions) { noncurrentVersionTransitions(Arrays.asList(noncurrentVersionTransitions)); return this; } @Override @SafeVarargs public final Builder noncurrentVersionTransitions( Consumer... noncurrentVersionTransitions) { noncurrentVersionTransitions(Stream.of(noncurrentVersionTransitions) .map(c -> NoncurrentVersionTransition.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final NoncurrentVersionExpiration.Builder getNoncurrentVersionExpiration() { return noncurrentVersionExpiration != null ? noncurrentVersionExpiration.toBuilder() : null; } public final void setNoncurrentVersionExpiration(NoncurrentVersionExpiration.BuilderImpl noncurrentVersionExpiration) { this.noncurrentVersionExpiration = noncurrentVersionExpiration != null ? noncurrentVersionExpiration.build() : null; } @Override public final Builder noncurrentVersionExpiration(NoncurrentVersionExpiration noncurrentVersionExpiration) { this.noncurrentVersionExpiration = noncurrentVersionExpiration; return this; } public final AbortIncompleteMultipartUpload.Builder getAbortIncompleteMultipartUpload() { return abortIncompleteMultipartUpload != null ? abortIncompleteMultipartUpload.toBuilder() : null; } public final void setAbortIncompleteMultipartUpload( AbortIncompleteMultipartUpload.BuilderImpl abortIncompleteMultipartUpload) { this.abortIncompleteMultipartUpload = abortIncompleteMultipartUpload != null ? abortIncompleteMultipartUpload.build() : null; } @Override public final Builder abortIncompleteMultipartUpload(AbortIncompleteMultipartUpload abortIncompleteMultipartUpload) { this.abortIncompleteMultipartUpload = abortIncompleteMultipartUpload; return this; } @Override public LifecycleRule build() { return new LifecycleRule(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy