Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 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 com.amazonaws.services.ec2.model;
 

Describes a snapshot.

 
 public class Snapshot implements SerializableCloneable {

    
The ID of the snapshot.
 
     private String snapshotId;

    
The ID of the volume.
 
     private String volumeId;

    
The snapshot state.

Constraints:
Allowed Values: pending, completed, error

 
     private String state;

    
The time stamp when the snapshot was initiated.
 
     private java.util.Date startTime;

    
The progress of the snapshot, as a percentage.
 
     private String progress;

    
The AWS account ID of the Amazon EBS snapshot owner.
 
     private String ownerId;

    
The description for the snapshot.
 
     private String description;

    
The size of the volume, in GiB.
 
     private Integer volumeSize;

    
The AWS account alias (for example, amazon, self) or AWS account ID that owns the snapshot.
 
     private String ownerAlias;

    
Any tags assigned to the snapshot.
 
Indicates whether the snapshot is encrypted.
 
     private Boolean encrypted;

    
The full ARN of the AWS Key Management Service (KMS) master key that was used to protect the volume encryption key for the parent volume.
 
     private String kmsKeyId;

    
The ID of the snapshot.

Returns:
The ID of the snapshot.
 
     public String getSnapshotId() {
         return ;
     }
    
    
The ID of the snapshot.

Parameters:
snapshotId The ID of the snapshot.
    public void setSnapshotId(String snapshotId) {
        this. = snapshotId;
    }
    
    
The ID of the snapshot.

Returns a reference to this object so that method calls can be chained together.

Parameters:
snapshotId The ID of the snapshot.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withSnapshotId(String snapshotId) {
        this. = snapshotId;
        return this;
    }

    
The ID of the volume.

Returns:
The ID of the volume.
    public String getVolumeId() {
        return ;
    }
    
    
The ID of the volume.

Parameters:
volumeId The ID of the volume.
    public void setVolumeId(String volumeId) {
        this. = volumeId;
    }
    
    
The ID of the volume.

Returns a reference to this object so that method calls can be chained together.

Parameters:
volumeId The ID of the volume.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withVolumeId(String volumeId) {
        this. = volumeId;
        return this;
    }

    
The snapshot state.

Constraints:
Allowed Values: pending, completed, error

Returns:
The snapshot state.
See also:
SnapshotState
    public String getState() {
        return ;
    }
    
    
The snapshot state.

Constraints:
Allowed Values: pending, completed, error

Parameters:
state The snapshot state.
See also:
SnapshotState
    public void setState(String state) {
        this. = state;
    }
    
    
The snapshot state.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: pending, completed, error

Parameters:
state The snapshot state.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
SnapshotState
    public Snapshot withState(String state) {
        this. = state;
        return this;
    }

    
The snapshot state.

Constraints:
Allowed Values: pending, completed, error

Parameters:
state The snapshot state.
See also:
SnapshotState
    public void setState(SnapshotState state) {
        this. = state.toString();
    }
    
    
The snapshot state.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Allowed Values: pending, completed, error

Parameters:
state The snapshot state.
Returns:
A reference to this updated object so that method calls can be chained together.
See also:
SnapshotState
    public Snapshot withState(SnapshotState state) {
        this. = state.toString();
        return this;
    }

    
The time stamp when the snapshot was initiated.

Returns:
The time stamp when the snapshot was initiated.
    public java.util.Date getStartTime() {
        return ;
    }
    
    
The time stamp when the snapshot was initiated.

Parameters:
startTime The time stamp when the snapshot was initiated.
    public void setStartTime(java.util.Date startTime) {
        this. = startTime;
    }
    
    
The time stamp when the snapshot was initiated.

Returns a reference to this object so that method calls can be chained together.

Parameters:
startTime The time stamp when the snapshot was initiated.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withStartTime(java.util.Date startTime) {
        this. = startTime;
        return this;
    }

    
The progress of the snapshot, as a percentage.

Returns:
The progress of the snapshot, as a percentage.
    public String getProgress() {
        return ;
    }
    
    
The progress of the snapshot, as a percentage.

Parameters:
progress The progress of the snapshot, as a percentage.
    public void setProgress(String progress) {
        this. = progress;
    }
    
    
The progress of the snapshot, as a percentage.

Returns a reference to this object so that method calls can be chained together.

Parameters:
progress The progress of the snapshot, as a percentage.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withProgress(String progress) {
        this. = progress;
        return this;
    }

    
The AWS account ID of the Amazon EBS snapshot owner.

Returns:
The AWS account ID of the Amazon EBS snapshot owner.
    public String getOwnerId() {
        return ;
    }
    
    
The AWS account ID of the Amazon EBS snapshot owner.

Parameters:
ownerId The AWS account ID of the Amazon EBS snapshot owner.
    public void setOwnerId(String ownerId) {
        this. = ownerId;
    }
    
    
The AWS account ID of the Amazon EBS snapshot owner.

Returns a reference to this object so that method calls can be chained together.

Parameters:
ownerId The AWS account ID of the Amazon EBS snapshot owner.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withOwnerId(String ownerId) {
        this. = ownerId;
        return this;
    }

    
The description for the snapshot.

Returns:
The description for the snapshot.
    public String getDescription() {
        return ;
    }
    
    
The description for the snapshot.

Parameters:
description The description for the snapshot.
    public void setDescription(String description) {
        this. = description;
    }
    
    
The description for the snapshot.

Returns a reference to this object so that method calls can be chained together.

Parameters:
description The description for the snapshot.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withDescription(String description) {
        this. = description;
        return this;
    }

    
The size of the volume, in GiB.

Returns:
The size of the volume, in GiB.
    public Integer getVolumeSize() {
        return ;
    }
    
    
The size of the volume, in GiB.

Parameters:
volumeSize The size of the volume, in GiB.
    public void setVolumeSize(Integer volumeSize) {
        this. = volumeSize;
    }
    
    
The size of the volume, in GiB.

Returns a reference to this object so that method calls can be chained together.

Parameters:
volumeSize The size of the volume, in GiB.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withVolumeSize(Integer volumeSize) {
        this. = volumeSize;
        return this;
    }

    
The AWS account alias (for example, amazon, self) or AWS account ID that owns the snapshot.

Returns:
The AWS account alias (for example, amazon, self) or AWS account ID that owns the snapshot.
    public String getOwnerAlias() {
        return ;
    }
    
    
The AWS account alias (for example, amazon, self) or AWS account ID that owns the snapshot.

Parameters:
ownerAlias The AWS account alias (for example, amazon, self) or AWS account ID that owns the snapshot.
    public void setOwnerAlias(String ownerAlias) {
        this. = ownerAlias;
    }
    
    
The AWS account alias (for example, amazon, self) or AWS account ID that owns the snapshot.

Returns a reference to this object so that method calls can be chained together.

Parameters:
ownerAlias The AWS account alias (for example, amazon, self) or AWS account ID that owns the snapshot.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withOwnerAlias(String ownerAlias) {
        this. = ownerAlias;
        return this;
    }

    
Any tags assigned to the snapshot.

Returns:
Any tags assigned to the snapshot.
    public java.util.List<TaggetTags() {
        if ( == null) {
               = new com.amazonaws.internal.ListWithAutoConstructFlag<Tag>();
              .setAutoConstruct(true);
        }
        return ;
    }
    
    
Any tags assigned to the snapshot.

Parameters:
tags Any tags assigned to the snapshot.
    public void setTags(java.util.Collection<Tagtags) {
        if (tags == null) {
            this. = null;
            return;
        }
        tagsCopy.addAll(tags);
        this. = tagsCopy;
    }
    
    
Any tags assigned to the snapshot.

NOTE: This method appends the values to the existing list (if any). Use setTags(java.util.Collection) or withTags(java.util.Collection) if you want to override the existing values.

Returns a reference to this object so that method calls can be chained together.

Parameters:
tags Any tags assigned to the snapshot.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withTags(Tag... tags) {
        if (getTags() == nullsetTags(new java.util.ArrayList<Tag>(tags.length));
        for (Tag value : tags) {
            getTags().add(value);
        }
        return this;
    }
    
    
Any tags assigned to the snapshot.

Returns a reference to this object so that method calls can be chained together.

Parameters:
tags Any tags assigned to the snapshot.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withTags(java.util.Collection<Tagtags) {
        if (tags == null) {
            this. = null;
        } else {
            tagsCopy.addAll(tags);
            this. = tagsCopy;
        }
        return this;
    }

    
Indicates whether the snapshot is encrypted.

Returns:
Indicates whether the snapshot is encrypted.
    public Boolean isEncrypted() {
        return ;
    }
    
    
Indicates whether the snapshot is encrypted.

Parameters:
encrypted Indicates whether the snapshot is encrypted.
    public void setEncrypted(Boolean encrypted) {
        this. = encrypted;
    }
    
    
Indicates whether the snapshot is encrypted.

Returns a reference to this object so that method calls can be chained together.

Parameters:
encrypted Indicates whether the snapshot is encrypted.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withEncrypted(Boolean encrypted) {
        this. = encrypted;
        return this;
    }

    
Indicates whether the snapshot is encrypted.

Returns:
Indicates whether the snapshot is encrypted.
    public Boolean getEncrypted() {
        return ;
    }

    
The full ARN of the AWS Key Management Service (KMS) master key that was used to protect the volume encryption key for the parent volume.

Returns:
The full ARN of the AWS Key Management Service (KMS) master key that was used to protect the volume encryption key for the parent volume.
    public String getKmsKeyId() {
        return ;
    }
    
    
The full ARN of the AWS Key Management Service (KMS) master key that was used to protect the volume encryption key for the parent volume.

Parameters:
kmsKeyId The full ARN of the AWS Key Management Service (KMS) master key that was used to protect the volume encryption key for the parent volume.
    public void setKmsKeyId(String kmsKeyId) {
        this. = kmsKeyId;
    }
    
    
The full ARN of the AWS Key Management Service (KMS) master key that was used to protect the volume encryption key for the parent volume.

Returns a reference to this object so that method calls can be chained together.

Parameters:
kmsKeyId The full ARN of the AWS Key Management Service (KMS) master key that was used to protect the volume encryption key for the parent volume.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Snapshot withKmsKeyId(String kmsKeyId) {
        this. = kmsKeyId;
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getSnapshotId() != nullsb.append("SnapshotId: " + getSnapshotId() + ",");
        if (getVolumeId() != nullsb.append("VolumeId: " + getVolumeId() + ",");
        if (getState() != nullsb.append("State: " + getState() + ",");
        if (getStartTime() != nullsb.append("StartTime: " + getStartTime() + ",");
        if (getProgress() != nullsb.append("Progress: " + getProgress() + ",");
        if (getOwnerId() != nullsb.append("OwnerId: " + getOwnerId() + ",");
        if (getDescription() != nullsb.append("Description: " + getDescription() + ",");
        if (getVolumeSize() != nullsb.append("VolumeSize: " + getVolumeSize() + ",");
        if (getOwnerAlias() != nullsb.append("OwnerAlias: " + getOwnerAlias() + ",");
        if (getTags() != nullsb.append("Tags: " + getTags() + ",");
        if (isEncrypted() != nullsb.append("Encrypted: " + isEncrypted() + ",");
        if (getKmsKeyId() != nullsb.append("KmsKeyId: " + getKmsKeyId() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getSnapshotId() == null) ? 0 : getSnapshotId().hashCode()); 
        hashCode = prime * hashCode + ((getVolumeId() == null) ? 0 : getVolumeId().hashCode()); 
        hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); 
        hashCode = prime * hashCode + ((getStartTime() == null) ? 0 : getStartTime().hashCode()); 
        hashCode = prime * hashCode + ((getProgress() == null) ? 0 : getProgress().hashCode()); 
        hashCode = prime * hashCode + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode()); 
        hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); 
        hashCode = prime * hashCode + ((getVolumeSize() == null) ? 0 : getVolumeSize().hashCode()); 
        hashCode = prime * hashCode + ((getOwnerAlias() == null) ? 0 : getOwnerAlias().hashCode()); 
        hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); 
        hashCode = prime * hashCode + ((isEncrypted() == null) ? 0 : isEncrypted().hashCode()); 
        hashCode = prime * hashCode + ((getKmsKeyId() == null) ? 0 : getKmsKeyId().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof Snapshot == falsereturn false;
        Snapshot other = (Snapshot)obj;
        
        if (other.getSnapshotId() == null ^ this.getSnapshotId() == nullreturn false;
        if (other.getSnapshotId() != null && other.getSnapshotId().equals(this.getSnapshotId()) == falsereturn false
        if (other.getVolumeId() == null ^ this.getVolumeId() == nullreturn false;
        if (other.getVolumeId() != null && other.getVolumeId().equals(this.getVolumeId()) == falsereturn false
        if (other.getState() == null ^ this.getState() == nullreturn false;
        if (other.getState() != null && other.getState().equals(this.getState()) == falsereturn false
        if (other.getStartTime() == null ^ this.getStartTime() == nullreturn false;
        if (other.getStartTime() != null && other.getStartTime().equals(this.getStartTime()) == falsereturn false
        if (other.getProgress() == null ^ this.getProgress() == nullreturn false;
        if (other.getProgress() != null && other.getProgress().equals(this.getProgress()) == falsereturn false
        if (other.getOwnerId() == null ^ this.getOwnerId() == nullreturn false;
        if (other.getOwnerId() != null && other.getOwnerId().equals(this.getOwnerId()) == falsereturn false
        if (other.getDescription() == null ^ this.getDescription() == nullreturn false;
        if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == falsereturn false
        if (other.getVolumeSize() == null ^ this.getVolumeSize() == nullreturn false;
        if (other.getVolumeSize() != null && other.getVolumeSize().equals(this.getVolumeSize()) == falsereturn false
        if (other.getOwnerAlias() == null ^ this.getOwnerAlias() == nullreturn false;
        if (other.getOwnerAlias() != null && other.getOwnerAlias().equals(this.getOwnerAlias()) == falsereturn false
        if (other.getTags() == null ^ this.getTags() == nullreturn false;
        if (other.getTags() != null && other.getTags().equals(this.getTags()) == falsereturn false
        if (other.isEncrypted() == null ^ this.isEncrypted() == nullreturn false;
        if (other.isEncrypted() != null && other.isEncrypted().equals(this.isEncrypted()) == falsereturn false
        if (other.getKmsKeyId() == null ^ this.getKmsKeyId() == nullreturn false;
        if (other.getKmsKeyId() != null && other.getKmsKeyId().equals(this.getKmsKeyId()) == falsereturn false
        return true;
    }
    
    @Override
    public Snapshot clone() {
        try {
            return (Snapshotsuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X