public class BucketVersioningConfiguration extends Object implements Serializable
A bucket's versioning configuration can be in one of three possible states:
BucketVersioningConfiguration.OFF
BucketVersioningConfiguration.ENABLED
BucketVersioningConfiguration.SUSPENDED
By default, new buckets are in the
off
state. Once versioning is
enabled for a bucket the status can never be reverted to
off
.
In addition to enabling versioning, a bucket's versioning configuration can also enable Multi-Factor Authentication (MFA) Delete, which restricts the ability to permanently delete a version of an object. When MFA Delete is enabled, only requests from the bucket owner which include an MFA token generated by the hardware authentication device associated with the bucket owner's Amazon Web Services account can permanently delete an object version. For more information on Amazon Web Services Multi-Factor Authentication see http://aws.amazon.com/mfa/
The versioning configuration of a bucket has different implications for each operation performed on that bucket or for objects within that bucket. For instance, when versioning is enabled, a PutObject operation creates a unique object version-id for the object being uploaded. The PutObject API guarantees that, if versioning is enabled for a bucket at the time of the request, the new object can only be permanently deleted using the DeleteVersion operation. It can never be overwritten. Additionally, PutObject guarantees that, if versioning is enabled for a bucket the request, no other object will be overwritten by that request. Refer to the documentation sections for each API for information on how versioning status affects the semantics of that particular API.
S3 is eventually consistent. It may take time for the versioning status of a bucket to be propagated throughout the system.
Modifier and Type | Field and Description |
---|---|
static String |
ENABLED
S3 bucket versioning status indicating that versioning is enabled for a
bucket.
|
static String |
OFF
S3 bucket versioning status indicating that versioning is off for a
bucket.
|
static String |
SUSPENDED
S3 bucket versioning status indicating that versioning is suspended for a
bucket.
|
Constructor and Description |
---|
BucketVersioningConfiguration()
Creates a new bucket versioning configuration object which defaults to
BucketVersioningConfiguration.OFF status. |
BucketVersioningConfiguration(String status)
Creates a new bucket versioning configuration object with the specified
status.
|
Modifier and Type | Method and Description |
---|---|
String |
getStatus()
Returns the current status of versioning for this bucket versioning
configuration object, indicating if versioning is enabled or not for a
bucket.
|
Boolean |
isMfaDeleteEnabled()
Returns true if Multi-Factor Authentication (MFA) Delete is enabled for
this bucket versioning configuration, false if it isn't enabled, and null
if no information is available about the status of MFADelete.
|
void |
setMfaDeleteEnabled(Boolean mfaDeleteEnabled)
Sets the status of Multi-Factor Authentication (MFA) Delete for a bucket.
|
void |
setStatus(String status)
Sets the desired status of versioning for this bucket versioning
configuration object.
|
BucketVersioningConfiguration |
withMfaDeleteEnabled(Boolean mfaDeleteEnabled)
Sets the status of Multi-Factor Authentication (MFA) Delete for a bucket,
and returns this object so that additional method calls may be chained
together.
|
BucketVersioningConfiguration |
withStatus(String status)
Sets the desired status of versioning for this bucket versioning
configuration object, and returns this object so that additional method
calls may be chained together.
|
public static final String OFF
public static final String SUSPENDED
public static final String ENABLED
public BucketVersioningConfiguration()
BucketVersioningConfiguration.OFF
status.public BucketVersioningConfiguration(String status)
Note that once versioning has been enabled for a bucket, its status can
only be suspended
and can never be set back to
off
.
status
- The desired bucket versioning status for the new configuration
object.BucketVersioningConfiguration.ENABLED
,
BucketVersioningConfiguration.SUSPENDED
public String getStatus()
BucketVersioningConfiguration.OFF
,
BucketVersioningConfiguration.ENABLED
,
BucketVersioningConfiguration.SUSPENDED
public void setStatus(String status)
Note that once versioning has been enabled for a bucket, its status can
only be suspended
and can never be set back to
off
.
status
- The desired status of versioning for this bucket versioning
configuration.BucketVersioningConfiguration.ENABLED
,
BucketVersioningConfiguration.SUSPENDED
public BucketVersioningConfiguration withStatus(String status)
Note that once versioning has been enabled for a bucket, its status can
only be suspended
and can never be set back to
off
.
status
- The desired status of versioning for this bucket versioning
configuration.BucketVersioningConfiguration.ENABLED
,
BucketVersioningConfiguration.SUSPENDED
public Boolean isMfaDeleteEnabled()
When MFA Delete is enabled, object versions can only be permanently deleted when the bucket owner passes in, as part of a delete version request, an MFA token from the hardware token generator associated with their Amazon Web Services account.
By default, MFA Delete is not enabled.
When enabling or disabling MFA Delete controls, you must also supply an MFA token from the hardware token generator.
public void setMfaDeleteEnabled(Boolean mfaDeleteEnabled)
By default, MFA Delete is not enabled.
When enabling or disabling MFA Delete controls, you must also supply an MFA token from the hardware token generator as part of the request.
mfaDeleteEnabled
- True if the Multi-Factor Authentication (MFA) Delete is being
enabled enabled, false if it is being disabled.public BucketVersioningConfiguration withMfaDeleteEnabled(Boolean mfaDeleteEnabled)
By default, MFA Delete is not enabled.
When enabling or disabling MFA Delete controls, you must also supply an MFA token from the hardware token generator as part of the request.
mfaDeleteEnabled
- True if the Multi-Factor Authentication (MFA) Delete is being
enabled enabled, false if it is being disabled.Copyright © 2024. All rights reserved.