-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageBuilderClient.php
More file actions
252 lines (237 loc) · 11.3 KB
/
ImageBuilderClient.php
File metadata and controls
252 lines (237 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
namespace AsyncAws\ImageBuilder;
use AsyncAws\Core\AbstractApi;
use AsyncAws\Core\AwsError\AwsErrorFactoryInterface;
use AsyncAws\Core\AwsError\JsonRestAwsErrorFactory;
use AsyncAws\Core\Configuration;
use AsyncAws\Core\RequestContext;
use AsyncAws\ImageBuilder\Enum\Ownership;
use AsyncAws\ImageBuilder\Exception\CallRateLimitExceededException;
use AsyncAws\ImageBuilder\Exception\ClientException;
use AsyncAws\ImageBuilder\Exception\ForbiddenException;
use AsyncAws\ImageBuilder\Exception\IdempotentParameterMismatchException;
use AsyncAws\ImageBuilder\Exception\InvalidPaginationTokenException;
use AsyncAws\ImageBuilder\Exception\InvalidRequestException;
use AsyncAws\ImageBuilder\Exception\ResourceDependencyException;
use AsyncAws\ImageBuilder\Exception\ResourceInUseException;
use AsyncAws\ImageBuilder\Exception\ResourceNotFoundException;
use AsyncAws\ImageBuilder\Exception\ServiceException;
use AsyncAws\ImageBuilder\Exception\ServiceUnavailableException;
use AsyncAws\ImageBuilder\Input\DeleteImageRequest;
use AsyncAws\ImageBuilder\Input\GetImageRequest;
use AsyncAws\ImageBuilder\Input\ListImageBuildVersionsRequest;
use AsyncAws\ImageBuilder\Input\ListImagesRequest;
use AsyncAws\ImageBuilder\Input\StartImagePipelineExecutionRequest;
use AsyncAws\ImageBuilder\Result\DeleteImageResponse;
use AsyncAws\ImageBuilder\Result\GetImageResponse;
use AsyncAws\ImageBuilder\Result\ListImageBuildVersionsResponse;
use AsyncAws\ImageBuilder\Result\ListImagesResponse;
use AsyncAws\ImageBuilder\Result\StartImagePipelineExecutionResponse;
use AsyncAws\ImageBuilder\ValueObject\Filter;
class ImageBuilderClient extends AbstractApi
{
/**
* Deletes an Image Builder image resource. This does not delete any EC2 AMIs or ECR container images that are created
* during the image build process. You must clean those up separately, using the appropriate Amazon EC2 or Amazon ECR
* console actions, or API or CLI commands.
*
* - To deregister an EC2 Linux AMI, see Deregister your Linux AMI [^1] in the **Amazon EC2 User Guide**.
* - To deregister an EC2 Windows AMI, see Deregister your Windows AMI [^2] in the **Amazon EC2 Windows Guide**.
* - To delete a container image from Amazon ECR, see Deleting an image [^3] in the *Amazon ECR User Guide*.
*
* [^1]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/deregister-ami.html
* [^2]: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/deregister-ami.html
* [^3]: https://docs.aws.amazon.com/AmazonECR/latest/userguide/delete_image.html
*
* @see https://docs.aws.amazon.com/imagebuilder/latest/APIReference/API_DeleteImage.html
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-imagebuilder-2019-12-02.html#deleteimage
*
* @param array{
* imageBuildVersionArn: string,
* '@region'?: string|null,
* }|DeleteImageRequest $input
*
* @throws CallRateLimitExceededException
* @throws ClientException
* @throws ForbiddenException
* @throws InvalidRequestException
* @throws ResourceDependencyException
* @throws ServiceException
* @throws ServiceUnavailableException
*/
public function deleteImage($input): DeleteImageResponse
{
$input = DeleteImageRequest::create($input);
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'DeleteImage', 'region' => $input->getRegion(), 'exceptionMapping' => [
'CallRateLimitExceededException' => CallRateLimitExceededException::class,
'ClientException' => ClientException::class,
'ForbiddenException' => ForbiddenException::class,
'InvalidRequestException' => InvalidRequestException::class,
'ResourceDependencyException' => ResourceDependencyException::class,
'ServiceException' => ServiceException::class,
'ServiceUnavailableException' => ServiceUnavailableException::class,
]]));
return new DeleteImageResponse($response);
}
/**
* Gets an image.
*
* @see https://docs.aws.amazon.com/imagebuilder/latest/APIReference/API_GetImage.html
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-imagebuilder-2019-12-02.html#getimage
*
* @param array{
* imageBuildVersionArn: string,
* '@region'?: string|null,
* }|GetImageRequest $input
*
* @throws CallRateLimitExceededException
* @throws ClientException
* @throws ForbiddenException
* @throws InvalidRequestException
* @throws ServiceException
* @throws ServiceUnavailableException
*/
public function getImage($input): GetImageResponse
{
$input = GetImageRequest::create($input);
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'GetImage', 'region' => $input->getRegion(), 'exceptionMapping' => [
'CallRateLimitExceededException' => CallRateLimitExceededException::class,
'ClientException' => ClientException::class,
'ForbiddenException' => ForbiddenException::class,
'InvalidRequestException' => InvalidRequestException::class,
'ServiceException' => ServiceException::class,
'ServiceUnavailableException' => ServiceUnavailableException::class,
]]));
return new GetImageResponse($response);
}
/**
* Returns a list of image build versions.
*
* @see https://docs.aws.amazon.com/imagebuilder/latest/APIReference/API_ListImageBuildVersions.html
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-imagebuilder-2019-12-02.html#listimagebuildversions
*
* @param array{
* imageVersionArn?: string|null,
* filters?: array<Filter|array>|null,
* maxResults?: int|null,
* nextToken?: string|null,
* '@region'?: string|null,
* }|ListImageBuildVersionsRequest $input
*
* @throws CallRateLimitExceededException
* @throws ClientException
* @throws ForbiddenException
* @throws InvalidPaginationTokenException
* @throws InvalidRequestException
* @throws ServiceException
* @throws ServiceUnavailableException
*/
public function listImageBuildVersions($input = []): ListImageBuildVersionsResponse
{
$input = ListImageBuildVersionsRequest::create($input);
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListImageBuildVersions', 'region' => $input->getRegion(), 'exceptionMapping' => [
'CallRateLimitExceededException' => CallRateLimitExceededException::class,
'ClientException' => ClientException::class,
'ForbiddenException' => ForbiddenException::class,
'InvalidPaginationTokenException' => InvalidPaginationTokenException::class,
'InvalidRequestException' => InvalidRequestException::class,
'ServiceException' => ServiceException::class,
'ServiceUnavailableException' => ServiceUnavailableException::class,
]]));
return new ListImageBuildVersionsResponse($response, $this, $input);
}
/**
* Returns the list of images that you have access to. Newly created images can take up to two minutes to appear in the
* ListImages API Results.
*
* @see https://docs.aws.amazon.com/imagebuilder/latest/APIReference/API_ListImages.html
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-imagebuilder-2019-12-02.html#listimages
*
* @param array{
* owner?: Ownership::*|null,
* filters?: array<Filter|array>|null,
* byName?: bool|null,
* maxResults?: int|null,
* nextToken?: string|null,
* includeDeprecated?: bool|null,
* '@region'?: string|null,
* }|ListImagesRequest $input
*
* @throws CallRateLimitExceededException
* @throws ClientException
* @throws ForbiddenException
* @throws InvalidPaginationTokenException
* @throws InvalidRequestException
* @throws ServiceException
* @throws ServiceUnavailableException
*/
public function listImages($input = []): ListImagesResponse
{
$input = ListImagesRequest::create($input);
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'ListImages', 'region' => $input->getRegion(), 'exceptionMapping' => [
'CallRateLimitExceededException' => CallRateLimitExceededException::class,
'ClientException' => ClientException::class,
'ForbiddenException' => ForbiddenException::class,
'InvalidPaginationTokenException' => InvalidPaginationTokenException::class,
'InvalidRequestException' => InvalidRequestException::class,
'ServiceException' => ServiceException::class,
'ServiceUnavailableException' => ServiceUnavailableException::class,
]]));
return new ListImagesResponse($response, $this, $input);
}
/**
* Manually triggers a pipeline to create an image.
*
* @see https://docs.aws.amazon.com/imagebuilder/latest/APIReference/API_StartImagePipelineExecution.html
* @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-imagebuilder-2019-12-02.html#startimagepipelineexecution
*
* @param array{
* imagePipelineArn: string,
* clientToken: string,
* tags?: array<string, string>|null,
* '@region'?: string|null,
* }|StartImagePipelineExecutionRequest $input
*
* @throws CallRateLimitExceededException
* @throws ClientException
* @throws ForbiddenException
* @throws IdempotentParameterMismatchException
* @throws InvalidRequestException
* @throws ResourceInUseException
* @throws ResourceNotFoundException
* @throws ServiceException
* @throws ServiceUnavailableException
*/
public function startImagePipelineExecution($input): StartImagePipelineExecutionResponse
{
$input = StartImagePipelineExecutionRequest::create($input);
$response = $this->getResponse($input->request(), new RequestContext(['operation' => 'StartImagePipelineExecution', 'region' => $input->getRegion(), 'exceptionMapping' => [
'CallRateLimitExceededException' => CallRateLimitExceededException::class,
'ClientException' => ClientException::class,
'ForbiddenException' => ForbiddenException::class,
'IdempotentParameterMismatchException' => IdempotentParameterMismatchException::class,
'InvalidRequestException' => InvalidRequestException::class,
'ResourceInUseException' => ResourceInUseException::class,
'ResourceNotFoundException' => ResourceNotFoundException::class,
'ServiceException' => ServiceException::class,
'ServiceUnavailableException' => ServiceUnavailableException::class,
]]));
return new StartImagePipelineExecutionResponse($response);
}
protected function getAwsErrorFactory(): AwsErrorFactoryInterface
{
return new JsonRestAwsErrorFactory();
}
protected function getEndpointMetadata(?string $region): array
{
if (null === $region) {
$region = Configuration::DEFAULT_REGION;
}
return [
'endpoint' => "https://imagebuilder.$region.amazonaws.com",
'signRegion' => $region,
'signService' => 'imagebuilder',
'signVersions' => ['v4'],
];
}
}