Skip to content

Commit

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

* Fix test

---------

Co-authored-by: Jérémy Derussé <[email protected]>
  • Loading branch information
async-aws-bot and jderusse authored May 10, 2024
1 parent 887181f commit 552da3a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## NOT RELEASED

### Added

- AWS api-change: This release adds MessageSystemAttributeNames to ReceiveMessageRequest to replace AttributeNames.

### Changed

- AWS enhancement: Documentation updates.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "2.1-dev"
}
}
}
75 changes: 72 additions & 3 deletions src/Input/ReceiveMessageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,37 @@ final class ReceiveMessageRequest extends Input
*/
private $attributeNames;

/**
* A list of attributes that need to be returned along with each message. These attributes include:
*
* - `All` – Returns all values.
* - `ApproximateFirstReceiveTimestamp` – Returns the time the message was first received from the queue (epoch time
* [^1] in milliseconds).
* - `ApproximateReceiveCount` – Returns the number of times a message has been received across all queues but not
* deleted.
* - `AWSTraceHeader` – Returns the X-Ray trace header string.
* - `SenderId`
*
* - For a user, returns the user ID, for example `ABCDEFGHI1JKLMNOPQ23R`.
* - For an IAM role, returns the IAM role ID, for example `ABCDE1F2GH3I4JK5LMNOP:i-a123b456`.
*
* - `SentTimestamp` – Returns the time the message was sent to the queue (epoch time [^2] in milliseconds).
* - `SqsManagedSseEnabled` – Enables server-side queue encryption using SQS owned encryption keys. Only one
* server-side encryption option is supported per queue (for example, SSE-KMS [^3] or SSE-SQS [^4]).
* - `MessageDeduplicationId` – Returns the value provided by the producer that calls the `SendMessage` action.
* - `MessageGroupId` – Returns the value provided by the producer that calls the `SendMessage` action. Messages with
* the same `MessageGroupId` are returned in sequence.
* - `SequenceNumber` – Returns the value provided by Amazon SQS.
*
* [^1]: http://en.wikipedia.org/wiki/Unix_time
* [^2]: http://en.wikipedia.org/wiki/Unix_time
* [^3]: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-sse-existing-queue.html
* [^4]: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-sqs-sse-queue.html
*
* @var list<MessageSystemAttributeName::*>|null
*/
private $messageSystemAttributeNames;

