Skip to content

Commit 9c00809

Browse files
Update generated code (#1344)
* update generated code * Apply suggestions from code review Co-authored-by: Jérémy Derussé <[email protected]>
1 parent c59fccf commit 9c00809

9 files changed

+74
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## NOT RELEASED
44

5+
### Added
6+
7+
- AWS api-change: Add a `ValidationException` exception
8+
59
## 1.0.0
610

711
### Added
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace AsyncAws\StepFunctions\Enum;
4+
5+
/**
6+
* The input does not satisfy the constraints specified by an Amazon Web Services service.
7+
*/
8+
final class ValidationExceptionReason
9+
{
10+
public const API_DOES_NOT_SUPPORT_LABELED_ARNS = 'API_DOES_NOT_SUPPORT_LABELED_ARNS';
11+
public const CANNOT_UPDATE_COMPLETED_MAP_RUN = 'CANNOT_UPDATE_COMPLETED_MAP_RUN';
12+
public const MISSING_REQUIRED_PARAMETER = 'MISSING_REQUIRED_PARAMETER';
13+
14+
public static function exists(string $value): bool
15+
{
16+
return isset([
17+
self::API_DOES_NOT_SUPPORT_LABELED_ARNS => true,
18+
self::CANNOT_UPDATE_COMPLETED_MAP_RUN => true,
19+
self::MISSING_REQUIRED_PARAMETER => true,
20+
][$value]);
21+
}
22+
}

src/Exception/InvalidArnException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Symfony\Contracts\HttpClient\ResponseInterface;
77

88
/**
9-
* The provided Amazon Resource Name (ARN) is invalid.
9+
* The provided Amazon Resource Name (ARN) is not valid.
1010
*/
1111
final class InvalidArnException extends ClientException
1212
{

src/Exception/InvalidExecutionInputException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Symfony\Contracts\HttpClient\ResponseInterface;
77

88
/**
9-
* The provided JSON input data is invalid.
9+
* The provided JSON input data is not valid.
1010
*/
1111
final class InvalidExecutionInputException extends ClientException
1212
{

src/Exception/InvalidNameException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Symfony\Contracts\HttpClient\ResponseInterface;
77

88
/**
9-
* The provided name is invalid.
9+
* The provided name is not valid.
1010
*/
1111
final class InvalidNameException extends ClientException
1212
{

src/Exception/InvalidOutputException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Symfony\Contracts\HttpClient\ResponseInterface;
77

88
/**
9-
* The provided JSON output data is invalid.
9+
* The provided JSON output data is not valid.
1010
*/
1111
final class InvalidOutputException extends ClientException
1212
{

src/Exception/InvalidTokenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Symfony\Contracts\HttpClient\ResponseInterface;
77

88
/**
9-
* The provided token is invalid.
9+
* The provided token is not valid.
1010
*/
1111
final class InvalidTokenException extends ClientException
1212
{

src/Exception/ValidationException.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace AsyncAws\StepFunctions\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
use AsyncAws\StepFunctions\Enum\ValidationExceptionReason;
7+
use Symfony\Contracts\HttpClient\ResponseInterface;
8+
9+
/**
10+
* The input does not satisfy the constraints specified by an Amazon Web Services service.
11+
*/
12+
final class ValidationException extends ClientException
13+
{
14+
/**
15+
* The input does not satisfy the constraints specified by an Amazon Web Services service.
16+
*/
17+
private $reason;
18+
19+
/**
20+
* @return ValidationExceptionReason::*|null
21+
*/
22+
public function getReason(): ?string
23+
{
24+
return $this->reason;
25+
}
26+
27+
protected function populateResult(ResponseInterface $response): void
28+
{
29+
$data = $response->toArray(false);
30+
31+
if (null !== $v = (isset($data['message']) ? (string) $data['message'] : null)) {
32+
$this->message = $v;
33+
}
34+
$this->reason = isset($data['reason']) ? (string) $data['reason'] : null;
35+
}
36+
}

src/StepFunctionsClient.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use AsyncAws\StepFunctions\Exception\StateMachineDoesNotExistException;
2020
use AsyncAws\StepFunctions\Exception\TaskDoesNotExistException;
2121
use AsyncAws\StepFunctions\Exception\TaskTimedOutException;
22+
use AsyncAws\StepFunctions\Exception\ValidationException;
2223
use AsyncAws\StepFunctions\Input\SendTaskFailureInput;
2324
use AsyncAws\StepFunctions\Input\SendTaskHeartbeatInput;
2425
use AsyncAws\StepFunctions\Input\SendTaskSuccessInput;
@@ -131,7 +132,8 @@ public function sendTaskSuccess($input): SendTaskSuccessOutput
131132
}
132133

133134
/**
134-
* Starts a state machine execution.
135+
* Starts a state machine execution. If the given state machine Amazon Resource Name (ARN) is a qualified state machine
136+
* ARN, it will fail with ValidationException.
135137
*
136138
* @see https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartExecution.html
137139
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-states-2016-11-23.html#startexecution
@@ -151,6 +153,7 @@ public function sendTaskSuccess($input): SendTaskSuccessOutput
151153
* @throws InvalidNameException
152154
* @throws StateMachineDoesNotExistException
153155
* @throws StateMachineDeletingException
156+
* @throws ValidationException
154157
*/
155158
public function startExecution($input): StartExecutionOutput
156159
{
@@ -163,6 +166,7 @@ public function startExecution($input): StartExecutionOutput
163166
'InvalidName' => InvalidNameException::class,
164167
'StateMachineDoesNotExist' => StateMachineDoesNotExistException::class,
165168
'StateMachineDeleting' => StateMachineDeletingException::class,
169+
'ValidationException' => ValidationException::class,
166170
]]));
167171

168172
return new StartExecutionOutput($response);
@@ -183,13 +187,15 @@ public function startExecution($input): StartExecutionOutput
183187
*
184188
* @throws ExecutionDoesNotExistException
185189
* @throws InvalidArnException
190+
* @throws ValidationException
186191
*/
187192
public function stopExecution($input): StopExecutionOutput
188193
{
189194
$input = StopExecutionInput::create($input);
190195
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'StopExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [
191196
'ExecutionDoesNotExist' => ExecutionDoesNotExistException::class,
192197
'InvalidArn' => InvalidArnException::class,
198+
'ValidationException' => ValidationException::class,
193199
]]));
194200

195201
return new StopExecutionOutput($response);

0 commit comments

Comments
 (0)