software.amazon.awssdk.services.s3.model.ListObjectsV2Request Maven / Gradle / Ivy
/*
* Copyright 2014-2019 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.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 ListObjectsV2Request extends S3Request implements
ToCopyableBuilder {
private static final SdkField BUCKET_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(ListObjectsV2Request::bucket))
.setter(setter(Builder::bucket))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("Bucket")
.unmarshallLocationName("Bucket").build()).build();
private static final SdkField DELIMITER_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(ListObjectsV2Request::delimiter))
.setter(setter(Builder::delimiter))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("delimiter")
.unmarshallLocationName("delimiter").build()).build();
private static final SdkField ENCODING_TYPE_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(ListObjectsV2Request::encodingTypeAsString))
.setter(setter(Builder::encodingType))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("encoding-type")
.unmarshallLocationName("encoding-type").build()).build();
private static final SdkField MAX_KEYS_FIELD = SdkField
. builder(MarshallingType.INTEGER)
.getter(getter(ListObjectsV2Request::maxKeys))
.setter(setter(Builder::maxKeys))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("max-keys")
.unmarshallLocationName("max-keys").build()).build();
private static final SdkField PREFIX_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(ListObjectsV2Request::prefix))
.setter(setter(Builder::prefix))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("prefix")
.unmarshallLocationName("prefix").build()).build();
private static final SdkField CONTINUATION_TOKEN_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(ListObjectsV2Request::continuationToken))
.setter(setter(Builder::continuationToken))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("continuation-token")
.unmarshallLocationName("continuation-token").build()).build();
private static final SdkField FETCH_OWNER_FIELD = SdkField
. builder(MarshallingType.BOOLEAN)
.getter(getter(ListObjectsV2Request::fetchOwner))
.setter(setter(Builder::fetchOwner))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("fetch-owner")
.unmarshallLocationName("fetch-owner").build()).build();
private static final SdkField START_AFTER_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(ListObjectsV2Request::startAfter))
.setter(setter(Builder::startAfter))
.traits(LocationTrait.builder().location(MarshallLocation.QUERY_PARAM).locationName("start-after")
.unmarshallLocationName("start-after").build()).build();
private static final SdkField REQUEST_PAYER_FIELD = SdkField
. builder(MarshallingType.STRING)
.getter(getter(ListObjectsV2Request::requestPayerAsString))
.setter(setter(Builder::requestPayer))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-request-payer")
.unmarshallLocationName("x-amz-request-payer").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUCKET_FIELD, DELIMITER_FIELD,
ENCODING_TYPE_FIELD, MAX_KEYS_FIELD, PREFIX_FIELD, CONTINUATION_TOKEN_FIELD, FETCH_OWNER_FIELD, START_AFTER_FIELD,
REQUEST_PAYER_FIELD));
private final String bucket;
private final String delimiter;
private final String encodingType;
private final Integer maxKeys;
private final String prefix;
private final String continuationToken;
private final Boolean fetchOwner;
private final String startAfter;
private final String requestPayer;
private ListObjectsV2Request(BuilderImpl builder) {
super(builder);
this.bucket = builder.bucket;
this.delimiter = builder.delimiter;
this.encodingType = builder.encodingType;
this.maxKeys = builder.maxKeys;
this.prefix = builder.prefix;
this.continuationToken = builder.continuationToken;
this.fetchOwner = builder.fetchOwner;
this.startAfter = builder.startAfter;
this.requestPayer = builder.requestPayer;
}
/**
*
* Name of the bucket to list.
*
*
* @return Name of the bucket to list.
*/
public String bucket() {
return bucket;
}
/**
*
* A delimiter is a character you use to group keys.
*
*
* @return A delimiter is a character you use to group keys.
*/
public String delimiter() {
return delimiter;
}
/**
*
* Encoding type used by Amazon S3 to encode object keys in the response.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #encodingType} will
* return {@link EncodingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #encodingTypeAsString}.
*
*
* @return Encoding type used by Amazon S3 to encode object keys in the response.
* @see EncodingType
*/
public EncodingType encodingType() {
return EncodingType.fromValue(encodingType);
}
/**
*
* Encoding type used by Amazon S3 to encode object keys in the response.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #encodingType} will
* return {@link EncodingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #encodingTypeAsString}.
*
*
* @return Encoding type used by Amazon S3 to encode object keys in the response.
* @see EncodingType
*/
public String encodingTypeAsString() {
return encodingType;
}
/**
*
* Sets the maximum number of keys returned in the response. The response might contain fewer keys but will never
* contain more.
*
*
* @return Sets the maximum number of keys returned in the response. The response might contain fewer keys but will
* never contain more.
*/
public Integer maxKeys() {
return maxKeys;
}
/**
*
* Limits the response to keys that begin with the specified prefix.
*
*
* @return Limits the response to keys that begin with the specified prefix.
*/
public String prefix() {
return prefix;
}
/**
*
* ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token.
* ContinuationToken is obfuscated and is not a real key
*
*
* @return ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token.
* ContinuationToken is obfuscated and is not a real key
*/
public String continuationToken() {
return continuationToken;
}
/**
*
* The owner field is not present in listV2 by default, if you want to return owner field with each key in the
* result then set the fetch owner field to true
*
*
* @return The owner field is not present in listV2 by default, if you want to return owner field with each key in
* the result then set the fetch owner field to true
*/
public Boolean fetchOwner() {
return fetchOwner;
}
/**
*
* StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key.
* StartAfter can be any key in the bucket
*
*
* @return StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this
* specified key. StartAfter can be any key in the bucket
*/
public String startAfter() {
return startAfter;
}
/**
*
* Confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket
* owners need not specify this parameter in their requests.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #requestPayer} will
* return {@link RequestPayer#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #requestPayerAsString}.
*
*
* @return Confirms that the requester knows that she or he will be charged for the list objects request in V2
* style. Bucket owners need not specify this parameter in their requests.
* @see RequestPayer
*/
public RequestPayer requestPayer() {
return RequestPayer.fromValue(requestPayer);
}
/**
*
* Confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket
* owners need not specify this parameter in their requests.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #requestPayer} will
* return {@link RequestPayer#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #requestPayerAsString}.
*
*
* @return Confirms that the requester knows that she or he will be charged for the list objects request in V2
* style. Bucket owners need not specify this parameter in their requests.
* @see RequestPayer
*/
public String requestPayerAsString() {
return requestPayer;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(bucket());
hashCode = 31 * hashCode + Objects.hashCode(delimiter());
hashCode = 31 * hashCode + Objects.hashCode(encodingTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(maxKeys());
hashCode = 31 * hashCode + Objects.hashCode(prefix());
hashCode = 31 * hashCode + Objects.hashCode(continuationToken());
hashCode = 31 * hashCode + Objects.hashCode(fetchOwner());
hashCode = 31 * hashCode + Objects.hashCode(startAfter());
hashCode = 31 * hashCode + Objects.hashCode(requestPayerAsString());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ListObjectsV2Request)) {
return false;
}
ListObjectsV2Request other = (ListObjectsV2Request) obj;
return Objects.equals(bucket(), other.bucket()) && Objects.equals(delimiter(), other.delimiter())
&& Objects.equals(encodingTypeAsString(), other.encodingTypeAsString())
&& Objects.equals(maxKeys(), other.maxKeys()) && Objects.equals(prefix(), other.prefix())
&& Objects.equals(continuationToken(), other.continuationToken())
&& Objects.equals(fetchOwner(), other.fetchOwner()) && Objects.equals(startAfter(), other.startAfter())
&& Objects.equals(requestPayerAsString(), other.requestPayerAsString());
}
/**
* 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 String toString() {
return ToString.builder("ListObjectsV2Request").add("Bucket", bucket()).add("Delimiter", delimiter())
.add("EncodingType", encodingTypeAsString()).add("MaxKeys", maxKeys()).add("Prefix", prefix())
.add("ContinuationToken", continuationToken()).add("FetchOwner", fetchOwner()).add("StartAfter", startAfter())
.add("RequestPayer", requestPayerAsString()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Bucket":
return Optional.ofNullable(clazz.cast(bucket()));
case "Delimiter":
return Optional.ofNullable(clazz.cast(delimiter()));
case "EncodingType":
return Optional.ofNullable(clazz.cast(encodingTypeAsString()));
case "MaxKeys":
return Optional.ofNullable(clazz.cast(maxKeys()));
case "Prefix":
return Optional.ofNullable(clazz.cast(prefix()));
case "ContinuationToken":
return Optional.ofNullable(clazz.cast(continuationToken()));
case "FetchOwner":
return Optional.ofNullable(clazz.cast(fetchOwner()));
case "StartAfter":
return Optional.ofNullable(clazz.cast(startAfter()));
case "RequestPayer":
return Optional.ofNullable(clazz.cast(requestPayerAsString()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function