Skip to content

Commit e1822e6

Browse files
Update generated code (#2008)
* update generated code * Fix tests * Remove ResultWrapper for JSON * Update src/Service/CloudWatch/CHANGELOG.md --------- Co-authored-by: Jérémy Derussé <[email protected]>
1 parent 605d232 commit e1822e6

31 files changed

+406
-254
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"variables": {
3-
"${LATEST}": "3.366.4"
3+
"${LATEST}": "3.367.1"
44
},
55
"endpoints": "https://raw.githubusercontent.com/aws/aws-sdk-php/${LATEST}/src/data/endpoints.json",
66
"services": {

src/CodeGenerator/src/Generator/ResponseParser/RestJsonParser.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ public function generate(StructureShape $shape, bool $throwOnError = true): Pars
105105
}
106106

107107
$body = '$data = $response->toArray(' . ($throwOnError ? '' : 'false') . ');' . "\n";
108-
if (null !== $wrapper = $shape->getResultWrapper()) {
109-
$body .= strtr('$data = $data[WRAPPER];' . "\n", ['WRAPPER' => var_export($wrapper, true)]);
110-
}
111108
$body .= "\n" . implode("\n", $properties);
112109

113110
return new ParserResult($body, $this->imports, $this->functions);

src/Service/CloudWatch/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- AWS api-change: Added `us-isob-west-1` region
88
- AWS api-change: Added `eusc-de-east-1` region
9+
- AWS api-change: This release switch to the AWS JSON 1.1 Procol, replacing the currently utilized one, AWSQuery.
910

1011
### Dependency bumped
1112

src/Service/CloudWatch/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": "^8.2",
15-
"ext-simplexml": "*",
15+
"ext-json": "*",
1616
"async-aws/core": "^1.9"
1717
},
1818
"require-dev": {

src/Service/CloudWatch/src/CloudWatchClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use AsyncAws\CloudWatch\ValueObject\MetricDatum;
2727
use AsyncAws\Core\AbstractApi;
2828
use AsyncAws\Core\AwsError\AwsErrorFactoryInterface;
29-
use AsyncAws\Core\AwsError\XmlAwsErrorFactory;
29+
use AsyncAws\Core\AwsError\JsonRpcAwsErrorFactory;
3030
use AsyncAws\Core\Configuration;
3131
use AsyncAws\Core\RequestContext;
3232
use AsyncAws\Core\Result;
@@ -314,7 +314,7 @@ public function putMetricData($input): Result
314314

315315
protected function getAwsErrorFactory(): AwsErrorFactoryInterface
316316
{
317-
return new XmlAwsErrorFactory();
317+
return new JsonRpcAwsErrorFactory();
318318
}
319319

320320
protected function getEndpointMetadata(?string $region): array

src/Service/CloudWatch/src/Input/GetMetricDataInput.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ public function getStartTime(): ?\DateTimeImmutable
192192
public function request(): Request
193193
{
194194
// Prepare headers
195-
$headers = ['content-type' => 'application/x-www-form-urlencoded'];
195+
$headers = [
196+
'Content-Type' => 'application/x-amz-json-1.0',
197+
'X-Amz-Target' => 'GraniteServiceVersion20100801.GetMetricData',
198+
'Accept' => 'application/json',
199+
];
196200

197201
// Prepare query
198202
$query = [];
@@ -201,7 +205,8 @@ public function request(): Request
201205
$uriString = '/';
202206

203207
// Prepare Body
204-
$body = http_build_query(['Action' => 'GetMetricData', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738);
208+
$bodyPayload = $this->requestBody();
209+
$body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304);
205210

206211
// Return the Request
207212
return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body));
@@ -269,22 +274,21 @@ private function requestBody(): array
269274
throw new InvalidArgument(\sprintf('Missing parameter "MetricDataQueries" for "%s". The value cannot be null.', __CLASS__));
270275
}
271276

272-
$index = 0;
273-
foreach ($v as $mapValue) {
277+
$index = -1;
278+
$payload['MetricDataQueries'] = [];
279+
foreach ($v as $listValue) {
274280
++$index;
275-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
276-
$payload["MetricDataQueries.member.$index.$bodyKey"] = $bodyValue;
277-
}
281+
$payload['MetricDataQueries'][$index] = $listValue->requestBody();
278282
}
279283

