software.amazon.awssdk.services.s3.model.ListObjectsV2Request Maven / Gradle / Ivy
Show all versions of s3 Show documentation
/*
* 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.s3.model;
import java.util.Arrays;
import java.util.Collection;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.traits.RequiredTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
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)
.memberName("Bucket")
.getter(getter(ListObjectsV2Request::bucket))
.setter(setter(Builder::bucket))
.traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("Bucket")
.unmarshallLocationName("Bucket").build(), RequiredTrait.create()).build();
private static final SdkField DELIMITER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Delimiter")
.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)
.memberName("EncodingType")
.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)
.memberName("MaxKeys")
.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)
.memberName("Prefix")
.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)
.memberName("ContinuationToken")
.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)
.memberName("FetchOwner")
.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)
.memberName("StartAfter")
.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)
.memberName("RequestPayer")
.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 SdkField EXPECTED_BUCKET_OWNER_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ExpectedBucketOwner")
.getter(getter(ListObjectsV2Request::expectedBucketOwner))
.setter(setter(Builder::expectedBucketOwner))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-expected-bucket-owner")
.unmarshallLocationName("x-amz-expected-bucket-owner").build()).build();
private static final SdkField> OPTIONAL_OBJECT_ATTRIBUTES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("OptionalObjectAttributes")
.getter(getter(ListObjectsV2Request::optionalObjectAttributesAsStrings))
.setter(setter(Builder::optionalObjectAttributesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.HEADER).locationName("x-amz-optional-object-attributes")
.unmarshallLocationName("x-amz-optional-object-attributes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").unmarshallLocationName("member").build()).build())
.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, EXPECTED_BUCKET_OWNER_FIELD, OPTIONAL_OBJECT_ATTRIBUTES_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 final String expectedBucketOwner;
private final List optionalObjectAttributes;
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;
this.expectedBucketOwner = builder.expectedBucketOwner;
this.optionalObjectAttributes = builder.optionalObjectAttributes;
}
/**
*
* Bucket name to list.
*
*
* When using this action with an access point, you must direct requests to the access point hostname. The access
* point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com.
* When using this action with an access point through the Amazon Web Services SDKs, you provide the access point
* ARN in place of the bucket name. For more information about access point ARNs, see Using access points in
* the Amazon S3 User Guide.
*
*
* When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The
* S3 on Outposts hostname takes the form
* AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
* When you use this action with S3 on Outposts through the Amazon Web Services SDKs, you provide the Outposts
* access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see What is S3 on Outposts? in the
* Amazon S3 User Guide.
*
*
* @return Bucket name to list.
*
* When using this action with an access point, you must direct requests to the access point hostname. The
* access point hostname takes the form
* AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this
* action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in
* place of the bucket name. For more information about access point ARNs, see Using access
* points in the Amazon S3 User Guide.
*
*
* When you use this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts
* hostname. The S3 on Outposts hostname takes the form
* AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
* . When you use this action with S3 on Outposts through the Amazon Web Services SDKs, you provide the
* Outposts access point ARN in place of the bucket name. For more information about S3 on Outposts ARNs,
* see What is S3 on
* Outposts? in the Amazon S3 User Guide.
*/
public final String bucket() {
return bucket;
}
/**
*
* A delimiter is a character that you use to group keys.
*
*
* @return A delimiter is a character that you use to group keys.
*/
public final 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 final 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 final String encodingTypeAsString() {
return encodingType;
}
/**
*
* Sets the maximum number of keys returned in the response. By default, the action returns up to 1,000 key names.
* The response might contain fewer keys but will never contain more.
*
*
* @return Sets the maximum number of keys returned in the response. By default, the action returns up to 1,000 key
* names. The response might contain fewer keys but will never contain more.
*/
public final 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 final String prefix() {
return prefix;
}
/**
*
* ContinuationToken
indicates to 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 to Amazon S3 that the list is being continued on this bucket
* with a token. ContinuationToken
is obfuscated and is not a real key.
*/
public final String continuationToken() {
return continuationToken;
}
/**
*
* The owner field is not present in ListObjectsV2
by default. If you want to return the owner field
* with each key in the result, then set the FetchOwner
field to true
.
*
*
* @return The owner field is not present in ListObjectsV2
by default. If you want to return the owner
* field with each key in the result, then set the FetchOwner
field to true
.
*/
public final 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 final 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 final 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 final String requestPayerAsString() {
return requestPayer;
}
/**
*
* The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails
* with the HTTP status code 403 Forbidden
(access denied).
*
*
* @return The account ID of the expected bucket owner. If the bucket is owned by a different account, the request
* fails with the HTTP status code 403 Forbidden
(access denied).
*/
public final String expectedBucketOwner() {
return expectedBucketOwner;
}
/**
*
* Specifies the optional fields that you want returned in the response. Fields that you do not specify are not
* returned.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasOptionalObjectAttributes} method.
*
*
* @return Specifies the optional fields that you want returned in the response. Fields that you do not specify are
* not returned.
*/
public final List optionalObjectAttributes() {
return OptionalObjectAttributesListCopier.copyStringToEnum(optionalObjectAttributes);
}
/**
* For responses, this returns true if the service returned a value for the OptionalObjectAttributes property. This
* DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the
* property). This is useful because the SDK will never return a null collection or map, but you may need to
* differentiate between the service returning nothing (or null) and the service returning an empty collection or
* map. For requests, this returns true if a value for the property was specified in the request builder, and false
* if a value was not specified.
*/
public final boolean hasOptionalObjectAttributes() {
return optionalObjectAttributes != null && !(optionalObjectAttributes instanceof SdkAutoConstructList);
}
/**
*
* Specifies the optional fields that you want returned in the response. Fields that you do not specify are not
* returned.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasOptionalObjectAttributes} method.
*
*
* @return Specifies the optional fields that you want returned in the response. Fields that you do not specify are
* not returned.
*/
public final List optionalObjectAttributesAsStrings() {
return optionalObjectAttributes;
}
@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(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());
hashCode = 31 * hashCode + Objects.hashCode(expectedBucketOwner());
hashCode = 31 * hashCode + Objects.hashCode(hasOptionalObjectAttributes() ? optionalObjectAttributesAsStrings() : null);
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 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())
&& Objects.equals(expectedBucketOwner(), other.expectedBucketOwner())
&& hasOptionalObjectAttributes() == other.hasOptionalObjectAttributes()
&& Objects.equals(optionalObjectAttributesAsStrings(), other.optionalObjectAttributesAsStrings());
}
/**
* 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("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()).add("ExpectedBucketOwner", expectedBucketOwner())
.add("OptionalObjectAttributes", hasOptionalObjectAttributes() ? optionalObjectAttributesAsStrings() : null)
.build();
}
public final 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()));
case "ExpectedBucketOwner":
return Optional.ofNullable(clazz.cast(expectedBucketOwner()));
case "OptionalObjectAttributes":
return Optional.ofNullable(clazz.cast(optionalObjectAttributesAsStrings()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function