Skip to content

Commit cb6dd98

Browse files
[CodeDeploy] Added createDeployment() method (#1141)
* Added `createDeployment` method * fix psalm Co-authored-by: Jérémy Derussé <jeremy@derusse.com>
1 parent c95a61e commit cb6dd98

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1898
-0
lines changed

CHANGELOG.md

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

77
- AWS api-change: Added `us-iso-west-1` region
88
- AWS api-change: Use specific configuration for `us` regions
9+
- Added `createDeployment` method
910

1011
## 1.2.1
1112

src/CodeDeployClient.php

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,46 @@
22

33
namespace AsyncAws\CodeDeploy;
44

5+
use AsyncAws\CodeDeploy\Enum\FileExistsBehavior;
56
use AsyncAws\CodeDeploy\Enum\LifecycleEventStatus;
7+
use AsyncAws\CodeDeploy\Exception\ApplicationDoesNotExistException;
8+
use AsyncAws\CodeDeploy\Exception\ApplicationNameRequiredException;
9+
use AsyncAws\CodeDeploy\Exception\DeploymentConfigDoesNotExistException;
610
use AsyncAws\CodeDeploy\Exception\DeploymentDoesNotExistException;
11+
use AsyncAws\CodeDeploy\Exception\DeploymentGroupDoesNotExistException;
12+
use AsyncAws\CodeDeploy\Exception\DeploymentGroupNameRequiredException;
713
use AsyncAws\CodeDeploy\Exception\DeploymentIdRequiredException;
14+
use AsyncAws\CodeDeploy\Exception\DeploymentLimitExceededException;
15+
use AsyncAws\CodeDeploy\Exception\DescriptionTooLongException;
16+
use AsyncAws\CodeDeploy\Exception\InvalidApplicationNameException;
17+
use AsyncAws\CodeDeploy\Exception\InvalidAutoRollbackConfigException;
18+
use AsyncAws\CodeDeploy\Exception\InvalidAutoScalingGroupException;
19+
use AsyncAws\CodeDeploy\Exception\InvalidDeploymentConfigNameException;
20+
use AsyncAws\CodeDeploy\Exception\InvalidDeploymentGroupNameException;
821
use AsyncAws\CodeDeploy\Exception\InvalidDeploymentIdException;
22+
use AsyncAws\CodeDeploy\Exception\InvalidFileExistsBehaviorException;
23+
use AsyncAws\CodeDeploy\Exception\InvalidGitHubAccountTokenException;
24+
use AsyncAws\CodeDeploy\Exception\InvalidIgnoreApplicationStopFailuresValueException;
925
use AsyncAws\CodeDeploy\Exception\InvalidLifecycleEventHookExecutionIdException;
1026
use AsyncAws\CodeDeploy\Exception\InvalidLifecycleEventHookExecutionStatusException;
27+
use AsyncAws\CodeDeploy\Exception\InvalidLoadBalancerInfoException;
28+
use AsyncAws\CodeDeploy\Exception\InvalidRevisionException;
29+
use AsyncAws\CodeDeploy\Exception\InvalidRoleException;
30+
use AsyncAws\CodeDeploy\Exception\InvalidTargetInstancesException;
31+
use AsyncAws\CodeDeploy\Exception\InvalidTrafficRoutingConfigurationException;
32+
use AsyncAws\CodeDeploy\Exception\InvalidUpdateOutdatedInstancesOnlyValueException;
1133
use AsyncAws\CodeDeploy\Exception\LifecycleEventAlreadyCompletedException;
34+
use AsyncAws\CodeDeploy\Exception\RevisionDoesNotExistException;
35+
use AsyncAws\CodeDeploy\Exception\RevisionRequiredException;
36+
use AsyncAws\CodeDeploy\Exception\ThrottlingException;
1237
use AsyncAws\CodeDeploy\Exception\UnsupportedActionForDeploymentTypeException;
38+
use AsyncAws\CodeDeploy\Input\CreateDeploymentInput;
1339
use AsyncAws\CodeDeploy\Input\PutLifecycleEventHookExecutionStatusInput;
40+
use AsyncAws\CodeDeploy\Result\CreateDeploymentOutput;
1441
use AsyncAws\CodeDeploy\Result\PutLifecycleEventHookExecutionStatusOutput;
42+
use AsyncAws\CodeDeploy\ValueObject\AutoRollbackConfiguration;
43+
use AsyncAws\CodeDeploy\ValueObject\RevisionLocation;
44+
use AsyncAws\CodeDeploy\ValueObject\TargetInstances;
1545
use AsyncAws\Core\AbstractApi;
1646
use AsyncAws\Core\AwsError\AwsErrorFactoryInterface;
1747
use AsyncAws\Core\AwsError\JsonRpcAwsErrorFactory;
@@ -20,6 +50,84 @@
2050

2151
class CodeDeployClient extends AbstractApi
2252
{
53+
/**
54+
* Deploys an application revision through the specified deployment group.
55+
*
56+
* @see https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeployment.html
57+
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-codedeploy-2014-10-06.html#createdeployment
58+
*
59+
* @param array{
60+
* applicationName: string,
61+
* deploymentGroupName?: string,
62+
* revision?: RevisionLocation|array,
63+
* deploymentConfigName?: string,
64+
* description?: string,
65+
* ignoreApplicationStopFailures?: bool,
66+
* targetInstances?: TargetInstances|array,
67+
* autoRollbackConfiguration?: AutoRollbackConfiguration|array,
68+
* updateOutdatedInstancesOnly?: bool,
69+
* fileExistsBehavior?: FileExistsBehavior::*,
70+
* @region?: string,
71+
* }|CreateDeploymentInput $input
72+
*
73+
* @throws ApplicationNameRequiredException
74+
* @throws InvalidApplicationNameException
75+
* @throws ApplicationDoesNotExistException
76+
* @throws DeploymentGroupNameRequiredException
77+
* @throws InvalidDeploymentGroupNameException
78+
* @throws DeploymentGroupDoesNotExistException
79+
* @throws RevisionRequiredException
80+
* @throws RevisionDoesNotExistException
81+
* @throws InvalidRevisionException
82+
* @throws InvalidDeploymentConfigNameException
83+
* @throws DeploymentConfigDoesNotExistException
84+
* @throws DescriptionTooLongException
85+
* @throws DeploymentLimitExceededException
86+
* @throws InvalidTargetInstancesException
87+
* @throws InvalidAutoRollbackConfigException
88+
* @throws InvalidLoadBalancerInfoException
89+
* @throws InvalidFileExistsBehaviorException
90+
* @throws InvalidRoleException
91+
* @throws InvalidAutoScalingGroupException
92+
* @throws ThrottlingException
93+
* @throws InvalidUpdateOutdatedInstancesOnlyValueException
94+
* @throws InvalidIgnoreApplicationStopFailuresValueException
95+
* @throws InvalidGitHubAccountTokenException
96+
* @throws InvalidTrafficRoutingConfigurationException
97+
*/
98+
public function createDeployment($input): CreateDeploymentOutput
99+
{
100+
$input = CreateDeploymentInput::create($input);
101+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'CreateDeployment', 'region' => $input->getRegion(), 'exceptionMapping' => [
102+
'ApplicationNameRequiredException' => ApplicationNameRequiredException::class,
103+
'InvalidApplicationNameException' => InvalidApplicationNameException::class,
104+
'ApplicationDoesNotExistException' => ApplicationDoesNotExistException::class,
105+
'DeploymentGroupNameRequiredException' => DeploymentGroupNameRequiredException::class,
106+
'InvalidDeploymentGroupNameException' => InvalidDeploymentGroupNameException::class,
107+
'DeploymentGroupDoesNotExistException' => DeploymentGroupDoesNotExistException::class,
108+
'RevisionRequiredException' => RevisionRequiredException::class,
109+
'RevisionDoesNotExistException' => RevisionDoesNotExistException::class,
110+
'InvalidRevisionException' => InvalidRevisionException::class,
111+
'InvalidDeploymentConfigNameException' => InvalidDeploymentConfigNameException::class,
112+
'DeploymentConfigDoesNotExistException' => DeploymentConfigDoesNotExistException::class,
113+
'DescriptionTooLongException' => DescriptionTooLongException::class,
114+
'DeploymentLimitExceededException' => DeploymentLimitExceededException::class,
115+
'InvalidTargetInstancesException' => InvalidTargetInstancesException::class,
116+
'InvalidAutoRollbackConfigException' => InvalidAutoRollbackConfigException::class,
117+
'InvalidLoadBalancerInfoException' => InvalidLoadBalancerInfoException::class,
118+
'InvalidFileExistsBehaviorException' => InvalidFileExistsBehaviorException::class,
119+
'InvalidRoleException' => InvalidRoleException::class,
120+
'InvalidAutoScalingGroupException' => InvalidAutoScalingGroupException::class,
121+
'ThrottlingException' => ThrottlingException::class,
122+
'InvalidUpdateOutdatedInstancesOnlyValueException' => InvalidUpdateOutdatedInstancesOnlyValueException::class,
123+
'InvalidIgnoreApplicationStopFailuresValueException' => InvalidIgnoreApplicationStopFailuresValueException::class,
124+
'InvalidGitHubAccountTokenException' => InvalidGitHubAccountTokenException::class,
125+
'InvalidTrafficRoutingConfigurationException' => InvalidTrafficRoutingConfigurationException::class,
126+
]]));
127+
128+
return new CreateDeploymentOutput($response);
129+
}
130+
23131
/**
24132
* Sets the result of a Lambda validation function. The function validates lifecycle hooks during a deployment that uses
25133
* the AWS Lambda or Amazon ECS compute platform. For AWS Lambda deployments, the available lifecycle hooks are

src/Enum/AutoRollbackEvent.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
final class AutoRollbackEvent
6+
{
7+
public const DEPLOYMENT_FAILURE = 'DEPLOYMENT_FAILURE';
8+
public const DEPLOYMENT_STOP_ON_ALARM = 'DEPLOYMENT_STOP_ON_ALARM';
9+
public const DEPLOYMENT_STOP_ON_REQUEST = 'DEPLOYMENT_STOP_ON_REQUEST';
10+
11+
public static function exists(string $value): bool
12+
{
13+
return isset([
14+
self::DEPLOYMENT_FAILURE => true,
15+
self::DEPLOYMENT_STOP_ON_ALARM => true,
16+
self::DEPLOYMENT_STOP_ON_REQUEST => true,
17+
][$value]);
18+
}
19+
}

src/Enum/BundleType.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The file type of the application revision. Must be one of the following:.
7+
*
8+
* - `tar`: A tar archive file.
9+
* - `tgz`: A compressed tar archive file.
10+
* - `zip`: A zip archive file.
11+
*/
12+
final class BundleType
13+
{
14+
public const JSON = 'JSON';
15+
public const TAR = 'tar';
16+
public const TGZ = 'tgz';
17+
public const YAML = 'YAML';
18+
public const ZIP = 'zip';
19+
20+
public static function exists(string $value): bool
21+
{
22+
return isset([
23+
self::JSON => true,
24+
self::TAR => true,
25+
self::TGZ => true,
26+
self::YAML => true,
27+
self::ZIP => true,
28+
][$value]);
29+
}
30+
}

