Skip to content

Commit 1739133

Browse files
nealio82Neal Brooksjderusse
authored
add listRepositories, createRepository, deleteRepository to CodeCommit client (#1333)
* add listRepositories, createRepository, deleteRepository * cs fix * add 0.2.0 version to changelog * Update src/Service/CodeCommit/CHANGELOG.md Co-authored-by: Neal Brooks <[email protected]> Co-authored-by: Jérémy Derussé <[email protected]>
1 parent f356942 commit 1739133

29 files changed

+1380
-0
lines changed

CHANGELOG.md

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

33
## NOT RELEASED
44

5+
### Added
6+
7+
- Added operation `ListRepositories`
8+
- Added operation `CreateRepository`
9+
- Added operation `DeleteRepository`
10+
511
## 0.1.1
612

713
### Added

src/CodeCommitClient.php

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

33
namespace AsyncAws\CodeCommit;
44

5+
use AsyncAws\CodeCommit\Enum\OrderEnum;
6+
use AsyncAws\CodeCommit\Enum\SortByEnum;
57
use AsyncAws\CodeCommit\Exception\BlobIdDoesNotExistException;
68
use AsyncAws\CodeCommit\Exception\BlobIdRequiredException;
79
use AsyncAws\CodeCommit\Exception\BranchDoesNotExistException;
@@ -22,33 +24,48 @@
2224
use AsyncAws\CodeCommit\Exception\InvalidCommitIdException;
2325
use AsyncAws\CodeCommit\Exception\InvalidContinuationTokenException;
2426
use AsyncAws\CodeCommit\Exception\InvalidMaxResultsException;
27+
use AsyncAws\CodeCommit\Exception\InvalidOrderException;
2528
use AsyncAws\CodeCommit\Exception\InvalidPathException;
29+
use AsyncAws\CodeCommit\Exception\InvalidRepositoryDescriptionException;
2630
use AsyncAws\CodeCommit\Exception\InvalidRepositoryNameException;
2731
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerBranchNameException;
2832
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerCustomDataException;
2933
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerDestinationArnException;
3034
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerEventsException;
3135
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerNameException;
3236
use AsyncAws\CodeCommit\Exception\InvalidRepositoryTriggerRegionException;
37+
use AsyncAws\CodeCommit\Exception\InvalidSortByException;
38+
use AsyncAws\CodeCommit\Exception\InvalidSystemTagUsageException;
39+
use AsyncAws\CodeCommit\Exception\InvalidTagsMapException;
3340
use AsyncAws\CodeCommit\Exception\MaximumBranchesExceededException;
3441
use AsyncAws\CodeCommit\Exception\MaximumRepositoryTriggersExceededException;
3542
use AsyncAws\CodeCommit\Exception\PathDoesNotExistException;
3643
use AsyncAws\CodeCommit\Exception\RepositoryDoesNotExistException;
44+
use AsyncAws\CodeCommit\Exception\RepositoryLimitExceededException;
45+
use AsyncAws\CodeCommit\Exception\RepositoryNameExistsException;
3746
use AsyncAws\CodeCommit\Exception\RepositoryNameRequiredException;
3847
use AsyncAws\CodeCommit\Exception\RepositoryTriggerBranchNameListRequiredException;
3948
use AsyncAws\CodeCommit\Exception\RepositoryTriggerDestinationArnRequiredException;
4049
use AsyncAws\CodeCommit\Exception\RepositoryTriggerEventsListRequiredException;
4150
use AsyncAws\CodeCommit\Exception\RepositoryTriggerNameRequiredException;
4251
use AsyncAws\CodeCommit\Exception\RepositoryTriggersListRequiredException;
52+
use AsyncAws\CodeCommit\Exception\TagPolicyException;
53+
use AsyncAws\CodeCommit\Exception\TooManyTagsException;
54+
use AsyncAws\CodeCommit\Input\CreateRepositoryInput;
55+
use AsyncAws\CodeCommit\Input\DeleteRepositoryInput;
4356
use AsyncAws\CodeCommit\Input\GetBlobInput;
4457
use AsyncAws\CodeCommit\Input\GetBranchInput;
4558
use AsyncAws\CodeCommit\Input\GetCommitInput;
4659
use AsyncAws\CodeCommit\Input\GetDifferencesInput;
60+
use AsyncAws\CodeCommit\Input\ListRepositoriesInput;
4761
use AsyncAws\CodeCommit\Input\PutRepositoryTriggersInput;
62+
use AsyncAws\CodeCommit\Result\CreateRepositoryOutput;
63+
use AsyncAws\CodeCommit\Result\DeleteRepositoryOutput;
4864
use AsyncAws\CodeCommit\Result\GetBlobOutput;
4965
use AsyncAws\CodeCommit\Result\GetBranchOutput;
5066
use AsyncAws\CodeCommit\Result\GetCommitOutput;
5167
use AsyncAws\CodeCommit\Result\GetDifferencesOutput;
68+
use AsyncAws\CodeCommit\Result\ListRepositoriesOutput;
5269
use AsyncAws\CodeCommit\Result\PutRepositoryTriggersOutput;
5370
use AsyncAws\CodeCommit\ValueObject\RepositoryTrigger;
5471
use AsyncAws\Core\AbstractApi;
@@ -59,6 +76,92 @@
5976

6077
class CodeCommitClient extends AbstractApi
6178
{
79+
/**
80+
* Creates a new, empty repository.
81+
*
82+
* @see https://docs.aws.amazon.com/codecommit/latest/APIReference/API_CreateRepository.html
83+
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-codecommit-2015-04-13.html#createrepository
84+
*
85+
* @param array{
86+
* repositoryName: string,
87+
* repositoryDescription?: string,
88+
* tags?: array<string, string>,
89+
* @region?: string,
90+
* }|CreateRepositoryInput $input
91+
*
92+
* @throws RepositoryNameExistsException
93+
* @throws RepositoryNameRequiredException
94+
* @throws InvalidRepositoryNameException
95+
* @throws InvalidRepositoryDescriptionException
96+
* @throws RepositoryLimitExceededException
97+
* @throws EncryptionIntegrityChecksFailedException
98+
* @throws EncryptionKeyAccessDeniedException
99+
* @throws EncryptionKeyDisabledException
100+
* @throws EncryptionKeyNotFoundException
101+
* @throws EncryptionKeyUnavailableException
102+
* @throws InvalidTagsMapException
103+
* @throws TooManyTagsException
104+
* @throws InvalidSystemTagUsageException
105+
* @throws TagPolicyException
106+
*/
107+
public function createRepository($input): CreateRepositoryOutput
108+
{
109+
$input = CreateRepositoryInput::create($input);
110+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'CreateRepository', 'region' => $input->getRegion(), 'exceptionMapping' => [
111+
'RepositoryNameExistsException' => RepositoryNameExistsException::class,
112+
'RepositoryNameRequiredException' => RepositoryNameRequiredException::class,
113+
'InvalidRepositoryNameException' => InvalidRepositoryNameException::class,
114+
'InvalidRepositoryDescriptionException' => InvalidRepositoryDescriptionException::class,
115+
'RepositoryLimitExceededException' => RepositoryLimitExceededException::class,
116+
'EncryptionIntegrityChecksFailedException' => EncryptionIntegrityChecksFailedException::class,
117+
'EncryptionKeyAccessDeniedException' => EncryptionKeyAccessDeniedException::class,
118+
'EncryptionKeyDisabledException' => EncryptionKeyDisabledException::class,
119+
'EncryptionKeyNotFoundException' => EncryptionKeyNotFoundException::class,
120+
'EncryptionKeyUnavailableException' => EncryptionKeyUnavailableException::class,
121+
'InvalidTagsMapException' => InvalidTagsMapException::class,
122+
'TooManyTagsException' => TooManyTagsException::class,
123+
'InvalidSystemTagUsageException' => InvalidSystemTagUsageException::class,
124+
'TagPolicyException' => TagPolicyException::class,
125+
]]));
126+
127+
return new CreateRepositoryOutput($response);
128+
}
129+
130+
/**
131+
* Deletes a repository. If a specified repository was already deleted, a null repository ID is returned.
132+
*
133+
* @see https://docs.aws.amazon.com/codecommit/latest/APIReference/API_DeleteRepository.html
134+
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-codecommit-2015-04-13.html#deleterepository
135+
*
136+
* @param array{
137+
* repositoryName: string,
138+
* @region?: string,
139+
* }|DeleteRepositoryInput $input
140+
*
141+
* @throws RepositoryNameRequiredException
142+
* @throws InvalidRepositoryNameException
143+
* @throws EncryptionIntegrityChecksFailedException
144+
* @throws EncryptionKeyAccessDeniedException
145+
* @throws EncryptionKeyDisabledException
146+
* @throws EncryptionKeyNotFoundException
147+
* @throws EncryptionKeyUnavailableException
148+
*/
149+
public function deleteRepository($input): DeleteRepositoryOutput
150+
{
151+
$input = DeleteRepositoryInput::create($input);
152+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'DeleteRepository', 'region' => $input->getRegion(), 'exceptionMapping' => [
153+
'RepositoryNameRequiredException' => RepositoryNameRequiredException::class,
154+
'InvalidRepositoryNameException' => InvalidRepositoryNameException::class,
155+
'EncryptionIntegrityChecksFailedException' => EncryptionIntegrityChecksFailedException::class,
156+
'EncryptionKeyAccessDeniedException' => EncryptionKeyAccessDeniedException::class,
157+
'EncryptionKeyDisabledException' => EncryptionKeyDisabledException::class,
158+
'EncryptionKeyNotFoundException' => EncryptionKeyNotFoundException::class,
159+
'EncryptionKeyUnavailableException' => EncryptionKeyUnavailableException::class,
160+
]]));
161+
162+
return new DeleteRepositoryOutput($response);
163+
}
164+
62165
/**
63166
* Returns the base-64 encoded content of an individual blob in a repository.
64167
*
@@ -253,6 +356,35 @@ public function getDifferences($input): GetDifferencesOutput
253356
return new GetDifferencesOutput($response, $this, $input);
254357
}
255358

359+
/**
360+
* Gets information about one or more repositories.
361+
*
362+
* @see https://docs.aws.amazon.com/codecommit/latest/APIReference/API_ListRepositories.html
363+
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-codecommit-2015-04-13.html#listrepositories
364+
*
365+
* @param array{
366+
* nextToken?: string,
367+
* sortBy?: SortByEnum::*,
368+
* order?: OrderEnum::*,
369+
* @region?: string,
370+
* }|ListRepositoriesInput $input
371+
*
372+
* @throws InvalidSortByException
373+
* @throws InvalidOrderException
374+
* @throws InvalidContinuationTokenException
375+
*/
376+
public function listRepositories($input = []): ListRepositoriesOutput
377+
{
378+
$input = ListRepositoriesInput::create($input);
379+
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListRepositories', 'region' => $input->getRegion(), 'exceptionMapping' => [
380+
'InvalidSortByException' => InvalidSortByException::class,
381+
'InvalidOrderException' => InvalidOrderException::class,
382+
'InvalidContinuationTokenException' => InvalidContinuationTokenException::class,
383+
]]));
384+
385+
return new ListRepositoriesOutput($response, $this, $input);
386+
}
387+
256388
/**
257389
* Replaces all triggers for a repository. Used to create or delete triggers.
258390
*

src/Enum/OrderEnum.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\CodeCommit\Enum;
4+
5+
/**
6+
* The order in which to sort the results of a list repositories operation.
7+
*/
8+
final class OrderEnum
9+
{
10+
public const ASCENDING = 'ascending';
11+
public const DESCENDING = 'descending';
12+
13+
public static function exists(string $value): bool
14+
{
15+
return isset([
16+
self::ASCENDING => true,
17+
self::DESCENDING => true,
18+
][$value]);
19+
}
20+
}

src/Enum/SortByEnum.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\CodeCommit\Enum;
4+
5+
/**
6+
* The criteria used to sort the results of a list repositories operation.
7+
*/
8+
final class SortByEnum
9+
{
10+
public const LAST_MODIFIED_DATE = 'lastModifiedDate';
11+
public const REPOSITORY_NAME = 'repositoryName';
12+
13+
public static function exists(string $value): bool
14+
{
15+
return isset([
16+
self::LAST_MODIFIED_DATE => true,
17+
self::REPOSITORY_NAME => true,
18+
][$value]);
19+
}
20+
}
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 specified sort order is not valid.
9+
*/
10+
final class InvalidOrderException 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 specified repository description is not valid.
9+
*/
10+
final class InvalidRepositoryDescriptionException 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 specified sort by value is not valid.
9+
*/
10+
final class InvalidSortByException 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 specified tag is not valid. Key names cannot be prefixed with aws:.
9+
*/
10+
final class InvalidSystemTagUsageException 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 map of tags is not valid.
9+
*/
10+
final class InvalidTagsMapException 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 repository resource limit was exceeded.
9+
*/
10+
final class RepositoryLimitExceededException extends ClientException
11+
{
12+
}

0 commit comments

Comments
 (0)