Skip to content

Commit 1142e0a

Browse files
nealio82Neal Brooks
and
Neal Brooks
authored
add PutRepositoryTriggers to CodeCommit client (#1308)
* add PutRepositoryTriggers to CodeCommit client * fix docs copy/pasta * phpstan knows what's best * phpstan doesn't know best * ignore this, phpstan Co-authored-by: Neal Brooks <neali82@gmail.com>
1 parent 8110bae commit 1142e0a

22 files changed

+682
-1
lines changed

src/CodeCommitClient.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,31 @@
2222
use AsyncAws\CodeCommit\Exception\InvalidMaxResultsException;
2323
use AsyncAws\CodeCommit\Exception\InvalidPathException;
2424
use AsyncAws\CodeCommit\Exception\InvalidRepositoryNameException;
25+
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerBranchNameException;
26+
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerCustomDataException;
27+
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerDestinationArnException;
28+
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerEventsException;
29+
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerNameException;
30+
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerRegionException;
31+
use AsyncAws\CodeCommit\Exception\MaximumBranchesExceededException;
32+
use AsyncAws\CodeCommit\Exception\MaximumRepositoryTriggersExceededException;
2533
use AsyncAws\CodeCommit\Exception\PathDoesNotExistException;
2634
use AsyncAws\CodeCommit\Exception\RepositoryDoesNotExistException;
2735
use AsyncAws\CodeCommit\Exception\RepositoryNameRequiredException;
36+
use AsyncAws\CodeCommit\Exception\RepositoryTriggerBranchNameListRequiredException;
37+
use AsyncAws\CodeCommit\Exception\RepositoryTriggerDestinationArnRequiredException;
38+
use AsyncAws\CodeCommit\Exception\RepositoryTriggerEventsListRequiredException;
39+
use AsyncAws\CodeCommit\Exception\RepositoryTriggerNameRequiredException;
40+
use AsyncAws\CodeCommit\Exception\RepositoryTriggersListRequiredException;
2841
use AsyncAws\CodeCommit\Input\GetBlobInput;
2942
use AsyncAws\CodeCommit\Input\GetBranchInput;
3043
use AsyncAws\CodeCommit\Input\GetDifferencesInput;
44+
use AsyncAws\CodeCommit\Input\PutRepositoryTriggersInput;
3145
use AsyncAws\CodeCommit\Result\GetBlobOutput;
3246
use AsyncAws\CodeCommit\Result\GetBranchOutput;
3347
use AsyncAws\CodeCommit\Result\GetDifferencesOutput;
48+
use AsyncAws\CodeCommit\Result\PutRepositoryTriggersOutput;
49+
use AsyncAws\CodeCommit\ValueObject\RepositoryTrigger;
3450
use AsyncAws\Core\AbstractApi;
3551
use AsyncAws\Core\AwsError\AwsErrorFactoryInterface;
3652
use AsyncAws\Core\AwsError\JsonRpcAwsErrorFactory;
@@ -189,6 +205,70 @@ public function getDifferences($input): GetDifferencesOutput
189205
return new GetDifferencesOutput($response, $this, $input);
190206
}
191207

