Skip to content

Commit fcd674b

Browse files
authored
Differentiate empty list to not set list (#668)
1 parent f118bb9 commit fcd674b

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

src/Sts/Input/AssumeRoleRequest.php

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class AssumeRoleRequest extends Input
3333
* The Amazon Resource Names (ARNs) of the IAM managed policies that you want to use as managed session policies. The
3434
* policies must exist in the same account as the role.
3535
*
36-
* @var PolicyDescriptorType[]
36+
* @var PolicyDescriptorType[]|null
3737
*/
3838
private $PolicyArns;
3939

@@ -63,7 +63,7 @@ final class AssumeRoleRequest extends Input
6363
*
6464
* @see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html
6565
*
66-
* @var Tag[]
66+
* @var Tag[]|null
6767
*/
6868
private $Tags;
6969

@@ -74,7 +74,7 @@ final class AssumeRoleRequest extends Input
7474
*
7575
* @see https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_role-chaining
7676
*
77-
* @var string[]
77+
* @var string[]|null
7878
*/
7979
private $TransitiveTagKeys;
8080

@@ -131,11 +131,11 @@ public function __construct(array $input = [])
131131
{
132132
$this->RoleArn = $input['RoleArn'] ?? null;
133133
$this->RoleSessionName = $input['RoleSessionName'] ?? null;
134-
$this->PolicyArns = array_map([PolicyDescriptorType::class, 'create'], $input['PolicyArns'] ?? []);
134+
$this->PolicyArns = isset($input['PolicyArns']) ? array_map([PolicyDescriptorType::class, 'create'], $input['PolicyArns']) : null;
135135
$this->Policy = $input['Policy'] ?? null;
136136
$this->DurationSeconds = $input['DurationSeconds'] ?? null;
137-
$this->Tags = array_map([Tag::class, 'create'], $input['Tags'] ?? []);
138-
$this->TransitiveTagKeys = $input['TransitiveTagKeys'] ?? [];
137+
$this->Tags = isset($input['Tags']) ? array_map([Tag::class, 'create'], $input['Tags']) : null;
138+
$this->TransitiveTagKeys = $input['TransitiveTagKeys'] ?? null;
139139
$this->ExternalId = $input['ExternalId'] ?? null;
140140
$this->SerialNumber = $input['SerialNumber'] ?? null;
141141
$this->TokenCode = $input['TokenCode'] ?? null;
@@ -167,7 +167,7 @@ public function getPolicy(): ?string
167167
*/
168168
public function getPolicyArns(): array
169169
{
170-
return $this->PolicyArns;
170+
return $this->PolicyArns ?? [];
171171
}
172172

173173
public function getRoleArn(): ?string
@@ -190,7 +190,7 @@ public function getSerialNumber(): ?string
190190
*/
191191
public function getTags(): array
192192
{
193-
return $this->Tags;
193+
return $this->Tags ?? [];
194194
}
195195

196196
public function getTokenCode(): ?string
@@ -203,7 +203,7 @@ public function getTokenCode(): ?string
203203
*/
204204
public function getTransitiveTagKeys(): array
205205
{
206-
return $this->TransitiveTagKeys;
206+
return $this->TransitiveTagKeys ?? [];
207207
}
208208

209209
/**
@@ -317,36 +317,37 @@ private function requestBody(): array
317317
throw new InvalidArgument(sprintf('Missing parameter "RoleSessionName" for "%s". The value cannot be null.', __CLASS__));
318318
}
319319
$payload['RoleSessionName'] = $v;
320-
321-
$index = 0;
322-
foreach ($this->PolicyArns as $mapValue) {
323-
++$index;
324-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
325-
$payload["PolicyArns.member.$index.$bodyKey"] = $bodyValue;
320+
if (null !== $v = $this->PolicyArns) {
321+
$index = 0;
322+
foreach ($v as $mapValue) {
323+
++$index;
324+
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
325+
$payload["PolicyArns.member.$index.$bodyKey"] = $bodyValue;
326+
}
326327
}
327328
}
328-
329329
if (null !== $v = $this->Policy) {
330330
$payload['Policy'] = $v;
331331
}
332332
if (null !== $v = $this->DurationSeconds) {
333333
$payload['DurationSeconds'] = $v;
334334
}
335-
336-
$index = 0;
337-
foreach ($this->Tags as $mapValue) {
338-
++$index;
339-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
340-
$payload["Tags.member.$index.$bodyKey"] = $bodyValue;
335+
if (null !== $v = $this->Tags) {
336+
$index = 0;
337+
foreach ($v as $mapValue) {
338+
++$index;
339+
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
340+
$payload["Tags.member.$index.$bodyKey"] = $bodyValue;
341+
}
341342
}
342343
}
343-
344-
$index = 0;
345-
foreach ($this->TransitiveTagKeys as $mapValue) {
346-
++$index;
347-
$payload["TransitiveTagKeys.member.$index"] = $mapValue;
344+
if (null !== $v = $this->TransitiveTagKeys) {
345+
$index = 0;
346+
foreach ($v as $mapValue) {
347+
++$index;
348+
$payload["TransitiveTagKeys.member.$index"] = $mapValue;
349+
}
348350
}
349-
350351
if (null !== $v = $this->ExternalId) {
351352
$payload['ExternalId'] = $v;
352353
}

src/Sts/Input/AssumeRoleWithWebIdentityRequest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ final class AssumeRoleWithWebIdentityRequest extends Input
5353
* The Amazon Resource Names (ARNs) of the IAM managed policies that you want to use as managed session policies. The
5454
* policies must exist in the same account as the role.
5555
*
56-
* @var PolicyDescriptorType[]
56+
* @var PolicyDescriptorType[]|null
5757
*/
5858
private $PolicyArns;
5959

@@ -95,7 +95,7 @@ public function __construct(array $input = [])
9595
$this->RoleSessionName = $input['RoleSessionName'] ?? null;
9696
$this->WebIdentityToken = $input['WebIdentityToken'] ?? null;
9797
$this->ProviderId = $input['ProviderId'] ?? null;
98-
$this->PolicyArns = array_map([PolicyDescriptorType::class, 'create'], $input['PolicyArns'] ?? []);
98+
$this->PolicyArns = isset($input['PolicyArns']) ? array_map([PolicyDescriptorType::class, 'create'], $input['PolicyArns']) : null;
9999
$this->Policy = $input['Policy'] ?? null;
100100
$this->DurationSeconds = $input['DurationSeconds'] ?? null;
101101
parent::__construct($input);
@@ -121,7 +121,7 @@ public function getPolicy(): ?string
121121
*/
122122
public function getPolicyArns(): array
123123
{
124-
return $this->PolicyArns;
124+
return $this->PolicyArns ?? [];
125125
}
126126

127127
public function getProviderId(): ?string
@@ -235,15 +235,15 @@ private function requestBody(): array
235235
if (null !== $v = $this->ProviderId) {
236236
$payload['ProviderId'] = $v;
237237
}
238-
239-
$index = 0;
240-
foreach ($this->PolicyArns as $mapValue) {
241-
++$index;
242-
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
243-
$payload["PolicyArns.member.$index.$bodyKey"] = $bodyValue;
238+
if (null !== $v = $this->PolicyArns) {
239+
$index = 0;
240+
foreach ($v as $mapValue) {
241+
++$index;
242+
foreach ($mapValue->requestBody() as $bodyKey => $bodyValue) {
243+
$payload["PolicyArns.member.$index.$bodyKey"] = $bodyValue;
244+
}
244245
}
245246
}
246-
247247
if (null !== $v = $this->Policy) {
248248
$payload['Policy'] = $v;
249249
}

0 commit comments

Comments
 (0)