Skip to content

Commit

Permalink
Update generated code (#1750)
Browse files Browse the repository at this point in the history
* update generated code

* Fix tests

---------

Co-authored-by: Jérémy Derussé <[email protected]>
  • Loading branch information
async-aws-bot and jderusse authored Aug 19, 2024
1 parent 9c2750a commit 5efc64b
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 45 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"variables": {
"${LATEST}": "3.320.0"
"${LATEST}": "3.320.2"
},
"endpoints": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/endpoints.json",
"services": {
Expand Down
4 changes: 4 additions & 0 deletions src/Service/S3/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## NOT RELEASED

### Added

- AWS api-change: Amazon Simple Storage Service / Features : Adds support for pagination in the S3 ListBuckets API.

### Changed

- Enable compiler optimization for the `sprintf` function.
Expand Down
2 changes: 1 addition & 1 deletion src/Service/S3/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
"dev-master": "2.4-dev"
}
}
}
16 changes: 12 additions & 4 deletions src/Service/S3/src/Enum/EncodingType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
namespace AsyncAws\S3\Enum;

/**
* Requests Amazon S3 to encode the object keys in the response and specifies the encoding method to use. An object key
* can contain any Unicode character; however, the XML 1.0 parser cannot parse some characters, such as characters with
* an ASCII value from 0 to 10. For characters that are not supported in XML 1.0, you can add this parameter to request
* that Amazon S3 encode the keys in the response.
* Encoding type used by Amazon S3 to encode the object keys [^1] in the response. Responses are encoded only in UTF-8.
* An object key can contain any Unicode character. However, the XML 1.0 parser can't parse certain characters, such as
* characters with an ASCII value from 0 to 10. For characters that aren't supported in XML 1.0, you can add this
* parameter to request that Amazon S3 encode the keys in the response. For more information about characters to avoid
* in object key names, see Object key naming guidelines [^2].
*
* > When using the URL encoding type, non-ASCII characters that are used in an object's key name will be
* > percent-encoded according to UTF-8 code values. For example, the object `test_file(3).png` will appear as
* > `test_file%283%29.png`.
*
* [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html
* [^2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html#object-key-guidelines
*/
final class EncodingType
{
Expand Down
57 changes: 57 additions & 0 deletions src/Service/S3/src/Input/ListBucketsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,45 @@

final class ListBucketsRequest extends Input
{
/**
* Maximum number of buckets to be returned in response. When the number is more than the count of buckets that are
* owned by an Amazon Web Services account, return all the buckets in response.
*
* @var int|null
*/
private $maxBuckets;

/**
* `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. You can use this `ContinuationToken` for pagination of the
* list results.
*
* Length Constraints: Minimum length of 0. Maximum length of 1024.
*
* Required: No.
*
* @var string|null
*/
private $continuationToken;

/**
* @param array{
* MaxBuckets?: null|int,
* ContinuationToken?: null|string,
* '@region'?: string|null,
* } $input
*/
public function __construct(array $input = [])
{
$this->maxBuckets = $input['MaxBuckets'] ?? null;
$this->continuationToken = $input['ContinuationToken'] ?? null;
parent::__construct($input);
}

/**
* @param array{
* MaxBuckets?: null|int,
* ContinuationToken?: null|string,
* '@region'?: string|null,
* }|ListBucketsRequest $input
*/
Expand All @@ -28,6 +55,16 @@ public static function create($input): self
return $input instanceof self ? $input : new self($input);
}

public function getContinuationToken(): ?string
{
return $this->continuationToken;
}

public function getMaxBuckets(): ?int
{
return $this->maxBuckets;
}

/**
* @internal
*/
Expand All @@ -38,6 +75,12 @@ public function request(): Request

// Prepare query
$query = [];
if (null !== $this->maxBuckets) {
$query['max-buckets'] = (string) $this->maxBuckets;
}
if (null !== $this->continuationToken) {
$query['continuation-token'] = $this->continuationToken;
}

// Prepare URI
$uriString = '/';
Expand All @@ -48,4 +91,18 @@ public function request(): Request
// Return the Request
return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body));
}

