Skip to content

Commit 0dd0f2f

Browse files
[CodeDeploy] Added getDeployment method (#1150)
* [CodeDeploy] Added `getDeployment` method * Fix CS * regenerated code * Update psalm baseline * add missing assertion * fix assert
1 parent 87ffff4 commit 0dd0f2f

33 files changed

+2264
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- AWS api-change: Added `us-iso-west-1` region
88
- AWS api-change: Use specific configuration for `us` regions
99
- Added `createDeployment` method
10+
- Added `getDeployment` method
1011

1112
## 1.2.1
1213

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
],
1313
"require": {
1414
"php": "^7.2.5 || ^8.0",
15+
"ext-filter": "*",
1516
"ext-json": "*",
1617
"async-aws/core": "^1.9"
1718
},

src/CodeDeployClient.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636
use AsyncAws\CodeDeploy\Exception\ThrottlingException;
3737
use AsyncAws\CodeDeploy\Exception\UnsupportedActionForDeploymentTypeException;
3838
use AsyncAws\CodeDeploy\Input\CreateDeploymentInput;
39+
use AsyncAws\CodeDeploy\Input\GetDeploymentInput;
3940
use AsyncAws\CodeDeploy\Input\PutLifecycleEventHookExecutionStatusInput;
4041
use AsyncAws\CodeDeploy\Result\CreateDeploymentOutput;
42+
use AsyncAws\CodeDeploy\Result\GetDeploymentOutput;
4143
use AsyncAws\CodeDeploy\Result\PutLifecycleEventHookExecutionStatusOutput;
4244
use AsyncAws\CodeDeploy\ValueObject\AutoRollbackConfiguration;
4345
use AsyncAws\CodeDeploy\ValueObject\RevisionLocation;
@@ -128,6 +130,33 @@ public function createDeployment($input): CreateDeploymentOutput
128130
return new CreateDeploymentOutput($response);
129131
}
130132

133+
/**
134+
* Gets information about a deployment.
135+
*
136+
* @see https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetDeployment.html
137+
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-codedeploy-2014-10-06.html#getdeployment
138+
*
139+
* @param array{
140+
* deploymentId: string,
141+
* @region?: string,
142+
* }|GetDeploymentInput $input
143+
*
144+
* @throws DeploymentIdRequiredException
145+
* @throws InvalidDeploymentIdException
146+
* @throws DeploymentDoesNotExistException
147+
*/
148+
public function getDeployment($input): GetDeploymentOutput
149+
{
150+
$input = GetDeploymentInput::create($input);
151+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetDeployment', 'region' => $input->getRegion(), 'exceptionMapping' => [
152+
'DeploymentIdRequiredException' => DeploymentIdRequiredException::class,
153+
'InvalidDeploymentIdException' => InvalidDeploymentIdException::class,
154+
'DeploymentDoesNotExistException' => DeploymentDoesNotExistException::class,
155+
]]));
156+
157+
return new GetDeploymentOutput($response);
158+
}
159+
131160
/**
132161
* Sets the result of a Lambda validation function. The function validates lifecycle hooks during a deployment that uses
133162
* the AWS Lambda or Amazon ECS compute platform. For AWS Lambda deployments, the available lifecycle hooks are

src/Enum/ComputePlatform.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The destination platform type for the deployment (`Lambda`, `Server`, or `ECS`).
7+
*/
8+
final class ComputePlatform
9+
{
10+
public const ECS = 'ECS';
11+
public const LAMBDA = 'Lambda';
12+
public const SERVER = 'Server';
13+
14+
public static function exists(string $value): bool
15+
{
16+
return isset([
17+
self::ECS => true,
18+
self::LAMBDA => true,
19+
self::SERVER => true,
20+
][$value]);
21+
}
22+
}

