software.amazon.awssdk.services.ebs.model.PutSnapshotBlockRequest Maven / Gradle / Ivy
/*
* 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.ebs.model;
import java.util.Arrays;
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 software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class PutSnapshotBlockRequest extends EbsRequest implements
ToCopyableBuilder {
private static final SdkField SNAPSHOT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SnapshotId").getter(getter(PutSnapshotBlockRequest::snapshotId)).setter(setter(Builder::snapshotId))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("snapshotId").build()).build();
private static final SdkField BLOCK_INDEX_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("BlockIndex").getter(getter(PutSnapshotBlockRequest::blockIndex)).setter(setter(Builder::blockIndex))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("blockIndex").build()).build();
private static final SdkField DATA_LENGTH_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("DataLength").getter(getter(PutSnapshotBlockRequest::dataLength)).setter(setter(Builder::dataLength))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-Data-Length").build()).build();
private static final SdkField PROGRESS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("Progress").getter(getter(PutSnapshotBlockRequest::progress)).setter(setter(Builder::progress))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-Progress").build()).build();
private static final SdkField CHECKSUM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Checksum").getter(getter(PutSnapshotBlockRequest::checksum)).setter(setter(Builder::checksum))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-Checksum").build()).build();
private static final SdkField CHECKSUM_ALGORITHM_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ChecksumAlgorithm").getter(getter(PutSnapshotBlockRequest::checksumAlgorithmAsString))
.setter(setter(Builder::checksumAlgorithm))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-Checksum-Algorithm").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SNAPSHOT_ID_FIELD,
BLOCK_INDEX_FIELD, DATA_LENGTH_FIELD, PROGRESS_FIELD, CHECKSUM_FIELD, CHECKSUM_ALGORITHM_FIELD));
private final String snapshotId;
private final Integer blockIndex;
private final Integer dataLength;
private final Integer progress;
private final String checksum;
private final String checksumAlgorithm;
private PutSnapshotBlockRequest(BuilderImpl builder) {
super(builder);
this.snapshotId = builder.snapshotId;
this.blockIndex = builder.blockIndex;
this.dataLength = builder.dataLength;
this.progress = builder.progress;
this.checksum = builder.checksum;
this.checksumAlgorithm = builder.checksumAlgorithm;
}
/**
*
* The ID of the snapshot.
*
*
*
* If the specified snapshot is encrypted, you must have permission to use the KMS key that was used to encrypt the
* snapshot. For more information, see Using encryption in
* the Amazon Elastic Compute Cloud User Guide..
*
*
*
* @return The ID of the snapshot.
*
* If the specified snapshot is encrypted, you must have permission to use the KMS key that was used to
* encrypt the snapshot. For more information, see Using
* encryption in the Amazon Elastic Compute Cloud User Guide..
*
*/
public final String snapshotId() {
return snapshotId;
}
/**
*
* The block index of the block in which to write the data. A block index is a logical index in units of
* 512
KiB blocks. To identify the block index, divide the logical offset of the data in the logical
* volume by the block size (logical offset of data/524288
). The logical offset of the data must be
* 512
KiB aligned.
*
*
* @return The block index of the block in which to write the data. A block index is a logical index in units of
* 512
KiB blocks. To identify the block index, divide the logical offset of the data in the
* logical volume by the block size (logical offset of data/524288
). The logical offset of the
* data must be 512
KiB aligned.
*/
public final Integer blockIndex() {
return blockIndex;
}
/**
*
* The size of the data to write to the block, in bytes. Currently, the only supported size is 524288
* bytes.
*
*
* Valid values: 524288
*
*
* @return The size of the data to write to the block, in bytes. Currently, the only supported size is
* 524288
bytes.
*
* Valid values: 524288
*/
public final Integer dataLength() {
return dataLength;
}
/**
*
* The progress of the write process, as a percentage.
*
*
* @return The progress of the write process, as a percentage.
*/
public final Integer progress() {
return progress;
}
/**
*
* A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are supported.
*
*
* @return A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are supported.
*/
public final String checksum() {
return checksum;
}
/**
*
* The algorithm used to generate the checksum. Currently, the only supported algorithm is SHA256
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #checksumAlgorithm}
* will return {@link ChecksumAlgorithm#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #checksumAlgorithmAsString}.
*
*
* @return The algorithm used to generate the checksum. Currently, the only supported algorithm is
* SHA256
.
* @see ChecksumAlgorithm
*/
public final ChecksumAlgorithm checksumAlgorithm() {
return ChecksumAlgorithm.fromValue(checksumAlgorithm);
}
/**
*
* The algorithm used to generate the checksum. Currently, the only supported algorithm is SHA256
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #checksumAlgorithm}
* will return {@link ChecksumAlgorithm#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #checksumAlgorithmAsString}.
*
*
* @return The algorithm used to generate the checksum. Currently, the only supported algorithm is
* SHA256
.
* @see ChecksumAlgorithm
*/
public final String checksumAlgorithmAsString() {
return checksumAlgorithm;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(snapshotId());
hashCode = 31 * hashCode + Objects.hashCode(blockIndex());
hashCode = 31 * hashCode + Objects.hashCode(dataLength());
hashCode = 31 * hashCode + Objects.hashCode(progress());
hashCode = 31 * hashCode + Objects.hashCode(checksum());
hashCode = 31 * hashCode + Objects.hashCode(checksumAlgorithmAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PutSnapshotBlockRequest)) {
return false;
}
PutSnapshotBlockRequest other = (PutSnapshotBlockRequest) obj;
return Objects.equals(snapshotId(), other.snapshotId()) && Objects.equals(blockIndex(), other.blockIndex())
&& Objects.equals(dataLength(), other.dataLength()) && Objects.equals(progress(), other.progress())
&& Objects.equals(checksum(), other.checksum())
&& Objects.equals(checksumAlgorithmAsString(), other.checksumAlgorithmAsString());
}
/**
* 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("PutSnapshotBlockRequest").add("SnapshotId", snapshotId()).add("BlockIndex", blockIndex())
.add("DataLength", dataLength()).add("Progress", progress()).add("Checksum", checksum())
.add("ChecksumAlgorithm", checksumAlgorithmAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SnapshotId":
return Optional.ofNullable(clazz.cast(snapshotId()));
case "BlockIndex":
return Optional.ofNullable(clazz.cast(blockIndex()));
case "DataLength":
return Optional.ofNullable(clazz.cast(dataLength()));
case "Progress":
return Optional.ofNullable(clazz.cast(progress()));
case "Checksum":
return Optional.ofNullable(clazz.cast(checksum()));
case "ChecksumAlgorithm":
return Optional.ofNullable(clazz.cast(checksumAlgorithmAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function