208+
/**
209+
* Replaces all triggers for a repository. Used to create or delete triggers.
210+
*
211+
* @see https://docs.aws.amazon.com/codecommit/latest/APIReference/API_PutRepositoryTriggers.html
212+
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-codecommit-2015-04-13.html#putrepositorytriggers
213+
*
214+
* @param array{
215+
* repositoryName: string,
216+
* triggers: RepositoryTrigger[],
217+
* @region?: string,
218+
* }|PutRepositoryTriggersInput $input
219+
*
220+
* @throws RepositoryDoesNotExistException
221+
* @throws RepositoryNameRequiredException
222+
* @throws InvalidRepositoryNameException
223+
* @throws RepositoryTriggersListRequiredException
224+
* @throws MaximumRepositoryTriggersExceededException
225+
* @throws InvalidRepositoryTriggerNameException
226+
* @throws InvalidRepositoryTriggerDestinationArnException
227+
* @throws InvalidRepositoryTriggerRegionException
228+
* @throws InvalidRepositoryTriggerCustomDataException
229+
* @throws MaximumBranchesExceededException
230+
* @throws InvalidRepositoryTriggerBranchNameException
231+
* @throws InvalidRepositoryTriggerEventsException
232+
* @throws RepositoryTriggerNameRequiredException
233+
* @throws RepositoryTriggerDestinationArnRequiredException
234+
* @throws RepositoryTriggerBranchNameListRequiredException
235+
* @throws RepositoryTriggerEventsListRequiredException
236+
* @throws EncryptionIntegrityChecksFailedException
237+
* @throws EncryptionKeyAccessDeniedException
238+
* @throws EncryptionKeyDisabledException
239+
* @throws EncryptionKeyNotFoundException
240+
* @throws EncryptionKeyUnavailableException
241+
*/
242+
public function putRepositoryTriggers($input): PutRepositoryTriggersOutput
243+
{
244+
$input = PutRepositoryTriggersInput::create($input);
245+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'PutRepositoryTriggers', 'region' => $input->getRegion(), 'exceptionMapping' => [
246+
'RepositoryDoesNotExistException' => RepositoryDoesNotExistException::class,
247+
'RepositoryNameRequiredException' => RepositoryNameRequiredException::class,
248+
'InvalidRepositoryNameException' => InvalidRepositoryNameException::class,
249+
'RepositoryTriggersListRequiredException' => RepositoryTriggersListRequiredException::class,
250+
'MaximumRepositoryTriggersExceededException' => MaximumRepositoryTriggersExceededException::class,
251+
'InvalidRepositoryTriggerNameException' => InvalidRepositoryTriggerNameException::class,
252+
'InvalidRepositoryTriggerDestinationArnException' => InvalidRepositoryTriggerDestinationArnException::class,
253+
'InvalidRepositoryTriggerRegionException' => InvalidRepositoryTriggerRegionException::class,
254+
'InvalidRepositoryTriggerCustomDataException' => InvalidRepositoryTriggerCustomDataException::class,
255+
'MaximumBranchesExceededException' => MaximumBranchesExceededException::class,
256+
'InvalidRepositoryTriggerBranchNameException' => InvalidRepositoryTriggerBranchNameException::class,
257+
'InvalidRepositoryTriggerEventsException' => InvalidRepositoryTriggerEventsException::class,
258+
'RepositoryTriggerNameRequiredException' => RepositoryTriggerNameRequiredException::class,
259+
'RepositoryTriggerDestinationArnRequiredException' => RepositoryTriggerDestinationArnRequiredException::class,
260+
'RepositoryTriggerBranchNameListRequiredException' => RepositoryTriggerBranchNameListRequiredException::class,
261+
'RepositoryTriggerEventsListRequiredException' => RepositoryTriggerEventsListRequiredException::class,
262+
'EncryptionIntegrityChecksFailedException' => EncryptionIntegrityChecksFailedException::class,
263+
'EncryptionKeyAccessDeniedException' => EncryptionKeyAccessDeniedException::class,
264+
'EncryptionKeyDisabledException' => EncryptionKeyDisabledException::class,
265+
'EncryptionKeyNotFoundException' => EncryptionKeyNotFoundException::class,
266+
'EncryptionKeyUnavailableException' => EncryptionKeyUnavailableException::class,
267+
]]));
268+
269+
return new PutRepositoryTriggersOutput($response);
270+
}
271+
192272
protected function getAwsErrorFactory(): AwsErrorFactoryInterface
193273
{
194274
return new JsonRpcAwsErrorFactory();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeCommit\Enum;
4+
5+
final class RepositoryTriggerEventEnum
6+
{
7+
public const ALL = 'all';
8+
public const CREATE_REFERENCE = 'createReference';
9+
public const DELETE_REFERENCE = 'deleteReference';
10+
public const UPDATE_REFERENCE = 'updateReference';
11+
12+
public static function exists(string $value): bool
13+
{
14+
return isset([
15+
self::ALL => true,
16+
self::CREATE_REFERENCE => true,
17+
self::DELETE_REFERENCE => true,
18+
self::UPDATE_REFERENCE => true,
19+
][$value]);
20+
}
21+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace AsyncAws\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* One or more branch names specified for the trigger is not valid.
9+
*/
10+
final class InvalidRepositoryTriggerBranchNameException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The custom data provided for the trigger is not valid.
9+
*/
10+
final class InvalidRepositoryTriggerCustomDataException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The Amazon Resource Name (ARN) for the trigger is not valid for the specified destination. The most common reason for
9+
* this error is that the ARN does not meet the requirements for the service type.
10+
*/
11+
final class InvalidRepositoryTriggerDestinationArnException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* One or more events specified for the trigger is not valid. Check to make sure that all events specified match the
9+
* requirements for allowed events.
10+
*/
11+
final class InvalidRepositoryTriggerEventsException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The name of the trigger is not valid.
9+
*/
10+
final class InvalidRepositoryTriggerNameException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The AWS Region for the trigger target does not match the AWS Region for the repository. Triggers must be created in
9+
* the same Region as the target for the trigger.
10+
*/
11+
final class InvalidRepositoryTriggerRegionException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The number of branches for the trigger was exceeded.
9+
*/
10+
final class MaximumBranchesExceededException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The number of triggers allowed for the repository was exceeded.
9+
*/
10+
final class MaximumRepositoryTriggersExceededException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* At least one branch name is required, but was not specified in the trigger configuration.
9+
*/
10+
final class RepositoryTriggerBranchNameListRequiredException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* A destination ARN for the target service for the trigger is required, but was not specified.
9+
*/
10+
final class RepositoryTriggerDestinationArnRequiredException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* At least one event for the trigger is required, but was not specified.
9+
*/
10+
final class RepositoryTriggerEventsListRequiredException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* A name for the trigger is required, but was not specified.
9+
*/
10+
final class RepositoryTriggerNameRequiredException 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\CodeCommit\Exception;
4+
5+
use AsyncAws\Core\Exception\Http\ClientException;
6+
7+
/**
8+
* The list of triggers for the repository is required, but was not specified.
9+
*/
10+
final class RepositoryTriggersListRequiredException extends ClientException
11+
{
12+
}

0 commit comments

Comments
 (0)