src/Enum/DeploymentCreator.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The means by which the deployment was created:.
7+
*
8+
* - `user`: A user created the deployment.
9+
* - `autoscaling`: Amazon EC2 Auto Scaling created the deployment.
10+
* - `codeDeployRollback`: A rollback process created the deployment.
11+
* - `CodeDeployAutoUpdate`: An auto-update process created the deployment when it detected outdated EC2 instances.
12+
*/
13+
final class DeploymentCreator
14+
{
15+
public const AUTOSCALING = 'autoscaling';
16+
public const CLOUD_FORMATION = 'CloudFormation';
17+
public const CLOUD_FORMATION_ROLLBACK = 'CloudFormationRollback';
18+
public const CODE_DEPLOY = 'CodeDeploy';
19+
public const CODE_DEPLOY_AUTO_UPDATE = 'CodeDeployAutoUpdate';
20+
public const CODE_DEPLOY_ROLLBACK = 'codeDeployRollback';
21+
public const USER = 'user';
22+
23+
public static function exists(string $value): bool
24+
{
25+
return isset([
26+
self::AUTOSCALING => true,
27+
self::CLOUD_FORMATION => true,
28+
self::CLOUD_FORMATION_ROLLBACK => true,
29+
self::CODE_DEPLOY => true,
30+
self::CODE_DEPLOY_AUTO_UPDATE => true,
31+
self::CODE_DEPLOY_ROLLBACK => true,
32+
self::USER => true,
33+
][$value]);
34+
}
35+
}

src/Enum/DeploymentOption.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* Indicates whether to route deployment traffic behind a load balancer.
7+
*/
8+
final class DeploymentOption
9+
{
10+
public const WITHOUT_TRAFFIC_CONTROL = 'WITHOUT_TRAFFIC_CONTROL';
11+
public const WITH_TRAFFIC_CONTROL = 'WITH_TRAFFIC_CONTROL';
12+
13+
public static function exists(string $value): bool
14+
{
15+
return isset([
16+
self::WITHOUT_TRAFFIC_CONTROL => true,
17+
self::WITH_TRAFFIC_CONTROL => true,
18+
][$value]);
19+
}
20+
}

src/Enum/DeploymentReadyAction.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* Information about when to reroute traffic from an original environment to a replacement environment in a blue/green
7+
* deployment.
8+
*
9+
* - CONTINUE_DEPLOYMENT: Register new instances with the load balancer immediately after the new application revision
10+
* is installed on the instances in the replacement environment.
11+
* - STOP_DEPLOYMENT: Do not register new instances with a load balancer unless traffic rerouting is started using
12+
* ContinueDeployment. If traffic rerouting is not started before the end of the specified wait period, the deployment
13+
* status is changed to Stopped.
14+
*/
15+
final class DeploymentReadyAction
16+
{
17+
public const CONTINUE_DEPLOYMENT = 'CONTINUE_DEPLOYMENT';
18+
public const STOP_DEPLOYMENT = 'STOP_DEPLOYMENT';
19+
20+
public static function exists(string $value): bool
21+
{
22+
return isset([
23+
self::CONTINUE_DEPLOYMENT => true,
24+
self::STOP_DEPLOYMENT => true,
25+
][$value]);
26+
}
27+
}

src/Enum/DeploymentStatus.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The current state of the deployment as a whole.
7+
*/
8+
final class DeploymentStatus
9+
{
10+
public const BAKING = 'Baking';
11+
public const CREATED = 'Created';
12+
public const FAILED = 'Failed';
13+
public const IN_PROGRESS = 'InProgress';
14+
public const QUEUED = 'Queued';
15+
public const READY = 'Ready';
16+
public const STOPPED = 'Stopped';
17+
public const SUCCEEDED = 'Succeeded';
18+
19+
public static function exists(string $value): bool
20+
{
21+
return isset([
22+
self::BAKING => true,
23+
self::CREATED => true,
24+
self::FAILED => true,
25+
self::IN_PROGRESS => true,
26+
self::QUEUED => true,
27+
self::READY => true,
28+
self::STOPPED => true,
29+
self::SUCCEEDED => true,
30+
][$value]);
31+
}
32+
}

src/Enum/DeploymentType.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* Indicates whether to run an in-place deployment or a blue/green deployment.
7+
*/
8+
final class DeploymentType
9+
{
10+
public const BLUE_GREEN = 'BLUE_GREEN';
11+
public const IN_PLACE = 'IN_PLACE';
12+
13+
public static function exists(string $value): bool
14+
{
15+
return isset([
16+
self::BLUE_GREEN => true,
17+
self::IN_PLACE => true,
18+
][$value]);
19+
}
20+
}

