Skip to content

Commit

Permalink
Update generated code (#1806)
Browse files Browse the repository at this point in the history
update generated code
  • Loading branch information
async-aws-bot authored Nov 22, 2024
1 parent 409f70c commit 7b9cbfd
Show file tree
Hide file tree
Showing 11 changed files with 328 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- AWS api-change: Add support for the new optional bucket-region and prefix query parameters in the ListBuckets API. For ListBuckets requests that express pagination, Amazon S3 will now return both the bucket names and associated AWS regions in the response.
- AWS api-change: Add support for conditional deletes for the S3 DeleteObject and DeleteObjects APIs. Add support for write offset bytes option used to append to objects with the S3 PutObject API.

### Changed

Expand Down
13 changes: 13 additions & 0 deletions src/Exception/EncryptionTypeMismatchException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace AsyncAws\S3\Exception;

use AsyncAws\Core\Exception\Http\ClientException;

/**
* The existing object was created with a different encryption type. Subsequent write requests must include the
* appropriate encryption parameters in the request or while creating the session.
*/
final class EncryptionTypeMismatchException extends ClientException
{
}
17 changes: 17 additions & 0 deletions src/Exception/InvalidRequestException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace AsyncAws\S3\Exception;

use AsyncAws\Core\Exception\Http\ClientException;

/**
* You may receive this error in multiple cases. Depending on the reason for the error, you may receive one of the
* messages below:
*
* - Cannot specify both a write offset value and user-defined object metadata for existing objects.
* - Checksum Type mismatch occurred, expected checksum Type: sha1, actual checksum Type: crc32c.
* - Request body cannot be empty when 'write offset' is specified.
*/
final class InvalidRequestException extends ClientException
{
}
12 changes: 12 additions & 0 deletions src/Exception/InvalidWriteOffsetException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace AsyncAws\S3\Exception;

use AsyncAws\Core\Exception\Http\ClientException;

/**
* The write offset value that you specified does not match the current object size.
*/
final class InvalidWriteOffsetException extends ClientException
{
}
13 changes: 13 additions & 0 deletions src/Exception/TooManyPartsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace AsyncAws\S3\Exception;

use AsyncAws\Core\Exception\Http\ClientException;

/**
* You have attempted to add more parts than the maximum of 10000 that are allowed for this object. You can use the
* CopyObject operation to copy this object to another and then add more data to the newly copied object.
*/
final class TooManyPartsException extends ClientException
{
}
30 changes: 30 additions & 0 deletions src/Input/AbortMultipartUploadRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,26 @@ final class AbortMultipartUploadRequest extends Input
*/
private $expectedBucketOwner;

/**
* If present, this header aborts an in progress multipart upload only if it was initiated on the provided timestamp. If
* the initiated timestamp of the multipart upload does not match the provided value, the operation returns a `412
* Precondition Failed` error. If the initiated timestamp matches or if the multipart upload doesn’t exist, the
* operation returns a `204 Success (No Content)` response.
*
* > This functionality is only supported for directory buckets.
*
* @var \DateTimeImmutable|null
*/
private $ifMatchInitiatedTime;

/**
* @param array{
* Bucket?: string,
* Key?: string,
* UploadId?: string,
* RequestPayer?: null|RequestPayer::*,
* ExpectedBucketOwner?: null|string,
* IfMatchInitiatedTime?: null|\DateTimeImmutable|string,
* '@region'?: string|null,
* } $input
*/
Expand All @@ -92,6 +105,7 @@ public function __construct(array $input = [])
$this->uploadId = $input['UploadId'] ?? null;
$this->requestPayer = $input['RequestPayer'] ?? null;
$this->expectedBucketOwner = $input['ExpectedBucketOwner'] ?? null;
$this->ifMatchInitiatedTime = !isset($input['IfMatchInitiatedTime']) ? null : ($input['IfMatchInitiatedTime'] instanceof \DateTimeImmutable ? $input['IfMatchInitiatedTime'] : new \DateTimeImmutable($input['IfMatchInitiatedTime']));
parent::__construct($input);
}

Expand All @@ -102,6 +116,7 @@ public function __construct(array $input = [])
* UploadId?: string,
* RequestPayer?: null|RequestPayer::*,
* ExpectedBucketOwner?: null|string,
* IfMatchInitiatedTime?: null|\DateTimeImmutable|string,
* '@region'?: string|null,
* }|AbortMultipartUploadRequest $input
*/
Expand All @@ -120,6 +135,11 @@ public function getExpectedBucketOwner(): ?string
return $this->expectedBucketOwner;
}