public function setContinuationToken(?string $value): self
{
$this->continuationToken = $value;

return $this;
}

public function setMaxBuckets(?int $value): self
{
$this->maxBuckets = $value;

return $this;
}
}
15 changes: 12 additions & 3 deletions src/Service/S3/src/Input/ListObjectsV2Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,18 @@ final class ListObjectsV2Request extends Input
private $delimiter;

/**
* Encoding type used by Amazon S3 to encode object keys in the response. If using `url`, non-ASCII characters used in
* an object's key name will be URL encoded. For example, the object `test_file(3).png` will appear as
* `test_file%283%29.png`.
* Encoding type used by Amazon S3 to encode the object keys [^1] in the response. Responses are encoded only in UTF-8.
* An object key can contain any Unicode character. However, the XML 1.0 parser can't parse certain characters, such as
* characters with an ASCII value from 0 to 10. For characters that aren't supported in XML 1.0, you can add this
* parameter to request that Amazon S3 encode the keys in the response. For more information about characters to avoid
* in object key names, see Object key naming guidelines [^2].
*
* > When using the URL encoding type, non-ASCII characters that are used in an object's key name will be
* > percent-encoded according to UTF-8 code values. For example, the object `test_file(3).png` will appear as
* > `test_file%283%29.png`.
*
* [^1]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html
* [^2]: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html#object-key-guidelines
*
* @var EncodingType::*|null
*/
Expand Down
58 changes: 56 additions & 2 deletions src/Service/S3/src/Result/ListBucketsOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace AsyncAws\S3\Result;

use AsyncAws\Core\Exception\InvalidArgument;
use AsyncAws\Core\Response;
use AsyncAws\Core\Result;
use AsyncAws\S3\Input\ListBucketsRequest;
use AsyncAws\S3\S3Client;
use AsyncAws\S3\ValueObject\Bucket;
use AsyncAws\S3\ValueObject\Owner;

Expand All @@ -27,13 +30,63 @@ class ListBucketsOutput extends Result implements \IteratorAggregate
private $owner;

/**
* `ContinuationToken` is included in the response when there are more buckets that can be listed with pagination. The
* next `ListBuckets` request to Amazon S3 can be continued with this `ContinuationToken`. `ContinuationToken` is
* obfuscated and is not a real bucket.
*
* @var string|null
*/
private $continuationToken;

/**
* @param bool $currentPageOnly When true, iterates over items of the current page. Otherwise also fetch items in the next pages.
*
* @return iterable<Bucket>
*/
public function getBuckets(): iterable
public function getBuckets(bool $currentPageOnly = false): iterable
{
if ($currentPageOnly) {
$this->initialize();
yield from $this->buckets;

return;
}

$client = $this->awsClient;
if (!$client instanceof S3Client) {
throw new InvalidArgument('missing client injected in paginated result');
}
if (!$this->input instanceof ListBucketsRequest) {
throw new InvalidArgument('missing last request injected in paginated result');
}
$input = clone $this->input;
$page = $this;
while (true) {
$page->initialize();
if ($page->continuationToken) {
$input->setContinuationToken($page->continuationToken);

$this->registerPrefetch($nextPage = $client->listBuckets($input));
} else {
$nextPage = null;
}

yield from $page->buckets;

if (null === $nextPage) {
break;
}

$this->unregisterPrefetch($nextPage);
$page = $nextPage;
}
}

public function getContinuationToken(): ?string
{
$this->initialize();

return $this->buckets;
return $this->continuationToken;
}

/**
Expand Down Expand Up @@ -61,6 +114,7 @@ protected function populateResult(Response $response): void
'DisplayName' => ($v = $data->Owner->DisplayName) ? (string) $v : null,
'ID' => ($v = $data->Owner->ID) ? (string) $v : null,
]);
$this->continuationToken = ($v = $data->ContinuationToken) ? (string) $v : null;
}

/**
Expand Down
Loading

0 comments on commit 5efc64b

Please sign in to comment.