com.amazonaws.services.ec2.model.CreateImageRequest Maven / Gradle / Ivy
Show all versions of aws-java-sdk-ec2 Show documentation
/*
* Copyright 2016-2021 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;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.Request;
import com.amazonaws.services.ec2.model.transform.CreateImageRequestMarshaller;
/**
*
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class CreateImageRequest extends AmazonWebServiceRequest implements Serializable, Cloneable, DryRunSupportedRequest {
/**
*
* The block device mappings. This parameter cannot be used to modify the encryption status of existing volumes or
* snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
*
*/
private com.amazonaws.internal.SdkInternalList blockDeviceMappings;
/**
*
* A description for the new image.
*
*/
private String description;
/**
*
* The ID of the instance.
*
*/
private String instanceId;
/**
*
* A name for the new image.
*
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods (.),
* slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
*
*/
private String name;
/**
*
* By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the image.
* Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same time), but not
* application consistent (all the operating system buffers are not flushed to disk before the snapshots are
* created).
*
*/
private Boolean noReboot;
/**
*
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the
* instance, the value for ResourceType
must be snapshot
. The same tag is applied to all
* of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
*
*/
private com.amazonaws.internal.SdkInternalList tagSpecifications;
/**
* Default constructor for CreateImageRequest object. Callers should use the setter or fluent setter (with...)
* methods to initialize the object after creating it.
*/
public CreateImageRequest() {
}
/**
* Constructs a new CreateImageRequest object. Callers should use the setter or fluent setter (with...) methods to
* initialize any additional object members.
*
* @param instanceId
* The ID of the instance.
* @param name
* A name for the new image.
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods
* (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
*/
public CreateImageRequest(String instanceId, String name) {
setInstanceId(instanceId);
setName(name);
}
/**
*
* The block device mappings. This parameter cannot be used to modify the encryption status of existing volumes or
* snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
*
*
* @return The block device mappings. This parameter cannot be used to modify the encryption status of existing
* volumes or snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
*/
public java.util.List getBlockDeviceMappings() {
if (blockDeviceMappings == null) {
blockDeviceMappings = new com.amazonaws.internal.SdkInternalList();
}
return blockDeviceMappings;
}
/**
*
* The block device mappings. This parameter cannot be used to modify the encryption status of existing volumes or
* snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
*
*
* @param blockDeviceMappings
* The block device mappings. This parameter cannot be used to modify the encryption status of existing
* volumes or snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
*/
public void setBlockDeviceMappings(java.util.Collection blockDeviceMappings) {
if (blockDeviceMappings == null) {
this.blockDeviceMappings = null;
return;
}
this.blockDeviceMappings = new com.amazonaws.internal.SdkInternalList(blockDeviceMappings);
}
/**
*
* The block device mappings. This parameter cannot be used to modify the encryption status of existing volumes or
* snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setBlockDeviceMappings(java.util.Collection)} or {@link #withBlockDeviceMappings(java.util.Collection)}
* if you want to override the existing values.
*
*
* @param blockDeviceMappings
* The block device mappings. This parameter cannot be used to modify the encryption status of existing
* volumes or snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withBlockDeviceMappings(BlockDeviceMapping... blockDeviceMappings) {
if (this.blockDeviceMappings == null) {
setBlockDeviceMappings(new com.amazonaws.internal.SdkInternalList(blockDeviceMappings.length));
}
for (BlockDeviceMapping ele : blockDeviceMappings) {
this.blockDeviceMappings.add(ele);
}
return this;
}
/**
*
* The block device mappings. This parameter cannot be used to modify the encryption status of existing volumes or
* snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
*
*
* @param blockDeviceMappings
* The block device mappings. This parameter cannot be used to modify the encryption status of existing
* volumes or snapshots. To create an AMI with encrypted snapshots, use the CopyImage action.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withBlockDeviceMappings(java.util.Collection blockDeviceMappings) {
setBlockDeviceMappings(blockDeviceMappings);
return this;
}
/**
*
* A description for the new image.
*
*
* @param description
* A description for the new image.
*/
public void setDescription(String description) {
this.description = description;
}
/**
*
* A description for the new image.
*
*
* @return A description for the new image.
*/
public String getDescription() {
return this.description;
}
/**
*
* A description for the new image.
*
*
* @param description
* A description for the new image.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withDescription(String description) {
setDescription(description);
return this;
}
/**
*
* The ID of the instance.
*
*
* @param instanceId
* The ID of the instance.
*/
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
/**
*
* The ID of the instance.
*
*
* @return The ID of the instance.
*/
public String getInstanceId() {
return this.instanceId;
}
/**
*
* The ID of the instance.
*
*
* @param instanceId
* The ID of the instance.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withInstanceId(String instanceId) {
setInstanceId(instanceId);
return this;
}
/**
*
* A name for the new image.
*
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods (.),
* slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
*
*
* @param name
* A name for the new image.
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods
* (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
*/
public void setName(String name) {
this.name = name;
}
/**
*
* A name for the new image.
*
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods (.),
* slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
*
*
* @return A name for the new image.
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods
* (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
*/
public String getName() {
return this.name;
}
/**
*
* A name for the new image.
*
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods (.),
* slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
*
*
* @param name
* A name for the new image.
*
* Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods
* (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withName(String name) {
setName(name);
return this;
}
/**
*
* By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the image.
* Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same time), but not
* application consistent (all the operating system buffers are not flushed to disk before the snapshots are
* created).
*
*
* @param noReboot
* By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the image.
* Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same time), but
* not application consistent (all the operating system buffers are not flushed to disk before the snapshots
* are created).
*/
public void setNoReboot(Boolean noReboot) {
this.noReboot = noReboot;
}
/**
*
* By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the image.
* Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same time), but not
* application consistent (all the operating system buffers are not flushed to disk before the snapshots are
* created).
*
*
* @return By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the
* image. Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same
* time), but not application consistent (all the operating system buffers are not flushed to disk before
* the snapshots are created).
*/
public Boolean getNoReboot() {
return this.noReboot;
}
/**
*
* By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the image.
* Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same time), but not
* application consistent (all the operating system buffers are not flushed to disk before the snapshots are
* created).
*
*
* @param noReboot
* By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the image.
* Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same time), but
* not application consistent (all the operating system buffers are not flushed to disk before the snapshots
* are created).
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withNoReboot(Boolean noReboot) {
setNoReboot(noReboot);
return this;
}
/**
*
* By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the image.
* Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same time), but not
* application consistent (all the operating system buffers are not flushed to disk before the snapshots are
* created).
*
*
* @return By default, Amazon EC2 attempts to shut down and reboot the instance before creating the image. If the
* No Reboot
option is set, Amazon EC2 doesn't shut down the instance before creating the
* image. Without a reboot, the AMI will be crash consistent (all the volumes are snapshotted at the same
* time), but not application consistent (all the operating system buffers are not flushed to disk before
* the snapshots are created).
*/
public Boolean isNoReboot() {
return this.noReboot;
}
/**
*
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the
* instance, the value for ResourceType
must be snapshot
. The same tag is applied to all
* of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
*
*
* @return The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are
* attached to the instance, the value for ResourceType
must be snapshot
. The same
* tag is applied to all of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
*/
public java.util.List getTagSpecifications() {
if (tagSpecifications == null) {
tagSpecifications = new com.amazonaws.internal.SdkInternalList();
}
return tagSpecifications;
}
/**
*
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the
* instance, the value for ResourceType
must be snapshot
. The same tag is applied to all
* of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
*
*
* @param tagSpecifications
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached
* to the instance, the value for ResourceType
must be snapshot
. The same tag is
* applied to all of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
*/
public void setTagSpecifications(java.util.Collection tagSpecifications) {
if (tagSpecifications == null) {
this.tagSpecifications = null;
return;
}
this.tagSpecifications = new com.amazonaws.internal.SdkInternalList(tagSpecifications);
}
/**
*
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the
* instance, the value for ResourceType
must be snapshot
. The same tag is applied to all
* of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
*
*
* NOTE: This method appends the values to the existing list (if any). Use
* {@link #setTagSpecifications(java.util.Collection)} or {@link #withTagSpecifications(java.util.Collection)} if
* you want to override the existing values.
*
*
* @param tagSpecifications
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached
* to the instance, the value for ResourceType
must be snapshot
. The same tag is
* applied to all of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withTagSpecifications(TagSpecification... tagSpecifications) {
if (this.tagSpecifications == null) {
setTagSpecifications(new com.amazonaws.internal.SdkInternalList(tagSpecifications.length));
}
for (TagSpecification ele : tagSpecifications) {
this.tagSpecifications.add(ele);
}
return this;
}
/**
*
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached to the
* instance, the value for ResourceType
must be snapshot
. The same tag is applied to all
* of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
*
*
* @param tagSpecifications
* The tags to apply to the AMI and snapshots on creation. You can tag the AMI, the snapshots, or both.
*
* -
*
* To tag the AMI, the value for ResourceType
must be image
.
*
*
* -
*
* To tag the snapshots that are created of the root volume and of other Amazon EBS volumes that are attached
* to the instance, the value for ResourceType
must be snapshot
. The same tag is
* applied to all of the snapshots that are created.
*
*
*
*
* If you specify other values for ResourceType
, the request fails.
*
*
* To tag an AMI or snapshot after it has been created, see CreateTags.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public CreateImageRequest withTagSpecifications(java.util.Collection tagSpecifications) {
setTagSpecifications(tagSpecifications);
return this;
}
/**
* This method is intended for internal use only. Returns the marshaled request configured with additional
* parameters to enable operation dry-run.
*/
@Override
public Request getDryRunRequest() {
Request request = new CreateImageRequestMarshaller().marshall(this);
request.addParameter("DryRun", Boolean.toString(true));
return request;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getBlockDeviceMappings() != null)
sb.append("BlockDeviceMappings: ").append(getBlockDeviceMappings()).append(",");
if (getDescription() != null)
sb.append("Description: ").append(getDescription()).append(",");
if (getInstanceId() != null)
sb.append("InstanceId: ").append(getInstanceId()).append(",");
if (getName() != null)
sb.append("Name: ").append(getName()).append(",");
if (getNoReboot() != null)
sb.append("NoReboot: ").append(getNoReboot()).append(",");
if (getTagSpecifications() != null)
sb.append("TagSpecifications: ").append(getTagSpecifications());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof CreateImageRequest == false)
return false;
CreateImageRequest other = (CreateImageRequest) obj;
if (other.getBlockDeviceMappings() == null ^ this.getBlockDeviceMappings() == null)
return false;
if (other.getBlockDeviceMappings() != null && other.getBlockDeviceMappings().equals(this.getBlockDeviceMappings()) == false)
return false;
if (other.getDescription() == null ^ this.getDescription() == null)
return false;
if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false)
return false;
if (other.getInstanceId() == null ^ this.getInstanceId() == null)
return false;
if (other.getInstanceId() != null && other.getInstanceId().equals(this.getInstanceId()) == false)
return false;
if (other.getName() == null ^ this.getName() == null)
return false;
if (other.getName() != null && other.getName().equals(this.getName()) == false)
return false;
if (other.getNoReboot() == null ^ this.getNoReboot() == null)
return false;
if (other.getNoReboot() != null && other.getNoReboot().equals(this.getNoReboot()) == false)
return false;
if (other.getTagSpecifications() == null ^ this.getTagSpecifications() == null)
return false;
if (other.getTagSpecifications() != null && other.getTagSpecifications().equals(this.getTagSpecifications()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getBlockDeviceMappings() == null) ? 0 : getBlockDeviceMappings().hashCode());
hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode());
hashCode = prime * hashCode + ((getInstanceId() == null) ? 0 : getInstanceId().hashCode());
hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode());
hashCode = prime * hashCode + ((getNoReboot() == null) ? 0 : getNoReboot().hashCode());
hashCode = prime * hashCode + ((getTagSpecifications() == null) ? 0 : getTagSpecifications().hashCode());
return hashCode;
}
@Override
public CreateImageRequest clone() {
return (CreateImageRequest) super.clone();
}
}