src/Enum/ErrorCode.php

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* For more information, see Error Codes for AWS CodeDeploy in the AWS CodeDeploy User Guide.
7+
* The error code:.
8+
*
9+
* - APPLICATION_MISSING: The application was missing. This error code is most likely raised if the application is
10+
* deleted after the deployment is created, but before it is started.
11+
* - DEPLOYMENT_GROUP_MISSING: The deployment group was missing. This error code is most likely raised if the deployment
12+
* group is deleted after the deployment is created, but before it is started.
13+
* - HEALTH_CONSTRAINTS: The deployment failed on too many instances to be successfully deployed within the instance
14+
* health constraints specified.
15+
* - HEALTH_CONSTRAINTS_INVALID: The revision cannot be successfully deployed within the instance health constraints
16+
* specified.
17+
* - IAM_ROLE_MISSING: The service role cannot be accessed.
18+
* - IAM_ROLE_PERMISSIONS: The service role does not have the correct permissions.
19+
* - INTERNAL_ERROR: There was an internal error.
20+
* - NO_EC2_SUBSCRIPTION: The calling account is not subscribed to Amazon EC2.
21+
* - NO_INSTANCES: No instances were specified, or no instances can be found.
22+
* - OVER_MAX_INSTANCES: The maximum number of instances was exceeded.
23+
* - THROTTLED: The operation was throttled because the calling account exceeded the throttling limits of one or more
24+
* AWS services.
25+
* - TIMEOUT: The deployment has timed out.
26+
* - REVISION_MISSING: The revision ID was missing. This error code is most likely raised if the revision is deleted
27+
* after the deployment is created, but before it is started.
28+
*
29+
* @see https://docs.aws.amazon.com/codedeploy/latest/userguide/error-codes.html
30+
* @see https://docs.aws.amazon.com/codedeploy/latest/userguide
31+
*/
32+
final class ErrorCode
33+
{
34+
public const AGENT_ISSUE = 'AGENT_ISSUE';
35+
public const ALARM_ACTIVE = 'ALARM_ACTIVE';
36+
public const APPLICATION_MISSING = 'APPLICATION_MISSING';
37+
public const AUTOSCALING_VALIDATION_ERROR = 'AUTOSCALING_VALIDATION_ERROR';
38+
public const AUTO_SCALING_CONFIGURATION = 'AUTO_SCALING_CONFIGURATION';
39+
public const AUTO_SCALING_IAM_ROLE_PERMISSIONS = 'AUTO_SCALING_IAM_ROLE_PERMISSIONS';
40+
public const CLOUDFORMATION_STACK_FAILURE = 'CLOUDFORMATION_STACK_FAILURE';
41+
public const CODEDEPLOY_RESOURCE_CANNOT_BE_FOUND = 'CODEDEPLOY_RESOURCE_CANNOT_BE_FOUND';
42+
public const CUSTOMER_APPLICATION_UNHEALTHY = 'CUSTOMER_APPLICATION_UNHEALTHY';
43+
public const DEPLOYMENT_GROUP_MISSING = 'DEPLOYMENT_GROUP_MISSING';
44+
public const ECS_UPDATE_ERROR = 'ECS_UPDATE_ERROR';
45+
public const ELASTIC_LOAD_BALANCING_INVALID = 'ELASTIC_LOAD_BALANCING_INVALID';
46+
public const ELB_INVALID_INSTANCE = 'ELB_INVALID_INSTANCE';
47+
public const HEALTH_CONSTRAINTS = 'HEALTH_CONSTRAINTS';
48+
public const HEALTH_CONSTRAINTS_INVALID = 'HEALTH_CONSTRAINTS_INVALID';
49+
public const HOOK_EXECUTION_FAILURE = 'HOOK_EXECUTION_FAILURE';
50+
public const IAM_ROLE_MISSING = 'IAM_ROLE_MISSING';
51+
public const IAM_ROLE_PERMISSIONS = 'IAM_ROLE_PERMISSIONS';
52+
public const INTERNAL_ERROR = 'INTERNAL_ERROR';
53+
public const INVALID_ECS_SERVICE = 'INVALID_ECS_SERVICE';
54+
public const INVALID_LAMBDA_CONFIGURATION = 'INVALID_LAMBDA_CONFIGURATION';
55+
public const INVALID_LAMBDA_FUNCTION = 'INVALID_LAMBDA_FUNCTION';
56+
public const INVALID_REVISION = 'INVALID_REVISION';
57+
public const MANUAL_STOP = 'MANUAL_STOP';
58+
public const MISSING_BLUE_GREEN_DEPLOYMENT_CONFIGURATION = 'MISSING_BLUE_GREEN_DEPLOYMENT_CONFIGURATION';
59+
public const MISSING_ELB_INFORMATION = 'MISSING_ELB_INFORMATION';
60+
public const MISSING_GITHUB_TOKEN = 'MISSING_GITHUB_TOKEN';
61+
public const NO_EC2_SUBSCRIPTION = 'NO_EC2_SUBSCRIPTION';
62+
public const NO_INSTANCES = 'NO_INSTANCES';
63+
public const OVER_MAX_INSTANCES = 'OVER_MAX_INSTANCES';
64+
public const RESOURCE_LIMIT_EXCEEDED = 'RESOURCE_LIMIT_EXCEEDED';
65+
public const REVISION_MISSING = 'REVISION_MISSING';
66+
public const THROTTLED = 'THROTTLED';
67+
public const TIMEOUT = 'TIMEOUT';
68+
69+
public static function exists(string $value): bool
70+
{
71+
return isset([
72+
self::AGENT_ISSUE => true,
73+
self::ALARM_ACTIVE => true,
74+
self::APPLICATION_MISSING => true,
75+
self::AUTOSCALING_VALIDATION_ERROR => true,
76+
self::AUTO_SCALING_CONFIGURATION => true,
77+
self::AUTO_SCALING_IAM_ROLE_PERMISSIONS => true,
78+
self::CLOUDFORMATION_STACK_FAILURE => true,
79+
self::CODEDEPLOY_RESOURCE_CANNOT_BE_FOUND => true,
80+
self::CUSTOMER_APPLICATION_UNHEALTHY => true,
81+
self::DEPLOYMENT_GROUP_MISSING => true,
82+
self::ECS_UPDATE_ERROR => true,
83+
self::ELASTIC_LOAD_BALANCING_INVALID => true,
84+
self::ELB_INVALID_INSTANCE => true,
85+
self::HEALTH_CONSTRAINTS => true,
86+
self::HEALTH_CONSTRAINTS_INVALID => true,
87+
self::HOOK_EXECUTION_FAILURE => true,
88+
self::IAM_ROLE_MISSING => true,
89+
self::IAM_ROLE_PERMISSIONS => true,
90+
self::INTERNAL_ERROR => true,
91+
self::INVALID_ECS_SERVICE => true,
92+
self::INVALID_LAMBDA_CONFIGURATION => true,
93+
self::INVALID_LAMBDA_FUNCTION => true,
94+
self::INVALID_REVISION => true,
95+
self::MANUAL_STOP => true,
96+
self::MISSING_BLUE_GREEN_DEPLOYMENT_CONFIGURATION => true,
97+
self::MISSING_ELB_INFORMATION => true,
98+
self::MISSING_GITHUB_TOKEN => true,
99+
self::NO_EC2_SUBSCRIPTION => true,
100+
self::NO_INSTANCES => true,
101+
self::OVER_MAX_INSTANCES => true,
102+
self::RESOURCE_LIMIT_EXCEEDED => true,
103+
self::REVISION_MISSING => true,
104+
self::THROTTLED => true,
105+
self::TIMEOUT => true,
106+
][$value]);
107+
}
108+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The method used to add instances to a replacement environment.
7+
*
8+
* - `DISCOVER_EXISTING`: Use instances that already exist or will be created manually.
9+
* - `COPY_AUTO_SCALING_GROUP`: Use settings from a specified Auto Scaling group to define and create instances in a new
10+
* Auto Scaling group.
11+
*/
12+
final class GreenFleetProvisioningAction
13+
{
14+
public const COPY_AUTO_SCALING_GROUP = 'COPY_AUTO_SCALING_GROUP';
15+
public const DISCOVER_EXISTING = 'DISCOVER_EXISTING';
16+
17+
public static function exists(string $value): bool
18+
{
19+
return isset([
20+
self::COPY_AUTO_SCALING_GROUP => true,
21+
self::DISCOVER_EXISTING => true,
22+
][$value]);
23+
}
24+
}

src/Enum/InstanceAction.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The action to take on instances in the original environment after a successful blue/green deployment.
7+
*
8+
* - `TERMINATE`: Instances are terminated after a specified wait time.
9+
* - `KEEP_ALIVE`: Instances are left running after they are deregistered from the load balancer and removed from the
10+
* deployment group.
11+
*/
12+
final class InstanceAction
13+
{
14+
public const KEEP_ALIVE = 'KEEP_ALIVE';
15+
public const TERMINATE = 'TERMINATE';
16+
17+
public static function exists(string $value): bool
18+
{
19+
return isset([
20+
self::KEEP_ALIVE => true,
21+
self::TERMINATE => true,
22+
][$value]);
23+
}
24+
}

0 commit comments

Comments
 (0)