280284
if (null === $v = $this->startTime) {
281285
throw new InvalidArgument(\sprintf('Missing parameter "StartTime" for "%s". The value cannot be null.', __CLASS__));
282286
}
283-
$payload['StartTime'] = $v->format(\DateTimeInterface::ATOM);
287+
$payload['StartTime'] = $v->getTimestamp();
284288
if (null === $v = $this->endTime) {
285289
throw new InvalidArgument(\sprintf('Missing parameter "EndTime" for "%s". The value cannot be null.', __CLASS__));
286290
}
287-
$payload['EndTime'] = $v->format(\DateTimeInterface::ATOM);
291+
$payload['EndTime'] = $v->getTimestamp();
288292
if (null !== $v = $this->nextToken) {
289293
$payload['NextToken'] = $v;
290294
}
@@ -298,9 +302,7 @@ private function requestBody(): array
298302
$payload['MaxDatapoints'] = $v;
299303
}
300304
if (null !== $v = $this->labelOptions) {
301-
foreach ($v->requestBody() as $bodyKey => $bodyValue) {
302-
$payload["LabelOptions.$bodyKey"] = $bodyValue;
303-
}
305+
$payload['LabelOptions'] = $v->requestBody();
304306
}
305307

306308
return $payload;

src/Service/CloudWatch/src/Input/GetMetricStatisticsInput.php

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ public function getUnit(): ?string
240240
public function request(): Request
241241
{
242242
// Prepare headers
243-
$headers = ['content-type' => 'application/x-www-form-urlencoded'];
243+
$headers = [
244+
'Content-Type' => 'application/x-amz-json-1.0',
245+
'X-Amz-Target' => 'GraniteServiceVersion20100801.GetMetricStatistics',
246+
'Accept' => 'application/json',
247+
];
244248

245249
// Prepare query
246250
$query = [];
@@ -249,7 +253,8 @@ public function request(): Request
249253
$uriString = '/';
250254

251255
// Prepare Body
252-
$body = http_build_query(['Action' => 'GetMetricStatistics', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738);
256+
$bodyPayload = $this->requestBody();
257+
$body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304);
253258

254259
// Return the Request
255260
return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body));
@@ -342,41 +347,42 @@ private function requestBody(): array
342347
}
343348
$payload['MetricName'] = $v;
344349
if (null !== $v = $this->dimensions) {
345-
$index = 0;
346-
foreach ($v as $mapValue) {
350+
$index = -1;
351+
$payload['Dimensions'] = [];
352+
foreach ($v as $listValue) {
347353
++$index;
348-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
349-
$payload["Dimensions.member.$index.$bodyKey"] = $bodyValue;
350-
}
354+
$payload['Dimensions'][$index] = $listValue->requestBody();
351355
}
352356
}
353357
if (null === $v = $this->startTime) {
354358
throw new InvalidArgument(\sprintf('Missing parameter "StartTime" for "%s". The value cannot be null.', __CLASS__));
355359
}
356-
$payload['StartTime'] = $v->format(\DateTimeInterface::ATOM);
360+
$payload['StartTime'] = $v->getTimestamp();
357361
if (null === $v = $this->endTime) {
358362
throw new InvalidArgument(\sprintf('Missing parameter "EndTime" for "%s". The value cannot be null.', __CLASS__));
359363
}
360-
$payload['EndTime'] = $v->format(\DateTimeInterface::ATOM);
364+
$payload['EndTime'] = $v->getTimestamp();
361365
if (null === $v = $this->period) {
362366
throw new InvalidArgument(\sprintf('Missing parameter "Period" for "%s". The value cannot be null.', __CLASS__));
363367
}
364368
$payload['Period'] = $v;
365369
if (null !== $v = $this->statistics) {
366-
$index = 0;
367-
foreach ($v as $mapValue) {
370+
$index = -1;
371+
$payload['Statistics'] = [];
372+
foreach ($v as $listValue) {
368373
++$index;
369-
if (!Statistic::exists($mapValue)) {
370-
throw new InvalidArgument(\sprintf('Invalid parameter "Statistics.member" for "%s". The value "%s" is not a valid "Statistic".', __CLASS__, $mapValue));
374+
if (!Statistic::exists($listValue)) {
375+
throw new InvalidArgument(\sprintf('Invalid parameter "Statistics" for "%s". The value "%s" is not a valid "Statistic".', __CLASS__, $listValue));
371376
}
372-
$payload["Statistics.member.$index"] = $mapValue;
377+
$payload['Statistics'][$index] = $listValue;
373378
}
374379
}
375380
if (null !== $v = $this->extendedStatistics) {
376-
$index = 0;
377-
foreach ($v as $mapValue) {
381+
$index = -1;
382+
$payload['ExtendedStatistics'] = [];
383+
foreach ($v as $listValue) {
378384
++$index;
379-
$payload["ExtendedStatistics.member.$index"] = $mapValue;
385+
$payload['ExtendedStatistics'][$index] = $listValue;
380386
}
381387
}
382388
if (null !== $v = $this->unit) {

src/Service/CloudWatch/src/Input/ListMetricsInput.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ public function getRecentlyActive(): ?string
158158
public function request(): Request
159159
{
160160
// Prepare headers
161-
$headers = ['content-type' => 'application/x-www-form-urlencoded'];
161+
$headers = [
162+
'Content-Type' => 'application/x-amz-json-1.0',
163+
'X-Amz-Target' => 'GraniteServiceVersion20100801.ListMetrics',
164+
'Accept' => 'application/json',
165+
];
162166

163167
// Prepare query
164168
$query = [];
@@ -167,7 +171,8 @@ public function request(): Request
167171
$uriString = '/';
168172

169173
// Prepare Body
170-
$body = http_build_query(['Action' => 'ListMetrics', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738);
174+
$bodyPayload = $this->requestBody();
175+
$body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304);
171176

172177
// Return the Request
173178
return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body));
@@ -238,12 +243,11 @@ private function requestBody(): array
238243
$payload['MetricName'] = $v;
239244
}
240245
if (null !== $v = $this->dimensions) {
241-
$index = 0;
242-
foreach ($v as $mapValue) {
246+
$index = -1;
247+
$payload['Dimensions'] = [];
248+
foreach ($v as $listValue) {
243249
++$index;
244-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
245-
$payload["Dimensions.member.$index.$bodyKey"] = $bodyValue;
246-
}
250+
$payload['Dimensions'][$index] = $listValue->requestBody();
247251
}
248252
}
249253
if (null !== $v = $this->nextToken) {
@@ -256,7 +260,7 @@ private function requestBody(): array
256260
$payload['RecentlyActive'] = $v;
257261
}
258262
if (null !== $v = $this->includeLinkedAccounts) {
259-
$payload['IncludeLinkedAccounts'] = $v ? 'true' : 'false';
263+
$payload['IncludeLinkedAccounts'] = (bool) $v;
260264
}
261265
if (null !== $v = $this->owningAccount) {
262266
$payload['OwningAccount'] = $v;

src/Service/CloudWatch/src/Input/PutMetricDataInput.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ public function getStrictEntityValidation(): ?bool
140140
public function request(): Request
141141
{
142142
// Prepare headers
143-
$headers = ['content-type' => 'application/x-www-form-urlencoded'];
143+
$headers = [
144+
'Content-Type' => 'application/x-amz-json-1.0',
145+
'X-Amz-Target' => 'GraniteServiceVersion20100801.PutMetricData',
146+
'Accept' => 'application/json',
147+
];
144148

145149
// Prepare query
146150
$query = [];
@@ -149,7 +153,8 @@ public function request(): Request
149153
$uriString = '/';
150154

151155
// Prepare Body
152-
$body = http_build_query(['Action' => 'PutMetricData', 'Version' => '2010-08-01'] + $this->requestBody(), '', '&', \PHP_QUERY_RFC1738);
156+
$bodyPayload = $this->requestBody();
157+
$body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304);
153158

154159
// Return the Request
155160
return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body));
@@ -197,25 +202,23 @@ private function requestBody(): array
197202
}
198203
$payload['Namespace'] = $v;
199204
if (null !== $v = $this->metricData) {
200-
$index = 0;
201-
foreach ($v as $mapValue) {
205+
$index = -1;
206+
$payload['MetricData'] = [];
207+
foreach ($v as $listValue) {
202208
++$index;
203-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
204-
$payload["MetricData.member.$index.$bodyKey"] = $bodyValue;
205-
}
209+
$payload['MetricData'][$index] = $listValue->requestBody();
206210
}
207211
}
208212
if (null !== $v = $this->entityMetricData) {
209-
$index = 0;
210-
foreach ($v as $mapValue) {
213+
$index = -1;
214+
$payload['EntityMetricData'] = [];
215+
foreach ($v as $listValue) {
211216
++$index;
212-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
213-
$payload["EntityMetricData.member.$index.$bodyKey"] = $bodyValue;
214-
}
217+
$payload['EntityMetricData'][$index] = $listValue->requestBody();
215218
}
216219
}
217220
if (null !== $v = $this->strictEntityValidation) {
218-
$payload['StrictEntityValidation'] = $v ? 'true' : 'false';
221+
$payload['StrictEntityValidation'] = (bool) $v;
219222
}
220223

221224
return $payload;

0 commit comments

Comments
 (0)