public function getIfMatchInitiatedTime(): ?\DateTimeImmutable
{
return $this->ifMatchInitiatedTime;
}

public function getKey(): ?string
{
return $this->key;
Expand Down Expand Up @@ -154,6 +174,9 @@ public function request(): Request
if (null !== $this->expectedBucketOwner) {
$headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner;
}
if (null !== $this->ifMatchInitiatedTime) {
$headers['x-amz-if-match-initiated-time'] = $this->ifMatchInitiatedTime->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
}

// Prepare query
$query = [];
Expand Down Expand Up @@ -195,6 +218,13 @@ public function setExpectedBucketOwner(?string $value): self
return $this;
}

public function setIfMatchInitiatedTime(?\DateTimeImmutable $value): self
{
$this->ifMatchInitiatedTime = $value;

return $this;
}

public function setKey(?string $value): self
{
$this->key = $value;
Expand Down
94 changes: 94 additions & 0 deletions src/Input/DeleteObjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,46 @@ final class DeleteObjectRequest extends Input
*/
private $expectedBucketOwner;

/**
* The `If-Match` header field makes the request method conditional on ETags. If the ETag value does not match, the
* operation returns a `412 Precondition Failed` error. If the ETag matches or if the object doesn't exist, the
* operation will return a `204 Success (No Content) response`.
*
* For more information about conditional requests, see RFC 7232 [^1].
*
* > This functionality is only supported for directory buckets.
*
* [^1]: https://docs.aws.amazon.com/https:/tools.ietf.org/html/rfc7232
*
* @var string|null
*/
private $ifMatch;

/**
* If present, the object is deleted only if its modification times matches the provided `Timestamp`. If the `Timestamp`
* values do not match, the operation returns a `412 Precondition Failed` error. If the `Timestamp` matches or if the
* object doesn’t exist, the operation returns a `204 Success (No Content)` response.
*
* > This functionality is only supported for directory buckets.
*
* @var \DateTimeImmutable|null
*/
private $ifMatchLastModifiedTime;

/**
* If present, the object is deleted only if its size matches the provided size in bytes. If the `Size` value does not
* match, the operation returns a `412 Precondition Failed` error. If the `Size` matches or if the object doesn’t
* exist, the operation returns a `204 Success (No Content)` response.
*
* > This functionality is only supported for directory buckets.
*
* ! You can use the `If-Match`, `x-amz-if-match-last-modified-time` and `x-amz-if-match-size` conditional headers in
* ! conjunction with each-other or individually.
*
* @var int|null
*/
private $ifMatchSize;

/**
* @param array{
* Bucket?: string,
Expand All @@ -105,6 +145,9 @@ final class DeleteObjectRequest extends Input
* RequestPayer?: null|RequestPayer::*,
* BypassGovernanceRetention?: null|bool,
* ExpectedBucketOwner?: null|string,
* IfMatch?: null|string,
* IfMatchLastModifiedTime?: null|\DateTimeImmutable|string,
* IfMatchSize?: null|int,
* '@region'?: string|null,
* } $input
*/
Expand All @@ -117,6 +160,9 @@ public function __construct(array $input = [])
$this->requestPayer = $input['RequestPayer'] ?? null;
$this->bypassGovernanceRetention = $input['BypassGovernanceRetention'] ?? null;
$this->expectedBucketOwner = $input['ExpectedBucketOwner'] ?? null;
$this->ifMatch = $input['IfMatch'] ?? null;
$this->ifMatchLastModifiedTime = !isset($input['IfMatchLastModifiedTime']) ? null : ($input['IfMatchLastModifiedTime'] instanceof \DateTimeImmutable ? $input['IfMatchLastModifiedTime'] : new \DateTimeImmutable($input['IfMatchLastModifiedTime']));
$this->ifMatchSize = $input['IfMatchSize'] ?? null;
parent::__construct($input);
}

Expand All @@ -129,6 +175,9 @@ public function __construct(array $input = [])
* RequestPayer?: null|RequestPayer::*,
* BypassGovernanceRetention?: null|bool,
* ExpectedBucketOwner?: null|string,
* IfMatch?: null|string,
* IfMatchLastModifiedTime?: null|\DateTimeImmutable|string,
* IfMatchSize?: null|int,
* '@region'?: string|null,
* }|DeleteObjectRequest $input
*/
Expand All @@ -152,6 +201,21 @@ public function getExpectedBucketOwner(): ?string
return $this->expectedBucketOwner;
}

public function getIfMatch(): ?string
{
return $this->ifMatch;
}