src/Enum/EC2TagFilterType.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The tag filter type:.
7+
*
8+
* - `KEY_ONLY`: Key only.
9+
* - `VALUE_ONLY`: Value only.
10+
* - `KEY_AND_VALUE`: Key and value.
11+
*/
12+
final class EC2TagFilterType
13+
{
14+
public const KEY_AND_VALUE = 'KEY_AND_VALUE';
15+
public const KEY_ONLY = 'KEY_ONLY';
16+
public const VALUE_ONLY = 'VALUE_ONLY';
17+
18+
public static function exists(string $value): bool
19+
{
20+
return isset([
21+
self::KEY_AND_VALUE => true,
22+
self::KEY_ONLY => true,
23+
self::VALUE_ONLY => true,
24+
][$value]);
25+
}
26+
}

src/Enum/FileExistsBehavior.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* Information about how AWS CodeDeploy handles files that already exist in a deployment target location but weren't
7+
* part of the previous successful deployment.
8+
* The `fileExistsBehavior` parameter takes any of the following values:.
9+
*
10+
* - DISALLOW: The deployment fails. This is also the default behavior if no option is specified.
11+
* - OVERWRITE: The version of the file from the application revision currently being deployed replaces the version
12+
* already on the instance.
13+
* - RETAIN: The version of the file already on the instance is kept and used as part of the new deployment.
14+
*/
15+
final class FileExistsBehavior
16+
{
17+
public const DISALLOW = 'DISALLOW';
18+
public const OVERWRITE = 'OVERWRITE';
19+
public const RETAIN = 'RETAIN';
20+
21+
public static function exists(string $value): bool
22+
{
23+
return isset([
24+
self::DISALLOW => true,
25+
self::OVERWRITE => true,
26+
self::RETAIN => true,
27+
][$value]);
28+
}
29+
}