/**
* The name of the message attribute, where *N* is the index.
*
Expand Down Expand Up @@ -62,7 +93,7 @@ final class ReceiveMessageRequest extends Input
/**
* The duration (in seconds) for which the call waits for a message to arrive in the queue before returning. If a
* message is available, the call returns sooner than `WaitTimeSeconds`. If no messages are available and the wait time
* expires, the call returns successfully with an empty list of messages.
* expires, the call does not return a message list.
*
* ! To avoid HTTP errors, ensure that the HTTP response timeout for `ReceiveMessage` requests is longer than the
* ! `WaitTimeSeconds` parameter. For example, with the Java SDK, you can set HTTP transport settings using the
Expand All @@ -86,8 +117,6 @@ final class ReceiveMessageRequest extends Input
* - You can use `ReceiveRequestAttemptId` only for 5 minutes after a `ReceiveMessage` action.
* - When you set `FifoQueue`, a caller of the `ReceiveMessage` action can provide a `ReceiveRequestAttemptId`
* explicitly.
* - If a caller of the `ReceiveMessage` action doesn't provide a `ReceiveRequestAttemptId`, Amazon SQS generates a
* `ReceiveRequestAttemptId`.
* - It is possible to retry the `ReceiveMessage` action with the same `ReceiveRequestAttemptId` if none of the messages
* have been modified (deleted or had their visibility changes).
* - During a visibility timeout, subsequent calls with the same `ReceiveRequestAttemptId` return the same messages and
Expand Down Expand Up @@ -125,6 +154,7 @@ final class ReceiveMessageRequest extends Input
* @param array{
* QueueUrl?: string,
* AttributeNames?: null|array<MessageSystemAttributeName::*>,
* MessageSystemAttributeNames?: null|array<MessageSystemAttributeName::*>,
* MessageAttributeNames?: null|string[],
* MaxNumberOfMessages?: null|int,
* VisibilityTimeout?: null|int,
Expand All @@ -137,6 +167,7 @@ public function __construct(array $input = [])
{
$this->queueUrl = $input['QueueUrl'] ?? null;
$this->attributeNames = $input['AttributeNames'] ?? null;
$this->messageSystemAttributeNames = $input['MessageSystemAttributeNames'] ?? null;
$this->messageAttributeNames = $input['MessageAttributeNames'] ?? null;
$this->maxNumberOfMessages = $input['MaxNumberOfMessages'] ?? null;
$this->visibilityTimeout = $input['VisibilityTimeout'] ?? null;
Expand All @@ -149,6 +180,7 @@ public function __construct(array $input = [])
* @param array{
* QueueUrl?: string,
* AttributeNames?: null|array<MessageSystemAttributeName::*>,
* MessageSystemAttributeNames?: null|array<MessageSystemAttributeName::*>,
* MessageAttributeNames?: null|string[],
* MaxNumberOfMessages?: null|int,
* VisibilityTimeout?: null|int,
Expand All @@ -163,10 +195,14 @@ public static function create($input): self
}

/**
* @deprecated
*
* @return list<MessageSystemAttributeName::*>
*/
public function getAttributeNames(): array
{
@trigger_error(sprintf('The property "AttributeNames" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED);

return $this->attributeNames ?? [];
}

Expand All @@ -183,6 +219,14 @@ public function getMessageAttributeNames(): array
return $this->messageAttributeNames ?? [];
}

/**
* @return list<MessageSystemAttributeName::*>
*/
public function getMessageSystemAttributeNames(): array
{
return $this->messageSystemAttributeNames ?? [];
}

public function getQueueUrl(): ?string
{
return $this->queueUrl;
Expand Down Expand Up @@ -229,10 +273,13 @@ public function request(): Request
}

/**
* @deprecated
*
* @param list<MessageSystemAttributeName::*> $value
*/
public function setAttributeNames(array $value): self
{
@trigger_error(sprintf('The property "AttributeNames" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED);
$this->attributeNames = $value;

return $this;
Expand All @@ -255,6 +302,16 @@ public function setMessageAttributeNames(array $value): self
return $this;
}

/**
* @param list<MessageSystemAttributeName::*> $value
*/
public function setMessageSystemAttributeNames(array $value): self
{
$this->messageSystemAttributeNames = $value;

return $this;
}

public function setQueueUrl(?string $value): self
{
$this->queueUrl = $value;
Expand Down Expand Up @@ -291,6 +348,7 @@ private function requestBody(): array
}
$payload['QueueUrl'] = $v;
if (null !== $v = $this->attributeNames) {
@trigger_error(sprintf('The property "AttributeNames" of "%s" is deprecated by AWS.', __CLASS__), \E_USER_DEPRECATED);
$index = -1;
$payload['AttributeNames'] = [];
foreach ($v as $listValue) {
Expand All @@ -301,6 +359,17 @@ private function requestBody(): array
$payload['AttributeNames'][$index] = $listValue;
}
}
if (null !== $v = $this->messageSystemAttributeNames) {
$index = -1;
$payload['MessageSystemAttributeNames'] = [];
foreach ($v as $listValue) {
++$index;
if (!MessageSystemAttributeName::exists($listValue)) {
throw new InvalidArgument(sprintf('Invalid parameter "MessageSystemAttributeNames" for "%s". The value "%s" is not a valid "MessageSystemAttributeName".', __CLASS__, $listValue));
}
$payload['MessageSystemAttributeNames'][$index] = $listValue;
}
}
if (null !== $v = $this->messageAttributeNames) {
$index = -1;
$payload['MessageAttributeNames'] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Input/SendMessageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ final class SendMessageRequest extends Input
* - `ReceiveMessage` might return messages with multiple `MessageGroupId` values. For each `MessageGroupId`, the
* messages are sorted by time sent. The caller can't specify a `MessageGroupId`.
*
* The length of `MessageGroupId` is 128 characters. Valid values: alphanumeric characters and punctuation
* The maximum length of `MessageGroupId` is 128 characters. Valid values: alphanumeric characters and punctuation
* `(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)`.
*
* For best practices of using `MessageGroupId`, see Using the MessageGroupId Property [^1] in the *Amazon SQS Developer
Expand Down
1 change: 1 addition & 0 deletions src/SqsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ public function queueExists($input): QueueExistsWaiter
* @param array{
* QueueUrl: string,
* AttributeNames?: null|array<MessageSystemAttributeName::*>,
* MessageSystemAttributeNames?: null|array<MessageSystemAttributeName::*>,
* MessageAttributeNames?: null|string[],
* MaxNumberOfMessages?: null|int,
* VisibilityTimeout?: null|int,
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Input/ReceiveMessageRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testRequest(): void
{
$input = new ReceiveMessageRequest([
'QueueUrl' => 'queueUrl',
'AttributeNames' => [MessageSystemAttributeName::MESSAGE_GROUP_ID, MessageSystemAttributeName::MESSAGE_DEDUPLICATION_ID],
'MessageSystemAttributeNames' => [MessageSystemAttributeName::MESSAGE_GROUP_ID, MessageSystemAttributeName::MESSAGE_DEDUPLICATION_ID],
'MessageAttributeNames' => ['Attribute1'],
'MaxNumberOfMessages' => 5,
'VisibilityTimeout' => 15,
Expand All @@ -28,7 +28,7 @@ public function testRequest(): void
{
"QueueUrl": "queueUrl",
"AttributeNames": ["MessageGroupId", "MessageDeduplicationId"],
"MessageSystemAttributeNames": ["MessageGroupId", "MessageDeduplicationId"],
"MessageAttributeNames": ["Attribute1"],
"MaxNumberOfMessages": 5,
"VisibilityTimeout": 15,
Expand Down

0 comments on commit 552da3a

Please sign in to comment.