Skip to content

Commit 83956d5

Browse files
Nemo64jderusse
andauthored
implement rds-data service (#645)
* implement RDSDataService * Handle recurcion is JsonRest * Update Services * Update RdsDataService * Fallback endpoint when not available * set FUNCTION_KEY in more places * update readme for value object * php cs fix * implement $fn usage detection * make phpstan ignore array keys that are defined out of order phpstan/phpstan#3358 * revert added complexity by just ignoring phpstan messages * change capitalisation of the rds data service * ignore argument missmatch in generated code * avoid edge case where a function is accessed but not created Co-authored-by: Jérémy Derussé <[email protected]>
1 parent 71dcb26 commit 83956d5

11 files changed

+636
-747
lines changed

src/Result/CreateTableOutput.php

Lines changed: 115 additions & 138 deletions
Large diffs are not rendered by default.

src/Result/DeleteItemOutput.php

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,43 @@ public function getItemCollectionMetrics(): ?ItemCollectionMetrics
6161
protected function populateResult(Response $response): void
6262
{
6363
$data = $response->toArray();
64+
$fn = [];
65+
$fn['map-AttributeMap'] = static function (array $json): array {
66+
$items = [];
67+
foreach ($json as $name => $value) {
68+
$items[(string) $name] = AttributeValue::create($value);
69+
}
70+
71+
return $items;
72+
};
73+
$fn['map-SecondaryIndexesCapacityMap'] = static function (array $json): array {
74+
$items = [];
75+
foreach ($json as $name => $value) {
76+
$items[(string) $name] = Capacity::create($value);
77+
}
6478

65-
$this->Attributes = empty($data['Attributes']) ? [] : (function (array $json): array {
79+
return $items;
80+
};
81+
$fn['map-ItemCollectionKeyAttributeMap'] = static function (array $json): array {
6682
$items = [];
6783
foreach ($json as $name => $value) {
6884
$items[(string) $name] = AttributeValue::create($value);
6985
}
7086

7187
return $items;
72-
})($data['Attributes']);
88+
};
89+
$fn['list-ItemCollectionSizeEstimateRange'] = static function (array $json) use (&$fn): array {
90+
$items = [];
91+
foreach ($json as $item) {
92+
$a = isset($item) ? (float) $item : null;
93+
if (null !== $a) {
94+
$items[] = $a;
95+
}
96+
}
97+
98+
return $items;
99+
};
100+
$this->Attributes = empty($data['Attributes']) ? [] : $fn['map-AttributeMap']($data['Attributes']);
73101
$this->ConsumedCapacity = empty($data['ConsumedCapacity']) ? null : new ConsumedCapacity([
74102
'TableName' => isset($data['ConsumedCapacity']['TableName']) ? (string) $data['ConsumedCapacity']['TableName'] : null,
75103
'CapacityUnits' => isset($data['ConsumedCapacity']['CapacityUnits']) ? (float) $data['ConsumedCapacity']['CapacityUnits'] : null,
@@ -80,43 +108,12 @@ protected function populateResult(Response $response): void
80108
'WriteCapacityUnits' => isset($data['ConsumedCapacity']['Table']['WriteCapacityUnits']) ? (float) $data['ConsumedCapacity']['Table']['WriteCapacityUnits'] : null,
81109
'CapacityUnits' => isset($data['ConsumedCapacity']['Table']['CapacityUnits']) ? (float) $data['ConsumedCapacity']['Table']['CapacityUnits'] : null,
82110
]),
83-
'LocalSecondaryIndexes' => empty($data['ConsumedCapacity']['LocalSecondaryIndexes']) ? [] : (function (array $json): array {
84-
$items = [];
85-
foreach ($json as $name => $value) {
86-
$items[(string) $name] = Capacity::create($value);
87-
}
88-
89-
return $items;
90-
})($data['ConsumedCapacity']['LocalSecondaryIndexes']),
91-
'GlobalSecondaryIndexes' => empty($data['ConsumedCapacity']['GlobalSecondaryIndexes']) ? [] : (function (array $json): array {
92-
$items = [];
93-
foreach ($json as $name => $value) {
94-
$items[(string) $name] = Capacity::create($value);
95-
}
96-
97-
return $items;
98-
})($data['ConsumedCapacity']['GlobalSecondaryIndexes']),
111+
'LocalSecondaryIndexes' => empty($data['ConsumedCapacity']['LocalSecondaryIndexes']) ? [] : $fn['map-SecondaryIndexesCapacityMap']($data['ConsumedCapacity']['LocalSecondaryIndexes']),
112+
'GlobalSecondaryIndexes' => empty($data['ConsumedCapacity']['GlobalSecondaryIndexes']) ? [] : $fn['map-SecondaryIndexesCapacityMap']($data['ConsumedCapacity']['GlobalSecondaryIndexes']),
99113
]);
100114
$this->ItemCollectionMetrics = empty($data['ItemCollectionMetrics']) ? null : new ItemCollectionMetrics([
101-
'ItemCollectionKey' => empty($data['ItemCollectionMetrics']['ItemCollectionKey']) ? [] : (function (array $json): array {
102-
$items = [];
103-
foreach ($json as $name => $value) {
104-
$items[(string) $name] = AttributeValue::create($value);
105-
}
106-
107-
return $items;
108-
})($data['ItemCollectionMetrics']['ItemCollectionKey']),
109-
'SizeEstimateRangeGB' => empty($data['ItemCollectionMetrics']['SizeEstimateRangeGB']) ? [] : (function (array $json): array {
110-
$items = [];
111-
foreach ($json as $item) {
112-
$a = isset($item) ? (float) $item : null;
113-
if (null !== $a) {
114-
$items[] = $a;
115-
}
116-
}
117-
118-
return $items;
119-
})($data['ItemCollectionMetrics']['SizeEstimateRangeGB']),
115+
'ItemCollectionKey' => empty($data['ItemCollectionMetrics']['ItemCollectionKey']) ? [] : $fn['map-ItemCollectionKeyAttributeMap']($data['ItemCollectionMetrics']['ItemCollectionKey']),
116+
'SizeEstimateRangeGB' => empty($data['ItemCollectionMetrics']['SizeEstimateRangeGB']) ? [] : $fn['list-ItemCollectionSizeEstimateRange']($data['ItemCollectionMetrics']['SizeEstimateRangeGB']),
120117
]);
121118
}
122119
}

0 commit comments

Comments
 (0)