public function getIfMatchLastModifiedTime(): ?\DateTimeImmutable
{
return $this->ifMatchLastModifiedTime;
}

public function getIfMatchSize(): ?int
{
return $this->ifMatchSize;
}

public function getKey(): ?string
{
return $this->key;
Expand Down Expand Up @@ -197,6 +261,15 @@ public function request(): Request
if (null !== $this->expectedBucketOwner) {
$headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner;
}
if (null !== $this->ifMatch) {
$headers['If-Match'] = $this->ifMatch;
}
if (null !== $this->ifMatchLastModifiedTime) {
$headers['x-amz-if-match-last-modified-time'] = $this->ifMatchLastModifiedTime->setTimezone(new \DateTimeZone('GMT'))->format(\DateTimeInterface::RFC7231);
}
if (null !== $this->ifMatchSize) {
$headers['x-amz-if-match-size'] = (string) $this->ifMatchSize;
}

// Prepare query
$query = [];
Expand Down Expand Up @@ -244,6 +317,27 @@ public function setExpectedBucketOwner(?string $value): self
return $this;
}

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

return $this;
}

public function setIfMatchLastModifiedTime(?\DateTimeImmutable $value): self
{
$this->ifMatchLastModifiedTime = $value;

return $this;
}

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

return $this;
}

public function setKey(?string $value): self
{
$this->key = $value;
Expand Down
29 changes: 29 additions & 0 deletions src/Input/PutObjectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ final class PutObjectRequest extends Input
*/
private $key;

/**
* Specifies the offset for appending data to existing objects in bytes. The offset must be equal to the size of the
* existing object being appended to. If no object exists, setting this header to 0 will create a new object.
*
* > This functionality is only supported for objects in the Amazon S3 Express One Zone storage class in directory
* > buckets.
*
* @var int|null
*/
private $writeOffsetBytes;

/**
* A map of metadata to store with the object in S3.
*
Expand Down Expand Up @@ -592,6 +603,7 @@ final class PutObjectRequest extends Input
* GrantReadACP?: null|string,
* GrantWriteACP?: null|string,
* Key?: string,
* WriteOffsetBytes?: null|int,
* Metadata?: null|array<string, string>,
* ServerSideEncryption?: null|ServerSideEncryption::*,
* StorageClass?: null|StorageClass::*,
Expand Down Expand Up @@ -635,6 +647,7 @@ public function __construct(array $input = [])
$this->grantReadAcp = $input['GrantReadACP'] ?? null;
$this->grantWriteAcp = $input['GrantWriteACP'] ?? null;
$this->key = $input['Key'] ?? null;
$this->writeOffsetBytes = $input['WriteOffsetBytes'] ?? null;
$this->metadata = $input['Metadata'] ?? null;
$this->serverSideEncryption = $input['ServerSideEncryption'] ?? null;
$this->storageClass = $input['StorageClass'] ?? null;
Expand Down Expand Up @@ -678,6 +691,7 @@ public function __construct(array $input = [])
* GrantReadACP?: null|string,
* GrantWriteACP?: null|string,
* Key?: string,
* WriteOffsetBytes?: null|int,
* Metadata?: null|array<string, string>,
* ServerSideEncryption?: null|ServerSideEncryption::*,
* StorageClass?: null|StorageClass::*,
Expand Down Expand Up @@ -919,6 +933,11 @@ public function getWebsiteRedirectLocation(): ?string
return $this->websiteRedirectLocation;
}

public function getWriteOffsetBytes(): ?int
{
return $this->writeOffsetBytes;
}

/**
* @internal
*/
Expand Down Expand Up @@ -989,6 +1008,9 @@ public function request(): Request
if (null !== $this->grantWriteAcp) {
$headers['x-amz-grant-write-acp'] = $this->grantWriteAcp;
}
if (null !== $this->writeOffsetBytes) {
$headers['x-amz-write-offset-bytes'] = (string) $this->writeOffsetBytes;
}
if (null !== $this->serverSideEncryption) {
if (!ServerSideEncryption::exists($this->serverSideEncryption)) {
throw new InvalidArgument(\sprintf('Invalid parameter "ServerSideEncryption" for "%s". The value "%s" is not a valid "ServerSideEncryption".', __CLASS__, $this->serverSideEncryption));
Expand Down Expand Up @@ -1369,4 +1391,11 @@ public function setWebsiteRedirectLocation(?string $value): self

return $this;
}

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

return $this;
}
}
Loading

0 comments on commit 7b9cbfd

Please sign in to comment.