From 2d6e27883adea1e299fd2a4c74a5fd3218ae3d1a Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 1 Jul 2023 18:58:31 +0200 Subject: [PATCH 1/4] Refactor the code generating object properties --- .../src/Generator/ObjectGenerator.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/CodeGenerator/src/Generator/ObjectGenerator.php b/src/CodeGenerator/src/Generator/ObjectGenerator.php index f930a7bf7..e519c985a 100644 --- a/src/CodeGenerator/src/Generator/ObjectGenerator.php +++ b/src/CodeGenerator/src/Generator/ObjectGenerator.php @@ -196,29 +196,36 @@ private function namedConstructor(StructureShape $shape, ClassBuilder $classBuil $memberShape = $member->getShape(); if ($memberShape instanceof StructureShape) { $objectClass = $this->generate($memberShape); - $constructorBody .= strtr('$this->PROPERTY = isset($input["NAME"]) ? CLASS::create($input["NAME"]) : null;' . "\n", ['PROPERTY' => GeneratorHelper::normalizeName($member->getName()), 'NAME' => $member->getName(), 'CLASS' => $objectClass->getName()]); + $memberCode = strtr('CLASS::create($input["NAME"])', ['NAME' => $member->getName(), 'CLASS' => $objectClass->getName()]); } elseif ($memberShape instanceof ListShape) { $listMemberShape = $memberShape->getMember()->getShape(); // Check if this is a list of objects if ($listMemberShape instanceof StructureShape) { $objectClass = $this->generate($listMemberShape); - $constructorBody .= strtr('$this->PROPERTY = isset($input["NAME"]) ? array_map([CLASS::class, "create"], $input["NAME"]) : null;' . "\n", ['PROPERTY' => GeneratorHelper::normalizeName($member->getName()), 'NAME' => $member->getName(), 'CLASS' => $objectClass->getName()]); + $memberCode = strtr('array_map([CLASS::class, "create"], $input["NAME"])', ['NAME' => $member->getName(), 'CLASS' => $objectClass->getName()]); } else { - $constructorBody .= strtr('$this->PROPERTY = $input["NAME"] ?? null;' . "\n", ['PROPERTY' => GeneratorHelper::normalizeName($member->getName()), 'NAME' => $member->getName()]); + $memberCode = strtr('$input["NAME"]', ['NAME' => $member->getName()]); } } elseif ($memberShape instanceof MapShape) { $mapValueShape = $memberShape->getValue()->getShape(); if ($mapValueShape instanceof StructureShape) { $objectClass = $this->generate($mapValueShape); - $constructorBody .= strtr('$this->PROPERTY = isset($input["NAME"]) ? array_map([CLASS::class, "create"], $input["NAME"]) : null;' . "\n", ['PROPERTY' => GeneratorHelper::normalizeName($member->getName()), 'NAME' => $member->getName(), 'CLASS' => $objectClass->getName()]); + $memberCode = strtr('array_map([CLASS::class, "create"], $input["NAME"])', ['NAME' => $member->getName(), 'CLASS' => $objectClass->getName()]); } else { - $constructorBody .= strtr('$this->PROPERTY = $input["NAME"] ?? null;' . "\n", ['PROPERTY' => GeneratorHelper::normalizeName($member->getName()), 'NAME' => $member->getName()]); + $memberCode = strtr('$input["NAME"]', ['NAME' => $member->getName()]); } } else { - $constructorBody .= strtr('$this->PROPERTY = $input["NAME"] ?? null;' . "\n", ['PROPERTY' => GeneratorHelper::normalizeName($member->getName()), 'NAME' => $member->getName()]); + $memberCode = strtr('$input["NAME"]', ['NAME' => $member->getName()]); } + $fallback = 'null'; + $constructorBody .= strtr('$this->PROPERTY = isset($input["NAME"]) ? MEMBER_CODE : FALLBACK;' . "\n", [ + 'PROPERTY' => GeneratorHelper::normalizeName($member->getName()), + 'NAME' => $member->getName(), + 'MEMBER_CODE' => $memberCode, + 'FALLBACK' => $fallback, + ]); } $constructor->setBody($constructorBody); } From 62a0f95a1bf9ffe4496c4193a36d5d5fb280af6e Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 1 Jul 2023 19:01:49 +0200 Subject: [PATCH 2/4] Refactor the generation of array getters Optional array fields still need to consider the property as nullable even though the getter will return an empty array as AWS does not treat absent lists the same than empty lists in input. --- .../src/Generator/ObjectGenerator.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/CodeGenerator/src/Generator/ObjectGenerator.php b/src/CodeGenerator/src/Generator/ObjectGenerator.php index e519c985a..8859a0857 100644 --- a/src/CodeGenerator/src/Generator/ObjectGenerator.php +++ b/src/CodeGenerator/src/Generator/ObjectGenerator.php @@ -256,12 +256,12 @@ private function addProperties(StructureShape $shape, ClassBuilder $classBuilder $enumClassName = $this->enumGenerator->generate($memberShape); $classBuilder->addUse($enumClassName->getFqdn()); } - $getterSetterNullable = true; + $getterSetterNullable = null; if ($memberShape instanceof StructureShape) { $this->generate($memberShape); } elseif ($memberShape instanceof MapShape) { - $nullable = $getterSetterNullable = false; + $getterSetterNullable = false; $mapKeyShape = $memberShape->getKey()->getShape(); if ('string' !== $mapKeyShape->getType()) { throw new \RuntimeException('Complex maps are not supported'); @@ -278,7 +278,7 @@ private function addProperties(StructureShape $shape, ClassBuilder $classBuilder $classBuilder->addUse($enumClassName->getFqdn()); } } elseif ($memberShape instanceof ListShape) { - $nullable = $getterSetterNullable = false; + $getterSetterNullable = false; $memberShape->getMember()->getShape(); if (($memberShape = $memberShape->getMember()->getShape()) instanceof StructureShape) { @@ -304,7 +304,10 @@ private function addProperties(StructureShape $shape, ClassBuilder $classBuilder $deprecation = strtr('@trigger_error(\sprintf(\'The property "NAME" of "%s" is deprecated by AWS.\', __CLASS__), E_USER_DEPRECATED);', ['NAME' => $member->getName()]); } - if ($getterSetterNullable) { + $nullable = $nullable ?? !$member->isRequired(); + $getterSetterNullable = $getterSetterNullable ?? $nullable; + + if ($getterSetterNullable || !$nullable) { $method->setBody($deprecation . strtr(' return $this->PROPERTY; ', [ @@ -318,11 +321,10 @@ private function addProperties(StructureShape $shape, ClassBuilder $classBuilder ])); } - $nullable = $nullable ?? !$member->isRequired(); if ($parameterType && $parameterType !== $returnType && (empty($memberClassNames) || $memberClassNames[0]->getName() !== $parameterType)) { - $method->addComment('@return ' . $parameterType . ($nullable ? '|null' : '')); + $method->addComment('@return ' . $parameterType . ($getterSetterNullable ? '|null' : '')); } - $method->setReturnNullable($nullable); + $method->setReturnNullable($getterSetterNullable); } foreach ($forEndpointProps as $key => $ok) { From 27459dcb8428f02ac152279449231c0c54824a4f Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 1 Jul 2023 16:58:09 +0200 Subject: [PATCH 3/4] Add validation of required parameters in value object constructors --- .../src/Generator/ObjectGenerator.php | 19 +++++++++++- .../src/Sts/ValueObject/AssumedRoleUser.php | 14 +++++++-- src/Core/src/Sts/ValueObject/Credentials.php | 18 +++++++++--- src/Core/src/Sts/ValueObject/Tag.php | 12 ++++++-- .../src/ValueObject/AppSyncRuntime.php | 12 ++++++-- .../src/ValueObject/AuthorizationConfig.php | 10 ++++++- .../AppSync/src/ValueObject/CachingConfig.php | 10 ++++++- .../ValueObject/DynamodbDataSourceConfig.php | 12 ++++++-- .../ElasticsearchDataSourceConfig.php | 12 ++++++-- .../EventBridgeDataSourceConfig.php | 10 ++++++- .../ValueObject/LambdaDataSourceConfig.php | 10 ++++++- .../OpenSearchServiceDataSourceConfig.php | 12 ++++++-- .../src/ValueObject/AclConfiguration.php | 10 ++++++- src/Service/Athena/src/ValueObject/Column.php | 12 +++++++- .../Athena/src/ValueObject/ColumnInfo.php | 13 +++++++-- ...CustomerContentEncryptionConfiguration.php | 12 +++++++- .../Athena/src/ValueObject/DataCatalog.php | 13 +++++++-- .../Athena/src/ValueObject/Database.php | 12 +++++++- .../ValueObject/EncryptionConfiguration.php | 10 ++++++- .../src/ValueObject/EngineConfiguration.php | 10 ++++++- .../Athena/src/ValueObject/NamedQuery.php | 16 ++++++++-- .../ResultReuseByAgeConfiguration.php | 10 ++++++- .../ValueObject/ResultReuseInformation.php | 12 +++++++- .../Athena/src/ValueObject/TableMetadata.php | 12 +++++++- .../Athena/src/ValueObject/WorkGroup.php | 11 ++++++- .../src/ValueObject/RollbackTrigger.php | 14 +++++++-- .../CloudFormation/src/ValueObject/Stack.php | 15 ++++++++-- .../src/ValueObject/StackDriftInformation.php | 11 ++++++- .../src/ValueObject/StackEvent.php | 17 ++++++++--- .../CloudFormation/src/ValueObject/Tag.php | 14 +++++++-- .../src/ValueObject/Invalidation.php | 18 +++++++++--- .../src/ValueObject/InvalidationBatch.php | 12 ++++++-- .../CloudFront/src/ValueObject/Paths.php | 10 ++++++- .../CloudWatch/src/ValueObject/Dimension.php | 12 ++++++-- .../src/ValueObject/DimensionFilter.php | 10 ++++++- .../src/ValueObject/MetricDataQuery.php | 10 ++++++- .../src/ValueObject/MetricDatum.php | 10 ++++++- .../CloudWatch/src/ValueObject/MetricStat.php | 14 +++++++-- .../src/ValueObject/StatisticSet.php | 16 +++++++--- .../src/ValueObject/InputLogEvent.php | 12 ++++++-- .../src/ValueObject/CloudWatchLogsConfig.php | 10 ++++++- .../src/ValueObject/EnvironmentVariable.php | 12 ++++++-- .../src/ValueObject/GitSubmodulesConfig.php | 10 ++++++- .../src/ValueObject/ProjectArtifacts.php | 10 ++++++- .../src/ValueObject/ProjectCache.php | 10 ++++++- .../src/ValueObject/ProjectEnvironment.php | 15 ++++++++-- .../src/ValueObject/ProjectSource.php | 10 ++++++- .../src/ValueObject/ProjectSourceVersion.php | 12 ++++++-- .../src/ValueObject/RegistryCredential.php | 12 ++++++-- .../src/ValueObject/S3LogsConfig.php | 10 ++++++- .../CodeBuild/src/ValueObject/SourceAuth.php | 10 ++++++- .../src/ValueObject/RepositoryTrigger.php | 16 +++++++--- .../src/ValueObject/AttributeType.php | 10 ++++++- .../src/ValueObject/ContextDataType.php | 18 ++++++++---- .../src/ValueObject/AttributeDefinition.php | 12 ++++++-- .../DynamoDb/src/ValueObject/Condition.php | 10 ++++++- .../src/ValueObject/ConditionCheck.php | 16 +++++++--- .../CreateGlobalSecondaryIndexAction.php | 16 +++++++--- .../CreateReplicationGroupMemberAction.php | 10 ++++++- .../DynamoDb/src/ValueObject/Delete.php | 14 +++++++-- .../DeleteGlobalSecondaryIndexAction.php | 10 ++++++- .../DeleteReplicationGroupMemberAction.php | 10 ++++++- .../src/ValueObject/DeleteRequest.php | 12 ++++++-- .../DynamoDb/src/ValueObject/Endpoint.php | 13 +++++++-- .../src/ValueObject/GlobalSecondaryIndex.php | 16 +++++++--- .../src/ValueObject/KeySchemaElement.php | 12 ++++++-- .../src/ValueObject/KeysAndAttributes.php | 12 ++++++-- .../src/ValueObject/LocalSecondaryIndex.php | 16 +++++++--- .../src/ValueObject/ProvisionedThroughput.php | 12 ++++++-- src/Service/DynamoDb/src/ValueObject/Put.php | 14 +++++++-- .../DynamoDb/src/ValueObject/PutRequest.php | 12 ++++++-- .../ReplicaGlobalSecondaryIndex.php | 10 ++++++- .../src/ValueObject/RestoreSummary.php | 14 +++++++-- .../src/ValueObject/StreamSpecification.php | 10 ++++++- src/Service/DynamoDb/src/ValueObject/Tag.php | 12 ++++++-- .../ValueObject/TimeToLiveSpecification.php | 12 ++++++-- .../DynamoDb/src/ValueObject/Update.php | 16 +++++++--- .../UpdateGlobalSecondaryIndexAction.php | 12 ++++++-- .../UpdateReplicationGroupMemberAction.php | 10 ++++++- .../Firehose/src/ValueObject/Record.php | 10 ++++++- src/Service/Iam/src/ValueObject/AccessKey.php | 17 ++++++++--- .../ValueObject/ServiceSpecificCredential.php | 23 ++++++++++----- .../ServiceSpecificCredentialMetadata.php | 21 ++++++++++---- src/Service/Iam/src/ValueObject/Tag.php | 12 ++++++-- src/Service/Iam/src/ValueObject/User.php | 20 +++++++++---- src/Service/Iot/src/ValueObject/Tag.php | 10 ++++++- .../Kinesis/src/ValueObject/ChildShard.php | 18 +++++++++--- .../Kinesis/src/ValueObject/Consumer.php | 17 ++++++++--- .../src/ValueObject/ConsumerDescription.php | 19 ++++++++---- .../Kinesis/src/ValueObject/HashKeyRange.php | 14 +++++++-- .../ValueObject/PutRecordsRequestEntry.php | 12 ++++++-- .../Kinesis/src/ValueObject/Record.php | 15 ++++++++-- .../src/ValueObject/SequenceNumberRange.php | 12 +++++++- src/Service/Kinesis/src/ValueObject/Shard.php | 16 ++++++++-- .../Kinesis/src/ValueObject/ShardFilter.php | 10 ++++++- .../src/ValueObject/StreamDescription.php | 29 ++++++++++++------- .../ValueObject/StreamDescriptionSummary.php | 25 +++++++++++----- .../src/ValueObject/StreamModeDetails.php | 10 ++++++- .../Kinesis/src/ValueObject/StreamSummary.php | 15 ++++++++-- src/Service/Kinesis/src/ValueObject/Tag.php | 12 +++++++- .../Kms/src/ValueObject/KeyMetadata.php | 11 ++++++- src/Service/Kms/src/ValueObject/Tag.php | 12 ++++++-- .../src/ValueObject/EphemeralStorage.php | 12 +++++++- .../src/ValueObject/FileSystemConfig.php | 14 +++++++-- .../src/ValueObject/AccelerationSettings.php | 10 ++++++- .../MediaConvert/src/ValueObject/Job.php | 13 +++++++-- .../src/ValueObject/WarningGroup.php | 14 +++++++-- .../src/ValueObject/HumanLoopConfig.php | 12 ++++++-- .../Route53/src/ValueObject/AliasTarget.php | 14 +++++++-- .../Route53/src/ValueObject/Change.php | 12 ++++++-- .../Route53/src/ValueObject/ChangeBatch.php | 12 ++++++-- .../Route53/src/ValueObject/ChangeInfo.php | 15 ++++++++-- .../src/ValueObject/CidrRoutingConfig.php | 12 ++++++-- .../Route53/src/ValueObject/DelegationSet.php | 14 +++++++-- .../Route53/src/ValueObject/HostedZone.php | 16 ++++++++-- .../src/ValueObject/ResourceRecord.php | 10 ++++++- .../src/ValueObject/ResourceRecordSet.php | 12 ++++++-- .../S3/src/ValueObject/CORSConfiguration.php | 12 ++++++-- src/Service/S3/src/ValueObject/CORSRule.php | 16 +++++++--- src/Service/S3/src/ValueObject/Delete.php | 12 ++++++-- src/Service/S3/src/ValueObject/Grantee.php | 10 ++++++- .../LambdaFunctionConfiguration.php | 14 +++++++-- .../S3/src/ValueObject/ObjectIdentifier.php | 10 ++++++- .../S3/src/ValueObject/QueueConfiguration.php | 14 +++++++-- .../ServerSideEncryptionByDefault.php | 11 ++++++- .../ServerSideEncryptionConfiguration.php | 14 +++++++-- src/Service/S3/src/ValueObject/Tag.php | 12 ++++++-- src/Service/S3/src/ValueObject/Tagging.php | 12 ++++++-- .../S3/src/ValueObject/TopicConfiguration.php | 14 +++++++-- .../src/ValueObject/AwsVpcConfiguration.php | 12 ++++++-- .../CapacityProviderStrategyItem.php | 10 ++++++- .../src/ValueObject/EcsParameters.php | 10 ++++++- .../src/ValueObject/EventBridgeParameters.php | 12 ++++++-- .../src/ValueObject/FlexibleTimeWindow.php | 10 ++++++- .../src/ValueObject/KinesisParameters.php | 10 ++++++- .../SageMakerPipelineParameter.php | 12 ++++++-- src/Service/Scheduler/src/ValueObject/Tag.php | 12 ++++++-- .../Scheduler/src/ValueObject/Target.php | 12 ++++++-- .../src/ValueObject/TargetSummary.php | 12 +++++++- src/Service/Ses/src/ValueObject/Content.php | 10 ++++++- .../src/ValueObject/ListManagementOptions.php | 10 ++++++- src/Service/Ses/src/ValueObject/Message.php | 12 ++++++-- .../Ses/src/ValueObject/MessageTag.php | 12 ++++++-- .../Ses/src/ValueObject/RawMessage.php | 10 ++++++- .../src/ValueObject/BatchResultErrorEntry.php | 16 ++++++++-- .../src/ValueObject/MessageAttributeValue.php | 10 ++++++- .../ValueObject/PublishBatchRequestEntry.php | 12 ++++++-- src/Service/Sns/src/ValueObject/Tag.php | 12 ++++++-- .../src/ValueObject/BatchResultErrorEntry.php | 16 ++++++++-- ...angeMessageVisibilityBatchRequestEntry.php | 12 ++++++-- ...hangeMessageVisibilityBatchResultEntry.php | 12 +++++++- .../DeleteMessageBatchRequestEntry.php | 12 ++++++-- .../DeleteMessageBatchResultEntry.php | 12 +++++++- .../src/ValueObject/MessageAttributeValue.php | 10 ++++++- .../MessageSystemAttributeValue.php | 10 ++++++- .../SendMessageBatchRequestEntry.php | 12 ++++++-- .../SendMessageBatchResultEntry.php | 16 ++++++++-- .../src/ValueObject/ParameterStringFilter.php | 10 ++++++- src/Service/Ssm/src/ValueObject/Tag.php | 12 ++++++-- .../src/ValueObject/ColumnInfo.php | 12 +++++++- .../src/ValueObject/Endpoint.php | 13 +++++++-- .../src/ValueObject/ParameterMapping.php | 14 +++++++-- .../TimestreamQuery/src/ValueObject/Row.php | 14 +++++++-- .../src/ValueObject/TimeSeriesDataPoint.php | 14 +++++++-- .../src/ValueObject/Dimension.php | 12 ++++++-- .../src/ValueObject/Endpoint.php | 13 +++++++-- .../src/ValueObject/MeasureValue.php | 14 +++++++-- 167 files changed, 1786 insertions(+), 350 deletions(-) diff --git a/src/CodeGenerator/src/Generator/ObjectGenerator.php b/src/CodeGenerator/src/Generator/ObjectGenerator.php index 8859a0857..40efc2d2d 100644 --- a/src/CodeGenerator/src/Generator/ObjectGenerator.php +++ b/src/CodeGenerator/src/Generator/ObjectGenerator.php @@ -191,6 +191,9 @@ private function namedConstructor(StructureShape $shape, ClassBuilder $classBuil $constructor->addParameter('input')->setType('array'); + // To throw an exception in an expression, we need to use a method to support PHP 7.x + $needsThrowMethod = false; + $constructorBody = ''; foreach ($shape->getMembers() as $member) { $memberShape = $member->getShape(); @@ -219,7 +222,13 @@ private function namedConstructor(StructureShape $shape, ClassBuilder $classBuil } else { $memberCode = strtr('$input["NAME"]', ['NAME' => $member->getName()]); } - $fallback = 'null'; + if ($member->isRequired()) { + $fallback = strtr('$this->throwException(new InvalidArgument(\'Missing required field "NAME".\'))', ['NAME' => $member->getName()]); + $classBuilder->addUse(InvalidArgument::class); + $needsThrowMethod = true; + } else { + $fallback = 'null'; + } $constructorBody .= strtr('$this->PROPERTY = isset($input["NAME"]) ? MEMBER_CODE : FALLBACK;' . "\n", [ 'PROPERTY' => GeneratorHelper::normalizeName($member->getName()), 'NAME' => $member->getName(), @@ -228,6 +237,14 @@ private function namedConstructor(StructureShape $shape, ClassBuilder $classBuil ]); } $constructor->setBody($constructorBody); + + if ($needsThrowMethod) { + $throwMethod = $classBuilder->addMethod('throwException'); + $throwMethod->setPrivate(); + $throwMethod->addComment('@return never'); + $throwMethod->addParameter('exception')->setType(\Throwable::class); + $throwMethod->setBody('throw $exception;'); + } } /** diff --git a/src/Core/src/Sts/ValueObject/AssumedRoleUser.php b/src/Core/src/Sts/ValueObject/AssumedRoleUser.php index 40c0b922d..6b261f445 100644 --- a/src/Core/src/Sts/ValueObject/AssumedRoleUser.php +++ b/src/Core/src/Sts/ValueObject/AssumedRoleUser.php @@ -2,6 +2,8 @@ namespace AsyncAws\Core\Sts\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * The identifiers for the temporary security credentials that the operation returns. */ @@ -29,8 +31,8 @@ final class AssumedRoleUser */ public function __construct(array $input) { - $this->assumedRoleId = $input['AssumedRoleId'] ?? null; - $this->arn = $input['Arn'] ?? null; + $this->assumedRoleId = $input['AssumedRoleId'] ?? $this->throwException(new InvalidArgument('Missing required field "AssumedRoleId".')); + $this->arn = $input['Arn'] ?? $this->throwException(new InvalidArgument('Missing required field "Arn".')); } /** @@ -53,4 +55,12 @@ public function getAssumedRoleId(): string { return $this->assumedRoleId; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Core/src/Sts/ValueObject/Credentials.php b/src/Core/src/Sts/ValueObject/Credentials.php index eafc39ecb..74e316dc4 100644 --- a/src/Core/src/Sts/ValueObject/Credentials.php +++ b/src/Core/src/Sts/ValueObject/Credentials.php @@ -2,6 +2,8 @@ namespace AsyncAws\Core\Sts\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Amazon Web Services credentials for API authentication. */ @@ -37,10 +39,10 @@ final class Credentials */ public function __construct(array $input) { - $this->accessKeyId = $input['AccessKeyId'] ?? null; - $this->secretAccessKey = $input['SecretAccessKey'] ?? null; - $this->sessionToken = $input['SessionToken'] ?? null; - $this->expiration = $input['Expiration'] ?? null; + $this->accessKeyId = $input['AccessKeyId'] ?? $this->throwException(new InvalidArgument('Missing required field "AccessKeyId".')); + $this->secretAccessKey = $input['SecretAccessKey'] ?? $this->throwException(new InvalidArgument('Missing required field "SecretAccessKey".')); + $this->sessionToken = $input['SessionToken'] ?? $this->throwException(new InvalidArgument('Missing required field "SessionToken".')); + $this->expiration = $input['Expiration'] ?? $this->throwException(new InvalidArgument('Missing required field "Expiration".')); } /** @@ -75,4 +77,12 @@ public function getSessionToken(): string { return $this->sessionToken; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Core/src/Sts/ValueObject/Tag.php b/src/Core/src/Sts/ValueObject/Tag.php index 83d7649c4..20460ea2c 100644 --- a/src/Core/src/Sts/ValueObject/Tag.php +++ b/src/Core/src/Sts/ValueObject/Tag.php @@ -41,8 +41,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -83,4 +83,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php b/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php index e4d458f9a..51460f3db 100644 --- a/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php +++ b/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php @@ -30,8 +30,8 @@ final class AppSyncRuntime */ public function __construct(array $input) { - $this->name = $input['name'] ?? null; - $this->runtimeVersion = $input['runtimeVersion'] ?? null; + $this->name = $input['name'] ?? $this->throwException(new InvalidArgument('Missing required field "name".')); + $this->runtimeVersion = $input['runtimeVersion'] ?? $this->throwException(new InvalidArgument('Missing required field "runtimeVersion".')); } /** @@ -78,4 +78,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php b/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php index a81f67c53..5ae222c44 100644 --- a/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php +++ b/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php @@ -30,7 +30,7 @@ final class AuthorizationConfig */ public function __construct(array $input) { - $this->authorizationType = $input['authorizationType'] ?? null; + $this->authorizationType = $input['authorizationType'] ?? $this->throwException(new InvalidArgument('Missing required field "authorizationType".')); $this->awsIamConfig = isset($input['awsIamConfig']) ? AwsIamConfig::create($input['awsIamConfig']) : null; } @@ -77,4 +77,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/CachingConfig.php b/src/Service/AppSync/src/ValueObject/CachingConfig.php index 63fc85c11..17080a8aa 100644 --- a/src/Service/AppSync/src/ValueObject/CachingConfig.php +++ b/src/Service/AppSync/src/ValueObject/CachingConfig.php @@ -31,7 +31,7 @@ final class CachingConfig */ public function __construct(array $input) { - $this->ttl = $input['ttl'] ?? null; + $this->ttl = $input['ttl'] ?? $this->throwException(new InvalidArgument('Missing required field "ttl".')); $this->cachingKeys = $input['cachingKeys'] ?? null; } @@ -80,4 +80,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php index 8e77782ee..0e3e7eb61 100644 --- a/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php @@ -45,8 +45,8 @@ final class DynamodbDataSourceConfig */ public function __construct(array $input) { - $this->tableName = $input['tableName'] ?? null; - $this->awsRegion = $input['awsRegion'] ?? null; + $this->tableName = $input['tableName'] ?? $this->throwException(new InvalidArgument('Missing required field "tableName".')); + $this->awsRegion = $input['awsRegion'] ?? $this->throwException(new InvalidArgument('Missing required field "awsRegion".')); $this->useCallerCredentials = $input['useCallerCredentials'] ?? null; $this->deltaSyncConfig = isset($input['deltaSyncConfig']) ? DeltaSyncConfig::create($input['deltaSyncConfig']) : null; $this->versioned = $input['versioned'] ?? null; @@ -117,4 +117,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php index 5aeaf0b6f..945e34508 100644 --- a/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php @@ -30,8 +30,8 @@ final class ElasticsearchDataSourceConfig */ public function __construct(array $input) { - $this->endpoint = $input['endpoint'] ?? null; - $this->awsRegion = $input['awsRegion'] ?? null; + $this->endpoint = $input['endpoint'] ?? $this->throwException(new InvalidArgument('Missing required field "endpoint".')); + $this->awsRegion = $input['awsRegion'] ?? $this->throwException(new InvalidArgument('Missing required field "awsRegion".')); } /** @@ -72,4 +72,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php index 591f5623e..75461d6e5 100644 --- a/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php @@ -23,7 +23,7 @@ final class EventBridgeDataSourceConfig */ public function __construct(array $input) { - $this->eventBusArn = $input['eventBusArn'] ?? null; + $this->eventBusArn = $input['eventBusArn'] ?? $this->throwException(new InvalidArgument('Missing required field "eventBusArn".')); } /** @@ -54,4 +54,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php index 1ad75301c..d7279cd67 100644 --- a/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php @@ -21,7 +21,7 @@ final class LambdaDataSourceConfig */ public function __construct(array $input) { - $this->lambdaFunctionArn = $input['lambdaFunctionArn'] ?? null; + $this->lambdaFunctionArn = $input['lambdaFunctionArn'] ?? $this->throwException(new InvalidArgument('Missing required field "lambdaFunctionArn".')); } /** @@ -52,4 +52,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php index 0f273e914..1a07fb0af 100644 --- a/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php @@ -27,8 +27,8 @@ final class OpenSearchServiceDataSourceConfig */ public function __construct(array $input) { - $this->endpoint = $input['endpoint'] ?? null; - $this->awsRegion = $input['awsRegion'] ?? null; + $this->endpoint = $input['endpoint'] ?? $this->throwException(new InvalidArgument('Missing required field "endpoint".')); + $this->awsRegion = $input['awsRegion'] ?? $this->throwException(new InvalidArgument('Missing required field "awsRegion".')); } /** @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/AclConfiguration.php b/src/Service/Athena/src/ValueObject/AclConfiguration.php index 5bc76cda0..64409e460 100644 --- a/src/Service/Athena/src/ValueObject/AclConfiguration.php +++ b/src/Service/Athena/src/ValueObject/AclConfiguration.php @@ -31,7 +31,7 @@ final class AclConfiguration */ public function __construct(array $input) { - $this->s3AclOption = $input['S3AclOption'] ?? null; + $this->s3AclOption = $input['S3AclOption'] ?? $this->throwException(new InvalidArgument('Missing required field "S3AclOption".')); } /** @@ -68,4 +68,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/Column.php b/src/Service/Athena/src/ValueObject/Column.php index 1a01a4641..7914585b2 100644 --- a/src/Service/Athena/src/ValueObject/Column.php +++ b/src/Service/Athena/src/ValueObject/Column.php @@ -2,6 +2,8 @@ namespace AsyncAws\Athena\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains metadata for a column in a table. */ @@ -31,7 +33,7 @@ final class Column */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->type = $input['Type'] ?? null; $this->comment = $input['Comment'] ?? null; } @@ -62,4 +64,12 @@ public function getType(): ?string { return $this->type; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/ColumnInfo.php b/src/Service/Athena/src/ValueObject/ColumnInfo.php index 2522c565c..b02e39914 100644 --- a/src/Service/Athena/src/ValueObject/ColumnInfo.php +++ b/src/Service/Athena/src/ValueObject/ColumnInfo.php @@ -3,6 +3,7 @@ namespace AsyncAws\Athena\ValueObject; use AsyncAws\Athena\Enum\ColumnNullable; +use AsyncAws\Core\Exception\InvalidArgument; /** * Information about the columns in a query execution result. @@ -79,9 +80,9 @@ public function __construct(array $input) $this->catalogName = $input['CatalogName'] ?? null; $this->schemaName = $input['SchemaName'] ?? null; $this->tableName = $input['TableName'] ?? null; - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->label = $input['Label'] ?? null; - $this->type = $input['Type'] ?? null; + $this->type = $input['Type'] ?? $this->throwException(new InvalidArgument('Missing required field "Type".')); $this->precision = $input['Precision'] ?? null; $this->scale = $input['Scale'] ?? null; $this->nullable = $input['Nullable'] ?? null; @@ -159,4 +160,12 @@ public function getType(): string { return $this->type; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/CustomerContentEncryptionConfiguration.php b/src/Service/Athena/src/ValueObject/CustomerContentEncryptionConfiguration.php index 37add0650..804fc9840 100644 --- a/src/Service/Athena/src/ValueObject/CustomerContentEncryptionConfiguration.php +++ b/src/Service/Athena/src/ValueObject/CustomerContentEncryptionConfiguration.php @@ -2,6 +2,8 @@ namespace AsyncAws\Athena\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Specifies the KMS key that is used to encrypt the user's data stores in Athena. This setting does not apply to Athena * SQL workgroups. @@ -20,7 +22,7 @@ final class CustomerContentEncryptionConfiguration */ public function __construct(array $input) { - $this->kmsKey = $input['KmsKey'] ?? null; + $this->kmsKey = $input['KmsKey'] ?? $this->throwException(new InvalidArgument('Missing required field "KmsKey".')); } /** @@ -37,4 +39,12 @@ public function getKmsKey(): string { return $this->kmsKey; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/DataCatalog.php b/src/Service/Athena/src/ValueObject/DataCatalog.php index 9a7dd36b1..dfdce9319 100644 --- a/src/Service/Athena/src/ValueObject/DataCatalog.php +++ b/src/Service/Athena/src/ValueObject/DataCatalog.php @@ -3,6 +3,7 @@ namespace AsyncAws\Athena\ValueObject; use AsyncAws\Athena\Enum\DataCatalogType; +use AsyncAws\Core\Exception\InvalidArgument; /** * Contains information about a data catalog in an Amazon Web Services account. @@ -71,9 +72,9 @@ final class DataCatalog */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->description = $input['Description'] ?? null; - $this->type = $input['Type'] ?? null; + $this->type = $input['Type'] ?? $this->throwException(new InvalidArgument('Missing required field "Type".')); $this->parameters = $input['Parameters'] ?? null; } @@ -115,4 +116,12 @@ public function getType(): string { return $this->type; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/Database.php b/src/Service/Athena/src/ValueObject/Database.php index 083e9cad0..b6835a527 100644 --- a/src/Service/Athena/src/ValueObject/Database.php +++ b/src/Service/Athena/src/ValueObject/Database.php @@ -2,6 +2,8 @@ namespace AsyncAws\Athena\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains metadata information for a database in a data catalog. */ @@ -31,7 +33,7 @@ final class Database */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->description = $input['Description'] ?? null; $this->parameters = $input['Parameters'] ?? null; } @@ -65,4 +67,12 @@ public function getParameters(): array { return $this->parameters ?? []; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php b/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php index b8df45bf8..17cef7de0 100644 --- a/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php +++ b/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php @@ -33,7 +33,7 @@ final class EncryptionConfiguration */ public function __construct(array $input) { - $this->encryptionOption = $input['EncryptionOption'] ?? null; + $this->encryptionOption = $input['EncryptionOption'] ?? $this->throwException(new InvalidArgument('Missing required field "EncryptionOption".')); $this->kmsKey = $input['KmsKey'] ?? null; } @@ -80,4 +80,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/EngineConfiguration.php b/src/Service/Athena/src/ValueObject/EngineConfiguration.php index 3f4c88ec4..ffc74cf21 100644 --- a/src/Service/Athena/src/ValueObject/EngineConfiguration.php +++ b/src/Service/Athena/src/ValueObject/EngineConfiguration.php @@ -52,7 +52,7 @@ final class EngineConfiguration public function __construct(array $input) { $this->coordinatorDpuSize = $input['CoordinatorDpuSize'] ?? null; - $this->maxConcurrentDpus = $input['MaxConcurrentDpus'] ?? null; + $this->maxConcurrentDpus = $input['MaxConcurrentDpus'] ?? $this->throwException(new InvalidArgument('Missing required field "MaxConcurrentDpus".')); $this->defaultExecutorDpuSize = $input['DefaultExecutorDpuSize'] ?? null; $this->additionalConfigs = $input['AdditionalConfigs'] ?? null; $this->sparkProperties = $input['SparkProperties'] ?? null; @@ -142,4 +142,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/NamedQuery.php b/src/Service/Athena/src/ValueObject/NamedQuery.php index 7804323a1..ab14dabc7 100644 --- a/src/Service/Athena/src/ValueObject/NamedQuery.php +++ b/src/Service/Athena/src/ValueObject/NamedQuery.php @@ -2,6 +2,8 @@ namespace AsyncAws\Athena\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * A query, where `QueryString` contains the SQL statements that make up the query. */ @@ -49,10 +51,10 @@ final class NamedQuery */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->description = $input['Description'] ?? null; - $this->database = $input['Database'] ?? null; - $this->queryString = $input['QueryString'] ?? null; + $this->database = $input['Database'] ?? $this->throwException(new InvalidArgument('Missing required field "Database".')); + $this->queryString = $input['QueryString'] ?? $this->throwException(new InvalidArgument('Missing required field "QueryString".')); $this->namedQueryId = $input['NamedQueryId'] ?? null; $this->workGroup = $input['WorkGroup'] ?? null; } @@ -101,4 +103,12 @@ public function getWorkGroup(): ?string { return $this->workGroup; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php b/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php index 9085bfc9b..4eee0f391 100644 --- a/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php +++ b/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php @@ -28,7 +28,7 @@ final class ResultReuseByAgeConfiguration */ public function __construct(array $input) { - $this->enabled = $input['Enabled'] ?? null; + $this->enabled = $input['Enabled'] ?? $this->throwException(new InvalidArgument('Missing required field "Enabled".')); $this->maxAgeInMinutes = $input['MaxAgeInMinutes'] ?? null; } @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/ResultReuseInformation.php b/src/Service/Athena/src/ValueObject/ResultReuseInformation.php index 3057365fb..989272bd3 100644 --- a/src/Service/Athena/src/ValueObject/ResultReuseInformation.php +++ b/src/Service/Athena/src/ValueObject/ResultReuseInformation.php @@ -2,6 +2,8 @@ namespace AsyncAws\Athena\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains information about whether the result of a previous query was reused. */ @@ -19,7 +21,7 @@ final class ResultReuseInformation */ public function __construct(array $input) { - $this->reusedPreviousResult = $input['ReusedPreviousResult'] ?? null; + $this->reusedPreviousResult = $input['ReusedPreviousResult'] ?? $this->throwException(new InvalidArgument('Missing required field "ReusedPreviousResult".')); } /** @@ -36,4 +38,12 @@ public function getReusedPreviousResult(): bool { return $this->reusedPreviousResult; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/TableMetadata.php b/src/Service/Athena/src/ValueObject/TableMetadata.php index f1e4d6f4e..bc2c9194a 100644 --- a/src/Service/Athena/src/ValueObject/TableMetadata.php +++ b/src/Service/Athena/src/ValueObject/TableMetadata.php @@ -2,6 +2,8 @@ namespace AsyncAws\Athena\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains metadata for a table. */ @@ -55,7 +57,7 @@ final class TableMetadata */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->createTime = $input['CreateTime'] ?? null; $this->lastAccessTime = $input['LastAccessTime'] ?? null; $this->tableType = $input['TableType'] ?? null; @@ -123,4 +125,12 @@ public function getTableType(): ?string { return $this->tableType; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Athena/src/ValueObject/WorkGroup.php b/src/Service/Athena/src/ValueObject/WorkGroup.php index c95831967..e93377a30 100644 --- a/src/Service/Athena/src/ValueObject/WorkGroup.php +++ b/src/Service/Athena/src/ValueObject/WorkGroup.php @@ -3,6 +3,7 @@ namespace AsyncAws\Athena\ValueObject; use AsyncAws\Athena\Enum\WorkGroupState; +use AsyncAws\Core\Exception\InvalidArgument; /** * A workgroup, which contains a name, description, creation time, state, and other configuration, listed under @@ -56,7 +57,7 @@ final class WorkGroup */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->state = $input['State'] ?? null; $this->configuration = isset($input['Configuration']) ? WorkGroupConfiguration::create($input['Configuration']) : null; $this->description = $input['Description'] ?? null; @@ -104,4 +105,12 @@ public function getState(): ?string { return $this->state; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFormation/src/ValueObject/RollbackTrigger.php b/src/Service/CloudFormation/src/ValueObject/RollbackTrigger.php index cbc766519..23b55e2ec 100644 --- a/src/Service/CloudFormation/src/ValueObject/RollbackTrigger.php +++ b/src/Service/CloudFormation/src/ValueObject/RollbackTrigger.php @@ -2,6 +2,8 @@ namespace AsyncAws\CloudFormation\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * A rollback trigger CloudFormation monitors during creation and updating of stacks. If any of the alarms you specify * goes to ALARM state during the stack operation or within the specified monitoring period afterwards, CloudFormation @@ -33,8 +35,8 @@ final class RollbackTrigger */ public function __construct(array $input) { - $this->arn = $input['Arn'] ?? null; - $this->type = $input['Type'] ?? null; + $this->arn = $input['Arn'] ?? $this->throwException(new InvalidArgument('Missing required field "Arn".')); + $this->type = $input['Type'] ?? $this->throwException(new InvalidArgument('Missing required field "Type".')); } /** @@ -57,4 +59,12 @@ public function getType(): string { return $this->type; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFormation/src/ValueObject/Stack.php b/src/Service/CloudFormation/src/ValueObject/Stack.php index a6508d116..7874e056c 100644 --- a/src/Service/CloudFormation/src/ValueObject/Stack.php +++ b/src/Service/CloudFormation/src/ValueObject/Stack.php @@ -4,6 +4,7 @@ use AsyncAws\CloudFormation\Enum\Capability; use AsyncAws\CloudFormation\Enum\StackStatus; +use AsyncAws\Core\Exception\InvalidArgument; /** * The Stack data type. @@ -174,15 +175,15 @@ final class Stack public function __construct(array $input) { $this->stackId = $input['StackId'] ?? null; - $this->stackName = $input['StackName'] ?? null; + $this->stackName = $input['StackName'] ?? $this->throwException(new InvalidArgument('Missing required field "StackName".')); $this->changeSetId = $input['ChangeSetId'] ?? null; $this->description = $input['Description'] ?? null; $this->parameters = isset($input['Parameters']) ? array_map([Parameter::class, 'create'], $input['Parameters']) : null; - $this->creationTime = $input['CreationTime'] ?? null; + $this->creationTime = $input['CreationTime'] ?? $this->throwException(new InvalidArgument('Missing required field "CreationTime".')); $this->deletionTime = $input['DeletionTime'] ?? null; $this->lastUpdatedTime = $input['LastUpdatedTime'] ?? null; $this->rollbackConfiguration = isset($input['RollbackConfiguration']) ? RollbackConfiguration::create($input['RollbackConfiguration']) : null; - $this->stackStatus = $input['StackStatus'] ?? null; + $this->stackStatus = $input['StackStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "StackStatus".')); $this->stackStatusReason = $input['StackStatusReason'] ?? null; $this->disableRollback = $input['DisableRollback'] ?? null; $this->notificationArns = $input['NotificationARNs'] ?? null; @@ -355,4 +356,12 @@ public function getTimeoutInMinutes(): ?int { return $this->timeoutInMinutes; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFormation/src/ValueObject/StackDriftInformation.php b/src/Service/CloudFormation/src/ValueObject/StackDriftInformation.php index 9ad4f4282..fda7a796d 100644 --- a/src/Service/CloudFormation/src/ValueObject/StackDriftInformation.php +++ b/src/Service/CloudFormation/src/ValueObject/StackDriftInformation.php @@ -3,6 +3,7 @@ namespace AsyncAws\CloudFormation\ValueObject; use AsyncAws\CloudFormation\Enum\StackDriftStatus; +use AsyncAws\Core\Exception\InvalidArgument; /** * Contains information about whether the stack's actual configuration differs, or has *drifted*, from its expected @@ -36,7 +37,7 @@ final class StackDriftInformation */ public function __construct(array $input) { - $this->stackDriftStatus = $input['StackDriftStatus'] ?? null; + $this->stackDriftStatus = $input['StackDriftStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "StackDriftStatus".')); $this->lastCheckTimestamp = $input['LastCheckTimestamp'] ?? null; } @@ -63,4 +64,12 @@ public function getStackDriftStatus(): string { return $this->stackDriftStatus; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFormation/src/ValueObject/StackEvent.php b/src/Service/CloudFormation/src/ValueObject/StackEvent.php index 048ba966a..3aba0d011 100644 --- a/src/Service/CloudFormation/src/ValueObject/StackEvent.php +++ b/src/Service/CloudFormation/src/ValueObject/StackEvent.php @@ -6,6 +6,7 @@ use AsyncAws\CloudFormation\Enum\HookInvocationPoint; use AsyncAws\CloudFormation\Enum\HookStatus; use AsyncAws\CloudFormation\Enum\ResourceStatus; +use AsyncAws\Core\Exception\InvalidArgument; /** * The StackEvent data type. @@ -129,13 +130,13 @@ final class StackEvent */ public function __construct(array $input) { - $this->stackId = $input['StackId'] ?? null; - $this->eventId = $input['EventId'] ?? null; - $this->stackName = $input['StackName'] ?? null; + $this->stackId = $input['StackId'] ?? $this->throwException(new InvalidArgument('Missing required field "StackId".')); + $this->eventId = $input['EventId'] ?? $this->throwException(new InvalidArgument('Missing required field "EventId".')); + $this->stackName = $input['StackName'] ?? $this->throwException(new InvalidArgument('Missing required field "StackName".')); $this->logicalResourceId = $input['LogicalResourceId'] ?? null; $this->physicalResourceId = $input['PhysicalResourceId'] ?? null; $this->resourceType = $input['ResourceType'] ?? null; - $this->timestamp = $input['Timestamp'] ?? null; + $this->timestamp = $input['Timestamp'] ?? $this->throwException(new InvalidArgument('Missing required field "Timestamp".')); $this->resourceStatus = $input['ResourceStatus'] ?? null; $this->resourceStatusReason = $input['ResourceStatusReason'] ?? null; $this->resourceProperties = $input['ResourceProperties'] ?? null; @@ -263,4 +264,12 @@ public function getTimestamp(): \DateTimeImmutable { return $this->timestamp; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFormation/src/ValueObject/Tag.php b/src/Service/CloudFormation/src/ValueObject/Tag.php index 7cb49022e..73e07037c 100644 --- a/src/Service/CloudFormation/src/ValueObject/Tag.php +++ b/src/Service/CloudFormation/src/ValueObject/Tag.php @@ -2,6 +2,8 @@ namespace AsyncAws\CloudFormation\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * The Tag type enables you to specify a key-value pair that can be used to store information about an CloudFormation * stack. @@ -27,8 +29,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -51,4 +53,12 @@ public function getValue(): string { return $this->value; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFront/src/ValueObject/Invalidation.php b/src/Service/CloudFront/src/ValueObject/Invalidation.php index 97aa77bd6..c5a83ed8c 100644 --- a/src/Service/CloudFront/src/ValueObject/Invalidation.php +++ b/src/Service/CloudFront/src/ValueObject/Invalidation.php @@ -2,6 +2,8 @@ namespace AsyncAws\CloudFront\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * An invalidation. */ @@ -37,10 +39,10 @@ final class Invalidation */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->status = $input['Status'] ?? null; - $this->createTime = $input['CreateTime'] ?? null; - $this->invalidationBatch = isset($input['InvalidationBatch']) ? InvalidationBatch::create($input['InvalidationBatch']) : null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->status = $input['Status'] ?? $this->throwException(new InvalidArgument('Missing required field "Status".')); + $this->createTime = $input['CreateTime'] ?? $this->throwException(new InvalidArgument('Missing required field "CreateTime".')); + $this->invalidationBatch = isset($input['InvalidationBatch']) ? InvalidationBatch::create($input['InvalidationBatch']) : $this->throwException(new InvalidArgument('Missing required field "InvalidationBatch".')); } /** @@ -75,4 +77,12 @@ public function getStatus(): string { return $this->status; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php b/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php index c14f1fbf2..5cae2ea57 100644 --- a/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php +++ b/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php @@ -40,8 +40,8 @@ final class InvalidationBatch */ public function __construct(array $input) { - $this->paths = isset($input['Paths']) ? Paths::create($input['Paths']) : null; - $this->callerReference = $input['CallerReference'] ?? null; + $this->paths = isset($input['Paths']) ? Paths::create($input['Paths']) : $this->throwException(new InvalidArgument('Missing required field "Paths".')); + $this->callerReference = $input['CallerReference'] ?? $this->throwException(new InvalidArgument('Missing required field "CallerReference".')); } /** @@ -83,4 +83,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void } $node->appendChild($document->createElement('CallerReference', $v)); } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudFront/src/ValueObject/Paths.php b/src/Service/CloudFront/src/ValueObject/Paths.php index 8a757fe6d..13c4330bc 100644 --- a/src/Service/CloudFront/src/ValueObject/Paths.php +++ b/src/Service/CloudFront/src/ValueObject/Paths.php @@ -30,7 +30,7 @@ final class Paths */ public function __construct(array $input) { - $this->quantity = $input['Quantity'] ?? null; + $this->quantity = $input['Quantity'] ?? $this->throwException(new InvalidArgument('Missing required field "Quantity".')); $this->items = $input['Items'] ?? null; } @@ -74,4 +74,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void } } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudWatch/src/ValueObject/Dimension.php b/src/Service/CloudWatch/src/ValueObject/Dimension.php index 51545e803..1214b613d 100644 --- a/src/Service/CloudWatch/src/ValueObject/Dimension.php +++ b/src/Service/CloudWatch/src/ValueObject/Dimension.php @@ -35,8 +35,8 @@ final class Dimension */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; - $this->value = $input['Value'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -77,4 +77,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php b/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php index cc2c30f0b..147e33dfe 100644 --- a/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php +++ b/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php @@ -27,7 +27,7 @@ final class DimensionFilter */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->value = $input['Value'] ?? null; } @@ -68,4 +68,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php b/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php index 106acafab..69cf477fc 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php @@ -117,7 +117,7 @@ final class MetricDataQuery */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); $this->metricStat = isset($input['MetricStat']) ? MetricStat::create($input['MetricStat']) : null; $this->expression = $input['Expression'] ?? null; $this->label = $input['Label'] ?? null; @@ -210,4 +210,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudWatch/src/ValueObject/MetricDatum.php b/src/Service/CloudWatch/src/ValueObject/MetricDatum.php index 5f9d93883..eda532c97 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricDatum.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricDatum.php @@ -96,7 +96,7 @@ final class MetricDatum */ public function __construct(array $input) { - $this->metricName = $input['MetricName'] ?? null; + $this->metricName = $input['MetricName'] ?? $this->throwException(new InvalidArgument('Missing required field "MetricName".')); $this->dimensions = isset($input['Dimensions']) ? array_map([Dimension::class, 'create'], $input['Dimensions']) : null; $this->timestamp = $input['Timestamp'] ?? null; $this->value = $input['Value'] ?? null; @@ -238,4 +238,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudWatch/src/ValueObject/MetricStat.php b/src/Service/CloudWatch/src/ValueObject/MetricStat.php index 88558532f..4ca4c67a7 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricStat.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricStat.php @@ -55,9 +55,9 @@ final class MetricStat */ public function __construct(array $input) { - $this->metric = isset($input['Metric']) ? Metric::create($input['Metric']) : null; - $this->period = $input['Period'] ?? null; - $this->stat = $input['Stat'] ?? null; + $this->metric = isset($input['Metric']) ? Metric::create($input['Metric']) : $this->throwException(new InvalidArgument('Missing required field "Metric".')); + $this->period = $input['Period'] ?? $this->throwException(new InvalidArgument('Missing required field "Period".')); + $this->stat = $input['Stat'] ?? $this->throwException(new InvalidArgument('Missing required field "Stat".')); $this->unit = $input['Unit'] ?? null; } @@ -127,4 +127,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudWatch/src/ValueObject/StatisticSet.php b/src/Service/CloudWatch/src/ValueObject/StatisticSet.php index 2f4f812b8..b3ee83ec0 100644 --- a/src/Service/CloudWatch/src/ValueObject/StatisticSet.php +++ b/src/Service/CloudWatch/src/ValueObject/StatisticSet.php @@ -39,10 +39,10 @@ final class StatisticSet */ public function __construct(array $input) { - $this->sampleCount = $input['SampleCount'] ?? null; - $this->sum = $input['Sum'] ?? null; - $this->minimum = $input['Minimum'] ?? null; - $this->maximum = $input['Maximum'] ?? null; + $this->sampleCount = $input['SampleCount'] ?? $this->throwException(new InvalidArgument('Missing required field "SampleCount".')); + $this->sum = $input['Sum'] ?? $this->throwException(new InvalidArgument('Missing required field "Sum".')); + $this->minimum = $input['Minimum'] ?? $this->throwException(new InvalidArgument('Missing required field "Minimum".')); + $this->maximum = $input['Maximum'] ?? $this->throwException(new InvalidArgument('Missing required field "Maximum".')); } /** @@ -103,4 +103,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php b/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php index 08541368e..3da161ea3 100644 --- a/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php +++ b/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php @@ -28,8 +28,8 @@ final class InputLogEvent */ public function __construct(array $input) { - $this->timestamp = $input['timestamp'] ?? null; - $this->message = $input['message'] ?? null; + $this->timestamp = $input['timestamp'] ?? $this->throwException(new InvalidArgument('Missing required field "timestamp".')); + $this->message = $input['message'] ?? $this->throwException(new InvalidArgument('Missing required field "message".')); } /** @@ -70,4 +70,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php b/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php index feacbdebe..bc32b7e73 100644 --- a/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php +++ b/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php @@ -43,7 +43,7 @@ final class CloudWatchLogsConfig */ public function __construct(array $input) { - $this->status = $input['status'] ?? null; + $this->status = $input['status'] ?? $this->throwException(new InvalidArgument('Missing required field "status".')); $this->groupName = $input['groupName'] ?? null; $this->streamName = $input['streamName'] ?? null; } @@ -100,4 +100,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php b/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php index 54c1828c4..67464fd6f 100644 --- a/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php +++ b/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php @@ -48,8 +48,8 @@ final class EnvironmentVariable */ public function __construct(array $input) { - $this->name = $input['name'] ?? null; - $this->value = $input['value'] ?? null; + $this->name = $input['name'] ?? $this->throwException(new InvalidArgument('Missing required field "name".')); + $this->value = $input['value'] ?? $this->throwException(new InvalidArgument('Missing required field "value".')); $this->type = $input['type'] ?? null; } @@ -106,4 +106,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php b/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php index 9d382104b..5061c8d31 100644 --- a/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php +++ b/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php @@ -21,7 +21,7 @@ final class GitSubmodulesConfig */ public function __construct(array $input) { - $this->fetchSubmodules = $input['fetchSubmodules'] ?? null; + $this->fetchSubmodules = $input['fetchSubmodules'] ?? $this->throwException(new InvalidArgument('Missing required field "fetchSubmodules".')); } /** @@ -52,4 +52,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php b/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php index 32258ffca..0c4996ffe 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php @@ -136,7 +136,7 @@ final class ProjectArtifacts */ public function __construct(array $input) { - $this->type = $input['type'] ?? null; + $this->type = $input['type'] ?? $this->throwException(new InvalidArgument('Missing required field "type".')); $this->location = $input['location'] ?? null; $this->path = $input['path'] ?? null; $this->namespaceType = $input['namespaceType'] ?? null; @@ -281,4 +281,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectCache.php b/src/Service/CodeBuild/src/ValueObject/ProjectCache.php index 910e35670..061f7aad1 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectCache.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectCache.php @@ -71,7 +71,7 @@ final class ProjectCache */ public function __construct(array $input) { - $this->type = $input['type'] ?? null; + $this->type = $input['type'] ?? $this->throwException(new InvalidArgument('Missing required field "type".')); $this->location = $input['location'] ?? null; $this->modes = $input['modes'] ?? null; } @@ -139,4 +139,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectEnvironment.php b/src/Service/CodeBuild/src/ValueObject/ProjectEnvironment.php index a98b97f03..daaaf9afd 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectEnvironment.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectEnvironment.php @@ -5,6 +5,7 @@ use AsyncAws\CodeBuild\Enum\ComputeType; use AsyncAws\CodeBuild\Enum\EnvironmentType; use AsyncAws\CodeBuild\Enum\ImagePullCredentialsType; +use AsyncAws\Core\Exception\InvalidArgument; /** * Information about the build environment of the build project. @@ -141,9 +142,9 @@ final class ProjectEnvironment */ public function __construct(array $input) { - $this->type = $input['type'] ?? null; - $this->image = $input['image'] ?? null; - $this->computeType = $input['computeType'] ?? null; + $this->type = $input['type'] ?? $this->throwException(new InvalidArgument('Missing required field "type".')); + $this->image = $input['image'] ?? $this->throwException(new InvalidArgument('Missing required field "image".')); + $this->computeType = $input['computeType'] ?? $this->throwException(new InvalidArgument('Missing required field "computeType".')); $this->environmentVariables = isset($input['environmentVariables']) ? array_map([EnvironmentVariable::class, 'create'], $input['environmentVariables']) : null; $this->privilegedMode = $input['privilegedMode'] ?? null; $this->certificate = $input['certificate'] ?? null; @@ -219,4 +220,12 @@ public function getType(): string { return $this->type; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectSource.php b/src/Service/CodeBuild/src/ValueObject/ProjectSource.php index ad642bfee..d127c2593 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectSource.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectSource.php @@ -140,7 +140,7 @@ final class ProjectSource */ public function __construct(array $input) { - $this->type = $input['type'] ?? null; + $this->type = $input['type'] ?? $this->throwException(new InvalidArgument('Missing required field "type".')); $this->location = $input['location'] ?? null; $this->gitCloneDepth = $input['gitCloneDepth'] ?? null; $this->gitSubmodulesConfig = isset($input['gitSubmodulesConfig']) ? GitSubmodulesConfig::create($input['gitSubmodulesConfig']) : null; @@ -267,4 +267,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php b/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php index 73963c556..f40b0c10d 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php @@ -42,8 +42,8 @@ final class ProjectSourceVersion */ public function __construct(array $input) { - $this->sourceIdentifier = $input['sourceIdentifier'] ?? null; - $this->sourceVersion = $input['sourceVersion'] ?? null; + $this->sourceIdentifier = $input['sourceIdentifier'] ?? $this->throwException(new InvalidArgument('Missing required field "sourceIdentifier".')); + $this->sourceVersion = $input['sourceVersion'] ?? $this->throwException(new InvalidArgument('Missing required field "sourceVersion".')); } /** @@ -84,4 +84,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php b/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php index 5dc843e10..651475be9 100644 --- a/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php +++ b/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php @@ -38,8 +38,8 @@ final class RegistryCredential */ public function __construct(array $input) { - $this->credential = $input['credential'] ?? null; - $this->credentialProvider = $input['credentialProvider'] ?? null; + $this->credential = $input['credential'] ?? $this->throwException(new InvalidArgument('Missing required field "credential".')); + $this->credentialProvider = $input['credentialProvider'] ?? $this->throwException(new InvalidArgument('Missing required field "credentialProvider".')); } /** @@ -86,4 +86,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php b/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php index cd1ca9f61..85b480be9 100644 --- a/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php +++ b/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php @@ -42,7 +42,7 @@ final class S3LogsConfig */ public function __construct(array $input) { - $this->status = $input['status'] ?? null; + $this->status = $input['status'] ?? $this->throwException(new InvalidArgument('Missing required field "status".')); $this->location = $input['location'] ?? null; $this->encryptionDisabled = $input['encryptionDisabled'] ?? null; $this->bucketOwnerAccess = $input['bucketOwnerAccess'] ?? null; @@ -115,4 +115,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeBuild/src/ValueObject/SourceAuth.php b/src/Service/CodeBuild/src/ValueObject/SourceAuth.php index dda1141f6..757895e5b 100644 --- a/src/Service/CodeBuild/src/ValueObject/SourceAuth.php +++ b/src/Service/CodeBuild/src/ValueObject/SourceAuth.php @@ -32,7 +32,7 @@ final class SourceAuth */ public function __construct(array $input) { - $this->type = $input['type'] ?? null; + $this->type = $input['type'] ?? $this->throwException(new InvalidArgument('Missing required field "type".')); $this->resource = $input['resource'] ?? null; } @@ -79,4 +79,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php b/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php index 6f193b258..ce98bbdf4 100644 --- a/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php +++ b/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php @@ -52,11 +52,11 @@ final class RepositoryTrigger */ public function __construct(array $input) { - $this->name = $input['name'] ?? null; - $this->destinationArn = $input['destinationArn'] ?? null; + $this->name = $input['name'] ?? $this->throwException(new InvalidArgument('Missing required field "name".')); + $this->destinationArn = $input['destinationArn'] ?? $this->throwException(new InvalidArgument('Missing required field "destinationArn".')); $this->customData = $input['customData'] ?? null; $this->branches = $input['branches'] ?? null; - $this->events = $input['events'] ?? null; + $this->events = $input['events'] ?? $this->throwException(new InvalidArgument('Missing required field "events".')); } /** @@ -96,7 +96,7 @@ public function getDestinationArn(): string */ public function getEvents(): array { - return $this->events ?? []; + return $this->events; } public function getName(): string @@ -145,4 +145,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php b/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php index bfa92fa99..3aa6357dd 100644 --- a/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php +++ b/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php @@ -27,7 +27,7 @@ final class AttributeType */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); $this->value = $input['Value'] ?? null; } @@ -68,4 +68,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php b/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php index c76e8649c..f594b648c 100644 --- a/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php +++ b/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php @@ -48,10 +48,10 @@ final class ContextDataType */ public function __construct(array $input) { - $this->ipAddress = $input['IpAddress'] ?? null; - $this->serverName = $input['ServerName'] ?? null; - $this->serverPath = $input['ServerPath'] ?? null; - $this->httpHeaders = isset($input['HttpHeaders']) ? array_map([HttpHeader::class, 'create'], $input['HttpHeaders']) : null; + $this->ipAddress = $input['IpAddress'] ?? $this->throwException(new InvalidArgument('Missing required field "IpAddress".')); + $this->serverName = $input['ServerName'] ?? $this->throwException(new InvalidArgument('Missing required field "ServerName".')); + $this->serverPath = $input['ServerPath'] ?? $this->throwException(new InvalidArgument('Missing required field "ServerPath".')); + $this->httpHeaders = isset($input['HttpHeaders']) ? array_map([HttpHeader::class, 'create'], $input['HttpHeaders']) : $this->throwException(new InvalidArgument('Missing required field "HttpHeaders".')); $this->encodedData = $input['EncodedData'] ?? null; } @@ -79,7 +79,7 @@ public function getEncodedData(): ?string */ public function getHttpHeaders(): array { - return $this->httpHeaders ?? []; + return $this->httpHeaders; } public function getIpAddress(): string @@ -132,4 +132,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php b/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php index 00f20bf24..784c297cd 100644 --- a/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php +++ b/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php @@ -32,8 +32,8 @@ final class AttributeDefinition */ public function __construct(array $input) { - $this->attributeName = $input['AttributeName'] ?? null; - $this->attributeType = $input['AttributeType'] ?? null; + $this->attributeName = $input['AttributeName'] ?? $this->throwException(new InvalidArgument('Missing required field "AttributeName".')); + $this->attributeType = $input['AttributeType'] ?? $this->throwException(new InvalidArgument('Missing required field "AttributeType".')); } /** @@ -80,4 +80,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/Condition.php b/src/Service/DynamoDb/src/ValueObject/Condition.php index 876868c69..7db03f8fb 100644 --- a/src/Service/DynamoDb/src/ValueObject/Condition.php +++ b/src/Service/DynamoDb/src/ValueObject/Condition.php @@ -146,7 +146,7 @@ final class Condition public function __construct(array $input) { $this->attributeValueList = isset($input['AttributeValueList']) ? array_map([AttributeValue::class, 'create'], $input['AttributeValueList']) : null; - $this->comparisonOperator = $input['ComparisonOperator'] ?? null; + $this->comparisonOperator = $input['ComparisonOperator'] ?? $this->throwException(new InvalidArgument('Missing required field "ComparisonOperator".')); } /** @@ -200,4 +200,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php b/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php index c1a762942..3da7ffd2f 100644 --- a/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php +++ b/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php @@ -63,9 +63,9 @@ final class ConditionCheck */ public function __construct(array $input) { - $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : null; - $this->tableName = $input['TableName'] ?? null; - $this->conditionExpression = $input['ConditionExpression'] ?? null; + $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->tableName = $input['TableName'] ?? $this->throwException(new InvalidArgument('Missing required field "TableName".')); + $this->conditionExpression = $input['ConditionExpression'] ?? $this->throwException(new InvalidArgument('Missing required field "ConditionExpression".')); $this->expressionAttributeNames = $input['ExpressionAttributeNames'] ?? null; $this->expressionAttributeValues = isset($input['ExpressionAttributeValues']) ? array_map([AttributeValue::class, 'create'], $input['ExpressionAttributeValues']) : null; $this->returnValuesOnConditionCheckFailure = $input['ReturnValuesOnConditionCheckFailure'] ?? null; @@ -112,7 +112,7 @@ public function getExpressionAttributeValues(): array */ public function getKey(): array { - return $this->key ?? []; + return $this->key; } /** @@ -183,4 +183,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php b/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php index 99a5f0d39..9b125f57e 100644 --- a/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php +++ b/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php @@ -45,9 +45,9 @@ final class CreateGlobalSecondaryIndexAction */ public function __construct(array $input) { - $this->indexName = $input['IndexName'] ?? null; - $this->keySchema = isset($input['KeySchema']) ? array_map([KeySchemaElement::class, 'create'], $input['KeySchema']) : null; - $this->projection = isset($input['Projection']) ? Projection::create($input['Projection']) : null; + $this->indexName = $input['IndexName'] ?? $this->throwException(new InvalidArgument('Missing required field "IndexName".')); + $this->keySchema = isset($input['KeySchema']) ? array_map([KeySchemaElement::class, 'create'], $input['KeySchema']) : $this->throwException(new InvalidArgument('Missing required field "KeySchema".')); + $this->projection = isset($input['Projection']) ? Projection::create($input['Projection']) : $this->throwException(new InvalidArgument('Missing required field "Projection".')); $this->provisionedThroughput = isset($input['ProvisionedThroughput']) ? ProvisionedThroughput::create($input['ProvisionedThroughput']) : null; } @@ -74,7 +74,7 @@ public function getIndexName(): string */ public function getKeySchema(): array { - return $this->keySchema ?? []; + return $this->keySchema; } public function getProjection(): Projection @@ -118,4 +118,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php b/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php index ac013fce7..c5400a354 100644 --- a/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php +++ b/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php @@ -48,7 +48,7 @@ final class CreateReplicationGroupMemberAction */ public function __construct(array $input) { - $this->regionName = $input['RegionName'] ?? null; + $this->regionName = $input['RegionName'] ?? $this->throwException(new InvalidArgument('Missing required field "RegionName".')); $this->kmsMasterKeyId = $input['KMSMasterKeyId'] ?? null; $this->provisionedThroughputOverride = isset($input['ProvisionedThroughputOverride']) ? ProvisionedThroughputOverride::create($input['ProvisionedThroughputOverride']) : null; $this->globalSecondaryIndexes = isset($input['GlobalSecondaryIndexes']) ? array_map([ReplicaGlobalSecondaryIndex::class, 'create'], $input['GlobalSecondaryIndexes']) : null; @@ -133,4 +133,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/Delete.php b/src/Service/DynamoDb/src/ValueObject/Delete.php index 230da3a9b..30238988d 100644 --- a/src/Service/DynamoDb/src/ValueObject/Delete.php +++ b/src/Service/DynamoDb/src/ValueObject/Delete.php @@ -53,8 +53,8 @@ final class Delete */ public function __construct(array $input) { - $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : null; - $this->tableName = $input['TableName'] ?? null; + $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->tableName = $input['TableName'] ?? $this->throwException(new InvalidArgument('Missing required field "TableName".')); $this->conditionExpression = $input['ConditionExpression'] ?? null; $this->expressionAttributeNames = $input['ExpressionAttributeNames'] ?? null; $this->expressionAttributeValues = isset($input['ExpressionAttributeValues']) ? array_map([AttributeValue::class, 'create'], $input['ExpressionAttributeValues']) : null; @@ -102,7 +102,7 @@ public function getExpressionAttributeValues(): array */ public function getKey(): array { - return $this->key ?? []; + return $this->key; } /** @@ -172,4 +172,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php b/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php index 526a3eb8b..83324c0d6 100644 --- a/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php +++ b/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php @@ -21,7 +21,7 @@ final class DeleteGlobalSecondaryIndexAction */ public function __construct(array $input) { - $this->indexName = $input['IndexName'] ?? null; + $this->indexName = $input['IndexName'] ?? $this->throwException(new InvalidArgument('Missing required field "IndexName".')); } /** @@ -52,4 +52,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php b/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php index 91df024cb..395132380 100644 --- a/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php +++ b/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php @@ -21,7 +21,7 @@ final class DeleteReplicationGroupMemberAction */ public function __construct(array $input) { - $this->regionName = $input['RegionName'] ?? null; + $this->regionName = $input['RegionName'] ?? $this->throwException(new InvalidArgument('Missing required field "RegionName".')); } /** @@ -52,4 +52,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php b/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php index 6b4d8a7cc..6737c971f 100644 --- a/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php +++ b/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php @@ -22,7 +22,7 @@ final class DeleteRequest */ public function __construct(array $input) { - $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : null; + $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : $this->throwException(new InvalidArgument('Missing required field "Key".')); } /** @@ -40,7 +40,7 @@ public static function create($input): self */ public function getKey(): array { - return $this->key ?? []; + return $this->key; } /** @@ -64,4 +64,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/Endpoint.php b/src/Service/DynamoDb/src/ValueObject/Endpoint.php index 39c0150f4..bedeac374 100644 --- a/src/Service/DynamoDb/src/ValueObject/Endpoint.php +++ b/src/Service/DynamoDb/src/ValueObject/Endpoint.php @@ -3,6 +3,7 @@ namespace AsyncAws\DynamoDb\ValueObject; use AsyncAws\Core\EndpointDiscovery\EndpointInterface; +use AsyncAws\Core\Exception\InvalidArgument; /** * An endpoint information details. @@ -27,8 +28,8 @@ final class Endpoint implements EndpointInterface */ public function __construct(array $input) { - $this->address = $input['Address'] ?? null; - $this->cachePeriodInMinutes = $input['CachePeriodInMinutes'] ?? null; + $this->address = $input['Address'] ?? $this->throwException(new InvalidArgument('Missing required field "Address".')); + $this->cachePeriodInMinutes = $input['CachePeriodInMinutes'] ?? $this->throwException(new InvalidArgument('Missing required field "CachePeriodInMinutes".')); } /** @@ -51,4 +52,12 @@ public function getCachePeriodInMinutes(): int { return $this->cachePeriodInMinutes; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php b/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php index 5451eb334..a03d77886 100644 --- a/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php +++ b/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php @@ -56,9 +56,9 @@ final class GlobalSecondaryIndex */ public function __construct(array $input) { - $this->indexName = $input['IndexName'] ?? null; - $this->keySchema = isset($input['KeySchema']) ? array_map([KeySchemaElement::class, 'create'], $input['KeySchema']) : null; - $this->projection = isset($input['Projection']) ? Projection::create($input['Projection']) : null; + $this->indexName = $input['IndexName'] ?? $this->throwException(new InvalidArgument('Missing required field "IndexName".')); + $this->keySchema = isset($input['KeySchema']) ? array_map([KeySchemaElement::class, 'create'], $input['KeySchema']) : $this->throwException(new InvalidArgument('Missing required field "KeySchema".')); + $this->projection = isset($input['Projection']) ? Projection::create($input['Projection']) : $this->throwException(new InvalidArgument('Missing required field "Projection".')); $this->provisionedThroughput = isset($input['ProvisionedThroughput']) ? ProvisionedThroughput::create($input['ProvisionedThroughput']) : null; } @@ -85,7 +85,7 @@ public function getIndexName(): string */ public function getKeySchema(): array { - return $this->keySchema ?? []; + return $this->keySchema; } public function getProjection(): Projection @@ -129,4 +129,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php b/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php index 574db8857..c91db442d 100644 --- a/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php +++ b/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php @@ -46,8 +46,8 @@ final class KeySchemaElement */ public function __construct(array $input) { - $this->attributeName = $input['AttributeName'] ?? null; - $this->keyType = $input['KeyType'] ?? null; + $this->attributeName = $input['AttributeName'] ?? $this->throwException(new InvalidArgument('Missing required field "AttributeName".')); + $this->keyType = $input['KeyType'] ?? $this->throwException(new InvalidArgument('Missing required field "KeyType".')); } /** @@ -94,4 +94,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php b/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php index 3b03df9a0..3219c94bc 100644 --- a/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php +++ b/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php @@ -90,7 +90,7 @@ final class KeysAndAttributes */ public function __construct(array $input) { - $this->keys = $input['Keys'] ?? null; + $this->keys = $input['Keys'] ?? $this->throwException(new InvalidArgument('Missing required field "Keys".')); $this->attributesToGet = $input['AttributesToGet'] ?? null; $this->consistentRead = $input['ConsistentRead'] ?? null; $this->projectionExpression = $input['ProjectionExpression'] ?? null; @@ -137,7 +137,7 @@ public function getExpressionAttributeNames(): array */ public function getKeys(): array { - return $this->keys ?? []; + return $this->keys; } public function getProjectionExpression(): ?string @@ -197,4 +197,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php b/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php index 86975f53f..871af09bf 100644 --- a/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php +++ b/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php @@ -45,9 +45,9 @@ final class LocalSecondaryIndex */ public function __construct(array $input) { - $this->indexName = $input['IndexName'] ?? null; - $this->keySchema = isset($input['KeySchema']) ? array_map([KeySchemaElement::class, 'create'], $input['KeySchema']) : null; - $this->projection = isset($input['Projection']) ? Projection::create($input['Projection']) : null; + $this->indexName = $input['IndexName'] ?? $this->throwException(new InvalidArgument('Missing required field "IndexName".')); + $this->keySchema = isset($input['KeySchema']) ? array_map([KeySchemaElement::class, 'create'], $input['KeySchema']) : $this->throwException(new InvalidArgument('Missing required field "KeySchema".')); + $this->projection = isset($input['Projection']) ? Projection::create($input['Projection']) : $this->throwException(new InvalidArgument('Missing required field "Projection".')); } /** @@ -72,7 +72,7 @@ public function getIndexName(): string */ public function getKeySchema(): array { - return $this->keySchema ?? []; + return $this->keySchema; } public function getProjection(): Projection @@ -108,4 +108,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php b/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php index 815744eb6..40504fd34 100644 --- a/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php +++ b/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php @@ -43,8 +43,8 @@ final class ProvisionedThroughput */ public function __construct(array $input) { - $this->readCapacityUnits = $input['ReadCapacityUnits'] ?? null; - $this->writeCapacityUnits = $input['WriteCapacityUnits'] ?? null; + $this->readCapacityUnits = $input['ReadCapacityUnits'] ?? $this->throwException(new InvalidArgument('Missing required field "ReadCapacityUnits".')); + $this->writeCapacityUnits = $input['WriteCapacityUnits'] ?? $this->throwException(new InvalidArgument('Missing required field "WriteCapacityUnits".')); } /** @@ -85,4 +85,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/Put.php b/src/Service/DynamoDb/src/ValueObject/Put.php index f1d2fddac..0a585113a 100644 --- a/src/Service/DynamoDb/src/ValueObject/Put.php +++ b/src/Service/DynamoDb/src/ValueObject/Put.php @@ -56,8 +56,8 @@ final class Put */ public function __construct(array $input) { - $this->item = isset($input['Item']) ? array_map([AttributeValue::class, 'create'], $input['Item']) : null; - $this->tableName = $input['TableName'] ?? null; + $this->item = isset($input['Item']) ? array_map([AttributeValue::class, 'create'], $input['Item']) : $this->throwException(new InvalidArgument('Missing required field "Item".')); + $this->tableName = $input['TableName'] ?? $this->throwException(new InvalidArgument('Missing required field "TableName".')); $this->conditionExpression = $input['ConditionExpression'] ?? null; $this->expressionAttributeNames = $input['ExpressionAttributeNames'] ?? null; $this->expressionAttributeValues = isset($input['ExpressionAttributeValues']) ? array_map([AttributeValue::class, 'create'], $input['ExpressionAttributeValues']) : null; @@ -105,7 +105,7 @@ public function getExpressionAttributeValues(): array */ public function getItem(): array { - return $this->item ?? []; + return $this->item; } /** @@ -175,4 +175,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/PutRequest.php b/src/Service/DynamoDb/src/ValueObject/PutRequest.php index 8eb90cdbd..6f25c30e2 100644 --- a/src/Service/DynamoDb/src/ValueObject/PutRequest.php +++ b/src/Service/DynamoDb/src/ValueObject/PutRequest.php @@ -24,7 +24,7 @@ final class PutRequest */ public function __construct(array $input) { - $this->item = isset($input['Item']) ? array_map([AttributeValue::class, 'create'], $input['Item']) : null; + $this->item = isset($input['Item']) ? array_map([AttributeValue::class, 'create'], $input['Item']) : $this->throwException(new InvalidArgument('Missing required field "Item".')); } /** @@ -42,7 +42,7 @@ public static function create($input): self */ public function getItem(): array { - return $this->item ?? []; + return $this->item; } /** @@ -66,4 +66,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php b/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php index 85cc973a5..5ecba0d97 100644 --- a/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php +++ b/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php @@ -28,7 +28,7 @@ final class ReplicaGlobalSecondaryIndex */ public function __construct(array $input) { - $this->indexName = $input['IndexName'] ?? null; + $this->indexName = $input['IndexName'] ?? $this->throwException(new InvalidArgument('Missing required field "IndexName".')); $this->provisionedThroughputOverride = isset($input['ProvisionedThroughputOverride']) ? ProvisionedThroughputOverride::create($input['ProvisionedThroughputOverride']) : null; } @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/RestoreSummary.php b/src/Service/DynamoDb/src/ValueObject/RestoreSummary.php index 2982db324..fa1b564d7 100644 --- a/src/Service/DynamoDb/src/ValueObject/RestoreSummary.php +++ b/src/Service/DynamoDb/src/ValueObject/RestoreSummary.php @@ -2,6 +2,8 @@ namespace AsyncAws\DynamoDb\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains details for the restore. */ @@ -39,8 +41,8 @@ public function __construct(array $input) { $this->sourceBackupArn = $input['SourceBackupArn'] ?? null; $this->sourceTableArn = $input['SourceTableArn'] ?? null; - $this->restoreDateTime = $input['RestoreDateTime'] ?? null; - $this->restoreInProgress = $input['RestoreInProgress'] ?? null; + $this->restoreDateTime = $input['RestoreDateTime'] ?? $this->throwException(new InvalidArgument('Missing required field "RestoreDateTime".')); + $this->restoreInProgress = $input['RestoreInProgress'] ?? $this->throwException(new InvalidArgument('Missing required field "RestoreInProgress".')); } /** @@ -75,4 +77,12 @@ public function getSourceTableArn(): ?string { return $this->sourceTableArn; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php b/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php index 7b26cb86e..13f124b4b 100644 --- a/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php +++ b/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php @@ -34,7 +34,7 @@ final class StreamSpecification */ public function __construct(array $input) { - $this->streamEnabled = $input['StreamEnabled'] ?? null; + $this->streamEnabled = $input['StreamEnabled'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamEnabled".')); $this->streamViewType = $input['StreamViewType'] ?? null; } @@ -81,4 +81,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/Tag.php b/src/Service/DynamoDb/src/ValueObject/Tag.php index daa8c64bb..21a97d5e8 100644 --- a/src/Service/DynamoDb/src/ValueObject/Tag.php +++ b/src/Service/DynamoDb/src/ValueObject/Tag.php @@ -37,8 +37,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -79,4 +79,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php b/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php index 23989c732..ea66b2b1a 100644 --- a/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php +++ b/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php @@ -27,8 +27,8 @@ final class TimeToLiveSpecification */ public function __construct(array $input) { - $this->enabled = $input['Enabled'] ?? null; - $this->attributeName = $input['AttributeName'] ?? null; + $this->enabled = $input['Enabled'] ?? $this->throwException(new InvalidArgument('Missing required field "Enabled".')); + $this->attributeName = $input['AttributeName'] ?? $this->throwException(new InvalidArgument('Missing required field "AttributeName".')); } /** @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/Update.php b/src/Service/DynamoDb/src/ValueObject/Update.php index 364a3ab7e..915785287 100644 --- a/src/Service/DynamoDb/src/ValueObject/Update.php +++ b/src/Service/DynamoDb/src/ValueObject/Update.php @@ -60,9 +60,9 @@ final class Update */ public function __construct(array $input) { - $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : null; - $this->updateExpression = $input['UpdateExpression'] ?? null; - $this->tableName = $input['TableName'] ?? null; + $this->key = isset($input['Key']) ? array_map([AttributeValue::class, 'create'], $input['Key']) : $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->updateExpression = $input['UpdateExpression'] ?? $this->throwException(new InvalidArgument('Missing required field "UpdateExpression".')); + $this->tableName = $input['TableName'] ?? $this->throwException(new InvalidArgument('Missing required field "TableName".')); $this->conditionExpression = $input['ConditionExpression'] ?? null; $this->expressionAttributeNames = $input['ExpressionAttributeNames'] ?? null; $this->expressionAttributeValues = isset($input['ExpressionAttributeValues']) ? array_map([AttributeValue::class, 'create'], $input['ExpressionAttributeValues']) : null; @@ -111,7 +111,7 @@ public function getExpressionAttributeValues(): array */ public function getKey(): array { - return $this->key ?? []; + return $this->key; } /** @@ -190,4 +190,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php b/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php index ea97132aa..204d20003 100644 --- a/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php +++ b/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php @@ -32,8 +32,8 @@ final class UpdateGlobalSecondaryIndexAction */ public function __construct(array $input) { - $this->indexName = $input['IndexName'] ?? null; - $this->provisionedThroughput = isset($input['ProvisionedThroughput']) ? ProvisionedThroughput::create($input['ProvisionedThroughput']) : null; + $this->indexName = $input['IndexName'] ?? $this->throwException(new InvalidArgument('Missing required field "IndexName".')); + $this->provisionedThroughput = isset($input['ProvisionedThroughput']) ? ProvisionedThroughput::create($input['ProvisionedThroughput']) : $this->throwException(new InvalidArgument('Missing required field "ProvisionedThroughput".')); } /** @@ -74,4 +74,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php b/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php index c8872c399..b899eb5a5 100644 --- a/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php +++ b/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php @@ -48,7 +48,7 @@ final class UpdateReplicationGroupMemberAction */ public function __construct(array $input) { - $this->regionName = $input['RegionName'] ?? null; + $this->regionName = $input['RegionName'] ?? $this->throwException(new InvalidArgument('Missing required field "RegionName".')); $this->kmsMasterKeyId = $input['KMSMasterKeyId'] ?? null; $this->provisionedThroughputOverride = isset($input['ProvisionedThroughputOverride']) ? ProvisionedThroughputOverride::create($input['ProvisionedThroughputOverride']) : null; $this->globalSecondaryIndexes = isset($input['GlobalSecondaryIndexes']) ? array_map([ReplicaGlobalSecondaryIndex::class, 'create'], $input['GlobalSecondaryIndexes']) : null; @@ -133,4 +133,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Firehose/src/ValueObject/Record.php b/src/Service/Firehose/src/ValueObject/Record.php index 04559482f..e56632022 100644 --- a/src/Service/Firehose/src/ValueObject/Record.php +++ b/src/Service/Firehose/src/ValueObject/Record.php @@ -22,7 +22,7 @@ final class Record */ public function __construct(array $input) { - $this->data = $input['Data'] ?? null; + $this->data = $input['Data'] ?? $this->throwException(new InvalidArgument('Missing required field "Data".')); } /** @@ -53,4 +53,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Iam/src/ValueObject/AccessKey.php b/src/Service/Iam/src/ValueObject/AccessKey.php index 47453a6cb..2ed20a753 100644 --- a/src/Service/Iam/src/ValueObject/AccessKey.php +++ b/src/Service/Iam/src/ValueObject/AccessKey.php @@ -2,6 +2,7 @@ namespace AsyncAws\Iam\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Iam\Enum\StatusType; /** @@ -51,10 +52,10 @@ final class AccessKey */ public function __construct(array $input) { - $this->userName = $input['UserName'] ?? null; - $this->accessKeyId = $input['AccessKeyId'] ?? null; - $this->status = $input['Status'] ?? null; - $this->secretAccessKey = $input['SecretAccessKey'] ?? null; + $this->userName = $input['UserName'] ?? $this->throwException(new InvalidArgument('Missing required field "UserName".')); + $this->accessKeyId = $input['AccessKeyId'] ?? $this->throwException(new InvalidArgument('Missing required field "AccessKeyId".')); + $this->status = $input['Status'] ?? $this->throwException(new InvalidArgument('Missing required field "Status".')); + $this->secretAccessKey = $input['SecretAccessKey'] ?? $this->throwException(new InvalidArgument('Missing required field "SecretAccessKey".')); $this->createDate = $input['CreateDate'] ?? null; } @@ -99,4 +100,12 @@ public function getUserName(): string { return $this->userName; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Iam/src/ValueObject/ServiceSpecificCredential.php b/src/Service/Iam/src/ValueObject/ServiceSpecificCredential.php index fa19a4ff3..8c929222a 100644 --- a/src/Service/Iam/src/ValueObject/ServiceSpecificCredential.php +++ b/src/Service/Iam/src/ValueObject/ServiceSpecificCredential.php @@ -2,6 +2,7 @@ namespace AsyncAws\Iam\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Iam\Enum\StatusType; /** @@ -62,13 +63,13 @@ final class ServiceSpecificCredential */ public function __construct(array $input) { - $this->createDate = $input['CreateDate'] ?? null; - $this->serviceName = $input['ServiceName'] ?? null; - $this->serviceUserName = $input['ServiceUserName'] ?? null; - $this->servicePassword = $input['ServicePassword'] ?? null; - $this->serviceSpecificCredentialId = $input['ServiceSpecificCredentialId'] ?? null; - $this->userName = $input['UserName'] ?? null; - $this->status = $input['Status'] ?? null; + $this->createDate = $input['CreateDate'] ?? $this->throwException(new InvalidArgument('Missing required field "CreateDate".')); + $this->serviceName = $input['ServiceName'] ?? $this->throwException(new InvalidArgument('Missing required field "ServiceName".')); + $this->serviceUserName = $input['ServiceUserName'] ?? $this->throwException(new InvalidArgument('Missing required field "ServiceUserName".')); + $this->servicePassword = $input['ServicePassword'] ?? $this->throwException(new InvalidArgument('Missing required field "ServicePassword".')); + $this->serviceSpecificCredentialId = $input['ServiceSpecificCredentialId'] ?? $this->throwException(new InvalidArgument('Missing required field "ServiceSpecificCredentialId".')); + $this->userName = $input['UserName'] ?? $this->throwException(new InvalidArgument('Missing required field "UserName".')); + $this->status = $input['Status'] ?? $this->throwException(new InvalidArgument('Missing required field "Status".')); } /** @@ -124,4 +125,12 @@ public function getUserName(): string { return $this->userName; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Iam/src/ValueObject/ServiceSpecificCredentialMetadata.php b/src/Service/Iam/src/ValueObject/ServiceSpecificCredentialMetadata.php index c2a603c5c..c001b3400 100644 --- a/src/Service/Iam/src/ValueObject/ServiceSpecificCredentialMetadata.php +++ b/src/Service/Iam/src/ValueObject/ServiceSpecificCredentialMetadata.php @@ -2,6 +2,7 @@ namespace AsyncAws\Iam\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Iam\Enum\StatusType; /** @@ -54,12 +55,12 @@ final class ServiceSpecificCredentialMetadata */ public function __construct(array $input) { - $this->userName = $input['UserName'] ?? null; - $this->status = $input['Status'] ?? null; - $this->serviceUserName = $input['ServiceUserName'] ?? null; - $this->createDate = $input['CreateDate'] ?? null; - $this->serviceSpecificCredentialId = $input['ServiceSpecificCredentialId'] ?? null; - $this->serviceName = $input['ServiceName'] ?? null; + $this->userName = $input['UserName'] ?? $this->throwException(new InvalidArgument('Missing required field "UserName".')); + $this->status = $input['Status'] ?? $this->throwException(new InvalidArgument('Missing required field "Status".')); + $this->serviceUserName = $input['ServiceUserName'] ?? $this->throwException(new InvalidArgument('Missing required field "ServiceUserName".')); + $this->createDate = $input['CreateDate'] ?? $this->throwException(new InvalidArgument('Missing required field "CreateDate".')); + $this->serviceSpecificCredentialId = $input['ServiceSpecificCredentialId'] ?? $this->throwException(new InvalidArgument('Missing required field "ServiceSpecificCredentialId".')); + $this->serviceName = $input['ServiceName'] ?? $this->throwException(new InvalidArgument('Missing required field "ServiceName".')); } /** @@ -109,4 +110,12 @@ public function getUserName(): string { return $this->userName; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Iam/src/ValueObject/Tag.php b/src/Service/Iam/src/ValueObject/Tag.php index 0b4a6d1ad..a50c8279a 100644 --- a/src/Service/Iam/src/ValueObject/Tag.php +++ b/src/Service/Iam/src/ValueObject/Tag.php @@ -37,8 +37,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -79,4 +79,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Iam/src/ValueObject/User.php b/src/Service/Iam/src/ValueObject/User.php index 948025065..b0deaa705 100644 --- a/src/Service/Iam/src/ValueObject/User.php +++ b/src/Service/Iam/src/ValueObject/User.php @@ -2,6 +2,8 @@ namespace AsyncAws\Iam\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains information about an IAM user entity. * @@ -100,11 +102,11 @@ final class User */ public function __construct(array $input) { - $this->path = $input['Path'] ?? null; - $this->userName = $input['UserName'] ?? null; - $this->userId = $input['UserId'] ?? null; - $this->arn = $input['Arn'] ?? null; - $this->createDate = $input['CreateDate'] ?? null; + $this->path = $input['Path'] ?? $this->throwException(new InvalidArgument('Missing required field "Path".')); + $this->userName = $input['UserName'] ?? $this->throwException(new InvalidArgument('Missing required field "UserName".')); + $this->userId = $input['UserId'] ?? $this->throwException(new InvalidArgument('Missing required field "UserId".')); + $this->arn = $input['Arn'] ?? $this->throwException(new InvalidArgument('Missing required field "Arn".')); + $this->createDate = $input['CreateDate'] ?? $this->throwException(new InvalidArgument('Missing required field "CreateDate".')); $this->passwordLastUsed = $input['PasswordLastUsed'] ?? null; $this->permissionsBoundary = isset($input['PermissionsBoundary']) ? AttachedPermissionsBoundary::create($input['PermissionsBoundary']) : null; $this->tags = isset($input['Tags']) ? array_map([Tag::class, 'create'], $input['Tags']) : null; @@ -169,4 +171,12 @@ public function getUserName(): string { return $this->userName; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Iot/src/ValueObject/Tag.php b/src/Service/Iot/src/ValueObject/Tag.php index 7a784f8b5..478b92a29 100644 --- a/src/Service/Iot/src/ValueObject/Tag.php +++ b/src/Service/Iot/src/ValueObject/Tag.php @@ -27,7 +27,7 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); $this->value = $input['Value'] ?? null; } @@ -68,4 +68,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/ChildShard.php b/src/Service/Kinesis/src/ValueObject/ChildShard.php index 29ccbee8b..65553a5be 100644 --- a/src/Service/Kinesis/src/ValueObject/ChildShard.php +++ b/src/Service/Kinesis/src/ValueObject/ChildShard.php @@ -2,6 +2,8 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Output parameter of the GetRecords API. The existing child shard of the current shard. */ @@ -28,9 +30,9 @@ final class ChildShard */ public function __construct(array $input) { - $this->shardId = $input['ShardId'] ?? null; - $this->parentShards = $input['ParentShards'] ?? null; - $this->hashKeyRange = isset($input['HashKeyRange']) ? HashKeyRange::create($input['HashKeyRange']) : null; + $this->shardId = $input['ShardId'] ?? $this->throwException(new InvalidArgument('Missing required field "ShardId".')); + $this->parentShards = $input['ParentShards'] ?? $this->throwException(new InvalidArgument('Missing required field "ParentShards".')); + $this->hashKeyRange = isset($input['HashKeyRange']) ? HashKeyRange::create($input['HashKeyRange']) : $this->throwException(new InvalidArgument('Missing required field "HashKeyRange".')); } /** @@ -55,11 +57,19 @@ public function getHashKeyRange(): HashKeyRange */ public function getParentShards(): array { - return $this->parentShards ?? []; + return $this->parentShards; } public function getShardId(): string { return $this->shardId; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/Consumer.php b/src/Service/Kinesis/src/ValueObject/Consumer.php index fe268d24f..bcafb1b6e 100644 --- a/src/Service/Kinesis/src/ValueObject/Consumer.php +++ b/src/Service/Kinesis/src/ValueObject/Consumer.php @@ -2,6 +2,7 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Kinesis\Enum\ConsumerStatus; /** @@ -42,10 +43,10 @@ final class Consumer */ public function __construct(array $input) { - $this->consumerName = $input['ConsumerName'] ?? null; - $this->consumerArn = $input['ConsumerARN'] ?? null; - $this->consumerStatus = $input['ConsumerStatus'] ?? null; - $this->consumerCreationTimestamp = $input['ConsumerCreationTimestamp'] ?? null; + $this->consumerName = $input['ConsumerName'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerName".')); + $this->consumerArn = $input['ConsumerARN'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerARN".')); + $this->consumerStatus = $input['ConsumerStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerStatus".')); + $this->consumerCreationTimestamp = $input['ConsumerCreationTimestamp'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerCreationTimestamp".')); } /** @@ -83,4 +84,12 @@ public function getConsumerStatus(): string { return $this->consumerStatus; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/ConsumerDescription.php b/src/Service/Kinesis/src/ValueObject/ConsumerDescription.php index 44b97bbc7..0158ffc2d 100644 --- a/src/Service/Kinesis/src/ValueObject/ConsumerDescription.php +++ b/src/Service/Kinesis/src/ValueObject/ConsumerDescription.php @@ -2,6 +2,7 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Kinesis\Enum\ConsumerStatus; /** @@ -48,11 +49,11 @@ final class ConsumerDescription */ public function __construct(array $input) { - $this->consumerName = $input['ConsumerName'] ?? null; - $this->consumerArn = $input['ConsumerARN'] ?? null; - $this->consumerStatus = $input['ConsumerStatus'] ?? null; - $this->consumerCreationTimestamp = $input['ConsumerCreationTimestamp'] ?? null; - $this->streamArn = $input['StreamARN'] ?? null; + $this->consumerName = $input['ConsumerName'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerName".')); + $this->consumerArn = $input['ConsumerARN'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerARN".')); + $this->consumerStatus = $input['ConsumerStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerStatus".')); + $this->consumerCreationTimestamp = $input['ConsumerCreationTimestamp'] ?? $this->throwException(new InvalidArgument('Missing required field "ConsumerCreationTimestamp".')); + $this->streamArn = $input['StreamARN'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamARN".')); } /** @@ -96,4 +97,12 @@ public function getStreamArn(): string { return $this->streamArn; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/HashKeyRange.php b/src/Service/Kinesis/src/ValueObject/HashKeyRange.php index 4b9ba383a..aa9a10da2 100644 --- a/src/Service/Kinesis/src/ValueObject/HashKeyRange.php +++ b/src/Service/Kinesis/src/ValueObject/HashKeyRange.php @@ -2,6 +2,8 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * The range of possible hash key values for the shard, which is a set of ordered contiguous positive integers. */ @@ -25,8 +27,8 @@ final class HashKeyRange */ public function __construct(array $input) { - $this->startingHashKey = $input['StartingHashKey'] ?? null; - $this->endingHashKey = $input['EndingHashKey'] ?? null; + $this->startingHashKey = $input['StartingHashKey'] ?? $this->throwException(new InvalidArgument('Missing required field "StartingHashKey".')); + $this->endingHashKey = $input['EndingHashKey'] ?? $this->throwException(new InvalidArgument('Missing required field "EndingHashKey".')); } /** @@ -49,4 +51,12 @@ public function getStartingHashKey(): string { return $this->startingHashKey; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php b/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php index d4f4a1d44..241fcb796 100644 --- a/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php +++ b/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php @@ -40,9 +40,9 @@ final class PutRecordsRequestEntry */ public function __construct(array $input) { - $this->data = $input['Data'] ?? null; + $this->data = $input['Data'] ?? $this->throwException(new InvalidArgument('Missing required field "Data".')); $this->explicitHashKey = $input['ExplicitHashKey'] ?? null; - $this->partitionKey = $input['PartitionKey'] ?? null; + $this->partitionKey = $input['PartitionKey'] ?? $this->throwException(new InvalidArgument('Missing required field "PartitionKey".')); } /** @@ -92,4 +92,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/Record.php b/src/Service/Kinesis/src/ValueObject/Record.php index 62616598e..6a729cbf4 100644 --- a/src/Service/Kinesis/src/ValueObject/Record.php +++ b/src/Service/Kinesis/src/ValueObject/Record.php @@ -2,6 +2,7 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Kinesis\Enum\EncryptionType; /** @@ -52,10 +53,10 @@ final class Record */ public function __construct(array $input) { - $this->sequenceNumber = $input['SequenceNumber'] ?? null; + $this->sequenceNumber = $input['SequenceNumber'] ?? $this->throwException(new InvalidArgument('Missing required field "SequenceNumber".')); $this->approximateArrivalTimestamp = $input['ApproximateArrivalTimestamp'] ?? null; - $this->data = $input['Data'] ?? null; - $this->partitionKey = $input['PartitionKey'] ?? null; + $this->data = $input['Data'] ?? $this->throwException(new InvalidArgument('Missing required field "Data".')); + $this->partitionKey = $input['PartitionKey'] ?? $this->throwException(new InvalidArgument('Missing required field "PartitionKey".')); $this->encryptionType = $input['EncryptionType'] ?? null; } @@ -100,4 +101,12 @@ public function getSequenceNumber(): string { return $this->sequenceNumber; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/SequenceNumberRange.php b/src/Service/Kinesis/src/ValueObject/SequenceNumberRange.php index ae2f5b16a..52a7c69a7 100644 --- a/src/Service/Kinesis/src/ValueObject/SequenceNumberRange.php +++ b/src/Service/Kinesis/src/ValueObject/SequenceNumberRange.php @@ -2,6 +2,8 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * The range of possible sequence numbers for the shard. */ @@ -25,7 +27,7 @@ final class SequenceNumberRange */ public function __construct(array $input) { - $this->startingSequenceNumber = $input['StartingSequenceNumber'] ?? null; + $this->startingSequenceNumber = $input['StartingSequenceNumber'] ?? $this->throwException(new InvalidArgument('Missing required field "StartingSequenceNumber".')); $this->endingSequenceNumber = $input['EndingSequenceNumber'] ?? null; } @@ -49,4 +51,12 @@ public function getStartingSequenceNumber(): string { return $this->startingSequenceNumber; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/Shard.php b/src/Service/Kinesis/src/ValueObject/Shard.php index 559e98a8a..22e2a378b 100644 --- a/src/Service/Kinesis/src/ValueObject/Shard.php +++ b/src/Service/Kinesis/src/ValueObject/Shard.php @@ -2,6 +2,8 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * A uniquely identified group of data records in a Kinesis data stream. */ @@ -43,11 +45,11 @@ final class Shard */ public function __construct(array $input) { - $this->shardId = $input['ShardId'] ?? null; + $this->shardId = $input['ShardId'] ?? $this->throwException(new InvalidArgument('Missing required field "ShardId".')); $this->parentShardId = $input['ParentShardId'] ?? null; $this->adjacentParentShardId = $input['AdjacentParentShardId'] ?? null; - $this->hashKeyRange = isset($input['HashKeyRange']) ? HashKeyRange::create($input['HashKeyRange']) : null; - $this->sequenceNumberRange = isset($input['SequenceNumberRange']) ? SequenceNumberRange::create($input['SequenceNumberRange']) : null; + $this->hashKeyRange = isset($input['HashKeyRange']) ? HashKeyRange::create($input['HashKeyRange']) : $this->throwException(new InvalidArgument('Missing required field "HashKeyRange".')); + $this->sequenceNumberRange = isset($input['SequenceNumberRange']) ? SequenceNumberRange::create($input['SequenceNumberRange']) : $this->throwException(new InvalidArgument('Missing required field "SequenceNumberRange".')); } /** @@ -88,4 +90,12 @@ public function getShardId(): string { return $this->shardId; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/ShardFilter.php b/src/Service/Kinesis/src/ValueObject/ShardFilter.php index 758e78b5e..65dcb5ce7 100644 --- a/src/Service/Kinesis/src/ValueObject/ShardFilter.php +++ b/src/Service/Kinesis/src/ValueObject/ShardFilter.php @@ -51,7 +51,7 @@ final class ShardFilter */ public function __construct(array $input) { - $this->type = $input['Type'] ?? null; + $this->type = $input['Type'] ?? $this->throwException(new InvalidArgument('Missing required field "Type".')); $this->shardId = $input['ShardId'] ?? null; $this->timestamp = $input['Timestamp'] ?? null; } @@ -108,4 +108,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/StreamDescription.php b/src/Service/Kinesis/src/ValueObject/StreamDescription.php index 6563a1db1..4b5635238 100644 --- a/src/Service/Kinesis/src/ValueObject/StreamDescription.php +++ b/src/Service/Kinesis/src/ValueObject/StreamDescription.php @@ -2,6 +2,7 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Kinesis\Enum\EncryptionType; use AsyncAws\Kinesis\Enum\StreamStatus; @@ -104,15 +105,15 @@ final class StreamDescription */ public function __construct(array $input) { - $this->streamName = $input['StreamName'] ?? null; - $this->streamArn = $input['StreamARN'] ?? null; - $this->streamStatus = $input['StreamStatus'] ?? null; + $this->streamName = $input['StreamName'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamName".')); + $this->streamArn = $input['StreamARN'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamARN".')); + $this->streamStatus = $input['StreamStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamStatus".')); $this->streamModeDetails = isset($input['StreamModeDetails']) ? StreamModeDetails::create($input['StreamModeDetails']) : null; - $this->shards = isset($input['Shards']) ? array_map([Shard::class, 'create'], $input['Shards']) : null; - $this->hasMoreShards = $input['HasMoreShards'] ?? null; - $this->retentionPeriodHours = $input['RetentionPeriodHours'] ?? null; - $this->streamCreationTimestamp = $input['StreamCreationTimestamp'] ?? null; - $this->enhancedMonitoring = isset($input['EnhancedMonitoring']) ? array_map([EnhancedMetrics::class, 'create'], $input['EnhancedMonitoring']) : null; + $this->shards = isset($input['Shards']) ? array_map([Shard::class, 'create'], $input['Shards']) : $this->throwException(new InvalidArgument('Missing required field "Shards".')); + $this->hasMoreShards = $input['HasMoreShards'] ?? $this->throwException(new InvalidArgument('Missing required field "HasMoreShards".')); + $this->retentionPeriodHours = $input['RetentionPeriodHours'] ?? $this->throwException(new InvalidArgument('Missing required field "RetentionPeriodHours".')); + $this->streamCreationTimestamp = $input['StreamCreationTimestamp'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamCreationTimestamp".')); + $this->enhancedMonitoring = isset($input['EnhancedMonitoring']) ? array_map([EnhancedMetrics::class, 'create'], $input['EnhancedMonitoring']) : $this->throwException(new InvalidArgument('Missing required field "EnhancedMonitoring".')); $this->encryptionType = $input['EncryptionType'] ?? null; $this->keyId = $input['KeyId'] ?? null; } @@ -150,7 +151,7 @@ public function getEncryptionType(): ?string */ public function getEnhancedMonitoring(): array { - return $this->enhancedMonitoring ?? []; + return $this->enhancedMonitoring; } public function getHasMoreShards(): bool @@ -173,7 +174,7 @@ public function getRetentionPeriodHours(): int */ public function getShards(): array { - return $this->shards ?? []; + return $this->shards; } public function getStreamArn(): string @@ -203,4 +204,12 @@ public function getStreamStatus(): string { return $this->streamStatus; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/StreamDescriptionSummary.php b/src/Service/Kinesis/src/ValueObject/StreamDescriptionSummary.php index 661e18367..6d29315d4 100644 --- a/src/Service/Kinesis/src/ValueObject/StreamDescriptionSummary.php +++ b/src/Service/Kinesis/src/ValueObject/StreamDescriptionSummary.php @@ -2,6 +2,7 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Kinesis\Enum\EncryptionType; use AsyncAws\Kinesis\Enum\StreamStatus; @@ -103,16 +104,16 @@ final class StreamDescriptionSummary */ public function __construct(array $input) { - $this->streamName = $input['StreamName'] ?? null; - $this->streamArn = $input['StreamARN'] ?? null; - $this->streamStatus = $input['StreamStatus'] ?? null; + $this->streamName = $input['StreamName'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamName".')); + $this->streamArn = $input['StreamARN'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamARN".')); + $this->streamStatus = $input['StreamStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamStatus".')); $this->streamModeDetails = isset($input['StreamModeDetails']) ? StreamModeDetails::create($input['StreamModeDetails']) : null; - $this->retentionPeriodHours = $input['RetentionPeriodHours'] ?? null; - $this->streamCreationTimestamp = $input['StreamCreationTimestamp'] ?? null; - $this->enhancedMonitoring = isset($input['EnhancedMonitoring']) ? array_map([EnhancedMetrics::class, 'create'], $input['EnhancedMonitoring']) : null; + $this->retentionPeriodHours = $input['RetentionPeriodHours'] ?? $this->throwException(new InvalidArgument('Missing required field "RetentionPeriodHours".')); + $this->streamCreationTimestamp = $input['StreamCreationTimestamp'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamCreationTimestamp".')); + $this->enhancedMonitoring = isset($input['EnhancedMonitoring']) ? array_map([EnhancedMetrics::class, 'create'], $input['EnhancedMonitoring']) : $this->throwException(new InvalidArgument('Missing required field "EnhancedMonitoring".')); $this->encryptionType = $input['EncryptionType'] ?? null; $this->keyId = $input['KeyId'] ?? null; - $this->openShardCount = $input['OpenShardCount'] ?? null; + $this->openShardCount = $input['OpenShardCount'] ?? $this->throwException(new InvalidArgument('Missing required field "OpenShardCount".')); $this->consumerCount = $input['ConsumerCount'] ?? null; } @@ -154,7 +155,7 @@ public function getEncryptionType(): ?string */ public function getEnhancedMonitoring(): array { - return $this->enhancedMonitoring ?? []; + return $this->enhancedMonitoring; } public function getKeyId(): ?string @@ -199,4 +200,12 @@ public function getStreamStatus(): string { return $this->streamStatus; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php b/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php index fda4763e8..333e2d83e 100644 --- a/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php +++ b/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php @@ -24,7 +24,7 @@ final class StreamModeDetails */ public function __construct(array $input) { - $this->streamMode = $input['StreamMode'] ?? null; + $this->streamMode = $input['StreamMode'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamMode".')); } /** @@ -61,4 +61,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/StreamSummary.php b/src/Service/Kinesis/src/ValueObject/StreamSummary.php index 184df1b36..fbc9e3436 100644 --- a/src/Service/Kinesis/src/ValueObject/StreamSummary.php +++ b/src/Service/Kinesis/src/ValueObject/StreamSummary.php @@ -2,6 +2,7 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Kinesis\Enum\StreamStatus; /** @@ -42,9 +43,9 @@ final class StreamSummary */ public function __construct(array $input) { - $this->streamName = $input['StreamName'] ?? null; - $this->streamArn = $input['StreamARN'] ?? null; - $this->streamStatus = $input['StreamStatus'] ?? null; + $this->streamName = $input['StreamName'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamName".')); + $this->streamArn = $input['StreamARN'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamARN".')); + $this->streamStatus = $input['StreamStatus'] ?? $this->throwException(new InvalidArgument('Missing required field "StreamStatus".')); $this->streamModeDetails = isset($input['StreamModeDetails']) ? StreamModeDetails::create($input['StreamModeDetails']) : null; $this->streamCreationTimestamp = $input['StreamCreationTimestamp'] ?? null; } @@ -90,4 +91,12 @@ public function getStreamStatus(): string { return $this->streamStatus; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kinesis/src/ValueObject/Tag.php b/src/Service/Kinesis/src/ValueObject/Tag.php index 12ef5739c..720854963 100644 --- a/src/Service/Kinesis/src/ValueObject/Tag.php +++ b/src/Service/Kinesis/src/ValueObject/Tag.php @@ -2,6 +2,8 @@ namespace AsyncAws\Kinesis\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Metadata assigned to the stream, consisting of a key-value pair. */ @@ -27,7 +29,7 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); $this->value = $input['Value'] ?? null; } @@ -51,4 +53,12 @@ public function getValue(): ?string { return $this->value; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kms/src/ValueObject/KeyMetadata.php b/src/Service/Kms/src/ValueObject/KeyMetadata.php index 5498ba240..b1b05913e 100644 --- a/src/Service/Kms/src/ValueObject/KeyMetadata.php +++ b/src/Service/Kms/src/ValueObject/KeyMetadata.php @@ -2,6 +2,7 @@ namespace AsyncAws\Kms\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Kms\Enum\CustomerMasterKeySpec; use AsyncAws\Kms\Enum\EncryptionAlgorithmSpec; use AsyncAws\Kms\Enum\ExpirationModelType; @@ -241,7 +242,7 @@ final class KeyMetadata public function __construct(array $input) { $this->awsAccountId = $input['AWSAccountId'] ?? null; - $this->keyId = $input['KeyId'] ?? null; + $this->keyId = $input['KeyId'] ?? $this->throwException(new InvalidArgument('Missing required field "KeyId".')); $this->arn = $input['Arn'] ?? null; $this->creationDate = $input['CreationDate'] ?? null; $this->enabled = $input['Enabled'] ?? null; @@ -452,4 +453,12 @@ public function getXksKeyConfiguration(): ?XksKeyConfigurationType { return $this->xksKeyConfiguration; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Kms/src/ValueObject/Tag.php b/src/Service/Kms/src/ValueObject/Tag.php index 24db158f2..14858e8cd 100644 --- a/src/Service/Kms/src/ValueObject/Tag.php +++ b/src/Service/Kms/src/ValueObject/Tag.php @@ -36,8 +36,8 @@ final class Tag */ public function __construct(array $input) { - $this->tagKey = $input['TagKey'] ?? null; - $this->tagValue = $input['TagValue'] ?? null; + $this->tagKey = $input['TagKey'] ?? $this->throwException(new InvalidArgument('Missing required field "TagKey".')); + $this->tagValue = $input['TagValue'] ?? $this->throwException(new InvalidArgument('Missing required field "TagValue".')); } /** @@ -78,4 +78,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Lambda/src/ValueObject/EphemeralStorage.php b/src/Service/Lambda/src/ValueObject/EphemeralStorage.php index ef6adf2ff..9fe9673d8 100644 --- a/src/Service/Lambda/src/ValueObject/EphemeralStorage.php +++ b/src/Service/Lambda/src/ValueObject/EphemeralStorage.php @@ -2,6 +2,8 @@ namespace AsyncAws\Lambda\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * The size of the function's `/tmp` directory in MB. The default value is 512, but it can be any whole number between * 512 and 10,240 MB. @@ -20,7 +22,7 @@ final class EphemeralStorage */ public function __construct(array $input) { - $this->size = $input['Size'] ?? null; + $this->size = $input['Size'] ?? $this->throwException(new InvalidArgument('Missing required field "Size".')); } /** @@ -37,4 +39,12 @@ public function getSize(): int { return $this->size; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Lambda/src/ValueObject/FileSystemConfig.php b/src/Service/Lambda/src/ValueObject/FileSystemConfig.php index e0c12f3db..f5e6d48cd 100644 --- a/src/Service/Lambda/src/ValueObject/FileSystemConfig.php +++ b/src/Service/Lambda/src/ValueObject/FileSystemConfig.php @@ -2,6 +2,8 @@ namespace AsyncAws\Lambda\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Details about the connection between a Lambda function and an Amazon EFS file system [^1]. * @@ -27,8 +29,8 @@ final class FileSystemConfig */ public function __construct(array $input) { - $this->arn = $input['Arn'] ?? null; - $this->localMountPath = $input['LocalMountPath'] ?? null; + $this->arn = $input['Arn'] ?? $this->throwException(new InvalidArgument('Missing required field "Arn".')); + $this->localMountPath = $input['LocalMountPath'] ?? $this->throwException(new InvalidArgument('Missing required field "LocalMountPath".')); } /** @@ -51,4 +53,12 @@ public function getLocalMountPath(): string { return $this->localMountPath; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php b/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php index 53c0ab7d6..4ef3f888f 100644 --- a/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php +++ b/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php @@ -22,7 +22,7 @@ final class AccelerationSettings */ public function __construct(array $input) { - $this->mode = $input['Mode'] ?? null; + $this->mode = $input['Mode'] ?? $this->throwException(new InvalidArgument('Missing required field "Mode".')); } /** @@ -59,4 +59,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/MediaConvert/src/ValueObject/Job.php b/src/Service/MediaConvert/src/ValueObject/Job.php index f8f86b6ab..0c3b435b0 100644 --- a/src/Service/MediaConvert/src/ValueObject/Job.php +++ b/src/Service/MediaConvert/src/ValueObject/Job.php @@ -2,6 +2,7 @@ namespace AsyncAws\MediaConvert\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\MediaConvert\Enum\AccelerationStatus; use AsyncAws\MediaConvert\Enum\BillingTagsSource; use AsyncAws\MediaConvert\Enum\JobPhase; @@ -226,8 +227,8 @@ public function __construct(array $input) $this->queue = $input['Queue'] ?? null; $this->queueTransitions = isset($input['QueueTransitions']) ? array_map([QueueTransition::class, 'create'], $input['QueueTransitions']) : null; $this->retryCount = $input['RetryCount'] ?? null; - $this->role = $input['Role'] ?? null; - $this->settings = isset($input['Settings']) ? JobSettings::create($input['Settings']) : null; + $this->role = $input['Role'] ?? $this->throwException(new InvalidArgument('Missing required field "Role".')); + $this->settings = isset($input['Settings']) ? JobSettings::create($input['Settings']) : $this->throwException(new InvalidArgument('Missing required field "Settings".')); $this->simulateReservedQueue = $input['SimulateReservedQueue'] ?? null; $this->status = $input['Status'] ?? null; $this->statusUpdateInterval = $input['StatusUpdateInterval'] ?? null; @@ -439,4 +440,12 @@ public function getWarnings(): array { return $this->warnings ?? []; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/MediaConvert/src/ValueObject/WarningGroup.php b/src/Service/MediaConvert/src/ValueObject/WarningGroup.php index 1067fddb0..3f273f9b5 100644 --- a/src/Service/MediaConvert/src/ValueObject/WarningGroup.php +++ b/src/Service/MediaConvert/src/ValueObject/WarningGroup.php @@ -2,6 +2,8 @@ namespace AsyncAws\MediaConvert\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains any warning codes and their count for the job. */ @@ -26,8 +28,8 @@ final class WarningGroup */ public function __construct(array $input) { - $this->code = $input['Code'] ?? null; - $this->count = $input['Count'] ?? null; + $this->code = $input['Code'] ?? $this->throwException(new InvalidArgument('Missing required field "Code".')); + $this->count = $input['Count'] ?? $this->throwException(new InvalidArgument('Missing required field "Count".')); } /** @@ -50,4 +52,12 @@ public function getCount(): int { return $this->count; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php b/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php index 6a869b70c..adf3fcff2 100644 --- a/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php +++ b/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php @@ -37,8 +37,8 @@ final class HumanLoopConfig */ public function __construct(array $input) { - $this->humanLoopName = $input['HumanLoopName'] ?? null; - $this->flowDefinitionArn = $input['FlowDefinitionArn'] ?? null; + $this->humanLoopName = $input['HumanLoopName'] ?? $this->throwException(new InvalidArgument('Missing required field "HumanLoopName".')); + $this->flowDefinitionArn = $input['FlowDefinitionArn'] ?? $this->throwException(new InvalidArgument('Missing required field "FlowDefinitionArn".')); $this->dataAttributes = isset($input['DataAttributes']) ? HumanLoopDataAttributes::create($input['DataAttributes']) : null; } @@ -89,4 +89,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/AliasTarget.php b/src/Service/Route53/src/ValueObject/AliasTarget.php index 339925bc5..df769e95a 100644 --- a/src/Service/Route53/src/ValueObject/AliasTarget.php +++ b/src/Service/Route53/src/ValueObject/AliasTarget.php @@ -282,9 +282,9 @@ final class AliasTarget */ public function __construct(array $input) { - $this->hostedZoneId = $input['HostedZoneId'] ?? null; - $this->dnsName = $input['DNSName'] ?? null; - $this->evaluateTargetHealth = $input['EvaluateTargetHealth'] ?? null; + $this->hostedZoneId = $input['HostedZoneId'] ?? $this->throwException(new InvalidArgument('Missing required field "HostedZoneId".')); + $this->dnsName = $input['DNSName'] ?? $this->throwException(new InvalidArgument('Missing required field "DNSName".')); + $this->evaluateTargetHealth = $input['EvaluateTargetHealth'] ?? $this->throwException(new InvalidArgument('Missing required field "EvaluateTargetHealth".')); } /** @@ -332,4 +332,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void } $node->appendChild($document->createElement('EvaluateTargetHealth', $v ? 'true' : 'false')); } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/Change.php b/src/Service/Route53/src/ValueObject/Change.php index e8ca22f3a..638ef5f79 100644 --- a/src/Service/Route53/src/ValueObject/Change.php +++ b/src/Service/Route53/src/ValueObject/Change.php @@ -41,8 +41,8 @@ final class Change */ public function __construct(array $input) { - $this->action = $input['Action'] ?? null; - $this->resourceRecordSet = isset($input['ResourceRecordSet']) ? ResourceRecordSet::create($input['ResourceRecordSet']) : null; + $this->action = $input['Action'] ?? $this->throwException(new InvalidArgument('Missing required field "Action".')); + $this->resourceRecordSet = isset($input['ResourceRecordSet']) ? ResourceRecordSet::create($input['ResourceRecordSet']) : $this->throwException(new InvalidArgument('Missing required field "ResourceRecordSet".')); } /** @@ -89,4 +89,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $v->requestBody($child, $document); } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/ChangeBatch.php b/src/Service/Route53/src/ValueObject/ChangeBatch.php index a8981657d..fa5e021a5 100644 --- a/src/Service/Route53/src/ValueObject/ChangeBatch.php +++ b/src/Service/Route53/src/ValueObject/ChangeBatch.php @@ -28,7 +28,7 @@ final class ChangeBatch public function __construct(array $input) { $this->comment = $input['Comment'] ?? null; - $this->changes = isset($input['Changes']) ? array_map([Change::class, 'create'], $input['Changes']) : null; + $this->changes = isset($input['Changes']) ? array_map([Change::class, 'create'], $input['Changes']) : $this->throwException(new InvalidArgument('Missing required field "Changes".')); } /** @@ -47,7 +47,7 @@ public static function create($input): self */ public function getChanges(): array { - return $this->changes ?? []; + return $this->changes; } public function getComment(): ?string @@ -74,4 +74,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $item->requestBody($child, $document); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/ChangeInfo.php b/src/Service/Route53/src/ValueObject/ChangeInfo.php index aaa94a198..ef60fb295 100644 --- a/src/Service/Route53/src/ValueObject/ChangeInfo.php +++ b/src/Service/Route53/src/ValueObject/ChangeInfo.php @@ -2,6 +2,7 @@ namespace AsyncAws\Route53\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\Route53\Enum\ChangeStatus; /** @@ -46,9 +47,9 @@ final class ChangeInfo */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->status = $input['Status'] ?? null; - $this->submittedAt = $input['SubmittedAt'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->status = $input['Status'] ?? $this->throwException(new InvalidArgument('Missing required field "Status".')); + $this->submittedAt = $input['SubmittedAt'] ?? $this->throwException(new InvalidArgument('Missing required field "SubmittedAt".')); $this->comment = $input['Comment'] ?? null; } @@ -87,4 +88,12 @@ public function getSubmittedAt(): \DateTimeImmutable { return $this->submittedAt; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php b/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php index 918195cf7..65b351548 100644 --- a/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php +++ b/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php @@ -31,8 +31,8 @@ final class CidrRoutingConfig */ public function __construct(array $input) { - $this->collectionId = $input['CollectionId'] ?? null; - $this->locationName = $input['LocationName'] ?? null; + $this->collectionId = $input['CollectionId'] ?? $this->throwException(new InvalidArgument('Missing required field "CollectionId".')); + $this->locationName = $input['LocationName'] ?? $this->throwException(new InvalidArgument('Missing required field "LocationName".')); } /** @@ -70,4 +70,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void } $node->appendChild($document->createElement('LocationName', $v)); } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/DelegationSet.php b/src/Service/Route53/src/ValueObject/DelegationSet.php index 8a9aeb576..2735da282 100644 --- a/src/Service/Route53/src/ValueObject/DelegationSet.php +++ b/src/Service/Route53/src/ValueObject/DelegationSet.php @@ -2,6 +2,8 @@ namespace AsyncAws\Route53\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * A complex type that lists the name servers in a delegation set, as well as the `CallerReference` and the `ID` for the * delegation set. @@ -35,7 +37,7 @@ public function __construct(array $input) { $this->id = $input['Id'] ?? null; $this->callerReference = $input['CallerReference'] ?? null; - $this->nameServers = $input['NameServers'] ?? null; + $this->nameServers = $input['NameServers'] ?? $this->throwException(new InvalidArgument('Missing required field "NameServers".')); } /** @@ -65,6 +67,14 @@ public function getId(): ?string */ public function getNameServers(): array { - return $this->nameServers ?? []; + return $this->nameServers; + } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; } } diff --git a/src/Service/Route53/src/ValueObject/HostedZone.php b/src/Service/Route53/src/ValueObject/HostedZone.php index e8c651996..a33a46dfd 100644 --- a/src/Service/Route53/src/ValueObject/HostedZone.php +++ b/src/Service/Route53/src/ValueObject/HostedZone.php @@ -2,6 +2,8 @@ namespace AsyncAws\Route53\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * A complex type that contains general information about the hosted zone. */ @@ -56,9 +58,9 @@ final class HostedZone */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->name = $input['Name'] ?? null; - $this->callerReference = $input['CallerReference'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->callerReference = $input['CallerReference'] ?? $this->throwException(new InvalidArgument('Missing required field "CallerReference".')); $this->config = isset($input['Config']) ? HostedZoneConfig::create($input['Config']) : null; $this->resourceRecordSetCount = $input['ResourceRecordSetCount'] ?? null; $this->linkedService = isset($input['LinkedService']) ? LinkedService::create($input['LinkedService']) : null; @@ -108,4 +110,12 @@ public function getResourceRecordSetCount(): ?int { return $this->resourceRecordSetCount; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/ResourceRecord.php b/src/Service/Route53/src/ValueObject/ResourceRecord.php index f7160203c..135b9c3da 100644 --- a/src/Service/Route53/src/ValueObject/ResourceRecord.php +++ b/src/Service/Route53/src/ValueObject/ResourceRecord.php @@ -31,7 +31,7 @@ final class ResourceRecord */ public function __construct(array $input) { - $this->value = $input['Value'] ?? null; + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -59,4 +59,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void } $node->appendChild($document->createElement('Value', $v)); } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Route53/src/ValueObject/ResourceRecordSet.php b/src/Service/Route53/src/ValueObject/ResourceRecordSet.php index e9e51158a..5182595fb 100644 --- a/src/Service/Route53/src/ValueObject/ResourceRecordSet.php +++ b/src/Service/Route53/src/ValueObject/ResourceRecordSet.php @@ -400,8 +400,8 @@ final class ResourceRecordSet */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; - $this->type = $input['Type'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->type = $input['Type'] ?? $this->throwException(new InvalidArgument('Missing required field "Type".')); $this->setIdentifier = $input['SetIdentifier'] ?? null; $this->weight = $input['Weight'] ?? null; $this->region = $input['Region'] ?? null; @@ -591,4 +591,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $v->requestBody($child, $document); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/CORSConfiguration.php b/src/Service/S3/src/ValueObject/CORSConfiguration.php index 78a8bd006..3877308e2 100644 --- a/src/Service/S3/src/ValueObject/CORSConfiguration.php +++ b/src/Service/S3/src/ValueObject/CORSConfiguration.php @@ -25,7 +25,7 @@ final class CORSConfiguration */ public function __construct(array $input) { - $this->corsRules = isset($input['CORSRules']) ? array_map([CORSRule::class, 'create'], $input['CORSRules']) : null; + $this->corsRules = isset($input['CORSRules']) ? array_map([CORSRule::class, 'create'], $input['CORSRules']) : $this->throwException(new InvalidArgument('Missing required field "CORSRules".')); } /** @@ -43,7 +43,7 @@ public static function create($input): self */ public function getCorsRules(): array { - return $this->corsRules ?? []; + return $this->corsRules; } /** @@ -60,4 +60,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $item->requestBody($child, $document); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/CORSRule.php b/src/Service/S3/src/ValueObject/CORSRule.php index 7ba5f3c61..0f9548728 100644 --- a/src/Service/S3/src/ValueObject/CORSRule.php +++ b/src/Service/S3/src/ValueObject/CORSRule.php @@ -56,8 +56,8 @@ public function __construct(array $input) { $this->id = $input['ID'] ?? null; $this->allowedHeaders = $input['AllowedHeaders'] ?? null; - $this->allowedMethods = $input['AllowedMethods'] ?? null; - $this->allowedOrigins = $input['AllowedOrigins'] ?? null; + $this->allowedMethods = $input['AllowedMethods'] ?? $this->throwException(new InvalidArgument('Missing required field "AllowedMethods".')); + $this->allowedOrigins = $input['AllowedOrigins'] ?? $this->throwException(new InvalidArgument('Missing required field "AllowedOrigins".')); $this->exposeHeaders = $input['ExposeHeaders'] ?? null; $this->maxAgeSeconds = $input['MaxAgeSeconds'] ?? null; } @@ -90,7 +90,7 @@ public function getAllowedHeaders(): array */ public function getAllowedMethods(): array { - return $this->allowedMethods ?? []; + return $this->allowedMethods; } /** @@ -98,7 +98,7 @@ public function getAllowedMethods(): array */ public function getAllowedOrigins(): array { - return $this->allowedOrigins ?? []; + return $this->allowedOrigins; } /** @@ -155,4 +155,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $node->appendChild($document->createElement('MaxAgeSeconds', (string) $v)); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/Delete.php b/src/Service/S3/src/ValueObject/Delete.php index bf0f0b322..6285af01b 100644 --- a/src/Service/S3/src/ValueObject/Delete.php +++ b/src/Service/S3/src/ValueObject/Delete.php @@ -27,7 +27,7 @@ final class Delete */ public function __construct(array $input) { - $this->objects = isset($input['Objects']) ? array_map([ObjectIdentifier::class, 'create'], $input['Objects']) : null; + $this->objects = isset($input['Objects']) ? array_map([ObjectIdentifier::class, 'create'], $input['Objects']) : $this->throwException(new InvalidArgument('Missing required field "Objects".')); $this->quiet = $input['Quiet'] ?? null; } @@ -47,7 +47,7 @@ public static function create($input): self */ public function getObjects(): array { - return $this->objects ?? []; + return $this->objects; } public function getQuiet(): ?bool @@ -73,4 +73,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $node->appendChild($document->createElement('Quiet', $v ? 'true' : 'false')); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/Grantee.php b/src/Service/S3/src/ValueObject/Grantee.php index ed79eec72..f5917cd57 100644 --- a/src/Service/S3/src/ValueObject/Grantee.php +++ b/src/Service/S3/src/ValueObject/Grantee.php @@ -65,7 +65,7 @@ public function __construct(array $input) $this->displayName = $input['DisplayName'] ?? null; $this->emailAddress = $input['EmailAddress'] ?? null; $this->id = $input['ID'] ?? null; - $this->type = $input['Type'] ?? null; + $this->type = $input['Type'] ?? $this->throwException(new InvalidArgument('Missing required field "Type".')); $this->uri = $input['URI'] ?? null; } @@ -136,4 +136,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $node->appendChild($document->createElement('URI', $v)); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php b/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php index 94d616826..f11892df2 100644 --- a/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php +++ b/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php @@ -38,8 +38,8 @@ final class LambdaFunctionConfiguration public function __construct(array $input) { $this->id = $input['Id'] ?? null; - $this->lambdaFunctionArn = $input['LambdaFunctionArn'] ?? null; - $this->events = $input['Events'] ?? null; + $this->lambdaFunctionArn = $input['LambdaFunctionArn'] ?? $this->throwException(new InvalidArgument('Missing required field "LambdaFunctionArn".')); + $this->events = $input['Events'] ?? $this->throwException(new InvalidArgument('Missing required field "Events".')); $this->filter = isset($input['Filter']) ? NotificationConfigurationFilter::create($input['Filter']) : null; } @@ -61,7 +61,7 @@ public static function create($input): self */ public function getEvents(): array { - return $this->events ?? []; + return $this->events; } public function getFilter(): ?NotificationConfigurationFilter @@ -107,4 +107,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $v->requestBody($child, $document); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/ObjectIdentifier.php b/src/Service/S3/src/ValueObject/ObjectIdentifier.php index 7b5a90df4..f60fc9b5e 100644 --- a/src/Service/S3/src/ValueObject/ObjectIdentifier.php +++ b/src/Service/S3/src/ValueObject/ObjectIdentifier.php @@ -32,7 +32,7 @@ final class ObjectIdentifier */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); $this->versionId = $input['VersionId'] ?? null; } @@ -70,4 +70,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $node->appendChild($document->createElement('VersionId', $v)); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/QueueConfiguration.php b/src/Service/S3/src/ValueObject/QueueConfiguration.php index fce17c54a..68140a0f3 100644 --- a/src/Service/S3/src/ValueObject/QueueConfiguration.php +++ b/src/Service/S3/src/ValueObject/QueueConfiguration.php @@ -37,8 +37,8 @@ final class QueueConfiguration public function __construct(array $input) { $this->id = $input['Id'] ?? null; - $this->queueArn = $input['QueueArn'] ?? null; - $this->events = $input['Events'] ?? null; + $this->queueArn = $input['QueueArn'] ?? $this->throwException(new InvalidArgument('Missing required field "QueueArn".')); + $this->events = $input['Events'] ?? $this->throwException(new InvalidArgument('Missing required field "Events".')); $this->filter = isset($input['Filter']) ? NotificationConfigurationFilter::create($input['Filter']) : null; } @@ -60,7 +60,7 @@ public static function create($input): self */ public function getEvents(): array { - return $this->events ?? []; + return $this->events; } public function getFilter(): ?NotificationConfigurationFilter @@ -106,4 +106,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $v->requestBody($child, $document); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/ServerSideEncryptionByDefault.php b/src/Service/S3/src/ValueObject/ServerSideEncryptionByDefault.php index c2adab5b3..186fd138f 100644 --- a/src/Service/S3/src/ValueObject/ServerSideEncryptionByDefault.php +++ b/src/Service/S3/src/ValueObject/ServerSideEncryptionByDefault.php @@ -2,6 +2,7 @@ namespace AsyncAws\S3\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; use AsyncAws\S3\Enum\ServerSideEncryption; /** @@ -49,7 +50,7 @@ final class ServerSideEncryptionByDefault */ public function __construct(array $input) { - $this->sseAlgorithm = $input['SSEAlgorithm'] ?? null; + $this->sseAlgorithm = $input['SSEAlgorithm'] ?? $this->throwException(new InvalidArgument('Missing required field "SSEAlgorithm".')); $this->kmsMasterKeyId = $input['KMSMasterKeyID'] ?? null; } @@ -76,4 +77,12 @@ public function getSseAlgorithm(): string { return $this->sseAlgorithm; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/ServerSideEncryptionConfiguration.php b/src/Service/S3/src/ValueObject/ServerSideEncryptionConfiguration.php index f5d1d9eed..f5035ea73 100644 --- a/src/Service/S3/src/ValueObject/ServerSideEncryptionConfiguration.php +++ b/src/Service/S3/src/ValueObject/ServerSideEncryptionConfiguration.php @@ -2,6 +2,8 @@ namespace AsyncAws\S3\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Specifies the default server-side-encryption configuration. */ @@ -19,7 +21,7 @@ final class ServerSideEncryptionConfiguration */ public function __construct(array $input) { - $this->rules = isset($input['Rules']) ? array_map([ServerSideEncryptionRule::class, 'create'], $input['Rules']) : null; + $this->rules = isset($input['Rules']) ? array_map([ServerSideEncryptionRule::class, 'create'], $input['Rules']) : $this->throwException(new InvalidArgument('Missing required field "Rules".')); } /** @@ -37,6 +39,14 @@ public static function create($input): self */ public function getRules(): array { - return $this->rules ?? []; + return $this->rules; + } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; } } diff --git a/src/Service/S3/src/ValueObject/Tag.php b/src/Service/S3/src/ValueObject/Tag.php index 64b34ec8e..c23a6f989 100644 --- a/src/Service/S3/src/ValueObject/Tag.php +++ b/src/Service/S3/src/ValueObject/Tag.php @@ -27,8 +27,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -66,4 +66,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void } $node->appendChild($document->createElement('Value', $v)); } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/Tagging.php b/src/Service/S3/src/ValueObject/Tagging.php index f6a5e8614..1185af13e 100644 --- a/src/Service/S3/src/ValueObject/Tagging.php +++ b/src/Service/S3/src/ValueObject/Tagging.php @@ -21,7 +21,7 @@ final class Tagging */ public function __construct(array $input) { - $this->tagSet = isset($input['TagSet']) ? array_map([Tag::class, 'create'], $input['TagSet']) : null; + $this->tagSet = isset($input['TagSet']) ? array_map([Tag::class, 'create'], $input['TagSet']) : $this->throwException(new InvalidArgument('Missing required field "TagSet".')); } /** @@ -39,7 +39,7 @@ public static function create($input): self */ public function getTagSet(): array { - return $this->tagSet ?? []; + return $this->tagSet; } /** @@ -58,4 +58,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $item->requestBody($child, $document); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/S3/src/ValueObject/TopicConfiguration.php b/src/Service/S3/src/ValueObject/TopicConfiguration.php index 06dc19bba..860e94c48 100644 --- a/src/Service/S3/src/ValueObject/TopicConfiguration.php +++ b/src/Service/S3/src/ValueObject/TopicConfiguration.php @@ -40,8 +40,8 @@ final class TopicConfiguration public function __construct(array $input) { $this->id = $input['Id'] ?? null; - $this->topicArn = $input['TopicArn'] ?? null; - $this->events = $input['Events'] ?? null; + $this->topicArn = $input['TopicArn'] ?? $this->throwException(new InvalidArgument('Missing required field "TopicArn".')); + $this->events = $input['Events'] ?? $this->throwException(new InvalidArgument('Missing required field "Events".')); $this->filter = isset($input['Filter']) ? NotificationConfigurationFilter::create($input['Filter']) : null; } @@ -63,7 +63,7 @@ public static function create($input): self */ public function getEvents(): array { - return $this->events ?? []; + return $this->events; } public function getFilter(): ?NotificationConfigurationFilter @@ -109,4 +109,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $v->requestBody($child, $document); } } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php b/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php index dd7f1d5d6..d9dd7c2c4 100644 --- a/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php +++ b/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php @@ -41,7 +41,7 @@ public function __construct(array $input) { $this->assignPublicIp = $input['AssignPublicIp'] ?? null; $this->securityGroups = $input['SecurityGroups'] ?? null; - $this->subnets = $input['Subnets'] ?? null; + $this->subnets = $input['Subnets'] ?? $this->throwException(new InvalidArgument('Missing required field "Subnets".')); } /** @@ -77,7 +77,7 @@ public function getSecurityGroups(): array */ public function getSubnets(): array { - return $this->subnets ?? []; + return $this->subnets; } /** @@ -113,4 +113,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php b/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php index c7615eded..1b94c063b 100644 --- a/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php +++ b/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php @@ -38,7 +38,7 @@ final class CapacityProviderStrategyItem public function __construct(array $input) { $this->base = $input['base'] ?? null; - $this->capacityProvider = $input['capacityProvider'] ?? null; + $this->capacityProvider = $input['capacityProvider'] ?? $this->throwException(new InvalidArgument('Missing required field "capacityProvider".')); $this->weight = $input['weight'] ?? null; } @@ -88,4 +88,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/EcsParameters.php b/src/Service/Scheduler/src/ValueObject/EcsParameters.php index 06545e1e4..f1fd4384a 100644 --- a/src/Service/Scheduler/src/ValueObject/EcsParameters.php +++ b/src/Service/Scheduler/src/ValueObject/EcsParameters.php @@ -134,7 +134,7 @@ public function __construct(array $input) $this->referenceId = $input['ReferenceId'] ?? null; $this->tags = $input['Tags'] ?? null; $this->taskCount = $input['TaskCount'] ?? null; - $this->taskDefinitionArn = $input['TaskDefinitionArn'] ?? null; + $this->taskDefinitionArn = $input['TaskDefinitionArn'] ?? $this->throwException(new InvalidArgument('Missing required field "TaskDefinitionArn".')); } /** @@ -334,4 +334,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php b/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php index bb030b47d..b26ed25b9 100644 --- a/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php +++ b/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php @@ -29,8 +29,8 @@ final class EventBridgeParameters */ public function __construct(array $input) { - $this->detailType = $input['DetailType'] ?? null; - $this->source = $input['Source'] ?? null; + $this->detailType = $input['DetailType'] ?? $this->throwException(new InvalidArgument('Missing required field "DetailType".')); + $this->source = $input['Source'] ?? $this->throwException(new InvalidArgument('Missing required field "Source".')); } /** @@ -71,4 +71,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php b/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php index 2a9ddad56..9aa8e4e04 100644 --- a/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php +++ b/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php @@ -29,7 +29,7 @@ final class FlexibleTimeWindow public function __construct(array $input) { $this->maximumWindowInMinutes = $input['MaximumWindowInMinutes'] ?? null; - $this->mode = $input['Mode'] ?? null; + $this->mode = $input['Mode'] ?? $this->throwException(new InvalidArgument('Missing required field "Mode".')); } /** @@ -75,4 +75,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/KinesisParameters.php b/src/Service/Scheduler/src/ValueObject/KinesisParameters.php index fd4e4831a..410d273ae 100644 --- a/src/Service/Scheduler/src/ValueObject/KinesisParameters.php +++ b/src/Service/Scheduler/src/ValueObject/KinesisParameters.php @@ -26,7 +26,7 @@ final class KinesisParameters */ public function __construct(array $input) { - $this->partitionKey = $input['PartitionKey'] ?? null; + $this->partitionKey = $input['PartitionKey'] ?? $this->throwException(new InvalidArgument('Missing required field "PartitionKey".')); } /** @@ -57,4 +57,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php b/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php index 09958504a..cdfa039b3 100644 --- a/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php +++ b/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php @@ -27,8 +27,8 @@ final class SageMakerPipelineParameter */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; - $this->value = $input['Value'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/Tag.php b/src/Service/Scheduler/src/ValueObject/Tag.php index 95bf11a57..9ab94b5f7 100644 --- a/src/Service/Scheduler/src/ValueObject/Tag.php +++ b/src/Service/Scheduler/src/ValueObject/Tag.php @@ -27,8 +27,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/Target.php b/src/Service/Scheduler/src/ValueObject/Target.php index ab6990d68..1f1bf807e 100644 --- a/src/Service/Scheduler/src/ValueObject/Target.php +++ b/src/Service/Scheduler/src/ValueObject/Target.php @@ -98,14 +98,14 @@ final class Target */ public function __construct(array $input) { - $this->arn = $input['Arn'] ?? null; + $this->arn = $input['Arn'] ?? $this->throwException(new InvalidArgument('Missing required field "Arn".')); $this->deadLetterConfig = isset($input['DeadLetterConfig']) ? DeadLetterConfig::create($input['DeadLetterConfig']) : null; $this->ecsParameters = isset($input['EcsParameters']) ? EcsParameters::create($input['EcsParameters']) : null; $this->eventBridgeParameters = isset($input['EventBridgeParameters']) ? EventBridgeParameters::create($input['EventBridgeParameters']) : null; $this->input = $input['Input'] ?? null; $this->kinesisParameters = isset($input['KinesisParameters']) ? KinesisParameters::create($input['KinesisParameters']) : null; $this->retryPolicy = isset($input['RetryPolicy']) ? RetryPolicy::create($input['RetryPolicy']) : null; - $this->roleArn = $input['RoleArn'] ?? null; + $this->roleArn = $input['RoleArn'] ?? $this->throwException(new InvalidArgument('Missing required field "RoleArn".')); $this->sageMakerPipelineParameters = isset($input['SageMakerPipelineParameters']) ? SageMakerPipelineParameters::create($input['SageMakerPipelineParameters']) : null; $this->sqsParameters = isset($input['SqsParameters']) ? SqsParameters::create($input['SqsParameters']) : null; } @@ -220,4 +220,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Scheduler/src/ValueObject/TargetSummary.php b/src/Service/Scheduler/src/ValueObject/TargetSummary.php index 9b22a9346..6a0365241 100644 --- a/src/Service/Scheduler/src/ValueObject/TargetSummary.php +++ b/src/Service/Scheduler/src/ValueObject/TargetSummary.php @@ -2,6 +2,8 @@ namespace AsyncAws\Scheduler\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * The details of a target. */ @@ -19,7 +21,7 @@ final class TargetSummary */ public function __construct(array $input) { - $this->arn = $input['Arn'] ?? null; + $this->arn = $input['Arn'] ?? $this->throwException(new InvalidArgument('Missing required field "Arn".')); } /** @@ -36,4 +38,12 @@ public function getArn(): string { return $this->arn; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Ses/src/ValueObject/Content.php b/src/Service/Ses/src/ValueObject/Content.php index 74b93a8b2..38f70a2c9 100644 --- a/src/Service/Ses/src/ValueObject/Content.php +++ b/src/Service/Ses/src/ValueObject/Content.php @@ -29,7 +29,7 @@ final class Content */ public function __construct(array $input) { - $this->data = $input['Data'] ?? null; + $this->data = $input['Data'] ?? $this->throwException(new InvalidArgument('Missing required field "Data".')); $this->charset = $input['Charset'] ?? null; } @@ -70,4 +70,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Ses/src/ValueObject/ListManagementOptions.php b/src/Service/Ses/src/ValueObject/ListManagementOptions.php index 0e4eead09..815f21874 100644 --- a/src/Service/Ses/src/ValueObject/ListManagementOptions.php +++ b/src/Service/Ses/src/ValueObject/ListManagementOptions.php @@ -28,7 +28,7 @@ final class ListManagementOptions */ public function __construct(array $input) { - $this->contactListName = $input['ContactListName'] ?? null; + $this->contactListName = $input['ContactListName'] ?? $this->throwException(new InvalidArgument('Missing required field "ContactListName".')); $this->topicName = $input['TopicName'] ?? null; } @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Ses/src/ValueObject/Message.php b/src/Service/Ses/src/ValueObject/Message.php index 313fe3600..2e984f783 100644 --- a/src/Service/Ses/src/ValueObject/Message.php +++ b/src/Service/Ses/src/ValueObject/Message.php @@ -30,8 +30,8 @@ final class Message */ public function __construct(array $input) { - $this->subject = isset($input['Subject']) ? Content::create($input['Subject']) : null; - $this->body = isset($input['Body']) ? Body::create($input['Body']) : null; + $this->subject = isset($input['Subject']) ? Content::create($input['Subject']) : $this->throwException(new InvalidArgument('Missing required field "Subject".')); + $this->body = isset($input['Body']) ? Body::create($input['Body']) : $this->throwException(new InvalidArgument('Missing required field "Body".')); } /** @@ -72,4 +72,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Ses/src/ValueObject/MessageTag.php b/src/Service/Ses/src/ValueObject/MessageTag.php index 0060ad2d0..fd530de14 100644 --- a/src/Service/Ses/src/ValueObject/MessageTag.php +++ b/src/Service/Ses/src/ValueObject/MessageTag.php @@ -34,8 +34,8 @@ final class MessageTag */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; - $this->value = $input['Value'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -76,4 +76,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Ses/src/ValueObject/RawMessage.php b/src/Service/Ses/src/ValueObject/RawMessage.php index 8c3879f40..b4ad245c2 100644 --- a/src/Service/Ses/src/ValueObject/RawMessage.php +++ b/src/Service/Ses/src/ValueObject/RawMessage.php @@ -33,7 +33,7 @@ final class RawMessage */ public function __construct(array $input) { - $this->data = $input['Data'] ?? null; + $this->data = $input['Data'] ?? $this->throwException(new InvalidArgument('Missing required field "Data".')); } /** @@ -64,4 +64,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sns/src/ValueObject/BatchResultErrorEntry.php b/src/Service/Sns/src/ValueObject/BatchResultErrorEntry.php index b20150e24..989a2b137 100644 --- a/src/Service/Sns/src/ValueObject/BatchResultErrorEntry.php +++ b/src/Service/Sns/src/ValueObject/BatchResultErrorEntry.php @@ -2,6 +2,8 @@ namespace AsyncAws\Sns\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Gives a detailed description of failed messages in the batch. */ @@ -37,10 +39,10 @@ final class BatchResultErrorEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->code = $input['Code'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->code = $input['Code'] ?? $this->throwException(new InvalidArgument('Missing required field "Code".')); $this->message = $input['Message'] ?? null; - $this->senderFault = $input['SenderFault'] ?? null; + $this->senderFault = $input['SenderFault'] ?? $this->throwException(new InvalidArgument('Missing required field "SenderFault".')); } /** @@ -75,4 +77,12 @@ public function getSenderFault(): bool { return $this->senderFault; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sns/src/ValueObject/MessageAttributeValue.php b/src/Service/Sns/src/ValueObject/MessageAttributeValue.php index 5c5192a5e..e9d95697a 100644 --- a/src/Service/Sns/src/ValueObject/MessageAttributeValue.php +++ b/src/Service/Sns/src/ValueObject/MessageAttributeValue.php @@ -48,7 +48,7 @@ final class MessageAttributeValue */ public function __construct(array $input) { - $this->dataType = $input['DataType'] ?? null; + $this->dataType = $input['DataType'] ?? $this->throwException(new InvalidArgument('Missing required field "DataType".')); $this->stringValue = $input['StringValue'] ?? null; $this->binaryValue = $input['BinaryValue'] ?? null; } @@ -99,4 +99,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php b/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php index 83fd03ba5..12295b939 100644 --- a/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php +++ b/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php @@ -122,8 +122,8 @@ final class PublishBatchRequestEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->message = $input['Message'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->message = $input['Message'] ?? $this->throwException(new InvalidArgument('Missing required field "Message".')); $this->subject = $input['Subject'] ?? null; $this->messageStructure = $input['MessageStructure'] ?? null; $this->messageAttributes = isset($input['MessageAttributes']) ? array_map([MessageAttributeValue::class, 'create'], $input['MessageAttributes']) : null; @@ -224,4 +224,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sns/src/ValueObject/Tag.php b/src/Service/Sns/src/ValueObject/Tag.php index 81ed35a8a..dc8dcbc15 100644 --- a/src/Service/Sns/src/ValueObject/Tag.php +++ b/src/Service/Sns/src/ValueObject/Tag.php @@ -27,8 +27,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -69,4 +69,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/BatchResultErrorEntry.php b/src/Service/Sqs/src/ValueObject/BatchResultErrorEntry.php index 0bb24a59f..1ffbc8c74 100644 --- a/src/Service/Sqs/src/ValueObject/BatchResultErrorEntry.php +++ b/src/Service/Sqs/src/ValueObject/BatchResultErrorEntry.php @@ -2,6 +2,8 @@ namespace AsyncAws\Sqs\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Gives a detailed description of the result of an action on each entry in the request. */ @@ -37,9 +39,9 @@ final class BatchResultErrorEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->senderFault = $input['SenderFault'] ?? null; - $this->code = $input['Code'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->senderFault = $input['SenderFault'] ?? $this->throwException(new InvalidArgument('Missing required field "SenderFault".')); + $this->code = $input['Code'] ?? $this->throwException(new InvalidArgument('Missing required field "Code".')); $this->message = $input['Message'] ?? null; } @@ -75,4 +77,12 @@ public function getSenderFault(): bool { return $this->senderFault; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php b/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php index 52524cbf2..430b8e22a 100644 --- a/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php +++ b/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php @@ -38,8 +38,8 @@ final class ChangeMessageVisibilityBatchRequestEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->receiptHandle = $input['ReceiptHandle'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->receiptHandle = $input['ReceiptHandle'] ?? $this->throwException(new InvalidArgument('Missing required field "ReceiptHandle".')); $this->visibilityTimeout = $input['VisibilityTimeout'] ?? null; } @@ -90,4 +90,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchResultEntry.php b/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchResultEntry.php index 0095972de..97f7680c0 100644 --- a/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchResultEntry.php +++ b/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchResultEntry.php @@ -2,6 +2,8 @@ namespace AsyncAws\Sqs\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Encloses the `Id` of an entry in `ChangeMessageVisibilityBatch.`. */ @@ -19,7 +21,7 @@ final class ChangeMessageVisibilityBatchResultEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); } /** @@ -36,4 +38,12 @@ public function getId(): string { return $this->id; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php b/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php index 5bc3e7e3c..5e72063fd 100644 --- a/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php +++ b/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php @@ -32,8 +32,8 @@ final class DeleteMessageBatchRequestEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->receiptHandle = $input['ReceiptHandle'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->receiptHandle = $input['ReceiptHandle'] ?? $this->throwException(new InvalidArgument('Missing required field "ReceiptHandle".')); } /** @@ -74,4 +74,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/DeleteMessageBatchResultEntry.php b/src/Service/Sqs/src/ValueObject/DeleteMessageBatchResultEntry.php index 964d554d4..4bc4a8842 100644 --- a/src/Service/Sqs/src/ValueObject/DeleteMessageBatchResultEntry.php +++ b/src/Service/Sqs/src/ValueObject/DeleteMessageBatchResultEntry.php @@ -2,6 +2,8 @@ namespace AsyncAws\Sqs\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Encloses the `Id` of an entry in `DeleteMessageBatch.`. */ @@ -19,7 +21,7 @@ final class DeleteMessageBatchResultEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); } /** @@ -36,4 +38,12 @@ public function getId(): string { return $this->id; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php b/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php index 602f252f7..6ead4284c 100644 --- a/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php +++ b/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php @@ -61,7 +61,7 @@ public function __construct(array $input) $this->binaryValue = $input['BinaryValue'] ?? null; $this->stringListValues = $input['StringListValues'] ?? null; $this->binaryListValues = $input['BinaryListValues'] ?? null; - $this->dataType = $input['DataType'] ?? null; + $this->dataType = $input['DataType'] ?? $this->throwException(new InvalidArgument('Missing required field "DataType".')); } /** @@ -142,4 +142,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php b/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php index 4f88c16ee..d85feef99 100644 --- a/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php +++ b/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php @@ -60,7 +60,7 @@ public function __construct(array $input) $this->binaryValue = $input['BinaryValue'] ?? null; $this->stringListValues = $input['StringListValues'] ?? null; $this->binaryListValues = $input['BinaryListValues'] ?? null; - $this->dataType = $input['DataType'] ?? null; + $this->dataType = $input['DataType'] ?? $this->throwException(new InvalidArgument('Missing required field "DataType".')); } /** @@ -141,4 +141,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php b/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php index fac632964..7af7a9fb7 100644 --- a/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php +++ b/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php @@ -135,8 +135,8 @@ final class SendMessageBatchRequestEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->messageBody = $input['MessageBody'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->messageBody = $input['MessageBody'] ?? $this->throwException(new InvalidArgument('Missing required field "MessageBody".')); $this->delaySeconds = $input['DelaySeconds'] ?? null; $this->messageAttributes = isset($input['MessageAttributes']) ? array_map([MessageAttributeValue::class, 'create'], $input['MessageAttributes']) : null; $this->messageSystemAttributes = isset($input['MessageSystemAttributes']) ? array_map([MessageSystemAttributeValue::class, 'create'], $input['MessageSystemAttributes']) : null; @@ -250,4 +250,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Sqs/src/ValueObject/SendMessageBatchResultEntry.php b/src/Service/Sqs/src/ValueObject/SendMessageBatchResultEntry.php index 6285ea08f..15c65d816 100644 --- a/src/Service/Sqs/src/ValueObject/SendMessageBatchResultEntry.php +++ b/src/Service/Sqs/src/ValueObject/SendMessageBatchResultEntry.php @@ -2,6 +2,8 @@ namespace AsyncAws\Sqs\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Encloses a `MessageId` for a successfully-enqueued message in a `SendMessageBatch.`. */ @@ -66,9 +68,9 @@ final class SendMessageBatchResultEntry */ public function __construct(array $input) { - $this->id = $input['Id'] ?? null; - $this->messageId = $input['MessageId'] ?? null; - $this->md5OfMessageBody = $input['MD5OfMessageBody'] ?? null; + $this->id = $input['Id'] ?? $this->throwException(new InvalidArgument('Missing required field "Id".')); + $this->messageId = $input['MessageId'] ?? $this->throwException(new InvalidArgument('Missing required field "MessageId".')); + $this->md5OfMessageBody = $input['MD5OfMessageBody'] ?? $this->throwException(new InvalidArgument('Missing required field "MD5OfMessageBody".')); $this->md5OfMessageAttributes = $input['MD5OfMessageAttributes'] ?? null; $this->md5OfMessageSystemAttributes = $input['MD5OfMessageSystemAttributes'] ?? null; $this->sequenceNumber = $input['SequenceNumber'] ?? null; @@ -118,4 +120,12 @@ public function getSequenceNumber(): ?string { return $this->sequenceNumber; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php b/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php index eb5cbcb86..e89a644ce 100644 --- a/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php +++ b/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php @@ -51,7 +51,7 @@ final class ParameterStringFilter */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); $this->option = $input['Option'] ?? null; $this->values = $input['Values'] ?? null; } @@ -110,4 +110,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/Ssm/src/ValueObject/Tag.php b/src/Service/Ssm/src/ValueObject/Tag.php index 2d9b971f5..94bc0ca38 100644 --- a/src/Service/Ssm/src/ValueObject/Tag.php +++ b/src/Service/Ssm/src/ValueObject/Tag.php @@ -30,8 +30,8 @@ final class Tag */ public function __construct(array $input) { - $this->key = $input['Key'] ?? null; - $this->value = $input['Value'] ?? null; + $this->key = $input['Key'] ?? $this->throwException(new InvalidArgument('Missing required field "Key".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -72,4 +72,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/TimestreamQuery/src/ValueObject/ColumnInfo.php b/src/Service/TimestreamQuery/src/ValueObject/ColumnInfo.php index 1f72b4cd1..0eaf1712c 100644 --- a/src/Service/TimestreamQuery/src/ValueObject/ColumnInfo.php +++ b/src/Service/TimestreamQuery/src/ValueObject/ColumnInfo.php @@ -2,6 +2,8 @@ namespace AsyncAws\TimestreamQuery\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Contains the metadata for query results such as the column names, data types, and other attributes. */ @@ -28,7 +30,7 @@ final class ColumnInfo public function __construct(array $input) { $this->name = $input['Name'] ?? null; - $this->type = isset($input['Type']) ? Type::create($input['Type']) : null; + $this->type = isset($input['Type']) ? Type::create($input['Type']) : $this->throwException(new InvalidArgument('Missing required field "Type".')); } /** @@ -51,4 +53,12 @@ public function getType(): Type { return $this->type; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/TimestreamQuery/src/ValueObject/Endpoint.php b/src/Service/TimestreamQuery/src/ValueObject/Endpoint.php index 23bddcf95..d7b361df7 100644 --- a/src/Service/TimestreamQuery/src/ValueObject/Endpoint.php +++ b/src/Service/TimestreamQuery/src/ValueObject/Endpoint.php @@ -3,6 +3,7 @@ namespace AsyncAws\TimestreamQuery\ValueObject; use AsyncAws\Core\EndpointDiscovery\EndpointInterface; +use AsyncAws\Core\Exception\InvalidArgument; /** * Represents an available endpoint against which to make API calls against, as well as the TTL for that endpoint. @@ -27,8 +28,8 @@ final class Endpoint implements EndpointInterface */ public function __construct(array $input) { - $this->address = $input['Address'] ?? null; - $this->cachePeriodInMinutes = $input['CachePeriodInMinutes'] ?? null; + $this->address = $input['Address'] ?? $this->throwException(new InvalidArgument('Missing required field "Address".')); + $this->cachePeriodInMinutes = $input['CachePeriodInMinutes'] ?? $this->throwException(new InvalidArgument('Missing required field "CachePeriodInMinutes".')); } /** @@ -51,4 +52,12 @@ public function getCachePeriodInMinutes(): int { return $this->cachePeriodInMinutes; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/TimestreamQuery/src/ValueObject/ParameterMapping.php b/src/Service/TimestreamQuery/src/ValueObject/ParameterMapping.php index 43e049abb..36104916b 100644 --- a/src/Service/TimestreamQuery/src/ValueObject/ParameterMapping.php +++ b/src/Service/TimestreamQuery/src/ValueObject/ParameterMapping.php @@ -2,6 +2,8 @@ namespace AsyncAws\TimestreamQuery\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Mapping for named parameters. */ @@ -22,8 +24,8 @@ final class ParameterMapping */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; - $this->type = isset($input['Type']) ? Type::create($input['Type']) : null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->type = isset($input['Type']) ? Type::create($input['Type']) : $this->throwException(new InvalidArgument('Missing required field "Type".')); } /** @@ -46,4 +48,12 @@ public function getType(): Type { return $this->type; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/TimestreamQuery/src/ValueObject/Row.php b/src/Service/TimestreamQuery/src/ValueObject/Row.php index 4927132a5..7bf522c61 100644 --- a/src/Service/TimestreamQuery/src/ValueObject/Row.php +++ b/src/Service/TimestreamQuery/src/ValueObject/Row.php @@ -2,6 +2,8 @@ namespace AsyncAws\TimestreamQuery\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * Represents a single row in the query results. */ @@ -19,7 +21,7 @@ final class Row */ public function __construct(array $input) { - $this->data = isset($input['Data']) ? array_map([Datum::class, 'create'], $input['Data']) : null; + $this->data = isset($input['Data']) ? array_map([Datum::class, 'create'], $input['Data']) : $this->throwException(new InvalidArgument('Missing required field "Data".')); } /** @@ -37,6 +39,14 @@ public static function create($input): self */ public function getData(): array { - return $this->data ?? []; + return $this->data; + } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; } } diff --git a/src/Service/TimestreamQuery/src/ValueObject/TimeSeriesDataPoint.php b/src/Service/TimestreamQuery/src/ValueObject/TimeSeriesDataPoint.php index b69730754..291120088 100644 --- a/src/Service/TimestreamQuery/src/ValueObject/TimeSeriesDataPoint.php +++ b/src/Service/TimestreamQuery/src/ValueObject/TimeSeriesDataPoint.php @@ -2,6 +2,8 @@ namespace AsyncAws\TimestreamQuery\ValueObject; +use AsyncAws\Core\Exception\InvalidArgument; + /** * The timeseries data type represents the values of a measure over time. A time series is an array of rows of * timestamps and measure values, with rows sorted in ascending order of time. A TimeSeriesDataPoint is a single data @@ -27,8 +29,8 @@ final class TimeSeriesDataPoint */ public function __construct(array $input) { - $this->time = $input['Time'] ?? null; - $this->value = isset($input['Value']) ? Datum::create($input['Value']) : null; + $this->time = $input['Time'] ?? $this->throwException(new InvalidArgument('Missing required field "Time".')); + $this->value = isset($input['Value']) ? Datum::create($input['Value']) : $this->throwException(new InvalidArgument('Missing required field "Value".')); } /** @@ -51,4 +53,12 @@ public function getValue(): Datum { return $this->value; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/TimestreamWrite/src/ValueObject/Dimension.php b/src/Service/TimestreamWrite/src/ValueObject/Dimension.php index 47f6201d6..a943d9602 100644 --- a/src/Service/TimestreamWrite/src/ValueObject/Dimension.php +++ b/src/Service/TimestreamWrite/src/ValueObject/Dimension.php @@ -40,8 +40,8 @@ final class Dimension */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; - $this->value = $input['Value'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); $this->dimensionValueType = $input['DimensionValueType'] ?? null; } @@ -98,4 +98,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/TimestreamWrite/src/ValueObject/Endpoint.php b/src/Service/TimestreamWrite/src/ValueObject/Endpoint.php index a99689e1c..1ffecfc34 100644 --- a/src/Service/TimestreamWrite/src/ValueObject/Endpoint.php +++ b/src/Service/TimestreamWrite/src/ValueObject/Endpoint.php @@ -3,6 +3,7 @@ namespace AsyncAws\TimestreamWrite\ValueObject; use AsyncAws\Core\EndpointDiscovery\EndpointInterface; +use AsyncAws\Core\Exception\InvalidArgument; /** * Represents an available endpoint against which to make API calls against, as well as the TTL for that endpoint. @@ -27,8 +28,8 @@ final class Endpoint implements EndpointInterface */ public function __construct(array $input) { - $this->address = $input['Address'] ?? null; - $this->cachePeriodInMinutes = $input['CachePeriodInMinutes'] ?? null; + $this->address = $input['Address'] ?? $this->throwException(new InvalidArgument('Missing required field "Address".')); + $this->cachePeriodInMinutes = $input['CachePeriodInMinutes'] ?? $this->throwException(new InvalidArgument('Missing required field "CachePeriodInMinutes".')); } /** @@ -51,4 +52,12 @@ public function getCachePeriodInMinutes(): int { return $this->cachePeriodInMinutes; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } diff --git a/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php b/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php index 919001fb5..58e2d236f 100644 --- a/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php +++ b/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php @@ -44,9 +44,9 @@ final class MeasureValue */ public function __construct(array $input) { - $this->name = $input['Name'] ?? null; - $this->value = $input['Value'] ?? null; - $this->type = $input['Type'] ?? null; + $this->name = $input['Name'] ?? $this->throwException(new InvalidArgument('Missing required field "Name".')); + $this->value = $input['Value'] ?? $this->throwException(new InvalidArgument('Missing required field "Value".')); + $this->type = $input['Type'] ?? $this->throwException(new InvalidArgument('Missing required field "Type".')); } /** @@ -103,4 +103,12 @@ public function requestBody(): array return $payload; } + + /** + * @return never + */ + private function throwException(\Throwable $exception) + { + throw $exception; + } } From bc0a48ee323f9265892455b07bbbe7abe9c87e57 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 1 Jul 2023 17:06:45 +0200 Subject: [PATCH 4/4] Remove checks for missing properties for value object request bodies This is already validated in the constructor now. --- .../src/Generator/InputGenerator.php | 2 +- .../src/Generator/ObjectGenerator.php | 2 +- .../RequestSerializer/QuerySerializer.php | 15 ++++++++++----- .../RequestSerializer/RestJsonSerializer.php | 15 ++++++++++----- .../RequestSerializer/RestXmlSerializer.php | 15 ++++++++++----- .../Generator/RequestSerializer/Serializer.php | 2 +- src/Core/src/Sts/ValueObject/Tag.php | 8 ++------ .../AppSync/src/ValueObject/AppSyncRuntime.php | 8 ++------ .../src/ValueObject/AuthorizationConfig.php | 4 +--- .../AppSync/src/ValueObject/CachingConfig.php | 4 +--- .../src/ValueObject/DynamodbDataSourceConfig.php | 8 ++------ .../ElasticsearchDataSourceConfig.php | 8 ++------ .../ValueObject/EventBridgeDataSourceConfig.php | 4 +--- .../src/ValueObject/LambdaDataSourceConfig.php | 4 +--- .../OpenSearchServiceDataSourceConfig.php | 8 ++------ .../Athena/src/ValueObject/AclConfiguration.php | 4 +--- .../src/ValueObject/EncryptionConfiguration.php | 4 +--- .../src/ValueObject/EngineConfiguration.php | 4 +--- .../ResultReuseByAgeConfiguration.php | 4 +--- .../src/ValueObject/InvalidationBatch.php | 8 ++------ src/Service/CloudFront/src/ValueObject/Paths.php | 4 +--- .../CloudWatch/src/ValueObject/Dimension.php | 8 ++------ .../src/ValueObject/DimensionFilter.php | 4 +--- .../src/ValueObject/MetricDataQuery.php | 4 +--- .../CloudWatch/src/ValueObject/MetricDatum.php | 4 +--- .../CloudWatch/src/ValueObject/MetricStat.php | 12 +++--------- .../CloudWatch/src/ValueObject/StatisticSet.php | 16 ++++------------ .../src/ValueObject/InputLogEvent.php | 8 ++------ .../src/ValueObject/CloudWatchLogsConfig.php | 4 +--- .../src/ValueObject/EnvironmentVariable.php | 8 ++------ .../src/ValueObject/GitSubmodulesConfig.php | 4 +--- .../src/ValueObject/ProjectArtifacts.php | 4 +--- .../CodeBuild/src/ValueObject/ProjectCache.php | 4 +--- .../CodeBuild/src/ValueObject/ProjectSource.php | 4 +--- .../src/ValueObject/ProjectSourceVersion.php | 8 ++------ .../src/ValueObject/RegistryCredential.php | 8 ++------ .../CodeBuild/src/ValueObject/S3LogsConfig.php | 4 +--- .../CodeBuild/src/ValueObject/SourceAuth.php | 4 +--- .../src/ValueObject/RepositoryTrigger.php | 12 +++--------- .../src/ValueObject/AttributeType.php | 4 +--- .../src/ValueObject/ContextDataType.php | 16 ++++------------ .../src/ValueObject/AttributeDefinition.php | 8 ++------ .../DynamoDb/src/ValueObject/Condition.php | 4 +--- .../DynamoDb/src/ValueObject/ConditionCheck.php | 12 +++--------- .../CreateGlobalSecondaryIndexAction.php | 12 +++--------- .../CreateReplicationGroupMemberAction.php | 4 +--- src/Service/DynamoDb/src/ValueObject/Delete.php | 8 ++------ .../DeleteGlobalSecondaryIndexAction.php | 4 +--- .../DeleteReplicationGroupMemberAction.php | 4 +--- .../DynamoDb/src/ValueObject/DeleteRequest.php | 4 +--- .../src/ValueObject/GlobalSecondaryIndex.php | 12 +++--------- .../src/ValueObject/KeySchemaElement.php | 8 ++------ .../src/ValueObject/KeysAndAttributes.php | 4 +--- .../src/ValueObject/LocalSecondaryIndex.php | 12 +++--------- .../src/ValueObject/ProvisionedThroughput.php | 8 ++------ src/Service/DynamoDb/src/ValueObject/Put.php | 8 ++------ .../DynamoDb/src/ValueObject/PutRequest.php | 4 +--- .../ValueObject/ReplicaGlobalSecondaryIndex.php | 4 +--- .../src/ValueObject/StreamSpecification.php | 4 +--- src/Service/DynamoDb/src/ValueObject/Tag.php | 8 ++------ .../src/ValueObject/TimeToLiveSpecification.php | 8 ++------ src/Service/DynamoDb/src/ValueObject/Update.php | 12 +++--------- .../UpdateGlobalSecondaryIndexAction.php | 8 ++------ .../UpdateReplicationGroupMemberAction.php | 4 +--- src/Service/Firehose/src/ValueObject/Record.php | 4 +--- src/Service/Iam/src/ValueObject/Tag.php | 8 ++------ src/Service/Iot/src/ValueObject/Tag.php | 4 +--- .../src/ValueObject/PutRecordsRequestEntry.php | 8 ++------ .../Kinesis/src/ValueObject/ShardFilter.php | 4 +--- .../src/ValueObject/StreamModeDetails.php | 4 +--- src/Service/Kms/src/ValueObject/Tag.php | 8 ++------ .../src/ValueObject/AccelerationSettings.php | 4 +--- .../src/ValueObject/HumanLoopConfig.php | 8 ++------ .../Route53/src/ValueObject/AliasTarget.php | 12 +++--------- src/Service/Route53/src/ValueObject/Change.php | 8 ++------ .../Route53/src/ValueObject/ChangeBatch.php | 4 +--- .../src/ValueObject/CidrRoutingConfig.php | 8 ++------ .../Route53/src/ValueObject/ResourceRecord.php | 4 +--- .../src/ValueObject/ResourceRecordSet.php | 8 ++------ .../S3/src/ValueObject/CORSConfiguration.php | 4 +--- src/Service/S3/src/ValueObject/CORSRule.php | 8 ++------ src/Service/S3/src/ValueObject/Delete.php | 4 +--- src/Service/S3/src/ValueObject/Grantee.php | 4 +--- .../ValueObject/LambdaFunctionConfiguration.php | 8 ++------ .../S3/src/ValueObject/ObjectIdentifier.php | 4 +--- .../S3/src/ValueObject/QueueConfiguration.php | 8 ++------ src/Service/S3/src/ValueObject/Tag.php | 8 ++------ src/Service/S3/src/ValueObject/Tagging.php | 4 +--- .../S3/src/ValueObject/TopicConfiguration.php | 8 ++------ .../src/ValueObject/AwsVpcConfiguration.php | 4 +--- .../ValueObject/CapacityProviderStrategyItem.php | 4 +--- .../Scheduler/src/ValueObject/EcsParameters.php | 4 +--- .../src/ValueObject/EventBridgeParameters.php | 8 ++------ .../src/ValueObject/FlexibleTimeWindow.php | 4 +--- .../src/ValueObject/KinesisParameters.php | 4 +--- .../ValueObject/SageMakerPipelineParameter.php | 8 ++------ src/Service/Scheduler/src/ValueObject/Tag.php | 8 ++------ src/Service/Scheduler/src/ValueObject/Target.php | 8 ++------ src/Service/Ses/src/ValueObject/Content.php | 4 +--- .../src/ValueObject/ListManagementOptions.php | 4 +--- src/Service/Ses/src/ValueObject/Message.php | 8 ++------ src/Service/Ses/src/ValueObject/MessageTag.php | 8 ++------ src/Service/Ses/src/ValueObject/RawMessage.php | 4 +--- .../src/ValueObject/MessageAttributeValue.php | 4 +--- .../src/ValueObject/PublishBatchRequestEntry.php | 8 ++------ src/Service/Sns/src/ValueObject/Tag.php | 8 ++------ .../ChangeMessageVisibilityBatchRequestEntry.php | 8 ++------ .../DeleteMessageBatchRequestEntry.php | 8 ++------ .../src/ValueObject/MessageAttributeValue.php | 4 +--- .../ValueObject/MessageSystemAttributeValue.php | 4 +--- .../ValueObject/SendMessageBatchRequestEntry.php | 8 ++------ .../src/ValueObject/ParameterStringFilter.php | 4 +--- src/Service/Ssm/src/ValueObject/Tag.php | 8 ++------ .../src/ValueObject/Dimension.php | 8 ++------ .../src/ValueObject/MeasureValue.php | 12 +++--------- 115 files changed, 210 insertions(+), 549 deletions(-) diff --git a/src/CodeGenerator/src/Generator/InputGenerator.php b/src/CodeGenerator/src/Generator/InputGenerator.php index b9b6db316..038ebb607 100644 --- a/src/CodeGenerator/src/Generator/InputGenerator.php +++ b/src/CodeGenerator/src/Generator/InputGenerator.php @@ -429,7 +429,7 @@ private function inputClassRequestGetters(StructureShape $inputShape, ClassBuild if ($operation->hasBody()) { [$body['body'], $hasRequestBody, $overrideArgs] = $serializer->generateRequestBody($operation, $inputShape) + [null, null, []]; if ($hasRequestBody) { - [$returnType, $requestBody, $args] = $serializer->generateRequestBuilder($inputShape) + [null, null, []]; + [$returnType, $requestBody, $args] = $serializer->generateRequestBuilder($inputShape, true) + [null, null, []]; if ('' === trim($requestBody)) { $body['body'] = '$body = "";'; } else { diff --git a/src/CodeGenerator/src/Generator/ObjectGenerator.php b/src/CodeGenerator/src/Generator/ObjectGenerator.php index 40efc2d2d..878d851c7 100644 --- a/src/CodeGenerator/src/Generator/ObjectGenerator.php +++ b/src/CodeGenerator/src/Generator/ObjectGenerator.php @@ -106,7 +106,7 @@ public function generate(StructureShape $shape, bool $forEndpoint = false): Clas $serializer = $this->serializer->get($shape->getService()); if ($this->isShapeUsedInput($shape)) { - [$returnType, $requestBody, $args] = $serializer->generateRequestBuilder($shape) + [null, null, []]; + [$returnType, $requestBody, $args] = $serializer->generateRequestBuilder($shape, false) + [null, null, []]; $method = $classBuilder->addMethod('requestBody')->setReturnType($returnType)->setBody($requestBody)->setPublic()->setComment('@internal'); foreach ($args as $arg => $type) { $method->addParameter($arg)->setType($type); diff --git a/src/CodeGenerator/src/Generator/RequestSerializer/QuerySerializer.php b/src/CodeGenerator/src/Generator/RequestSerializer/QuerySerializer.php index 5445bc47b..0d27e68ea 100644 --- a/src/CodeGenerator/src/Generator/RequestSerializer/QuerySerializer.php +++ b/src/CodeGenerator/src/Generator/RequestSerializer/QuerySerializer.php @@ -69,9 +69,9 @@ public function generateRequestBody(Operation $operation, StructureShape $shape) ]), true]; } - public function generateRequestBuilder(StructureShape $shape): array + public function generateRequestBuilder(StructureShape $shape, bool $needsChecks): array { - $body = implode("\n", array_map(function (StructureMember $member) { + $body = implode("\n", array_map(function (StructureMember $member) use ($needsChecks) { if (null !== $member->getLocation()) { return ''; } @@ -84,10 +84,15 @@ public function generateRequestBuilder(StructureShape $shape): array MEMBER_CODE'; $inputElement = '$v'; } elseif ($member->isRequired()) { - $body = 'if (null === $v = $this->PROPERTY) { - throw new InvalidArgument(sprintf(\'Missing parameter "NAME" for "%s". The value cannot be null.\', __CLASS__)); + if ($needsChecks) { + $body = 'if (null === $v = $this->PROPERTY) { + throw new InvalidArgument(sprintf(\'Missing parameter "NAME" for "%s". The value cannot be null.\', __CLASS__)); + } + MEMBER_CODE'; + } else { + $body = '$v = $this->PROPERTY; + MEMBER_CODE'; } - MEMBER_CODE'; $inputElement = '$v'; } else { $body = 'if (null !== $v = $this->PROPERTY) { diff --git a/src/CodeGenerator/src/Generator/RequestSerializer/RestJsonSerializer.php b/src/CodeGenerator/src/Generator/RequestSerializer/RestJsonSerializer.php index db07cf388..1abe0a450 100644 --- a/src/CodeGenerator/src/Generator/RequestSerializer/RestJsonSerializer.php +++ b/src/CodeGenerator/src/Generator/RequestSerializer/RestJsonSerializer.php @@ -68,9 +68,9 @@ public function generateRequestBody(Operation $operation, StructureShape $shape) return ['$bodyPayload = $this->requestBody(); $body = empty($bodyPayload) ? "{}" : \json_encode($bodyPayload, ' . \JSON_THROW_ON_ERROR . ');', true]; } - public function generateRequestBuilder(StructureShape $shape): array + public function generateRequestBuilder(StructureShape $shape, bool $needsChecks): array { - $body = implode("\n", array_map(function (StructureMember $member) { + $body = implode("\n", array_map(function (StructureMember $member) use ($needsChecks) { if (null !== $member->getLocation()) { return ''; } @@ -83,10 +83,15 @@ public function generateRequestBuilder(StructureShape $shape): array MEMBER_CODE'; $inputElement = '$v'; } elseif ($member->isRequired()) { - $body = 'if (null === $v = $this->PROPERTY) { - throw new InvalidArgument(sprintf(\'Missing parameter "NAME" for "%s". The value cannot be null.\', __CLASS__)); + if ($needsChecks) { + $body = 'if (null === $v = $this->PROPERTY) { + throw new InvalidArgument(sprintf(\'Missing parameter "NAME" for "%s". The value cannot be null.\', __CLASS__)); + } + MEMBER_CODE'; + } else { + $body = '$v = $this->PROPERTY; + MEMBER_CODE'; } - MEMBER_CODE'; $inputElement = '$v'; } else { $body = 'if (null !== $v = $this->PROPERTY) { diff --git a/src/CodeGenerator/src/Generator/RequestSerializer/RestXmlSerializer.php b/src/CodeGenerator/src/Generator/RequestSerializer/RestXmlSerializer.php index 2d519279a..09b68851c 100644 --- a/src/CodeGenerator/src/Generator/RequestSerializer/RestXmlSerializer.php +++ b/src/CodeGenerator/src/Generator/RequestSerializer/RestXmlSerializer.php @@ -93,9 +93,9 @@ public function generateRequestBody(Operation $operation, StructureShape $shape) ', true, ['node' => \DOMNode::class]]; } - public function generateRequestBuilder(StructureShape $shape): array + public function generateRequestBuilder(StructureShape $shape, bool $needsChecks): array { - $body = implode("\n", array_map(function (StructureMember $member) { + $body = implode("\n", array_map(function (StructureMember $member) use ($needsChecks) { if (null !== $member->getLocation()) { return ''; } @@ -108,10 +108,15 @@ public function generateRequestBuilder(StructureShape $shape): array MEMBER_CODE'; $inputElement = '$v'; } elseif ($member->isRequired()) { - $body = 'if (null === $v = $this->PROPERTY) { - throw new InvalidArgument(sprintf(\'Missing parameter "NAME" for "%s". The value cannot be null.\', __CLASS__)); + if ($needsChecks) { + $body = 'if (null === $v = $this->PROPERTY) { + throw new InvalidArgument(sprintf(\'Missing parameter "NAME" for "%s". The value cannot be null.\', __CLASS__)); + } + MEMBER_CODE'; + } else { + $body = '$v = $this->PROPERTY; + MEMBER_CODE'; } - MEMBER_CODE'; $inputElement = '$v'; } else { $body = 'if (null !== $v = $this->PROPERTY) { diff --git a/src/CodeGenerator/src/Generator/RequestSerializer/Serializer.php b/src/CodeGenerator/src/Generator/RequestSerializer/Serializer.php index 2a4f9f635..8c6585abb 100644 --- a/src/CodeGenerator/src/Generator/RequestSerializer/Serializer.php +++ b/src/CodeGenerator/src/Generator/RequestSerializer/Serializer.php @@ -29,7 +29,7 @@ public function generateRequestBody(Operation $operation, StructureShape $shape) * * @return array{0: string, 1: string, 2?: array} */ - public function generateRequestBuilder(StructureShape $shape): array; + public function generateRequestBuilder(StructureShape $shape, bool $needsChecks): array; public function getHeaders(Operation $operation): string; } diff --git a/src/Core/src/Sts/ValueObject/Tag.php b/src/Core/src/Sts/ValueObject/Tag.php index 20460ea2c..d6791e459 100644 --- a/src/Core/src/Sts/ValueObject/Tag.php +++ b/src/Core/src/Sts/ValueObject/Tag.php @@ -72,13 +72,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php b/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php index 51460f3db..e6bda58bc 100644 --- a/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php +++ b/src/Service/AppSync/src/ValueObject/AppSyncRuntime.php @@ -64,16 +64,12 @@ public function getRuntimeVersion(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; if (!RuntimeName::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "name" for "%s". The value "%s" is not a valid "RuntimeName".', __CLASS__, $v)); } $payload['name'] = $v; - if (null === $v = $this->runtimeVersion) { - throw new InvalidArgument(sprintf('Missing parameter "runtimeVersion" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->runtimeVersion; $payload['runtimeVersion'] = $v; return $payload; diff --git a/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php b/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php index 5ae222c44..037384773 100644 --- a/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php +++ b/src/Service/AppSync/src/ValueObject/AuthorizationConfig.php @@ -64,9 +64,7 @@ public function getAwsIamConfig(): ?AwsIamConfig public function requestBody(): array { $payload = []; - if (null === $v = $this->authorizationType) { - throw new InvalidArgument(sprintf('Missing parameter "authorizationType" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->authorizationType; if (!AuthorizationType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "authorizationType" for "%s". The value "%s" is not a valid "AuthorizationType".', __CLASS__, $v)); } diff --git a/src/Service/AppSync/src/ValueObject/CachingConfig.php b/src/Service/AppSync/src/ValueObject/CachingConfig.php index 17080a8aa..4c7f0078a 100644 --- a/src/Service/AppSync/src/ValueObject/CachingConfig.php +++ b/src/Service/AppSync/src/ValueObject/CachingConfig.php @@ -65,9 +65,7 @@ public function getTtl(): int public function requestBody(): array { $payload = []; - if (null === $v = $this->ttl) { - throw new InvalidArgument(sprintf('Missing parameter "ttl" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->ttl; $payload['ttl'] = $v; if (null !== $v = $this->cachingKeys) { $index = -1; diff --git a/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php index 0e3e7eb61..ce718eebe 100644 --- a/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/DynamodbDataSourceConfig.php @@ -97,13 +97,9 @@ public function getVersioned(): ?bool public function requestBody(): array { $payload = []; - if (null === $v = $this->tableName) { - throw new InvalidArgument(sprintf('Missing parameter "tableName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tableName; $payload['tableName'] = $v; - if (null === $v = $this->awsRegion) { - throw new InvalidArgument(sprintf('Missing parameter "awsRegion" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->awsRegion; $payload['awsRegion'] = $v; if (null !== $v = $this->useCallerCredentials) { $payload['useCallerCredentials'] = (bool) $v; diff --git a/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php index 945e34508..33f72ddbd 100644 --- a/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/ElasticsearchDataSourceConfig.php @@ -61,13 +61,9 @@ public function getEndpoint(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->endpoint) { - throw new InvalidArgument(sprintf('Missing parameter "endpoint" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->endpoint; $payload['endpoint'] = $v; - if (null === $v = $this->awsRegion) { - throw new InvalidArgument(sprintf('Missing parameter "awsRegion" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->awsRegion; $payload['awsRegion'] = $v; return $payload; diff --git a/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php index 75461d6e5..6ef78a7d9 100644 --- a/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/EventBridgeDataSourceConfig.php @@ -47,9 +47,7 @@ public function getEventBusArn(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->eventBusArn) { - throw new InvalidArgument(sprintf('Missing parameter "eventBusArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->eventBusArn; $payload['eventBusArn'] = $v; return $payload; diff --git a/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php index d7279cd67..fc6151f7e 100644 --- a/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/LambdaDataSourceConfig.php @@ -45,9 +45,7 @@ public function getLambdaFunctionArn(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->lambdaFunctionArn) { - throw new InvalidArgument(sprintf('Missing parameter "lambdaFunctionArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->lambdaFunctionArn; $payload['lambdaFunctionArn'] = $v; return $payload; diff --git a/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php b/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php index 1a07fb0af..2ae215318 100644 --- a/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php +++ b/src/Service/AppSync/src/ValueObject/OpenSearchServiceDataSourceConfig.php @@ -58,13 +58,9 @@ public function getEndpoint(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->endpoint) { - throw new InvalidArgument(sprintf('Missing parameter "endpoint" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->endpoint; $payload['endpoint'] = $v; - if (null === $v = $this->awsRegion) { - throw new InvalidArgument(sprintf('Missing parameter "awsRegion" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->awsRegion; $payload['awsRegion'] = $v; return $payload; diff --git a/src/Service/Athena/src/ValueObject/AclConfiguration.php b/src/Service/Athena/src/ValueObject/AclConfiguration.php index 64409e460..5b3e385bb 100644 --- a/src/Service/Athena/src/ValueObject/AclConfiguration.php +++ b/src/Service/Athena/src/ValueObject/AclConfiguration.php @@ -58,9 +58,7 @@ public function getS3AclOption(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->s3AclOption) { - throw new InvalidArgument(sprintf('Missing parameter "S3AclOption" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->s3AclOption; if (!S3AclOption::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "S3AclOption" for "%s". The value "%s" is not a valid "S3AclOption".', __CLASS__, $v)); } diff --git a/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php b/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php index 17cef7de0..da56cd0d3 100644 --- a/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php +++ b/src/Service/Athena/src/ValueObject/EncryptionConfiguration.php @@ -67,9 +67,7 @@ public function getKmsKey(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->encryptionOption) { - throw new InvalidArgument(sprintf('Missing parameter "EncryptionOption" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->encryptionOption; if (!EncryptionOption::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "EncryptionOption" for "%s". The value "%s" is not a valid "EncryptionOption".', __CLASS__, $v)); } diff --git a/src/Service/Athena/src/ValueObject/EngineConfiguration.php b/src/Service/Athena/src/ValueObject/EngineConfiguration.php index ffc74cf21..8debe4182 100644 --- a/src/Service/Athena/src/ValueObject/EngineConfiguration.php +++ b/src/Service/Athena/src/ValueObject/EngineConfiguration.php @@ -112,9 +112,7 @@ public function requestBody(): array if (null !== $v = $this->coordinatorDpuSize) { $payload['CoordinatorDpuSize'] = $v; } - if (null === $v = $this->maxConcurrentDpus) { - throw new InvalidArgument(sprintf('Missing parameter "MaxConcurrentDpus" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->maxConcurrentDpus; $payload['MaxConcurrentDpus'] = $v; if (null !== $v = $this->defaultExecutorDpuSize) { $payload['DefaultExecutorDpuSize'] = $v; diff --git a/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php b/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php index 4eee0f391..b966260d6 100644 --- a/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php +++ b/src/Service/Athena/src/ValueObject/ResultReuseByAgeConfiguration.php @@ -59,9 +59,7 @@ public function getMaxAgeInMinutes(): ?int public function requestBody(): array { $payload = []; - if (null === $v = $this->enabled) { - throw new InvalidArgument(sprintf('Missing parameter "Enabled" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->enabled; $payload['Enabled'] = (bool) $v; if (null !== $v = $this->maxAgeInMinutes) { $payload['MaxAgeInMinutes'] = $v; diff --git a/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php b/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php index 5cae2ea57..f32a7abf3 100644 --- a/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php +++ b/src/Service/CloudFront/src/ValueObject/InvalidationBatch.php @@ -70,17 +70,13 @@ public function getPaths(): Paths */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->paths) { - throw new InvalidArgument(sprintf('Missing parameter "Paths" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->paths; $node->appendChild($child = $document->createElement('Paths')); $v->requestBody($child, $document); - if (null === $v = $this->callerReference) { - throw new InvalidArgument(sprintf('Missing parameter "CallerReference" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->callerReference; $node->appendChild($document->createElement('CallerReference', $v)); } diff --git a/src/Service/CloudFront/src/ValueObject/Paths.php b/src/Service/CloudFront/src/ValueObject/Paths.php index 13c4330bc..a506b0325 100644 --- a/src/Service/CloudFront/src/ValueObject/Paths.php +++ b/src/Service/CloudFront/src/ValueObject/Paths.php @@ -63,9 +63,7 @@ public function getQuantity(): int */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->quantity) { - throw new InvalidArgument(sprintf('Missing parameter "Quantity" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->quantity; $node->appendChild($document->createElement('Quantity', (string) $v)); if (null !== $v = $this->items) { $node->appendChild($nodeList = $document->createElement('Items')); diff --git a/src/Service/CloudWatch/src/ValueObject/Dimension.php b/src/Service/CloudWatch/src/ValueObject/Dimension.php index 1214b613d..08c96a026 100644 --- a/src/Service/CloudWatch/src/ValueObject/Dimension.php +++ b/src/Service/CloudWatch/src/ValueObject/Dimension.php @@ -66,13 +66,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['Name'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php b/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php index 147e33dfe..5c7942921 100644 --- a/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php +++ b/src/Service/CloudWatch/src/ValueObject/DimensionFilter.php @@ -58,9 +58,7 @@ public function getValue(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['Name'] = $v; if (null !== $v = $this->value) { $payload['Value'] = $v; diff --git a/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php b/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php index 69cf477fc..1705bc1de 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricDataQuery.php @@ -183,9 +183,7 @@ public function getReturnData(): ?bool public function requestBody(): array { $payload = []; - if (null === $v = $this->id) { - throw new InvalidArgument(sprintf('Missing parameter "Id" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->id; $payload['Id'] = $v; if (null !== $v = $this->metricStat) { foreach ($v->requestBody() as $bodyKey => $bodyValue) { diff --git a/src/Service/CloudWatch/src/ValueObject/MetricDatum.php b/src/Service/CloudWatch/src/ValueObject/MetricDatum.php index eda532c97..0d5076868 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricDatum.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricDatum.php @@ -188,9 +188,7 @@ public function getValues(): array public function requestBody(): array { $payload = []; - if (null === $v = $this->metricName) { - throw new InvalidArgument(sprintf('Missing parameter "MetricName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->metricName; $payload['MetricName'] = $v; if (null !== $v = $this->dimensions) { $index = 0; diff --git a/src/Service/CloudWatch/src/ValueObject/MetricStat.php b/src/Service/CloudWatch/src/ValueObject/MetricStat.php index 4ca4c67a7..412211358 100644 --- a/src/Service/CloudWatch/src/ValueObject/MetricStat.php +++ b/src/Service/CloudWatch/src/ValueObject/MetricStat.php @@ -103,20 +103,14 @@ public function getUnit(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->metric) { - throw new InvalidArgument(sprintf('Missing parameter "Metric" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->metric; foreach ($v->requestBody() as $bodyKey => $bodyValue) { $payload["Metric.$bodyKey"] = $bodyValue; } - if (null === $v = $this->period) { - throw new InvalidArgument(sprintf('Missing parameter "Period" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->period; $payload['Period'] = $v; - if (null === $v = $this->stat) { - throw new InvalidArgument(sprintf('Missing parameter "Stat" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->stat; $payload['Stat'] = $v; if (null !== $v = $this->unit) { if (!StandardUnit::exists($v)) { diff --git a/src/Service/CloudWatch/src/ValueObject/StatisticSet.php b/src/Service/CloudWatch/src/ValueObject/StatisticSet.php index b3ee83ec0..4d3bcc38a 100644 --- a/src/Service/CloudWatch/src/ValueObject/StatisticSet.php +++ b/src/Service/CloudWatch/src/ValueObject/StatisticSet.php @@ -84,21 +84,13 @@ public function getSum(): float public function requestBody(): array { $payload = []; - if (null === $v = $this->sampleCount) { - throw new InvalidArgument(sprintf('Missing parameter "SampleCount" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->sampleCount; $payload['SampleCount'] = $v; - if (null === $v = $this->sum) { - throw new InvalidArgument(sprintf('Missing parameter "Sum" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->sum; $payload['Sum'] = $v; - if (null === $v = $this->minimum) { - throw new InvalidArgument(sprintf('Missing parameter "Minimum" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->minimum; $payload['Minimum'] = $v; - if (null === $v = $this->maximum) { - throw new InvalidArgument(sprintf('Missing parameter "Maximum" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->maximum; $payload['Maximum'] = $v; return $payload; diff --git a/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php b/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php index 3da161ea3..b2733c501 100644 --- a/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php +++ b/src/Service/CloudWatchLogs/src/ValueObject/InputLogEvent.php @@ -59,13 +59,9 @@ public function getTimestamp(): int public function requestBody(): array { $payload = []; - if (null === $v = $this->timestamp) { - throw new InvalidArgument(sprintf('Missing parameter "timestamp" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->timestamp; $payload['timestamp'] = $v; - if (null === $v = $this->message) { - throw new InvalidArgument(sprintf('Missing parameter "message" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->message; $payload['message'] = $v; return $payload; diff --git a/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php b/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php index bc32b7e73..5774c94a6 100644 --- a/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php +++ b/src/Service/CodeBuild/src/ValueObject/CloudWatchLogsConfig.php @@ -84,9 +84,7 @@ public function getStreamName(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->status) { - throw new InvalidArgument(sprintf('Missing parameter "status" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->status; if (!LogsConfigStatusType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "status" for "%s". The value "%s" is not a valid "LogsConfigStatusType".', __CLASS__, $v)); } diff --git a/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php b/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php index 67464fd6f..2be342f62 100644 --- a/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php +++ b/src/Service/CodeBuild/src/ValueObject/EnvironmentVariable.php @@ -89,13 +89,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['name'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['value'] = $v; if (null !== $v = $this->type) { if (!EnvironmentVariableType::exists($v)) { diff --git a/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php b/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php index 5061c8d31..f43f49fc4 100644 --- a/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php +++ b/src/Service/CodeBuild/src/ValueObject/GitSubmodulesConfig.php @@ -45,9 +45,7 @@ public function getFetchSubmodules(): bool public function requestBody(): array { $payload = []; - if (null === $v = $this->fetchSubmodules) { - throw new InvalidArgument(sprintf('Missing parameter "fetchSubmodules" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->fetchSubmodules; $payload['fetchSubmodules'] = (bool) $v; return $payload; diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php b/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php index 0c4996ffe..6cb6880e0 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectArtifacts.php @@ -235,9 +235,7 @@ public function getType(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!ArtifactsType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "type" for "%s". The value "%s" is not a valid "ArtifactsType".', __CLASS__, $v)); } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectCache.php b/src/Service/CodeBuild/src/ValueObject/ProjectCache.php index 061f7aad1..b88de7aa7 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectCache.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectCache.php @@ -115,9 +115,7 @@ public function getType(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!CacheType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "type" for "%s". The value "%s" is not a valid "CacheType".', __CLASS__, $v)); } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectSource.php b/src/Service/CodeBuild/src/ValueObject/ProjectSource.php index d127c2593..bb3945efe 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectSource.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectSource.php @@ -230,9 +230,7 @@ public function getType(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!SourceType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "type" for "%s". The value "%s" is not a valid "SourceType".', __CLASS__, $v)); } diff --git a/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php b/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php index f40b0c10d..7de272a93 100644 --- a/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php +++ b/src/Service/CodeBuild/src/ValueObject/ProjectSourceVersion.php @@ -73,13 +73,9 @@ public function getSourceVersion(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->sourceIdentifier) { - throw new InvalidArgument(sprintf('Missing parameter "sourceIdentifier" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->sourceIdentifier; $payload['sourceIdentifier'] = $v; - if (null === $v = $this->sourceVersion) { - throw new InvalidArgument(sprintf('Missing parameter "sourceVersion" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->sourceVersion; $payload['sourceVersion'] = $v; return $payload; diff --git a/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php b/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php index 651475be9..74f32cc9c 100644 --- a/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php +++ b/src/Service/CodeBuild/src/ValueObject/RegistryCredential.php @@ -72,13 +72,9 @@ public function getCredentialProvider(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->credential) { - throw new InvalidArgument(sprintf('Missing parameter "credential" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->credential; $payload['credential'] = $v; - if (null === $v = $this->credentialProvider) { - throw new InvalidArgument(sprintf('Missing parameter "credentialProvider" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->credentialProvider; if (!CredentialProviderType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "credentialProvider" for "%s". The value "%s" is not a valid "CredentialProviderType".', __CLASS__, $v)); } diff --git a/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php b/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php index 85b480be9..8d849a800 100644 --- a/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php +++ b/src/Service/CodeBuild/src/ValueObject/S3LogsConfig.php @@ -93,9 +93,7 @@ public function getStatus(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->status) { - throw new InvalidArgument(sprintf('Missing parameter "status" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->status; if (!LogsConfigStatusType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "status" for "%s". The value "%s" is not a valid "LogsConfigStatusType".', __CLASS__, $v)); } diff --git a/src/Service/CodeBuild/src/ValueObject/SourceAuth.php b/src/Service/CodeBuild/src/ValueObject/SourceAuth.php index 757895e5b..0c722b7d3 100644 --- a/src/Service/CodeBuild/src/ValueObject/SourceAuth.php +++ b/src/Service/CodeBuild/src/ValueObject/SourceAuth.php @@ -66,9 +66,7 @@ public function getType(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!SourceAuthType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "type" for "%s". The value "%s" is not a valid "SourceAuthType".', __CLASS__, $v)); } diff --git a/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php b/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php index ce98bbdf4..47dddbe69 100644 --- a/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php +++ b/src/Service/CodeCommit/src/ValueObject/RepositoryTrigger.php @@ -110,13 +110,9 @@ public function getName(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['name'] = $v; - if (null === $v = $this->destinationArn) { - throw new InvalidArgument(sprintf('Missing parameter "destinationArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->destinationArn; $payload['destinationArn'] = $v; if (null !== $v = $this->customData) { $payload['customData'] = $v; @@ -129,9 +125,7 @@ public function requestBody(): array $payload['branches'][$index] = $listValue; } } - if (null === $v = $this->events) { - throw new InvalidArgument(sprintf('Missing parameter "events" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->events; $index = -1; $payload['events'] = []; diff --git a/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php b/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php index 3aa6357dd..beb7d6dc0 100644 --- a/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php +++ b/src/Service/CognitoIdentityProvider/src/ValueObject/AttributeType.php @@ -58,9 +58,7 @@ public function getValue(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['Name'] = $v; if (null !== $v = $this->value) { $payload['Value'] = $v; diff --git a/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php b/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php index f594b648c..b2fa37608 100644 --- a/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php +++ b/src/Service/CognitoIdentityProvider/src/ValueObject/ContextDataType.php @@ -103,21 +103,13 @@ public function getServerPath(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->ipAddress) { - throw new InvalidArgument(sprintf('Missing parameter "IpAddress" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->ipAddress; $payload['IpAddress'] = $v; - if (null === $v = $this->serverName) { - throw new InvalidArgument(sprintf('Missing parameter "ServerName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->serverName; $payload['ServerName'] = $v; - if (null === $v = $this->serverPath) { - throw new InvalidArgument(sprintf('Missing parameter "ServerPath" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->serverPath; $payload['ServerPath'] = $v; - if (null === $v = $this->httpHeaders) { - throw new InvalidArgument(sprintf('Missing parameter "HttpHeaders" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->httpHeaders; $index = -1; $payload['HttpHeaders'] = []; diff --git a/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php b/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php index 784c297cd..fe532378e 100644 --- a/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php +++ b/src/Service/DynamoDb/src/ValueObject/AttributeDefinition.php @@ -66,13 +66,9 @@ public function getAttributeType(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->attributeName) { - throw new InvalidArgument(sprintf('Missing parameter "AttributeName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->attributeName; $payload['AttributeName'] = $v; - if (null === $v = $this->attributeType) { - throw new InvalidArgument(sprintf('Missing parameter "AttributeType" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->attributeType; if (!ScalarAttributeType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "AttributeType" for "%s". The value "%s" is not a valid "ScalarAttributeType".', __CLASS__, $v)); } diff --git a/src/Service/DynamoDb/src/ValueObject/Condition.php b/src/Service/DynamoDb/src/ValueObject/Condition.php index 7db03f8fb..974b729bb 100644 --- a/src/Service/DynamoDb/src/ValueObject/Condition.php +++ b/src/Service/DynamoDb/src/ValueObject/Condition.php @@ -190,9 +190,7 @@ public function requestBody(): array $payload['AttributeValueList'][$index] = $listValue->requestBody(); } } - if (null === $v = $this->comparisonOperator) { - throw new InvalidArgument(sprintf('Missing parameter "ComparisonOperator" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->comparisonOperator; if (!ComparisonOperator::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "ComparisonOperator" for "%s". The value "%s" is not a valid "ComparisonOperator".', __CLASS__, $v)); } diff --git a/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php b/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php index 3da7ffd2f..57f86f044 100644 --- a/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php +++ b/src/Service/DynamoDb/src/ValueObject/ConditionCheck.php @@ -134,9 +134,7 @@ public function getTableName(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; if (empty($v)) { $payload['Key'] = new \stdClass(); @@ -146,13 +144,9 @@ public function requestBody(): array $payload['Key'][$name] = $mv->requestBody(); } } - if (null === $v = $this->tableName) { - throw new InvalidArgument(sprintf('Missing parameter "TableName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tableName; $payload['TableName'] = $v; - if (null === $v = $this->conditionExpression) { - throw new InvalidArgument(sprintf('Missing parameter "ConditionExpression" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->conditionExpression; $payload['ConditionExpression'] = $v; if (null !== $v = $this->expressionAttributeNames) { if (empty($v)) { diff --git a/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php b/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php index 9b125f57e..24c9c3678 100644 --- a/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php +++ b/src/Service/DynamoDb/src/ValueObject/CreateGlobalSecondaryIndexAction.php @@ -93,13 +93,9 @@ public function getProvisionedThroughput(): ?ProvisionedThroughput public function requestBody(): array { $payload = []; - if (null === $v = $this->indexName) { - throw new InvalidArgument(sprintf('Missing parameter "IndexName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->indexName; $payload['IndexName'] = $v; - if (null === $v = $this->keySchema) { - throw new InvalidArgument(sprintf('Missing parameter "KeySchema" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->keySchema; $index = -1; $payload['KeySchema'] = []; @@ -108,9 +104,7 @@ public function requestBody(): array $payload['KeySchema'][$index] = $listValue->requestBody(); } - if (null === $v = $this->projection) { - throw new InvalidArgument(sprintf('Missing parameter "Projection" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->projection; $payload['Projection'] = $v->requestBody(); if (null !== $v = $this->provisionedThroughput) { $payload['ProvisionedThroughput'] = $v->requestBody(); diff --git a/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php b/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php index c5400a354..65bda4039 100644 --- a/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php +++ b/src/Service/DynamoDb/src/ValueObject/CreateReplicationGroupMemberAction.php @@ -106,9 +106,7 @@ public function getTableClassOverride(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->regionName) { - throw new InvalidArgument(sprintf('Missing parameter "RegionName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->regionName; $payload['RegionName'] = $v; if (null !== $v = $this->kmsMasterKeyId) { $payload['KMSMasterKeyId'] = $v; diff --git a/src/Service/DynamoDb/src/ValueObject/Delete.php b/src/Service/DynamoDb/src/ValueObject/Delete.php index 30238988d..f6ad74a25 100644 --- a/src/Service/DynamoDb/src/ValueObject/Delete.php +++ b/src/Service/DynamoDb/src/ValueObject/Delete.php @@ -124,9 +124,7 @@ public function getTableName(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; if (empty($v)) { $payload['Key'] = new \stdClass(); @@ -136,9 +134,7 @@ public function requestBody(): array $payload['Key'][$name] = $mv->requestBody(); } } - if (null === $v = $this->tableName) { - throw new InvalidArgument(sprintf('Missing parameter "TableName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tableName; $payload['TableName'] = $v; if (null !== $v = $this->conditionExpression) { $payload['ConditionExpression'] = $v; diff --git a/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php b/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php index 83324c0d6..65c879650 100644 --- a/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php +++ b/src/Service/DynamoDb/src/ValueObject/DeleteGlobalSecondaryIndexAction.php @@ -45,9 +45,7 @@ public function getIndexName(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->indexName) { - throw new InvalidArgument(sprintf('Missing parameter "IndexName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->indexName; $payload['IndexName'] = $v; return $payload; diff --git a/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php b/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php index 395132380..88c0e97cf 100644 --- a/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php +++ b/src/Service/DynamoDb/src/ValueObject/DeleteReplicationGroupMemberAction.php @@ -45,9 +45,7 @@ public function getRegionName(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->regionName) { - throw new InvalidArgument(sprintf('Missing parameter "RegionName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->regionName; $payload['RegionName'] = $v; return $payload; diff --git a/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php b/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php index 6737c971f..2cc25a6ce 100644 --- a/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php +++ b/src/Service/DynamoDb/src/ValueObject/DeleteRequest.php @@ -49,9 +49,7 @@ public function getKey(): array public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; if (empty($v)) { $payload['Key'] = new \stdClass(); diff --git a/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php b/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php index a03d77886..56187402b 100644 --- a/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php +++ b/src/Service/DynamoDb/src/ValueObject/GlobalSecondaryIndex.php @@ -104,13 +104,9 @@ public function getProvisionedThroughput(): ?ProvisionedThroughput public function requestBody(): array { $payload = []; - if (null === $v = $this->indexName) { - throw new InvalidArgument(sprintf('Missing parameter "IndexName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->indexName; $payload['IndexName'] = $v; - if (null === $v = $this->keySchema) { - throw new InvalidArgument(sprintf('Missing parameter "KeySchema" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->keySchema; $index = -1; $payload['KeySchema'] = []; @@ -119,9 +115,7 @@ public function requestBody(): array $payload['KeySchema'][$index] = $listValue->requestBody(); } - if (null === $v = $this->projection) { - throw new InvalidArgument(sprintf('Missing parameter "Projection" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->projection; $payload['Projection'] = $v->requestBody(); if (null !== $v = $this->provisionedThroughput) { $payload['ProvisionedThroughput'] = $v->requestBody(); diff --git a/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php b/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php index c91db442d..d88570416 100644 --- a/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php +++ b/src/Service/DynamoDb/src/ValueObject/KeySchemaElement.php @@ -80,13 +80,9 @@ public function getKeyType(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->attributeName) { - throw new InvalidArgument(sprintf('Missing parameter "AttributeName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->attributeName; $payload['AttributeName'] = $v; - if (null === $v = $this->keyType) { - throw new InvalidArgument(sprintf('Missing parameter "KeyType" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->keyType; if (!KeyType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "KeyType" for "%s". The value "%s" is not a valid "KeyType".', __CLASS__, $v)); } diff --git a/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php b/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php index 3219c94bc..fba385e45 100644 --- a/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php +++ b/src/Service/DynamoDb/src/ValueObject/KeysAndAttributes.php @@ -151,9 +151,7 @@ public function getProjectionExpression(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->keys) { - throw new InvalidArgument(sprintf('Missing parameter "Keys" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->keys; $index = -1; $payload['Keys'] = []; diff --git a/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php b/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php index 871af09bf..57d05c813 100644 --- a/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php +++ b/src/Service/DynamoDb/src/ValueObject/LocalSecondaryIndex.php @@ -86,13 +86,9 @@ public function getProjection(): Projection public function requestBody(): array { $payload = []; - if (null === $v = $this->indexName) { - throw new InvalidArgument(sprintf('Missing parameter "IndexName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->indexName; $payload['IndexName'] = $v; - if (null === $v = $this->keySchema) { - throw new InvalidArgument(sprintf('Missing parameter "KeySchema" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->keySchema; $index = -1; $payload['KeySchema'] = []; @@ -101,9 +97,7 @@ public function requestBody(): array $payload['KeySchema'][$index] = $listValue->requestBody(); } - if (null === $v = $this->projection) { - throw new InvalidArgument(sprintf('Missing parameter "Projection" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->projection; $payload['Projection'] = $v->requestBody(); return $payload; diff --git a/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php b/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php index 40504fd34..7c98f7a36 100644 --- a/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php +++ b/src/Service/DynamoDb/src/ValueObject/ProvisionedThroughput.php @@ -74,13 +74,9 @@ public function getWriteCapacityUnits(): int public function requestBody(): array { $payload = []; - if (null === $v = $this->readCapacityUnits) { - throw new InvalidArgument(sprintf('Missing parameter "ReadCapacityUnits" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->readCapacityUnits; $payload['ReadCapacityUnits'] = $v; - if (null === $v = $this->writeCapacityUnits) { - throw new InvalidArgument(sprintf('Missing parameter "WriteCapacityUnits" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->writeCapacityUnits; $payload['WriteCapacityUnits'] = $v; return $payload; diff --git a/src/Service/DynamoDb/src/ValueObject/Put.php b/src/Service/DynamoDb/src/ValueObject/Put.php index 0a585113a..7e276bf06 100644 --- a/src/Service/DynamoDb/src/ValueObject/Put.php +++ b/src/Service/DynamoDb/src/ValueObject/Put.php @@ -127,9 +127,7 @@ public function getTableName(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->item) { - throw new InvalidArgument(sprintf('Missing parameter "Item" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->item; if (empty($v)) { $payload['Item'] = new \stdClass(); @@ -139,9 +137,7 @@ public function requestBody(): array $payload['Item'][$name] = $mv->requestBody(); } } - if (null === $v = $this->tableName) { - throw new InvalidArgument(sprintf('Missing parameter "TableName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tableName; $payload['TableName'] = $v; if (null !== $v = $this->conditionExpression) { $payload['ConditionExpression'] = $v; diff --git a/src/Service/DynamoDb/src/ValueObject/PutRequest.php b/src/Service/DynamoDb/src/ValueObject/PutRequest.php index 6f25c30e2..650d38384 100644 --- a/src/Service/DynamoDb/src/ValueObject/PutRequest.php +++ b/src/Service/DynamoDb/src/ValueObject/PutRequest.php @@ -51,9 +51,7 @@ public function getItem(): array public function requestBody(): array { $payload = []; - if (null === $v = $this->item) { - throw new InvalidArgument(sprintf('Missing parameter "Item" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->item; if (empty($v)) { $payload['Item'] = new \stdClass(); diff --git a/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php b/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php index 5ecba0d97..8228b95c6 100644 --- a/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php +++ b/src/Service/DynamoDb/src/ValueObject/ReplicaGlobalSecondaryIndex.php @@ -59,9 +59,7 @@ public function getProvisionedThroughputOverride(): ?ProvisionedThroughputOverri public function requestBody(): array { $payload = []; - if (null === $v = $this->indexName) { - throw new InvalidArgument(sprintf('Missing parameter "IndexName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->indexName; $payload['IndexName'] = $v; if (null !== $v = $this->provisionedThroughputOverride) { $payload['ProvisionedThroughputOverride'] = $v->requestBody(); diff --git a/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php b/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php index 13f124b4b..09def8ee1 100644 --- a/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php +++ b/src/Service/DynamoDb/src/ValueObject/StreamSpecification.php @@ -68,9 +68,7 @@ public function getStreamViewType(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->streamEnabled) { - throw new InvalidArgument(sprintf('Missing parameter "StreamEnabled" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->streamEnabled; $payload['StreamEnabled'] = (bool) $v; if (null !== $v = $this->streamViewType) { if (!StreamViewType::exists($v)) { diff --git a/src/Service/DynamoDb/src/ValueObject/Tag.php b/src/Service/DynamoDb/src/ValueObject/Tag.php index 21a97d5e8..19ffacaf5 100644 --- a/src/Service/DynamoDb/src/ValueObject/Tag.php +++ b/src/Service/DynamoDb/src/ValueObject/Tag.php @@ -68,13 +68,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php b/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php index ea66b2b1a..7ed7e4a9b 100644 --- a/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php +++ b/src/Service/DynamoDb/src/ValueObject/TimeToLiveSpecification.php @@ -58,13 +58,9 @@ public function getEnabled(): bool public function requestBody(): array { $payload = []; - if (null === $v = $this->enabled) { - throw new InvalidArgument(sprintf('Missing parameter "Enabled" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->enabled; $payload['Enabled'] = (bool) $v; - if (null === $v = $this->attributeName) { - throw new InvalidArgument(sprintf('Missing parameter "AttributeName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->attributeName; $payload['AttributeName'] = $v; return $payload; diff --git a/src/Service/DynamoDb/src/ValueObject/Update.php b/src/Service/DynamoDb/src/ValueObject/Update.php index 915785287..90702eb86 100644 --- a/src/Service/DynamoDb/src/ValueObject/Update.php +++ b/src/Service/DynamoDb/src/ValueObject/Update.php @@ -138,9 +138,7 @@ public function getUpdateExpression(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; if (empty($v)) { $payload['Key'] = new \stdClass(); @@ -150,13 +148,9 @@ public function requestBody(): array $payload['Key'][$name] = $mv->requestBody(); } } - if (null === $v = $this->updateExpression) { - throw new InvalidArgument(sprintf('Missing parameter "UpdateExpression" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->updateExpression; $payload['UpdateExpression'] = $v; - if (null === $v = $this->tableName) { - throw new InvalidArgument(sprintf('Missing parameter "TableName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tableName; $payload['TableName'] = $v; if (null !== $v = $this->conditionExpression) { $payload['ConditionExpression'] = $v; diff --git a/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php b/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php index 204d20003..b3b2b3712 100644 --- a/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php +++ b/src/Service/DynamoDb/src/ValueObject/UpdateGlobalSecondaryIndexAction.php @@ -63,13 +63,9 @@ public function getProvisionedThroughput(): ProvisionedThroughput public function requestBody(): array { $payload = []; - if (null === $v = $this->indexName) { - throw new InvalidArgument(sprintf('Missing parameter "IndexName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->indexName; $payload['IndexName'] = $v; - if (null === $v = $this->provisionedThroughput) { - throw new InvalidArgument(sprintf('Missing parameter "ProvisionedThroughput" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->provisionedThroughput; $payload['ProvisionedThroughput'] = $v->requestBody(); return $payload; diff --git a/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php b/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php index b899eb5a5..213800d4a 100644 --- a/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php +++ b/src/Service/DynamoDb/src/ValueObject/UpdateReplicationGroupMemberAction.php @@ -106,9 +106,7 @@ public function getTableClassOverride(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->regionName) { - throw new InvalidArgument(sprintf('Missing parameter "RegionName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->regionName; $payload['RegionName'] = $v; if (null !== $v = $this->kmsMasterKeyId) { $payload['KMSMasterKeyId'] = $v; diff --git a/src/Service/Firehose/src/ValueObject/Record.php b/src/Service/Firehose/src/ValueObject/Record.php index e56632022..ea9216ec2 100644 --- a/src/Service/Firehose/src/ValueObject/Record.php +++ b/src/Service/Firehose/src/ValueObject/Record.php @@ -46,9 +46,7 @@ public function getData(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->data) { - throw new InvalidArgument(sprintf('Missing parameter "Data" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->data; $payload['Data'] = base64_encode($v); return $payload; diff --git a/src/Service/Iam/src/ValueObject/Tag.php b/src/Service/Iam/src/ValueObject/Tag.php index a50c8279a..9b4acd343 100644 --- a/src/Service/Iam/src/ValueObject/Tag.php +++ b/src/Service/Iam/src/ValueObject/Tag.php @@ -68,13 +68,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/Iot/src/ValueObject/Tag.php b/src/Service/Iot/src/ValueObject/Tag.php index 478b92a29..cbfd3ec43 100644 --- a/src/Service/Iot/src/ValueObject/Tag.php +++ b/src/Service/Iot/src/ValueObject/Tag.php @@ -58,9 +58,7 @@ public function getValue(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; if (null !== $v = $this->value) { $payload['Value'] = $v; diff --git a/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php b/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php index 241fcb796..102082265 100644 --- a/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php +++ b/src/Service/Kinesis/src/ValueObject/PutRecordsRequestEntry.php @@ -78,16 +78,12 @@ public function getPartitionKey(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->data) { - throw new InvalidArgument(sprintf('Missing parameter "Data" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->data; $payload['Data'] = base64_encode($v); if (null !== $v = $this->explicitHashKey) { $payload['ExplicitHashKey'] = $v; } - if (null === $v = $this->partitionKey) { - throw new InvalidArgument(sprintf('Missing parameter "PartitionKey" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->partitionKey; $payload['PartitionKey'] = $v; return $payload; diff --git a/src/Service/Kinesis/src/ValueObject/ShardFilter.php b/src/Service/Kinesis/src/ValueObject/ShardFilter.php index 65dcb5ce7..23017d50d 100644 --- a/src/Service/Kinesis/src/ValueObject/ShardFilter.php +++ b/src/Service/Kinesis/src/ValueObject/ShardFilter.php @@ -92,9 +92,7 @@ public function getType(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "Type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!ShardFilterType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "Type" for "%s". The value "%s" is not a valid "ShardFilterType".', __CLASS__, $v)); } diff --git a/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php b/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php index 333e2d83e..c389c0a7d 100644 --- a/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php +++ b/src/Service/Kinesis/src/ValueObject/StreamModeDetails.php @@ -51,9 +51,7 @@ public function getStreamMode(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->streamMode) { - throw new InvalidArgument(sprintf('Missing parameter "StreamMode" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->streamMode; if (!StreamMode::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "StreamMode" for "%s". The value "%s" is not a valid "StreamMode".', __CLASS__, $v)); } diff --git a/src/Service/Kms/src/ValueObject/Tag.php b/src/Service/Kms/src/ValueObject/Tag.php index 14858e8cd..372b613d0 100644 --- a/src/Service/Kms/src/ValueObject/Tag.php +++ b/src/Service/Kms/src/ValueObject/Tag.php @@ -67,13 +67,9 @@ public function getTagValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->tagKey) { - throw new InvalidArgument(sprintf('Missing parameter "TagKey" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tagKey; $payload['TagKey'] = $v; - if (null === $v = $this->tagValue) { - throw new InvalidArgument(sprintf('Missing parameter "TagValue" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tagValue; $payload['TagValue'] = $v; return $payload; diff --git a/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php b/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php index 4ef3f888f..c710bfd82 100644 --- a/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php +++ b/src/Service/MediaConvert/src/ValueObject/AccelerationSettings.php @@ -49,9 +49,7 @@ public function getMode(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->mode) { - throw new InvalidArgument(sprintf('Missing parameter "Mode" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->mode; if (!AccelerationMode::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "mode" for "%s". The value "%s" is not a valid "AccelerationMode".', __CLASS__, $v)); } diff --git a/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php b/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php index adf3fcff2..80db499b2 100644 --- a/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php +++ b/src/Service/Rekognition/src/ValueObject/HumanLoopConfig.php @@ -75,13 +75,9 @@ public function getHumanLoopName(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->humanLoopName) { - throw new InvalidArgument(sprintf('Missing parameter "HumanLoopName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->humanLoopName; $payload['HumanLoopName'] = $v; - if (null === $v = $this->flowDefinitionArn) { - throw new InvalidArgument(sprintf('Missing parameter "FlowDefinitionArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->flowDefinitionArn; $payload['FlowDefinitionArn'] = $v; if (null !== $v = $this->dataAttributes) { $payload['DataAttributes'] = $v->requestBody(); diff --git a/src/Service/Route53/src/ValueObject/AliasTarget.php b/src/Service/Route53/src/ValueObject/AliasTarget.php index df769e95a..0c74531f7 100644 --- a/src/Service/Route53/src/ValueObject/AliasTarget.php +++ b/src/Service/Route53/src/ValueObject/AliasTarget.php @@ -319,17 +319,11 @@ public function getHostedZoneId(): string */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->hostedZoneId) { - throw new InvalidArgument(sprintf('Missing parameter "HostedZoneId" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->hostedZoneId; $node->appendChild($document->createElement('HostedZoneId', $v)); - if (null === $v = $this->dnsName) { - throw new InvalidArgument(sprintf('Missing parameter "DNSName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->dnsName; $node->appendChild($document->createElement('DNSName', $v)); - if (null === $v = $this->evaluateTargetHealth) { - throw new InvalidArgument(sprintf('Missing parameter "EvaluateTargetHealth" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->evaluateTargetHealth; $node->appendChild($document->createElement('EvaluateTargetHealth', $v ? 'true' : 'false')); } diff --git a/src/Service/Route53/src/ValueObject/Change.php b/src/Service/Route53/src/ValueObject/Change.php index 638ef5f79..ac3214a7b 100644 --- a/src/Service/Route53/src/ValueObject/Change.php +++ b/src/Service/Route53/src/ValueObject/Change.php @@ -74,16 +74,12 @@ public function getResourceRecordSet(): ResourceRecordSet */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->action) { - throw new InvalidArgument(sprintf('Missing parameter "Action" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->action; if (!ChangeAction::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "Action" for "%s". The value "%s" is not a valid "ChangeAction".', __CLASS__, $v)); } $node->appendChild($document->createElement('Action', $v)); - if (null === $v = $this->resourceRecordSet) { - throw new InvalidArgument(sprintf('Missing parameter "ResourceRecordSet" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->resourceRecordSet; $node->appendChild($child = $document->createElement('ResourceRecordSet')); diff --git a/src/Service/Route53/src/ValueObject/ChangeBatch.php b/src/Service/Route53/src/ValueObject/ChangeBatch.php index fa5e021a5..0e2b7f9cd 100644 --- a/src/Service/Route53/src/ValueObject/ChangeBatch.php +++ b/src/Service/Route53/src/ValueObject/ChangeBatch.php @@ -63,9 +63,7 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void if (null !== $v = $this->comment) { $node->appendChild($document->createElement('Comment', $v)); } - if (null === $v = $this->changes) { - throw new InvalidArgument(sprintf('Missing parameter "Changes" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->changes; $node->appendChild($nodeList = $document->createElement('Changes')); foreach ($v as $item) { diff --git a/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php b/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php index 65b351548..8fc760f12 100644 --- a/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php +++ b/src/Service/Route53/src/ValueObject/CidrRoutingConfig.php @@ -61,13 +61,9 @@ public function getLocationName(): string */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->collectionId) { - throw new InvalidArgument(sprintf('Missing parameter "CollectionId" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->collectionId; $node->appendChild($document->createElement('CollectionId', $v)); - if (null === $v = $this->locationName) { - throw new InvalidArgument(sprintf('Missing parameter "LocationName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->locationName; $node->appendChild($document->createElement('LocationName', $v)); } diff --git a/src/Service/Route53/src/ValueObject/ResourceRecord.php b/src/Service/Route53/src/ValueObject/ResourceRecord.php index 135b9c3da..dfc33f509 100644 --- a/src/Service/Route53/src/ValueObject/ResourceRecord.php +++ b/src/Service/Route53/src/ValueObject/ResourceRecord.php @@ -54,9 +54,7 @@ public function getValue(): string */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $node->appendChild($document->createElement('Value', $v)); } diff --git a/src/Service/Route53/src/ValueObject/ResourceRecordSet.php b/src/Service/Route53/src/ValueObject/ResourceRecordSet.php index 5182595fb..b25d29ed5 100644 --- a/src/Service/Route53/src/ValueObject/ResourceRecordSet.php +++ b/src/Service/Route53/src/ValueObject/ResourceRecordSet.php @@ -526,13 +526,9 @@ public function getWeight(): ?int */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $node->appendChild($document->createElement('Name', $v)); - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "Type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!RRType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "Type" for "%s". The value "%s" is not a valid "RRType".', __CLASS__, $v)); } diff --git a/src/Service/S3/src/ValueObject/CORSConfiguration.php b/src/Service/S3/src/ValueObject/CORSConfiguration.php index 3877308e2..39a8c57cc 100644 --- a/src/Service/S3/src/ValueObject/CORSConfiguration.php +++ b/src/Service/S3/src/ValueObject/CORSConfiguration.php @@ -51,9 +51,7 @@ public function getCorsRules(): array */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->corsRules) { - throw new InvalidArgument(sprintf('Missing parameter "CORSRules" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->corsRules; foreach ($v as $item) { $node->appendChild($child = $document->createElement('CORSRule')); diff --git a/src/Service/S3/src/ValueObject/CORSRule.php b/src/Service/S3/src/ValueObject/CORSRule.php index 0f9548728..1e14a3f73 100644 --- a/src/Service/S3/src/ValueObject/CORSRule.php +++ b/src/Service/S3/src/ValueObject/CORSRule.php @@ -132,16 +132,12 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void $node->appendChild($document->createElement('AllowedHeader', $item)); } } - if (null === $v = $this->allowedMethods) { - throw new InvalidArgument(sprintf('Missing parameter "AllowedMethods" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->allowedMethods; foreach ($v as $item) { $node->appendChild($document->createElement('AllowedMethod', $item)); } - if (null === $v = $this->allowedOrigins) { - throw new InvalidArgument(sprintf('Missing parameter "AllowedOrigins" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->allowedOrigins; foreach ($v as $item) { $node->appendChild($document->createElement('AllowedOrigin', $item)); } diff --git a/src/Service/S3/src/ValueObject/Delete.php b/src/Service/S3/src/ValueObject/Delete.php index 6285af01b..9808c3555 100644 --- a/src/Service/S3/src/ValueObject/Delete.php +++ b/src/Service/S3/src/ValueObject/Delete.php @@ -60,9 +60,7 @@ public function getQuiet(): ?bool */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->objects) { - throw new InvalidArgument(sprintf('Missing parameter "Objects" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->objects; foreach ($v as $item) { $node->appendChild($child = $document->createElement('Object')); diff --git a/src/Service/S3/src/ValueObject/Grantee.php b/src/Service/S3/src/ValueObject/Grantee.php index f5917cd57..7d8e269ac 100644 --- a/src/Service/S3/src/ValueObject/Grantee.php +++ b/src/Service/S3/src/ValueObject/Grantee.php @@ -125,9 +125,7 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void if (null !== $v = $this->id) { $node->appendChild($document->createElement('ID', $v)); } - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "Type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!Type::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "xsi:type" for "%s". The value "%s" is not a valid "Type".', __CLASS__, $v)); } diff --git a/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php b/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php index f11892df2..9f7a44345 100644 --- a/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php +++ b/src/Service/S3/src/ValueObject/LambdaFunctionConfiguration.php @@ -87,13 +87,9 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void if (null !== $v = $this->id) { $node->appendChild($document->createElement('Id', $v)); } - if (null === $v = $this->lambdaFunctionArn) { - throw new InvalidArgument(sprintf('Missing parameter "LambdaFunctionArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->lambdaFunctionArn; $node->appendChild($document->createElement('CloudFunction', $v)); - if (null === $v = $this->events) { - throw new InvalidArgument(sprintf('Missing parameter "Events" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->events; foreach ($v as $item) { if (!Event::exists($item)) { throw new InvalidArgument(sprintf('Invalid parameter "Event" for "%s". The value "%s" is not a valid "Event".', __CLASS__, $item)); diff --git a/src/Service/S3/src/ValueObject/ObjectIdentifier.php b/src/Service/S3/src/ValueObject/ObjectIdentifier.php index f60fc9b5e..4b7a150f1 100644 --- a/src/Service/S3/src/ValueObject/ObjectIdentifier.php +++ b/src/Service/S3/src/ValueObject/ObjectIdentifier.php @@ -62,9 +62,7 @@ public function getVersionId(): ?string */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $node->appendChild($document->createElement('Key', $v)); if (null !== $v = $this->versionId) { $node->appendChild($document->createElement('VersionId', $v)); diff --git a/src/Service/S3/src/ValueObject/QueueConfiguration.php b/src/Service/S3/src/ValueObject/QueueConfiguration.php index 68140a0f3..3dc5694bb 100644 --- a/src/Service/S3/src/ValueObject/QueueConfiguration.php +++ b/src/Service/S3/src/ValueObject/QueueConfiguration.php @@ -86,13 +86,9 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void if (null !== $v = $this->id) { $node->appendChild($document->createElement('Id', $v)); } - if (null === $v = $this->queueArn) { - throw new InvalidArgument(sprintf('Missing parameter "QueueArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->queueArn; $node->appendChild($document->createElement('Queue', $v)); - if (null === $v = $this->events) { - throw new InvalidArgument(sprintf('Missing parameter "Events" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->events; foreach ($v as $item) { if (!Event::exists($item)) { throw new InvalidArgument(sprintf('Invalid parameter "Event" for "%s". The value "%s" is not a valid "Event".', __CLASS__, $item)); diff --git a/src/Service/S3/src/ValueObject/Tag.php b/src/Service/S3/src/ValueObject/Tag.php index c23a6f989..3cc4c19eb 100644 --- a/src/Service/S3/src/ValueObject/Tag.php +++ b/src/Service/S3/src/ValueObject/Tag.php @@ -57,13 +57,9 @@ public function getValue(): string */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $node->appendChild($document->createElement('Key', $v)); - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $node->appendChild($document->createElement('Value', $v)); } diff --git a/src/Service/S3/src/ValueObject/Tagging.php b/src/Service/S3/src/ValueObject/Tagging.php index 1185af13e..25fdddf4c 100644 --- a/src/Service/S3/src/ValueObject/Tagging.php +++ b/src/Service/S3/src/ValueObject/Tagging.php @@ -47,9 +47,7 @@ public function getTagSet(): array */ public function requestBody(\DOMElement $node, \DOMDocument $document): void { - if (null === $v = $this->tagSet) { - throw new InvalidArgument(sprintf('Missing parameter "TagSet" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->tagSet; $node->appendChild($nodeList = $document->createElement('TagSet')); foreach ($v as $item) { diff --git a/src/Service/S3/src/ValueObject/TopicConfiguration.php b/src/Service/S3/src/ValueObject/TopicConfiguration.php index 860e94c48..ae4f4ef31 100644 --- a/src/Service/S3/src/ValueObject/TopicConfiguration.php +++ b/src/Service/S3/src/ValueObject/TopicConfiguration.php @@ -89,13 +89,9 @@ public function requestBody(\DOMElement $node, \DOMDocument $document): void if (null !== $v = $this->id) { $node->appendChild($document->createElement('Id', $v)); } - if (null === $v = $this->topicArn) { - throw new InvalidArgument(sprintf('Missing parameter "TopicArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->topicArn; $node->appendChild($document->createElement('Topic', $v)); - if (null === $v = $this->events) { - throw new InvalidArgument(sprintf('Missing parameter "Events" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->events; foreach ($v as $item) { if (!Event::exists($item)) { throw new InvalidArgument(sprintf('Invalid parameter "Event" for "%s". The value "%s" is not a valid "Event".', __CLASS__, $item)); diff --git a/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php b/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php index d9dd7c2c4..24cccfdb6 100644 --- a/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php +++ b/src/Service/Scheduler/src/ValueObject/AwsVpcConfiguration.php @@ -100,9 +100,7 @@ public function requestBody(): array $payload['SecurityGroups'][$index] = $listValue; } } - if (null === $v = $this->subnets) { - throw new InvalidArgument(sprintf('Missing parameter "Subnets" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->subnets; $index = -1; $payload['Subnets'] = []; diff --git a/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php b/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php index 1b94c063b..a705d8a29 100644 --- a/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php +++ b/src/Service/Scheduler/src/ValueObject/CapacityProviderStrategyItem.php @@ -78,9 +78,7 @@ public function requestBody(): array if (null !== $v = $this->base) { $payload['base'] = $v; } - if (null === $v = $this->capacityProvider) { - throw new InvalidArgument(sprintf('Missing parameter "capacityProvider" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->capacityProvider; $payload['capacityProvider'] = $v; if (null !== $v = $this->weight) { $payload['weight'] = $v; diff --git a/src/Service/Scheduler/src/ValueObject/EcsParameters.php b/src/Service/Scheduler/src/ValueObject/EcsParameters.php index f1fd4384a..ad7654257 100644 --- a/src/Service/Scheduler/src/ValueObject/EcsParameters.php +++ b/src/Service/Scheduler/src/ValueObject/EcsParameters.php @@ -327,9 +327,7 @@ public function requestBody(): array if (null !== $v = $this->taskCount) { $payload['TaskCount'] = $v; } - if (null === $v = $this->taskDefinitionArn) { - throw new InvalidArgument(sprintf('Missing parameter "TaskDefinitionArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->taskDefinitionArn; $payload['TaskDefinitionArn'] = $v; return $payload; diff --git a/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php b/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php index b26ed25b9..592af3612 100644 --- a/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php +++ b/src/Service/Scheduler/src/ValueObject/EventBridgeParameters.php @@ -60,13 +60,9 @@ public function getSource(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->detailType) { - throw new InvalidArgument(sprintf('Missing parameter "DetailType" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->detailType; $payload['DetailType'] = $v; - if (null === $v = $this->source) { - throw new InvalidArgument(sprintf('Missing parameter "Source" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->source; $payload['Source'] = $v; return $payload; diff --git a/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php b/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php index 9aa8e4e04..c0f4e0951 100644 --- a/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php +++ b/src/Service/Scheduler/src/ValueObject/FlexibleTimeWindow.php @@ -65,9 +65,7 @@ public function requestBody(): array if (null !== $v = $this->maximumWindowInMinutes) { $payload['MaximumWindowInMinutes'] = $v; } - if (null === $v = $this->mode) { - throw new InvalidArgument(sprintf('Missing parameter "Mode" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->mode; if (!FlexibleTimeWindowMode::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "Mode" for "%s". The value "%s" is not a valid "FlexibleTimeWindowMode".', __CLASS__, $v)); } diff --git a/src/Service/Scheduler/src/ValueObject/KinesisParameters.php b/src/Service/Scheduler/src/ValueObject/KinesisParameters.php index 410d273ae..6f1877b3f 100644 --- a/src/Service/Scheduler/src/ValueObject/KinesisParameters.php +++ b/src/Service/Scheduler/src/ValueObject/KinesisParameters.php @@ -50,9 +50,7 @@ public function getPartitionKey(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->partitionKey) { - throw new InvalidArgument(sprintf('Missing parameter "PartitionKey" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->partitionKey; $payload['PartitionKey'] = $v; return $payload; diff --git a/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php b/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php index cdfa039b3..6bdf510ac 100644 --- a/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php +++ b/src/Service/Scheduler/src/ValueObject/SageMakerPipelineParameter.php @@ -58,13 +58,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['Name'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/Scheduler/src/ValueObject/Tag.php b/src/Service/Scheduler/src/ValueObject/Tag.php index 9ab94b5f7..dba0a1c1c 100644 --- a/src/Service/Scheduler/src/ValueObject/Tag.php +++ b/src/Service/Scheduler/src/ValueObject/Tag.php @@ -58,13 +58,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/Scheduler/src/ValueObject/Target.php b/src/Service/Scheduler/src/ValueObject/Target.php index 1f1bf807e..c30b92a9f 100644 --- a/src/Service/Scheduler/src/ValueObject/Target.php +++ b/src/Service/Scheduler/src/ValueObject/Target.php @@ -185,9 +185,7 @@ public function getSqsParameters(): ?SqsParameters public function requestBody(): array { $payload = []; - if (null === $v = $this->arn) { - throw new InvalidArgument(sprintf('Missing parameter "Arn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->arn; $payload['Arn'] = $v; if (null !== $v = $this->deadLetterConfig) { $payload['DeadLetterConfig'] = $v->requestBody(); @@ -207,9 +205,7 @@ public function requestBody(): array if (null !== $v = $this->retryPolicy) { $payload['RetryPolicy'] = $v->requestBody(); } - if (null === $v = $this->roleArn) { - throw new InvalidArgument(sprintf('Missing parameter "RoleArn" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->roleArn; $payload['RoleArn'] = $v; if (null !== $v = $this->sageMakerPipelineParameters) { $payload['SageMakerPipelineParameters'] = $v->requestBody(); diff --git a/src/Service/Ses/src/ValueObject/Content.php b/src/Service/Ses/src/ValueObject/Content.php index 38f70a2c9..e1982f823 100644 --- a/src/Service/Ses/src/ValueObject/Content.php +++ b/src/Service/Ses/src/ValueObject/Content.php @@ -60,9 +60,7 @@ public function getData(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->data) { - throw new InvalidArgument(sprintf('Missing parameter "Data" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->data; $payload['Data'] = $v; if (null !== $v = $this->charset) { $payload['Charset'] = $v; diff --git a/src/Service/Ses/src/ValueObject/ListManagementOptions.php b/src/Service/Ses/src/ValueObject/ListManagementOptions.php index 815f21874..4eb235b35 100644 --- a/src/Service/Ses/src/ValueObject/ListManagementOptions.php +++ b/src/Service/Ses/src/ValueObject/ListManagementOptions.php @@ -59,9 +59,7 @@ public function getTopicName(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->contactListName) { - throw new InvalidArgument(sprintf('Missing parameter "ContactListName" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->contactListName; $payload['ContactListName'] = $v; if (null !== $v = $this->topicName) { $payload['TopicName'] = $v; diff --git a/src/Service/Ses/src/ValueObject/Message.php b/src/Service/Ses/src/ValueObject/Message.php index 2e984f783..0435e39ef 100644 --- a/src/Service/Ses/src/ValueObject/Message.php +++ b/src/Service/Ses/src/ValueObject/Message.php @@ -61,13 +61,9 @@ public function getSubject(): Content public function requestBody(): array { $payload = []; - if (null === $v = $this->subject) { - throw new InvalidArgument(sprintf('Missing parameter "Subject" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->subject; $payload['Subject'] = $v->requestBody(); - if (null === $v = $this->body) { - throw new InvalidArgument(sprintf('Missing parameter "Body" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->body; $payload['Body'] = $v->requestBody(); return $payload; diff --git a/src/Service/Ses/src/ValueObject/MessageTag.php b/src/Service/Ses/src/ValueObject/MessageTag.php index fd530de14..b94c8d53e 100644 --- a/src/Service/Ses/src/ValueObject/MessageTag.php +++ b/src/Service/Ses/src/ValueObject/MessageTag.php @@ -65,13 +65,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['Name'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/Ses/src/ValueObject/RawMessage.php b/src/Service/Ses/src/ValueObject/RawMessage.php index b4ad245c2..746c6c5db 100644 --- a/src/Service/Ses/src/ValueObject/RawMessage.php +++ b/src/Service/Ses/src/ValueObject/RawMessage.php @@ -57,9 +57,7 @@ public function getData(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->data) { - throw new InvalidArgument(sprintf('Missing parameter "Data" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->data; $payload['Data'] = base64_encode($v); return $payload; diff --git a/src/Service/Sns/src/ValueObject/MessageAttributeValue.php b/src/Service/Sns/src/ValueObject/MessageAttributeValue.php index e9d95697a..d418d8686 100644 --- a/src/Service/Sns/src/ValueObject/MessageAttributeValue.php +++ b/src/Service/Sns/src/ValueObject/MessageAttributeValue.php @@ -86,9 +86,7 @@ public function getStringValue(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->dataType) { - throw new InvalidArgument(sprintf('Missing parameter "DataType" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->dataType; $payload['DataType'] = $v; if (null !== $v = $this->stringValue) { $payload['StringValue'] = $v; diff --git a/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php b/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php index 12295b939..8f692d54d 100644 --- a/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php +++ b/src/Service/Sns/src/ValueObject/PublishBatchRequestEntry.php @@ -191,13 +191,9 @@ public function getSubject(): ?string public function requestBody(): array { $payload = []; - if (null === $v = $this->id) { - throw new InvalidArgument(sprintf('Missing parameter "Id" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->id; $payload['Id'] = $v; - if (null === $v = $this->message) { - throw new InvalidArgument(sprintf('Missing parameter "Message" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->message; $payload['Message'] = $v; if (null !== $v = $this->subject) { $payload['Subject'] = $v; diff --git a/src/Service/Sns/src/ValueObject/Tag.php b/src/Service/Sns/src/ValueObject/Tag.php index dc8dcbc15..d4d6527d8 100644 --- a/src/Service/Sns/src/ValueObject/Tag.php +++ b/src/Service/Sns/src/ValueObject/Tag.php @@ -58,13 +58,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php b/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php index 430b8e22a..4804170a9 100644 --- a/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php +++ b/src/Service/Sqs/src/ValueObject/ChangeMessageVisibilityBatchRequestEntry.php @@ -76,13 +76,9 @@ public function getVisibilityTimeout(): ?int public function requestBody(): array { $payload = []; - if (null === $v = $this->id) { - throw new InvalidArgument(sprintf('Missing parameter "Id" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->id; $payload['Id'] = $v; - if (null === $v = $this->receiptHandle) { - throw new InvalidArgument(sprintf('Missing parameter "ReceiptHandle" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->receiptHandle; $payload['ReceiptHandle'] = $v; if (null !== $v = $this->visibilityTimeout) { $payload['VisibilityTimeout'] = $v; diff --git a/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php b/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php index 5e72063fd..cb668b17a 100644 --- a/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php +++ b/src/Service/Sqs/src/ValueObject/DeleteMessageBatchRequestEntry.php @@ -63,13 +63,9 @@ public function getReceiptHandle(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->id) { - throw new InvalidArgument(sprintf('Missing parameter "Id" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->id; $payload['Id'] = $v; - if (null === $v = $this->receiptHandle) { - throw new InvalidArgument(sprintf('Missing parameter "ReceiptHandle" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->receiptHandle; $payload['ReceiptHandle'] = $v; return $payload; diff --git a/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php b/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php index 6ead4284c..e10d6dd3b 100644 --- a/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php +++ b/src/Service/Sqs/src/ValueObject/MessageAttributeValue.php @@ -135,9 +135,7 @@ public function requestBody(): array $payload["BinaryListValue.$index"] = base64_encode($mapValue); } } - if (null === $v = $this->dataType) { - throw new InvalidArgument(sprintf('Missing parameter "DataType" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->dataType; $payload['DataType'] = $v; return $payload; diff --git a/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php b/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php index d85feef99..fa51bae10 100644 --- a/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php +++ b/src/Service/Sqs/src/ValueObject/MessageSystemAttributeValue.php @@ -134,9 +134,7 @@ public function requestBody(): array $payload["BinaryListValue.$index"] = base64_encode($mapValue); } } - if (null === $v = $this->dataType) { - throw new InvalidArgument(sprintf('Missing parameter "DataType" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->dataType; $payload['DataType'] = $v; return $payload; diff --git a/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php b/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php index 7af7a9fb7..18c05f59f 100644 --- a/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php +++ b/src/Service/Sqs/src/ValueObject/SendMessageBatchRequestEntry.php @@ -207,13 +207,9 @@ public function getMessageSystemAttributes(): array public function requestBody(): array { $payload = []; - if (null === $v = $this->id) { - throw new InvalidArgument(sprintf('Missing parameter "Id" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->id; $payload['Id'] = $v; - if (null === $v = $this->messageBody) { - throw new InvalidArgument(sprintf('Missing parameter "MessageBody" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->messageBody; $payload['MessageBody'] = $v; if (null !== $v = $this->delaySeconds) { $payload['DelaySeconds'] = $v; diff --git a/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php b/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php index e89a644ce..a694c6b5a 100644 --- a/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php +++ b/src/Service/Ssm/src/ValueObject/ParameterStringFilter.php @@ -92,9 +92,7 @@ public function getValues(): array public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; if (null !== $v = $this->option) { $payload['Option'] = $v; diff --git a/src/Service/Ssm/src/ValueObject/Tag.php b/src/Service/Ssm/src/ValueObject/Tag.php index 94bc0ca38..5ff2f1424 100644 --- a/src/Service/Ssm/src/ValueObject/Tag.php +++ b/src/Service/Ssm/src/ValueObject/Tag.php @@ -61,13 +61,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->key) { - throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->key; $payload['Key'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; return $payload; diff --git a/src/Service/TimestreamWrite/src/ValueObject/Dimension.php b/src/Service/TimestreamWrite/src/ValueObject/Dimension.php index a943d9602..69cd0515a 100644 --- a/src/Service/TimestreamWrite/src/ValueObject/Dimension.php +++ b/src/Service/TimestreamWrite/src/ValueObject/Dimension.php @@ -81,13 +81,9 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['Name'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; if (null !== $v = $this->dimensionValueType) { if (!DimensionValueType::exists($v)) { diff --git a/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php b/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php index 58e2d236f..6fc8c0041 100644 --- a/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php +++ b/src/Service/TimestreamWrite/src/ValueObject/MeasureValue.php @@ -85,17 +85,11 @@ public function getValue(): string public function requestBody(): array { $payload = []; - if (null === $v = $this->name) { - throw new InvalidArgument(sprintf('Missing parameter "Name" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->name; $payload['Name'] = $v; - if (null === $v = $this->value) { - throw new InvalidArgument(sprintf('Missing parameter "Value" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->value; $payload['Value'] = $v; - if (null === $v = $this->type) { - throw new InvalidArgument(sprintf('Missing parameter "Type" for "%s". The value cannot be null.', __CLASS__)); - } + $v = $this->type; if (!MeasureValueType::exists($v)) { throw new InvalidArgument(sprintf('Invalid parameter "Type" for "%s". The value "%s" is not a valid "MeasureValueType".', __CLASS__, $v)); }