Skip to content

Commit 6aa68a7

Browse files
authored
Generate Exceptions (#921)
* Generate Exceptions * Add documentation on top of class * Leverage the new AwsErrorFactory * Fix __constructor signature in GeneratedException * Fix private vs protected * Generate all methods * Fix things * Add constraint in composer.Json * Add changelog entry
1 parent c8719be commit 6aa68a7

10 files changed

+112
-2
lines changed

CHANGELOG.md

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

77
- Added documentation in class's headers.
8+
- Added Business Exceptions.
89

910
## 1.1.1
1011

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"require": {
1414
"php": "^7.2.5 || ^8.0",
1515
"ext-json": "*",
16-
"async-aws/core": "^1.2"
16+
"async-aws/core": "^1.9"
1717
},
1818
"extra": {
1919
"branch-alias": {

src/CodeDeployClient.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
namespace AsyncAws\CodeDeploy;
44

55
use AsyncAws\CodeDeploy\Enum\LifecycleEventStatus;
6+
use AsyncAws\CodeDeploy\Exception\DeploymentDoesNotExistException;
7+
use AsyncAws\CodeDeploy\Exception\DeploymentIdRequiredException;
8+
use AsyncAws\CodeDeploy\Exception\InvalidDeploymentIdException;
9+
use AsyncAws\CodeDeploy\Exception\InvalidLifecycleEventHookExecutionIdException;
10+
use AsyncAws\CodeDeploy\Exception\InvalidLifecycleEventHookExecutionStatusException;
11+
use AsyncAws\CodeDeploy\Exception\LifecycleEventAlreadyCompletedException;
12+
use AsyncAws\CodeDeploy\Exception\UnsupportedActionForDeploymentTypeException;
613
use AsyncAws\CodeDeploy\Input\PutLifecycleEventHookExecutionStatusInput;
714
use AsyncAws\CodeDeploy\Result\PutLifecycleEventHookExecutionStatusOutput;
815
use AsyncAws\Core\AbstractApi;
@@ -32,11 +39,27 @@ class CodeDeployClient extends AbstractApi
3239
* status?: LifecycleEventStatus::*,
3340
* @region?: string,
3441
* }|PutLifecycleEventHookExecutionStatusInput $input
42+
*
43+
* @throws InvalidLifecycleEventHookExecutionStatusException
44+
* @throws InvalidLifecycleEventHookExecutionIdException
45+
* @throws LifecycleEventAlreadyCompletedException
46+
* @throws DeploymentIdRequiredException
47+
* @throws DeploymentDoesNotExistException
48+
* @throws InvalidDeploymentIdException
49+
* @throws UnsupportedActionForDeploymentTypeException
3550
*/
3651
public function putLifecycleEventHookExecutionStatus($input = []): PutLifecycleEventHookExecutionStatusOutput
3752
{
3853
$input = PutLifecycleEventHookExecutionStatusInput::create($input);
39-
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'PutLifecycleEventHookExecutionStatus', 'region' => $input->getRegion()]));
54+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'PutLifecycleEventHookExecutionStatus', 'region' => $input->getRegion(), 'exceptionMapping' => [
55+
'InvalidLifecycleEventHookExecutionStatusException' => InvalidLifecycleEventHookExecutionStatusException::class,
56+
'InvalidLifecycleEventHookExecutionIdException' => InvalidLifecycleEventHookExecutionIdException::class,
57+
'LifecycleEventAlreadyCompletedException' => LifecycleEventAlreadyCompletedException::class,
58+
'DeploymentIdRequiredException' => DeploymentIdRequiredException::class,
59+
'DeploymentDoesNotExistException' => DeploymentDoesNotExistException::class,
60+
'InvalidDeploymentIdException' => InvalidDeploymentIdException::class,
61+
'UnsupportedActionForDeploymentTypeException' => UnsupportedActionForDeploymentTypeException::class,
62+
]]));
4063

4164
return new PutLifecycleEventHookExecutionStatusOutput($response);
4265
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The deployment with the IAM user or AWS account does not exist.
9+
*/
10+
final class DeploymentDoesNotExistException extends ClientException
11+
{
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* At least one deployment ID must be specified.
9+
*/
10+
final class DeploymentIdRequiredException extends ClientException
11+
{
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* At least one of the deployment IDs was specified in an invalid format.
9+
*/
10+
final class InvalidDeploymentIdException extends ClientException
11+
{
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* A lifecycle event hook is invalid. Review the `hooks` section in your AppSpec file to ensure the lifecycle events and
9+
* `hooks` functions are valid.
10+
*/
11+
final class InvalidLifecycleEventHookExecutionIdException extends ClientException
12+
{
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The result of a Lambda validation function that verifies a lifecycle event is invalid. It should return `Succeeded`
9+
* or `Failed`.
10+
*/
11+
final class InvalidLifecycleEventHookExecutionStatusException extends ClientException
12+
{
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* An attempt to return the status of an already completed lifecycle event occurred.
9+
*/
10+
final class LifecycleEventAlreadyCompletedException extends ClientException
11+
{
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* A call was submitted that is not supported for the specified deployment type.
9+
*/
10+
final class UnsupportedActionForDeploymentTypeException extends ClientException
11+
{
12+
}

0 commit comments

Comments
 (0)