src/Enum/RevisionLocationType.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeDeploy\Enum;
4+
5+
/**
6+
* The type of application revision:.
7+
*
8+
* - S3: An application revision stored in Amazon S3.
9+
* - GitHub: An application revision stored in GitHub (EC2/On-premises deployments only).
10+
* - String: A YAML-formatted or JSON-formatted string (AWS Lambda deployments only).
11+
* - AppSpecContent: An `AppSpecContent` object that contains the contents of an AppSpec file for an AWS Lambda or
12+
* Amazon ECS deployment. The content is formatted as JSON or YAML stored as a RawString.
13+
*/
14+
final class RevisionLocationType
15+
{
16+
public const APP_SPEC_CONTENT = 'AppSpecContent';
17+
public const GIT_HUB = 'GitHub';
18+
public const S3 = 'S3';
19+
public const STRING = 'String';
20+
21+
public static function exists(string $value): bool
22+
{
23+
return isset([
24+
self::APP_SPEC_CONTENT => true,
25+
self::GIT_HUB => true,
26+
self::S3 => true,
27+
self::STRING => true,
28+
][$value]);
29+
}
30+
}
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 application does not exist with the IAM user or AWS account.
9+
*/
10+
final class ApplicationDoesNotExistException 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+
* The minimum number of required application names was not specified.
9+
*/
10+
final class ApplicationNameRequiredException 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+
* The deployment configuration does not exist with the IAM user or AWS account.
9+
*/
10+
final class DeploymentConfigDoesNotExistException 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+
* The named deployment group with the IAM user or AWS account does not exist.
9+
*/
10+
final class DeploymentGroupDoesNotExistException 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+
* The deployment group name was not specified.
9+
*/
10+
final class DeploymentGroupNameRequiredException 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+
* The number of allowed deployments was exceeded.
9+
*/
10+
final class DeploymentLimitExceededException 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+
* The description is too long.
9+
*/
10+
final class DescriptionTooLongException 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+
* The application name was specified in an invalid format.
9+
*/
10+
final class InvalidApplicationNameException 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+
* The automatic rollback configuration was specified in an invalid format. For example, automatic rollback is enabled,
9+
* but an invalid triggering event type or no event types were listed.
10+
*/
11+
final class InvalidAutoRollbackConfigException extends ClientException
12+
{
13+
}

0 commit comments

Comments
 (0)