diff --git a/manifest.json b/manifest.json index cfad299a7..2836438c6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "variables": { - "${LATEST}": "3.366.4" + "${LATEST}": "3.367.1" }, "endpoints": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/endpoints.json", "services": { diff --git a/src/CodeGenerator/src/Generator/ResponseParser/RestJsonParser.php b/src/CodeGenerator/src/Generator/ResponseParser/RestJsonParser.php index 4bf86e25f..23df950b7 100644 --- a/src/CodeGenerator/src/Generator/ResponseParser/RestJsonParser.php +++ b/src/CodeGenerator/src/Generator/ResponseParser/RestJsonParser.php @@ -105,9 +105,6 @@ public function generate(StructureShape $shape, bool $throwOnError = true): Pars } $body = '$data = $response->toArray(' . ($throwOnError ? '' : 'false') . ');' . "\n"; - if (null !== $wrapper = $shape->getResultWrapper()) { - $body .= strtr('$data = $data[WRAPPER];' . "\n", ['WRAPPER' => var_export($wrapper, true)]); - } $body .= "\n" . implode("\n", $properties); return new ParserResult($body, $this->imports, $this->functions); diff --git a/src/Service/CloudWatch/CHANGELOG.md b/src/Service/CloudWatch/CHANGELOG.md index 3115035eb..07f25e03c 100644 --- a/src/Service/CloudWatch/CHANGELOG.md +++ b/src/Service/CloudWatch/CHANGELOG.md @@ -6,6 +6,7 @@ - AWS api-change: Added `us-isob-west-1` region - AWS api-change: Added `eusc-de-east-1` region +- AWS api-change: This release switch to the AWS JSON 1.1 Procol, replacing the currently utilized one, AWSQuery. ### Dependency bumped diff --git a/src/Service/CloudWatch/composer.json b/src/Service/CloudWatch/composer.json index c5125da6c..a429f7485 100644 --- a/src/Service/CloudWatch/composer.json +++ b/src/Service/CloudWatch/composer.json @@ -12,7 +12,7 @@ ], "require": { "php": "^8.2", - "ext-simplexml": "*", + "ext-json": "*", "async-aws/core": "^1.9" }, "require-dev": { diff --git a/src/Service/CloudWatch/src/CloudWatchClient.php b/src/Service/CloudWatch/src/CloudWatchClient.php index 5647ec74d..b7f1a9012 100644 --- a/src/Service/CloudWatch/src/CloudWatchClient.php +++ b/src/Service/CloudWatch/src/CloudWatchClient.php @@ -26,7 +26,7 @@ use AsyncAws\CloudWatch\ValueObject\MetricDatum; use AsyncAws\Core\AbstractApi; use AsyncAws\Core\AwsError\AwsErrorFactoryInterface; -use AsyncAws\Core\AwsError\XmlAwsErrorFactory; +use AsyncAws\Core\AwsError\JsonRpcAwsErrorFactory; use AsyncAws\Core\Configuration; use AsyncAws\Core\RequestContext; use AsyncAws\Core\Result; @@ -314,7 +314,7 @@ public function putMetricData($input): Result protected function getAwsErrorFactory(): AwsErrorFactoryInterface { - return new XmlAwsErrorFactory(); + return new JsonRpcAwsErrorFactory(); } protected function getEndpointMetadata(?string $region): array diff --git a/src/Service/CloudWatch/src/Input/GetMetricDataInput.php b/src/Service/CloudWatch/src/Input/GetMetricDataInput.php index 588973e3c..2b181d9db 100644 --- a/src/Service/CloudWatch/src/Input/GetMetricDataInput.php +++ b/src/Service/CloudWatch/src/Input/GetMetricDataInput.php @@ -192,7 +192,11 @@ public function getStartTime(): ?\DateTimeImmutable public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/x-www-form-urlencoded']; + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.0', + 'X-Amz-Target' => 'GraniteServiceVersion20100801.GetMetricData', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; @@ -201,7 +205,8 @@ public function request(): Request $uriString = '/'; // Prepare Body - $body = http_build_query(['Action' => 'GetMetricData', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738); + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); // Return the Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); @@ -269,22 +274,21 @@ private function requestBody(): array throw new InvalidArgument(\sprintf('Missing parameter "MetricDataQueries" for "%s". The value cannot be null.', __CLASS__)); } - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['MetricDataQueries'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["MetricDataQueries.member.$index.$bodyKey"] = $bodyValue; - } + $payload['MetricDataQueries'][$index] = $listValue->requestBody(); } if (null === $v = $this->startTime) { throw new InvalidArgument(\sprintf('Missing parameter "StartTime" for "%s". The value cannot be null.', __CLASS__)); } - $payload['StartTime'] = $v->format(\DateTimeInterface::ATOM); + $payload['StartTime'] = $v->getTimestamp(); if (null === $v = $this->endTime) { throw new InvalidArgument(\sprintf('Missing parameter "EndTime" for "%s". The value cannot be null.', __CLASS__)); } - $payload['EndTime'] = $v->format(\DateTimeInterface::ATOM); + $payload['EndTime'] = $v->getTimestamp(); if (null !== $v = $this->nextToken) { $payload['NextToken'] = $v; } @@ -298,9 +302,7 @@ private function requestBody(): array $payload['MaxDatapoints'] = $v; } if (null !== $v = $this->labelOptions) { - foreach ($v->requestBody() as $bodyKey => $bodyValue) { - $payload["LabelOptions.$bodyKey"] = $bodyValue; - } + $payload['LabelOptions'] = $v->requestBody(); } return $payload; diff --git a/src/Service/CloudWatch/src/Input/GetMetricStatisticsInput.php b/src/Service/CloudWatch/src/Input/GetMetricStatisticsInput.php index 729ef5aec..29b4d074a 100644 --- a/src/Service/CloudWatch/src/Input/GetMetricStatisticsInput.php +++ b/src/Service/CloudWatch/src/Input/GetMetricStatisticsInput.php @@ -240,7 +240,11 @@ public function getUnit(): ?string public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/x-www-form-urlencoded']; + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.0', + 'X-Amz-Target' => 'GraniteServiceVersion20100801.GetMetricStatistics', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; @@ -249,7 +253,8 @@ public function request(): Request $uriString = '/'; // Prepare Body - $body = http_build_query(['Action' => 'GetMetricStatistics', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738); + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); // Return the Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); @@ -342,41 +347,42 @@ private function requestBody(): array } $payload['MetricName'] = $v; if (null !== $v = $this->dimensions) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['Dimensions'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["Dimensions.member.$index.$bodyKey"] = $bodyValue; - } + $payload['Dimensions'][$index] = $listValue->requestBody(); } } if (null === $v = $this->startTime) { throw new InvalidArgument(\sprintf('Missing parameter "StartTime" for "%s". The value cannot be null.', __CLASS__)); } - $payload['StartTime'] = $v->format(\DateTimeInterface::ATOM); + $payload['StartTime'] = $v->getTimestamp(); if (null === $v = $this->endTime) { throw new InvalidArgument(\sprintf('Missing parameter "EndTime" for "%s". The value cannot be null.', __CLASS__)); } - $payload['EndTime'] = $v->format(\DateTimeInterface::ATOM); + $payload['EndTime'] = $v->getTimestamp(); if (null === $v = $this->period) { throw new InvalidArgument(\sprintf('Missing parameter "Period" for "%s". The value cannot be null.', __CLASS__)); } $payload['Period'] = $v; if (null !== $v = $this->statistics) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['Statistics'] = []; + foreach ($v as $listValue) { ++$index; - if (!Statistic::exists($mapValue)) { - throw new InvalidArgument(\sprintf('Invalid parameter "Statistics.member" for "%s". The value "%s" is not a valid "Statistic".', __CLASS__, $mapValue)); + if (!Statistic::exists($listValue)) { + throw new InvalidArgument(\sprintf('Invalid parameter "Statistics" for "%s". The value "%s" is not a valid "Statistic".', __CLASS__, $listValue)); } - $payload["Statistics.member.$index"] = $mapValue; + $payload['Statistics'][$index] = $listValue; } } if (null !== $v = $this->extendedStatistics) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['ExtendedStatistics'] = []; + foreach ($v as $listValue) { ++$index; - $payload["ExtendedStatistics.member.$index"] = $mapValue; + $payload['ExtendedStatistics'][$index] = $listValue; } } if (null !== $v = $this->unit) { diff --git a/src/Service/CloudWatch/src/Input/ListMetricsInput.php b/src/Service/CloudWatch/src/Input/ListMetricsInput.php index ae9b8f966..886ee2caa 100644 --- a/src/Service/CloudWatch/src/Input/ListMetricsInput.php +++ b/src/Service/CloudWatch/src/Input/ListMetricsInput.php @@ -158,7 +158,11 @@ public function getRecentlyActive(): ?string public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/x-www-form-urlencoded']; + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.0', + 'X-Amz-Target' => 'GraniteServiceVersion20100801.ListMetrics', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; @@ -167,7 +171,8 @@ public function request(): Request $uriString = '/'; // Prepare Body - $body = http_build_query(['Action' => 'ListMetrics', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738); + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); // Return the Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); @@ -238,12 +243,11 @@ private function requestBody(): array $payload['MetricName'] = $v; } if (null !== $v = $this->dimensions) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['Dimensions'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["Dimensions.member.$index.$bodyKey"] = $bodyValue; - } + $payload['Dimensions'][$index] = $listValue->requestBody(); } } if (null !== $v = $this->nextToken) { @@ -256,7 +260,7 @@ private function requestBody(): array $payload['RecentlyActive'] = $v; } if (null !== $v = $this->includeLinkedAccounts) { - $payload['IncludeLinkedAccounts'] = $v ? 'true' : 'false'; + $payload['IncludeLinkedAccounts'] = (bool) $v; } if (null !== $v = $this->owningAccount) { $payload['OwningAccount'] = $v; diff --git a/src/Service/CloudWatch/src/Input/PutMetricDataInput.php b/src/Service/CloudWatch/src/Input/PutMetricDataInput.php index 94916ee7f..720281ae0 100644 --- a/src/Service/CloudWatch/src/Input/PutMetricDataInput.php +++ b/src/Service/CloudWatch/src/Input/PutMetricDataInput.php @@ -140,7 +140,11 @@ public function getStrictEntityValidation(): ?bool public function request(): Request { // Prepare headers - $headers = ['content-type' => 'application/x-www-form-urlencoded']; + $headers = [ + 'Content-Type' => 'application/x-amz-json-1.0', + 'X-Amz-Target' => 'GraniteServiceVersion20100801.PutMetricData', + 'Accept' => 'application/json', + ]; // Prepare query $query = []; @@ -149,7 +153,8 @@ public function request(): Request $uriString = '/'; // Prepare Body - $body = http_build_query(['Action' => 'PutMetricData', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738); + $bodyPayload = $this->requestBody(); + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); // Return the Request return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); @@ -197,25 +202,23 @@ private function requestBody(): array } $payload['Namespace'] = $v; if (null !== $v = $this->metricData) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['MetricData'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["MetricData.member.$index.$bodyKey"] = $bodyValue; - } + $payload['MetricData'][$index] = $listValue->requestBody(); } } if (null !== $v = $this->entityMetricData) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['EntityMetricData'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["EntityMetricData.member.$index.$bodyKey"] = $bodyValue; - } + $payload['EntityMetricData'][$index] = $listValue->requestBody(); } } if (null !== $v = $this->strictEntityValidation) { - $payload['StrictEntityValidation'] = $v ? 'true' : 'false'; + $payload['StrictEntityValidation'] = (bool) $v; } return $payload; diff --git a/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php b/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php index e3367c5f2..da4ad78f3 100644 --- a/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php +++ b/src/Service/CloudWatch/src/Result/GetMetricDataOutput.php @@ -176,54 +176,56 @@ public function getNextToken(): ?string protected function populateResult(Response $response): void { - $data = new \SimpleXMLElement($response->getContent()); - $data = $data->GetMetricDataResult; + $data = $response->toArray(); - $this->metricDataResults = (0 === ($v = $data->MetricDataResults)->count()) ? [] : $this->populateResultMetricDataResults($v); - $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; - $this->messages = (0 === ($v = $data->Messages)->count()) ? [] : $this->populateResultMetricDataResultMessages($v); + $this->metricDataResults = empty($data['MetricDataResults']) ? [] : $this->populateResultMetricDataResults($data['MetricDataResults']); + $this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null; + $this->messages = empty($data['Messages']) ? [] : $this->populateResultMetricDataResultMessages($data['Messages']); } /** * @return float[] */ - private function populateResultDatapointValues(\SimpleXMLElement $xml): array + private function populateResultDatapointValues(array $json): array { $items = []; - foreach ($xml->member as $item) { - $items[] = (float) (string) $item; + foreach ($json as $item) { + $a = isset($item) ? (float) $item : null; + if (null !== $a) { + $items[] = $a; + } } return $items; } - private function populateResultMessageData(\SimpleXMLElement $xml): MessageData + private function populateResultMessageData(array $json): MessageData { return new MessageData([ - 'Code' => (null !== $v = $xml->Code[0]) ? (string) $v : null, - 'Value' => (null !== $v = $xml->Value[0]) ? (string) $v : null, + 'Code' => isset($json['Code']) ? (string) $json['Code'] : null, + 'Value' => isset($json['Value']) ? (string) $json['Value'] : null, ]); } - private function populateResultMetricDataResult(\SimpleXMLElement $xml): MetricDataResult + private function populateResultMetricDataResult(array $json): MetricDataResult { return new MetricDataResult([ - 'Id' => (null !== $v = $xml->Id[0]) ? (string) $v : null, - 'Label' => (null !== $v = $xml->Label[0]) ? (string) $v : null, - 'Timestamps' => (0 === ($v = $xml->Timestamps)->count()) ? null : $this->populateResultTimestamps($v), - 'Values' => (0 === ($v = $xml->Values)->count()) ? null : $this->populateResultDatapointValues($v), - 'StatusCode' => (null !== $v = $xml->StatusCode[0]) ? (string) $v : null, - 'Messages' => (0 === ($v = $xml->Messages)->count()) ? null : $this->populateResultMetricDataResultMessages($v), + 'Id' => isset($json['Id']) ? (string) $json['Id'] : null, + 'Label' => isset($json['Label']) ? (string) $json['Label'] : null, + 'Timestamps' => !isset($json['Timestamps']) ? null : $this->populateResultTimestamps($json['Timestamps']), + 'Values' => !isset($json['Values']) ? null : $this->populateResultDatapointValues($json['Values']), + 'StatusCode' => isset($json['StatusCode']) ? (string) $json['StatusCode'] : null, + 'Messages' => !isset($json['Messages']) ? null : $this->populateResultMetricDataResultMessages($json['Messages']), ]); } /** * @return MessageData[] */ - private function populateResultMetricDataResultMessages(\SimpleXMLElement $xml): array + private function populateResultMetricDataResultMessages(array $json): array { $items = []; - foreach ($xml->member as $item) { + foreach ($json as $item) { $items[] = $this->populateResultMessageData($item); } @@ -233,10 +235,10 @@ private function populateResultMetricDataResultMessages(\SimpleXMLElement $xml): /** * @return MetricDataResult[] */ - private function populateResultMetricDataResults(\SimpleXMLElement $xml): array + private function populateResultMetricDataResults(array $json): array { $items = []; - foreach ($xml->member as $item) { + foreach ($json as $item) { $items[] = $this->populateResultMetricDataResult($item); } @@ -246,11 +248,14 @@ private function populateResultMetricDataResults(\SimpleXMLElement $xml): array /** * @return \DateTimeImmutable[] */ - private function populateResultTimestamps(\SimpleXMLElement $xml): array + private function populateResultTimestamps(array $json): array { $items = []; - foreach ($xml->member as $item) { - $items[] = new \DateTimeImmutable((string) $item); + foreach ($json as $item) { + $a = (isset($item) && ($d = \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $item)))) ? $d : null; + if (null !== $a) { + $items[] = $a; + } } return $items; diff --git a/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php b/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php index dbc5340cd..a3a47937a 100644 --- a/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php +++ b/src/Service/CloudWatch/src/Result/GetMetricStatisticsOutput.php @@ -41,36 +41,34 @@ public function getLabel(): ?string protected function populateResult(Response $response): void { - $data = new \SimpleXMLElement($response->getContent()); - $data = $data->GetMetricStatisticsResult; + $data = $response->toArray(); - $this->label = (null !== $v = $data->Label[0]) ? (string) $v : null; - $this->datapoints = (0 === ($v = $data->Datapoints)->count()) ? [] : $this->populateResultDatapoints($v); + $this->label = isset($data['Label']) ? (string) $data['Label'] : null; + $this->datapoints = empty($data['Datapoints']) ? [] : $this->populateResultDatapoints($data['Datapoints']); } - private function populateResultDatapoint(\SimpleXMLElement $xml): Datapoint + private function populateResultDatapoint(array $json): Datapoint { return new Datapoint([ - 'Timestamp' => (null !== $v = $xml->Timestamp[0]) ? new \DateTimeImmutable((string) $v) : null, - 'SampleCount' => (null !== $v = $xml->SampleCount[0]) ? (float) (string) $v : null, - 'Average' => (null !== $v = $xml->Average[0]) ? (float) (string) $v : null, - 'Sum' => (null !== $v = $xml->Sum[0]) ? (float) (string) $v : null, - 'Minimum' => (null !== $v = $xml->Minimum[0]) ? (float) (string) $v : null, - 'Maximum' => (null !== $v = $xml->Maximum[0]) ? (float) (string) $v : null, - 'Unit' => (null !== $v = $xml->Unit[0]) ? (string) $v : null, - 'ExtendedStatistics' => (0 === ($v = $xml->ExtendedStatistics)->count()) ? null : $this->populateResultDatapointValueMap($v), + 'Timestamp' => (isset($json['Timestamp']) && ($d = \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $json['Timestamp'])))) ? $d : null, + 'SampleCount' => isset($json['SampleCount']) ? (float) $json['SampleCount'] : null, + 'Average' => isset($json['Average']) ? (float) $json['Average'] : null, + 'Sum' => isset($json['Sum']) ? (float) $json['Sum'] : null, + 'Minimum' => isset($json['Minimum']) ? (float) $json['Minimum'] : null, + 'Maximum' => isset($json['Maximum']) ? (float) $json['Maximum'] : null, + 'Unit' => isset($json['Unit']) ? (string) $json['Unit'] : null, + 'ExtendedStatistics' => !isset($json['ExtendedStatistics']) ? null : $this->populateResultDatapointValueMap($json['ExtendedStatistics']), ]); } /** * @return array */ - private function populateResultDatapointValueMap(\SimpleXMLElement $xml): array + private function populateResultDatapointValueMap(array $json): array { $items = []; - foreach ($xml->entry as $item) { - $a = $item->value; - $items[$item->key->__toString()] = (float) (string) $a; + foreach ($json as $name => $value) { + $items[(string) $name] = (float) $value; } return $items; @@ -79,10 +77,10 @@ private function populateResultDatapointValueMap(\SimpleXMLElement $xml): array /** * @return Datapoint[] */ - private function populateResultDatapoints(\SimpleXMLElement $xml): array + private function populateResultDatapoints(array $json): array { $items = []; - foreach ($xml->member as $item) { + foreach ($json as $item) { $items[] = $this->populateResultDatapoint($item); } diff --git a/src/Service/CloudWatch/src/Result/ListMetricsOutput.php b/src/Service/CloudWatch/src/Result/ListMetricsOutput.php index 3672a36af..6b836a777 100644 --- a/src/Service/CloudWatch/src/Result/ListMetricsOutput.php +++ b/src/Service/CloudWatch/src/Result/ListMetricsOutput.php @@ -174,51 +174,50 @@ public function getOwningAccounts(bool $currentPageOnly = false): iterable protected function populateResult(Response $response): void { - $data = new \SimpleXMLElement($response->getContent()); - $data = $data->ListMetricsResult; + $data = $response->toArray(); - $this->metrics = (0 === ($v = $data->Metrics)->count()) ? [] : $this->populateResultMetrics($v); - $this->nextToken = (null !== $v = $data->NextToken[0]) ? (string) $v : null; - $this->owningAccounts = (0 === ($v = $data->OwningAccounts)->count()) ? [] : $this->populateResultOwningAccounts($v); + $this->metrics = empty($data['Metrics']) ? [] : $this->populateResultMetrics($data['Metrics']); + $this->nextToken = isset($data['NextToken']) ? (string) $data['NextToken'] : null; + $this->owningAccounts = empty($data['OwningAccounts']) ? [] : $this->populateResultOwningAccounts($data['OwningAccounts']); } - private function populateResultDimension(\SimpleXMLElement $xml): Dimension + private function populateResultDimension(array $json): Dimension { return new Dimension([ - 'Name' => (string) $xml->Name, - 'Value' => (string) $xml->Value, + 'Name' => (string) $json['Name'], + 'Value' => (string) $json['Value'], ]); } /** * @return Dimension[] */ - private function populateResultDimensions(\SimpleXMLElement $xml): array + private function populateResultDimensions(array $json): array { $items = []; - foreach ($xml->member as $item) { + foreach ($json as $item) { $items[] = $this->populateResultDimension($item); } return $items; } - private function populateResultMetric(\SimpleXMLElement $xml): Metric + private function populateResultMetric(array $json): Metric { return new Metric([ - 'Namespace' => (null !== $v = $xml->Namespace[0]) ? (string) $v : null, - 'MetricName' => (null !== $v = $xml->MetricName[0]) ? (string) $v : null, - 'Dimensions' => (0 === ($v = $xml->Dimensions)->count()) ? null : $this->populateResultDimensions($v), + 'Namespace' => isset($json['Namespace']) ? (string) $json['Namespace'] : null, + 'MetricName' => isset($json['MetricName']) ? (string) $json['MetricName'] : null, + 'Dimensions' => !isset($json['Dimensions']) ? null : $this->populateResultDimensions($json['Dimensions']), ]); } /** * @return Metric[] */ - private function populateResultMetrics(\SimpleXMLElement $xml): array + private function populateResultMetrics(array $json): array { $items = []; - foreach ($xml->member as $item) { + foreach ($json as $item) { $items[] = $this->populateResultMetric($item); } @@ -228,11 +227,14 @@ private function populateResultMetrics(\SimpleXMLElement $xml): array /** * @return string[] */ - private function populateResultOwningAccounts(\SimpleXMLElement $xml): array + private function populateResultOwningAccounts(array $json): array { $items = []; - foreach ($xml->member as $item) { - $items[] = (string) $item; + foreach ($json as $item) { + $a = isset($item) ? (string) $item : null; + if (null !== $a) { + $items[] = $a; + } } return $items; diff --git a/src/Service/CloudWatch/src/ValueObject/Entity.php b/src/Service/CloudWatch/src/ValueObject/Entity.php index b942ca4ca..fb92839bf 100644 --- a/src/Service/CloudWatch/src/ValueObject/Entity.php +++ b/src/Service/CloudWatch/src/ValueObject/Entity.php @@ -84,19 +84,23 @@ public function requestBody(): array { $payload = []; if (null !== $v = $this->keyAttributes) { - $index = 0; - foreach ($v as $mapKey => $mapValue) { - ++$index; - $payload["KeyAttributes.entry.$index.key"] = $mapKey; - $payload["KeyAttributes.entry.$index.value"] = $mapValue; + if (empty($v)) { + $payload['KeyAttributes'] = new \stdClass(); + } else { + $payload['KeyAttributes'] = []; + foreach ($v as $name => $mv) { + $payload['KeyAttributes'][$name] = $mv; + } } } if (null !== $v = $this->attributes) { - $index = 0; - foreach ($v as $mapKey => $mapValue) { - ++$index; - $payload["Attributes.entry.$index.key"] = $mapKey; - $payload["Attributes.entry.$index.value"] = $mapValue; + if (empty($v)) { + $payload['Attributes'] = new \stdClass(); + } else { + $payload['Attributes'] = []; + foreach ($v as $name => $mv) { + $payload['Attributes'][$name] = $mv; + } } } diff --git a/src/Service/CloudWatch/src/ValueObject/EntityMetricData.php b/src/Service/CloudWatch/src/ValueObject/EntityMetricData.php index 0ba31b558..f3cccd993 100644 --- a/src/Service/CloudWatch/src/ValueObject/EntityMetricData.php +++ b/src/Service/CloudWatch/src/ValueObject/EntityMetricData.php @@ -65,17 +65,14 @@ public function requestBody(): array { $payload = []; if (null !== $v = $this->entity) { - foreach ($v->requestBody() as $bodyKey => $bodyValue) { - $payload["Entity.$bodyKey"] = $bodyValue; - } + $payload['Entity'] = $v->requestBody(); } if (null !== $v = $this->metricData) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['MetricData'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["MetricData.member.$index.$bodyKey"] = $bodyValue; - } + $payload['MetricData'][$index] = $listValue->requestBody(); } } diff --git a/src/Service/CloudWatch/src/ValueObject/Metric.php b/src/Service/CloudWatch/src/ValueObject/Metric.php index d217cd5f3..faf6c47a0 100644 --- a/src/Service/CloudWatch/src/ValueObject/Metric.php +++ b/src/Service/CloudWatch/src/ValueObject/Metric.php @@ -85,12 +85,11 @@ public function requestBody(): array $payload['MetricName'] = $v; } if (null !== $v = $this->dimensions) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['Dimensions'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["Dimensions.member.$index.$bodyKey"] = $bodyValue; - } + $payload['Dimensions'][$index] = $listValue->requestBody(); } } diff --git a/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php b/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php index 5176538ab..9e39283b6 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php @@ -200,9 +200,7 @@ public function requestBody(): array $v = $this->id; $payload['Id'] = $v; if (null !== $v = $this->metricStat) { - foreach ($v->requestBody() as $bodyKey => $bodyValue) { - $payload["MetricStat.$bodyKey"] = $bodyValue; - } + $payload['MetricStat'] = $v->requestBody(); } if (null !== $v = $this->expression) { $payload['Expression'] = $v; @@ -211,7 +209,7 @@ public function requestBody(): array $payload['Label'] = $v; } if (null !== $v = $this->returnData) { - $payload['ReturnData'] = $v ? 'true' : 'false'; + $payload['ReturnData'] = (bool) $v; } if (null !== $v = $this->period) { $payload['Period'] = $v; diff --git a/src/Service/CloudWatch/src/ValueObject/MetricDatum.php b/src/Service/CloudWatch/src/ValueObject/MetricDatum.php index 269d99a1c..87fba8de3 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricDatum.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricDatum.php @@ -209,37 +209,36 @@ public function requestBody(): array $v = $this->metricName; $payload['MetricName'] = $v; if (null !== $v = $this->dimensions) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['Dimensions'] = []; + foreach ($v as $listValue) { ++$index; - foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) { - $payload["Dimensions.member.$index.$bodyKey"] = $bodyValue; - } + $payload['Dimensions'][$index] = $listValue->requestBody(); } } if (null !== $v = $this->timestamp) { - $payload['Timestamp'] = $v->format(\DateTimeInterface::ATOM); + $payload['Timestamp'] = $v->getTimestamp(); } if (null !== $v = $this->value) { $payload['Value'] = $v; } if (null !== $v = $this->statisticValues) { - foreach ($v->requestBody() as $bodyKey => $bodyValue) { - $payload["StatisticValues.$bodyKey"] = $bodyValue; - } + $payload['StatisticValues'] = $v->requestBody(); } if (null !== $v = $this->values) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['Values'] = []; + foreach ($v as $listValue) { ++$index; - $payload["Values.member.$index"] = $mapValue; + $payload['Values'][$index] = $listValue; } } if (null !== $v = $this->counts) { - $index = 0; - foreach ($v as $mapValue) { + $index = -1; + $payload['Counts'] = []; + foreach ($v as $listValue) { ++$index; - $payload["Counts.member.$index"] = $mapValue; + $payload['Counts'][$index] = $listValue; } } if (null !== $v = $this->unit) { diff --git a/src/Service/CloudWatch/src/ValueObject/MetricStat.php b/src/Service/CloudWatch/src/ValueObject/MetricStat.php index bfd92b25e..1d35b8511 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricStat.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricStat.php @@ -112,10 +112,7 @@ public function requestBody(): array { $payload = []; $v = $this->metric; - foreach ($v->requestBody() as $bodyKey => $bodyValue) { - $payload["Metric.$bodyKey"] = $bodyValue; - } - + $payload['Metric'] = $v->requestBody(); $v = $this->period; $payload['Period'] = $v; $v = $this->stat; diff --git a/src/Service/CloudWatch/tests/Unit/Input/GetMetricDataInputTest.php b/src/Service/CloudWatch/tests/Unit/Input/GetMetricDataInputTest.php index 788686990..d398f7cbd 100644 --- a/src/Service/CloudWatch/tests/Unit/Input/GetMetricDataInputTest.php +++ b/src/Service/CloudWatch/tests/Unit/Input/GetMetricDataInputTest.php @@ -2,10 +2,8 @@ namespace AsyncAws\CloudWatch\Tests\Unit\Input; -use AsyncAws\CloudWatch\Enum\ScanBy; use AsyncAws\CloudWatch\Input\GetMetricDataInput; use AsyncAws\CloudWatch\ValueObject\Dimension; -use AsyncAws\CloudWatch\ValueObject\LabelOptions; use AsyncAws\CloudWatch\ValueObject\Metric; use AsyncAws\CloudWatch\ValueObject\MetricDataQuery; use AsyncAws\CloudWatch\ValueObject\MetricStat; @@ -17,59 +15,74 @@ public function testRequest(): void { $input = new GetMetricDataInput([ 'MetricDataQueries' => [new MetricDataQuery([ - 'Id' => 'change me', + 'Id' => 'q1', + 'Expression' => 'SELECT AVG(CPUUtilization) FROM SCHEMA("AWS/EC2", InstanceId)', + 'Label' => 'Cluster CpuUtilization', + 'Period' => 300, + ]), new MetricDataQuery([ + 'Id' => 'm1', + 'Label' => 'Unhealthy Behind Load Balancer', 'MetricStat' => new MetricStat([ 'Metric' => new Metric([ - 'Namespace' => 'foo', - 'MetricName' => 'bar', + 'Namespace' => 'AWS/ApplicationELB', + 'MetricName' => 'UnHealthyHostCount', 'Dimensions' => [new Dimension([ - 'Name' => 'bar', - 'Value' => '123', + 'Name' => 'TargetGroup', + 'Value' => 'targetgroup/EC2Co-Defau-EXAMPLEWNAD/89cc68152b367e5f', + ]), new Dimension([ + 'Name' => 'LoadBalancer', + 'Value' => 'app/EC2Co-EcsEl-EXAMPLE69Q/fdd2210e799e4376', ])], ]), - 'Period' => 1337, + 'Period' => 300, 'Stat' => 'Average', ]), - 'Expression' => 'change me', - 'Label' => 'hello world', - 'ReturnData' => false, - 'Period' => 1337, ])], - 'StartTime' => new \DateTimeImmutable('2021-08-28T06:10:58+00:00'), - 'EndTime' => new \DateTimeImmutable('2021-08-29T06:10:58+00:00'), - 'NextToken' => 'change me', - 'ScanBy' => ScanBy::TIMESTAMP_ASCENDING, - 'MaxDatapoints' => 1337, - 'LabelOptions' => new LabelOptions([ - 'Timezone' => 'change me', - ]), + 'StartTime' => new \DateTimeImmutable('2021-11-16T11:25:00+00:00'), + 'EndTime' => new \DateTimeImmutable('2021-11-16T14:55:00+00:00'), ]); // see https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html $expected = ' POST / HTTP/1.0 - Content-Type: application/x-www-form-urlencoded + Content-Type: application/x-amz-json-1.0 + x-amz-target: GraniteServiceVersion20100801.GetMetricData + accept: application/json - Action=GetMetricData& - Version=2010-08-01& - MetricDataQueries.member.1.Id=change+me& - MetricDataQueries.member.1.MetricStat.Metric.Namespace=foo& - MetricDataQueries.member.1.MetricStat.Metric.MetricName=bar& - MetricDataQueries.member.1.MetricStat.Metric.Dimensions.member.1.Name=bar& - MetricDataQueries.member.1.MetricStat.Metric.Dimensions.member.1.Value=123& - MetricDataQueries.member.1.MetricStat.Period=1337& - MetricDataQueries.member.1.MetricStat.Stat=Average& - MetricDataQueries.member.1.Expression=change+me& - MetricDataQueries.member.1.Label=hello+world& - MetricDataQueries.member.1.ReturnData=false& - MetricDataQueries.member.1.Period=1337& - StartTime=2021-08-28T06%3A10%3A58%2B00%3A00& - EndTime=2021-08-29T06%3A10%3A58%2B00%3A00& - NextToken=change+me& - ScanBy=TimestampAscending& - MaxDatapoints=1337& - LabelOptions.Timezone=change+me - '; + { + "StartTime": 1637061900, + "EndTime": 1637074500, + "MetricDataQueries": [ + { + "Expression": "SELECT AVG(CPUUtilization) FROM SCHEMA(\"AWS/EC2\", InstanceId)", + "Id": "q1", + "Period": 300, + "Label": "Cluster CpuUtilization" + }, + { + "Id": "m1", + "Label": "Unhealthy Behind Load Balancer", + "MetricStat": { + "Metric": { + "Namespace": "AWS/ApplicationELB", + "MetricName": "UnHealthyHostCount", + "Dimensions": [ + { + "Name": "TargetGroup", + "Value": "targetgroup/EC2Co-Defau-EXAMPLEWNAD/89cc68152b367e5f" + }, + { + "Name": "LoadBalancer", + "Value": "app/EC2Co-EcsEl-EXAMPLE69Q/fdd2210e799e4376" + } + ] + }, + "Period": 300, + "Stat": "Average" + } + } + ] + }'; self::assertRequestEqualsHttpRequest($expected, $input->request()); } diff --git a/src/Service/CloudWatch/tests/Unit/Input/GetMetricStatisticsInputTest.php b/src/Service/CloudWatch/tests/Unit/Input/GetMetricStatisticsInputTest.php index 22a53a40e..ed80039a2 100644 --- a/src/Service/CloudWatch/tests/Unit/Input/GetMetricStatisticsInputTest.php +++ b/src/Service/CloudWatch/tests/Unit/Input/GetMetricStatisticsInputTest.php @@ -27,19 +27,26 @@ public function testRequest(): void // see https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html $expected = ' POST / HTTP/1.0 - Content-Type: application/x-www-form-urlencoded + Content-Type: application/x-amz-json-1.0 + x-amz-target: GraniteServiceVersion20100801.GetMetricStatistics + accept: application/json - Action=GetMetricStatistics& - Version=2010-08-01& - Namespace=foo& - MetricName=bar& - Dimensions.member.1.Name=bar& - Dimensions.member.1.Value=123& - StartTime=2021-08-28T06%3A10%3A58%2B00%3A00& - EndTime=2021-08-29T06%3A10%3A58%2B00%3A00& - Period=1337& - Statistics.member.1=Minimum - '; + { + "Dimensions": [ + { + "Name": "bar", + "Value": "123" + } + ], + "EndTime": 1630217458, + "MetricName": "bar", + "Namespace": "foo", + "Period": 1337, + "StartTime": 1630131058, + "Statistics": [ + "Minimum" + ] + }'; self::assertRequestEqualsHttpRequest($expected, $input->request()); } diff --git a/src/Service/CloudWatch/tests/Unit/Input/ListMetricsInputTest.php b/src/Service/CloudWatch/tests/Unit/Input/ListMetricsInputTest.php index 098293991..fd933638e 100644 --- a/src/Service/CloudWatch/tests/Unit/Input/ListMetricsInputTest.php +++ b/src/Service/CloudWatch/tests/Unit/Input/ListMetricsInputTest.php @@ -25,17 +25,22 @@ public function testRequest(): void // see https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html $expected = ' POST / HTTP/1.0 - Content-Type: application/x-www-form-urlencoded + Content-Type: application/x-amz-json-1.0 + x-amz-target: GraniteServiceVersion20100801.ListMetrics + accept: application/json - Action=ListMetrics& - Version=2010-08-01& - Namespace=foo& - MetricName=bar& - Dimensions.member.1.Name=bar& - Dimensions.member.1.Value=123& - NextToken=change+me& - RecentlyActive=PT3H - '; + { + "Dimensions": [ + { + "Name": "bar", + "Value": "123" + } + ], + "MetricName": "bar", + "Namespace": "foo", + "NextToken": "change me", + "RecentlyActive": "PT3H" + }'; self::assertRequestEqualsHttpRequest($expected, $input->request()); } diff --git a/src/Service/CloudWatch/tests/Unit/Input/PutMetricDataInputTest.php b/src/Service/CloudWatch/tests/Unit/Input/PutMetricDataInputTest.php index f51854c81..729cc2652 100644 --- a/src/Service/CloudWatch/tests/Unit/Input/PutMetricDataInputTest.php +++ b/src/Service/CloudWatch/tests/Unit/Input/PutMetricDataInputTest.php @@ -37,24 +37,39 @@ public function testRequest(): void // see https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html $expected = ' POST / HTTP/1.0 - Content-Type: application/x-www-form-urlencoded + Content-Type: application/x-amz-json-1.0 + x-amz-target: GraniteServiceVersion20100801.PutMetricData + accept: application/json - Action=PutMetricData& - Version=2010-08-01& - Namespace=foo& - MetricData.member.1.MetricName=bar& - MetricData.member.1.Dimensions.member.1.Name=bar& - MetricData.member.1.Dimensions.member.1.Value=123& - MetricData.member.1.Timestamp=2021-08-28T06%3A05%3A55%2B00%3A00& - MetricData.member.1.Value=1337& - MetricData.member.1.StatisticValues.SampleCount=1337& - MetricData.member.1.StatisticValues.Sum=1337& - MetricData.member.1.StatisticValues.Minimum=1337& - MetricData.member.1.StatisticValues.Maximum=1337& - MetricData.member.1.Values.member.1=1337& - MetricData.member.1.Counts.member.1=1337& - MetricData.member.1.StorageResolution=1337 - '; + { + "MetricData": [ + { + "Counts": [ + 1337 + ], + "Dimensions": [ + { + "Name": "bar", + "Value": "123" + } + ], + "MetricName": "bar", + "StatisticValues": { + "Maximum": 1337, + "Minimum": 1337, + "SampleCount": 1337, + "Sum": 1337 + }, + "StorageResolution": 1337, + "Timestamp": 1630130755, + "Value": 1337, + "Values": [ + 1337 + ] + } + ], + "Namespace": "foo" + }'; self::assertRequestEqualsHttpRequest($expected, $input->request()); } diff --git a/src/Service/CloudWatch/tests/Unit/Result/GetMetricDataOutputTest.php b/src/Service/CloudWatch/tests/Unit/Result/GetMetricDataOutputTest.php index eece3c457..dd8aa7d3c 100644 --- a/src/Service/CloudWatch/tests/Unit/Result/GetMetricDataOutputTest.php +++ b/src/Service/CloudWatch/tests/Unit/Result/GetMetricDataOutputTest.php @@ -15,14 +15,49 @@ class GetMetricDataOutputTest extends TestCase { public function testGetMetricDataOutput(): void { - // see https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_GetMetricData.html - $response = new SimpleMockedResponse('foobar'); + // see https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricData.html + $response = new SimpleMockedResponse('{ + "MetricDataResults": [ + { + "Id": "m1", + "Label": "Unhealthy Behind Load Balancer", + "StatusCode": "Complete", + "Timestamps": [ + 1637074200, + 1637073900, + 1637073600 + ], + "Values": [ + 0, + 0, + 0 + ] + }, + { + "Id": "q1", + "Label": "Cluster CpuUtilization", + "StatusCode": "Complete", + "Timestamps": [ + 1637074245, + 1637073945, + 1637073645 + ], + "Values": [ + 1.2158469945359334, + 0.8678863271635757, + 0.7201860957623283 + ] + } + ] + }'); $client = new MockHttpClient($response); $result = new GetMetricDataOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()), new CloudWatchClient(), new GetMetricDataInput([])); - // self::assertTODO(expected, $result->getMetricDataResults()); - self::assertSame('foobar', $result->getNextToken()); - // self::assertTODO(expected, $result->getMessages()); + $metricDataResults = [...$result->getMetricDataResults(true)]; + self::assertCount(2, $metricDataResults); + self::assertSame('m1', $metricDataResults[0]->getId()); + self::assertCount(3, $metricDataResults[0]->getTimestamps()); + self::assertSame('2021-11-16T14:45:00+00:00', $metricDataResults[0]->getTimestamps()[1]->format(\DATE_ATOM)); } } diff --git a/src/Service/CloudWatch/tests/Unit/Result/GetMetricStatisticsOutputTest.php b/src/Service/CloudWatch/tests/Unit/Result/GetMetricStatisticsOutputTest.php index 8b8d0d224..3d943058a 100644 --- a/src/Service/CloudWatch/tests/Unit/Result/GetMetricStatisticsOutputTest.php +++ b/src/Service/CloudWatch/tests/Unit/Result/GetMetricStatisticsOutputTest.php @@ -14,11 +14,12 @@ class GetMetricStatisticsOutputTest extends TestCase public function testGetMetricStatisticsOutput(): void { // see https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html - $response = new SimpleMockedResponse(''); + $response = new SimpleMockedResponse('{ + "Label": "foobar" + }'); $client = new MockHttpClient($response); $result = new GetMetricStatisticsOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger())); - self::assertSame('foobar', $result->getLabel()); } } diff --git a/src/Service/CloudWatch/tests/Unit/Result/ListMetricsOutputTest.php b/src/Service/CloudWatch/tests/Unit/Result/ListMetricsOutputTest.php index fc1e3deee..52953cb5b 100644 --- a/src/Service/CloudWatch/tests/Unit/Result/ListMetricsOutputTest.php +++ b/src/Service/CloudWatch/tests/Unit/Result/ListMetricsOutputTest.php @@ -16,7 +16,9 @@ class ListMetricsOutputTest extends TestCase public function testListMetricsOutput(): void { // see https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html - $response = new SimpleMockedResponse('foobar'); + $response = new SimpleMockedResponse('{ + "NextToken": "foobar" + }'); $client = new MockHttpClient($response); $result = new ListMetricsOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()), new CloudWatchClient(), new ListMetricsInput([])); diff --git a/src/Service/Lambda/CHANGELOG.md b/src/Service/Lambda/CHANGELOG.md index c783b549d..454892f10 100644 --- a/src/Service/Lambda/CHANGELOG.md +++ b/src/Service/Lambda/CHANGELOG.md @@ -13,6 +13,7 @@ - AWS api-change: Launching Lambda Managed Instances - a new feature to run Lambda on EC2. - AWS api-change: Add DisallowedByVpcEncryptionControl to the LastUpdateStatusReasonCode and StateReasonCode enums to represent failures caused by VPC Encryption Controls. - AWS api-change: Added `eusc-de-east-1` region +- AWS api-change: Add Dotnet 10 (dotnet10) support to AWS Lambda. ### Dependency bumped diff --git a/src/Service/Lambda/src/Enum/Runtime.php b/src/Service/Lambda/src/Enum/Runtime.php index b5997cea7..4394b5200 100644 --- a/src/Service/Lambda/src/Enum/Runtime.php +++ b/src/Service/Lambda/src/Enum/Runtime.php @@ -8,6 +8,7 @@ final class Runtime public const DOTNETCORE_2_0 = 'dotnetcore2.0'; public const DOTNETCORE_2_1 = 'dotnetcore2.1'; public const DOTNETCORE_3_1 = 'dotnetcore3.1'; + public const DOTNET_10 = 'dotnet10'; public const DOTNET_6 = 'dotnet6'; public const DOTNET_8 = 'dotnet8'; public const GO_1_X = 'go1.x'; @@ -56,6 +57,7 @@ public static function exists(string $value): bool self::DOTNETCORE_2_0 => true, self::DOTNETCORE_2_1 => true, self::DOTNETCORE_3_1 => true, + self::DOTNET_10 => true, self::DOTNET_6 => true, self::DOTNET_8 => true, self::GO_1_X => true, diff --git a/src/Service/SecretsManager/CHANGELOG.md b/src/Service/SecretsManager/CHANGELOG.md index 10300a249..7c51e8b6c 100644 --- a/src/Service/SecretsManager/CHANGELOG.md +++ b/src/Service/SecretsManager/CHANGELOG.md @@ -7,6 +7,7 @@ - AWS api-change: Added `us-isob-west-1` region - AWS api-change: Adds support to create, update, retrieve, rotate, and delete managed external secrets. - AWS api-change: Added `eusc-de-east-1` region +- AWS api-change: Add SortBy parameter to ListSecrets ### Dependency bumped diff --git a/src/Service/SecretsManager/src/Enum/SortByType.php b/src/Service/SecretsManager/src/Enum/SortByType.php new file mode 100644 index 000000000..9d4b680cd --- /dev/null +++ b/src/Service/SecretsManager/src/Enum/SortByType.php @@ -0,0 +1,21 @@ + true, + self::LAST_ACCESSED_DATE => true, + self::LAST_CHANGED_DATE => true, + self::NAME => true, + ][$value]); + } +} diff --git a/src/Service/SecretsManager/src/Input/ListSecretsRequest.php b/src/Service/SecretsManager/src/Input/ListSecretsRequest.php index c22a8b71b..6d543abce 100644 --- a/src/Service/SecretsManager/src/Input/ListSecretsRequest.php +++ b/src/Service/SecretsManager/src/Input/ListSecretsRequest.php @@ -6,6 +6,7 @@ use AsyncAws\Core\Input; use AsyncAws\Core\Request; use AsyncAws\Core\Stream\StreamFactory; +use AsyncAws\SecretsManager\Enum\SortByType; use AsyncAws\SecretsManager\Enum\SortOrderType; use AsyncAws\SecretsManager\ValueObject\Filter; @@ -51,6 +52,13 @@ final class ListSecretsRequest extends Input */ private $sortOrder; + /** + * If not specified, secrets are listed by `CreatedDate`. + * + * @var SortByType::*|null + */ + private $sortBy; + /** * @param array{ * IncludePlannedDeletion?: bool|null, @@ -58,6 +66,7 @@ final class ListSecretsRequest extends Input * NextToken?: string|null, * Filters?: array|null, * SortOrder?: SortOrderType::*|null, + * SortBy?: SortByType::*|null, * '@region'?: string|null, * } $input */ @@ -68,6 +77,7 @@ public function __construct(array $input = []) $this->nextToken = $input['NextToken'] ?? null; $this->filters = isset($input['Filters']) ? array_map([Filter::class, 'create'], $input['Filters']) : null; $this->sortOrder = $input['SortOrder'] ?? null; + $this->sortBy = $input['SortBy'] ?? null; parent::__construct($input); } @@ -78,6 +88,7 @@ public function __construct(array $input = []) * NextToken?: string|null, * Filters?: array|null, * SortOrder?: SortOrderType::*|null, + * SortBy?: SortByType::*|null, * '@region'?: string|null, * }|ListSecretsRequest $input */ @@ -109,6 +120,14 @@ public function getNextToken(): ?string return $this->nextToken; } + /** + * @return SortByType::*|null + */ + public function getSortBy(): ?string + { + return $this->sortBy; + } + /** * @return SortOrderType::*|null */ @@ -174,6 +193,16 @@ public function setNextToken(?string $value): self return $this; } + /** + * @param SortByType::*|null $value + */ + public function setSortBy(?string $value): self + { + $this->sortBy = $value; + + return $this; + } + /** * @param SortOrderType::*|null $value */ @@ -210,6 +239,12 @@ private function requestBody(): array } $payload['SortOrder'] = $v; } + if (null !== $v = $this->sortBy) { + if (!SortByType::exists($v)) { + throw new InvalidArgument(\sprintf('Invalid parameter "SortBy" for "%s". The value "%s" is not a valid "SortByType".', __CLASS__, $v)); + } + $payload['SortBy'] = $v; + } return $payload; } diff --git a/src/Service/SecretsManager/src/SecretsManagerClient.php b/src/Service/SecretsManager/src/SecretsManagerClient.php index 94f55a2d6..7e0b3f7f5 100644 --- a/src/Service/SecretsManager/src/SecretsManagerClient.php +++ b/src/Service/SecretsManager/src/SecretsManagerClient.php @@ -7,6 +7,7 @@ use AsyncAws\Core\AwsError\JsonRpcAwsErrorFactory; use AsyncAws\Core\Configuration; use AsyncAws\Core\RequestContext; +use AsyncAws\SecretsManager\Enum\SortByType; use AsyncAws\SecretsManager\Enum\SortOrderType; use AsyncAws\SecretsManager\Exception\DecryptionFailureException; use AsyncAws\SecretsManager\Exception\EncryptionFailureException; @@ -293,6 +294,7 @@ public function getSecretValue($input): GetSecretValueResponse * NextToken?: string|null, * Filters?: array|null, * SortOrder?: SortOrderType::*|null, + * SortBy?: SortByType::*|null, * '@region'?: string|null, * }|ListSecretsRequest $input *