1 |
efrain |
1 |
<?php
|
|
|
2 |
namespace Aws\S3Control;
|
|
|
3 |
|
|
|
4 |
use Aws\AwsClient;
|
|
|
5 |
use Aws\CacheInterface;
|
|
|
6 |
use Aws\HandlerList;
|
|
|
7 |
use Aws\S3\UseArnRegion\Configuration;
|
|
|
8 |
use Aws\S3\UseArnRegion\ConfigurationInterface;
|
|
|
9 |
use Aws\S3\UseArnRegion\ConfigurationProvider as UseArnRegionConfigurationProvider;
|
|
|
10 |
use GuzzleHttp\Promise\PromiseInterface;
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* This client is used to interact with the **AWS S3 Control** service.
|
|
|
14 |
* @method \Aws\Result createAccessPoint(array $args = [])
|
|
|
15 |
* @method \GuzzleHttp\Promise\Promise createAccessPointAsync(array $args = [])
|
|
|
16 |
* @method \Aws\Result createAccessPointForObjectLambda(array $args = [])
|
|
|
17 |
* @method \GuzzleHttp\Promise\Promise createAccessPointForObjectLambdaAsync(array $args = [])
|
|
|
18 |
* @method \Aws\Result createBucket(array $args = [])
|
|
|
19 |
* @method \GuzzleHttp\Promise\Promise createBucketAsync(array $args = [])
|
|
|
20 |
* @method \Aws\Result createJob(array $args = [])
|
|
|
21 |
* @method \GuzzleHttp\Promise\Promise createJobAsync(array $args = [])
|
|
|
22 |
* @method \Aws\Result createMultiRegionAccessPoint(array $args = [])
|
|
|
23 |
* @method \GuzzleHttp\Promise\Promise createMultiRegionAccessPointAsync(array $args = [])
|
|
|
24 |
* @method \Aws\Result deleteAccessPoint(array $args = [])
|
|
|
25 |
* @method \GuzzleHttp\Promise\Promise deleteAccessPointAsync(array $args = [])
|
|
|
26 |
* @method \Aws\Result deleteAccessPointForObjectLambda(array $args = [])
|
|
|
27 |
* @method \GuzzleHttp\Promise\Promise deleteAccessPointForObjectLambdaAsync(array $args = [])
|
|
|
28 |
* @method \Aws\Result deleteAccessPointPolicy(array $args = [])
|
|
|
29 |
* @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyAsync(array $args = [])
|
|
|
30 |
* @method \Aws\Result deleteAccessPointPolicyForObjectLambda(array $args = [])
|
|
|
31 |
* @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyForObjectLambdaAsync(array $args = [])
|
|
|
32 |
* @method \Aws\Result deleteBucket(array $args = [])
|
|
|
33 |
* @method \GuzzleHttp\Promise\Promise deleteBucketAsync(array $args = [])
|
|
|
34 |
* @method \Aws\Result deleteBucketLifecycleConfiguration(array $args = [])
|
|
|
35 |
* @method \GuzzleHttp\Promise\Promise deleteBucketLifecycleConfigurationAsync(array $args = [])
|
|
|
36 |
* @method \Aws\Result deleteBucketPolicy(array $args = [])
|
|
|
37 |
* @method \GuzzleHttp\Promise\Promise deleteBucketPolicyAsync(array $args = [])
|
|
|
38 |
* @method \Aws\Result deleteBucketReplication(array $args = [])
|
|
|
39 |
* @method \GuzzleHttp\Promise\Promise deleteBucketReplicationAsync(array $args = [])
|
|
|
40 |
* @method \Aws\Result deleteBucketTagging(array $args = [])
|
|
|
41 |
* @method \GuzzleHttp\Promise\Promise deleteBucketTaggingAsync(array $args = [])
|
|
|
42 |
* @method \Aws\Result deleteJobTagging(array $args = [])
|
|
|
43 |
* @method \GuzzleHttp\Promise\Promise deleteJobTaggingAsync(array $args = [])
|
|
|
44 |
* @method \Aws\Result deleteMultiRegionAccessPoint(array $args = [])
|
|
|
45 |
* @method \GuzzleHttp\Promise\Promise deleteMultiRegionAccessPointAsync(array $args = [])
|
|
|
46 |
* @method \Aws\Result deletePublicAccessBlock(array $args = [])
|
|
|
47 |
* @method \GuzzleHttp\Promise\Promise deletePublicAccessBlockAsync(array $args = [])
|
|
|
48 |
* @method \Aws\Result deleteStorageLensConfiguration(array $args = [])
|
|
|
49 |
* @method \GuzzleHttp\Promise\Promise deleteStorageLensConfigurationAsync(array $args = [])
|
|
|
50 |
* @method \Aws\Result deleteStorageLensConfigurationTagging(array $args = [])
|
|
|
51 |
* @method \GuzzleHttp\Promise\Promise deleteStorageLensConfigurationTaggingAsync(array $args = [])
|
|
|
52 |
* @method \Aws\Result describeJob(array $args = [])
|
|
|
53 |
* @method \GuzzleHttp\Promise\Promise describeJobAsync(array $args = [])
|
|
|
54 |
* @method \Aws\Result describeMultiRegionAccessPointOperation(array $args = [])
|
|
|
55 |
* @method \GuzzleHttp\Promise\Promise describeMultiRegionAccessPointOperationAsync(array $args = [])
|
|
|
56 |
* @method \Aws\Result getAccessPoint(array $args = [])
|
|
|
57 |
* @method \GuzzleHttp\Promise\Promise getAccessPointAsync(array $args = [])
|
|
|
58 |
* @method \Aws\Result getAccessPointConfigurationForObjectLambda(array $args = [])
|
|
|
59 |
* @method \GuzzleHttp\Promise\Promise getAccessPointConfigurationForObjectLambdaAsync(array $args = [])
|
|
|
60 |
* @method \Aws\Result getAccessPointForObjectLambda(array $args = [])
|
|
|
61 |
* @method \GuzzleHttp\Promise\Promise getAccessPointForObjectLambdaAsync(array $args = [])
|
|
|
62 |
* @method \Aws\Result getAccessPointPolicy(array $args = [])
|
|
|
63 |
* @method \GuzzleHttp\Promise\Promise getAccessPointPolicyAsync(array $args = [])
|
|
|
64 |
* @method \Aws\Result getAccessPointPolicyForObjectLambda(array $args = [])
|
|
|
65 |
* @method \GuzzleHttp\Promise\Promise getAccessPointPolicyForObjectLambdaAsync(array $args = [])
|
|
|
66 |
* @method \Aws\Result getAccessPointPolicyStatus(array $args = [])
|
|
|
67 |
* @method \GuzzleHttp\Promise\Promise getAccessPointPolicyStatusAsync(array $args = [])
|
|
|
68 |
* @method \Aws\Result getAccessPointPolicyStatusForObjectLambda(array $args = [])
|
|
|
69 |
* @method \GuzzleHttp\Promise\Promise getAccessPointPolicyStatusForObjectLambdaAsync(array $args = [])
|
|
|
70 |
* @method \Aws\Result getBucket(array $args = [])
|
|
|
71 |
* @method \GuzzleHttp\Promise\Promise getBucketAsync(array $args = [])
|
|
|
72 |
* @method \Aws\Result getBucketLifecycleConfiguration(array $args = [])
|
|
|
73 |
* @method \GuzzleHttp\Promise\Promise getBucketLifecycleConfigurationAsync(array $args = [])
|
|
|
74 |
* @method \Aws\Result getBucketPolicy(array $args = [])
|
|
|
75 |
* @method \GuzzleHttp\Promise\Promise getBucketPolicyAsync(array $args = [])
|
|
|
76 |
* @method \Aws\Result getBucketReplication(array $args = [])
|
|
|
77 |
* @method \GuzzleHttp\Promise\Promise getBucketReplicationAsync(array $args = [])
|
|
|
78 |
* @method \Aws\Result getBucketTagging(array $args = [])
|
|
|
79 |
* @method \GuzzleHttp\Promise\Promise getBucketTaggingAsync(array $args = [])
|
|
|
80 |
* @method \Aws\Result getBucketVersioning(array $args = [])
|
|
|
81 |
* @method \GuzzleHttp\Promise\Promise getBucketVersioningAsync(array $args = [])
|
|
|
82 |
* @method \Aws\Result getJobTagging(array $args = [])
|
|
|
83 |
* @method \GuzzleHttp\Promise\Promise getJobTaggingAsync(array $args = [])
|
|
|
84 |
* @method \Aws\Result getMultiRegionAccessPoint(array $args = [])
|
|
|
85 |
* @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointAsync(array $args = [])
|
|
|
86 |
* @method \Aws\Result getMultiRegionAccessPointPolicy(array $args = [])
|
|
|
87 |
* @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointPolicyAsync(array $args = [])
|
|
|
88 |
* @method \Aws\Result getMultiRegionAccessPointPolicyStatus(array $args = [])
|
|
|
89 |
* @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointPolicyStatusAsync(array $args = [])
|
|
|
90 |
* @method \Aws\Result getMultiRegionAccessPointRoutes(array $args = [])
|
|
|
91 |
* @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointRoutesAsync(array $args = [])
|
|
|
92 |
* @method \Aws\Result getPublicAccessBlock(array $args = [])
|
|
|
93 |
* @method \GuzzleHttp\Promise\Promise getPublicAccessBlockAsync(array $args = [])
|
|
|
94 |
* @method \Aws\Result getStorageLensConfiguration(array $args = [])
|
|
|
95 |
* @method \GuzzleHttp\Promise\Promise getStorageLensConfigurationAsync(array $args = [])
|
|
|
96 |
* @method \Aws\Result getStorageLensConfigurationTagging(array $args = [])
|
|
|
97 |
* @method \GuzzleHttp\Promise\Promise getStorageLensConfigurationTaggingAsync(array $args = [])
|
|
|
98 |
* @method \Aws\Result listAccessPoints(array $args = [])
|
|
|
99 |
* @method \GuzzleHttp\Promise\Promise listAccessPointsAsync(array $args = [])
|
|
|
100 |
* @method \Aws\Result listAccessPointsForObjectLambda(array $args = [])
|
|
|
101 |
* @method \GuzzleHttp\Promise\Promise listAccessPointsForObjectLambdaAsync(array $args = [])
|
|
|
102 |
* @method \Aws\Result listJobs(array $args = [])
|
|
|
103 |
* @method \GuzzleHttp\Promise\Promise listJobsAsync(array $args = [])
|
|
|
104 |
* @method \Aws\Result listMultiRegionAccessPoints(array $args = [])
|
|
|
105 |
* @method \GuzzleHttp\Promise\Promise listMultiRegionAccessPointsAsync(array $args = [])
|
|
|
106 |
* @method \Aws\Result listRegionalBuckets(array $args = [])
|
|
|
107 |
* @method \GuzzleHttp\Promise\Promise listRegionalBucketsAsync(array $args = [])
|
|
|
108 |
* @method \Aws\Result listStorageLensConfigurations(array $args = [])
|
|
|
109 |
* @method \GuzzleHttp\Promise\Promise listStorageLensConfigurationsAsync(array $args = [])
|
|
|
110 |
* @method \Aws\Result putAccessPointConfigurationForObjectLambda(array $args = [])
|
|
|
111 |
* @method \GuzzleHttp\Promise\Promise putAccessPointConfigurationForObjectLambdaAsync(array $args = [])
|
|
|
112 |
* @method \Aws\Result putAccessPointPolicy(array $args = [])
|
|
|
113 |
* @method \GuzzleHttp\Promise\Promise putAccessPointPolicyAsync(array $args = [])
|
|
|
114 |
* @method \Aws\Result putAccessPointPolicyForObjectLambda(array $args = [])
|
|
|
115 |
* @method \GuzzleHttp\Promise\Promise putAccessPointPolicyForObjectLambdaAsync(array $args = [])
|
|
|
116 |
* @method \Aws\Result putBucketLifecycleConfiguration(array $args = [])
|
|
|
117 |
* @method \GuzzleHttp\Promise\Promise putBucketLifecycleConfigurationAsync(array $args = [])
|
|
|
118 |
* @method \Aws\Result putBucketPolicy(array $args = [])
|
|
|
119 |
* @method \GuzzleHttp\Promise\Promise putBucketPolicyAsync(array $args = [])
|
|
|
120 |
* @method \Aws\Result putBucketReplication(array $args = [])
|
|
|
121 |
* @method \GuzzleHttp\Promise\Promise putBucketReplicationAsync(array $args = [])
|
|
|
122 |
* @method \Aws\Result putBucketTagging(array $args = [])
|
|
|
123 |
* @method \GuzzleHttp\Promise\Promise putBucketTaggingAsync(array $args = [])
|
|
|
124 |
* @method \Aws\Result putBucketVersioning(array $args = [])
|
|
|
125 |
* @method \GuzzleHttp\Promise\Promise putBucketVersioningAsync(array $args = [])
|
|
|
126 |
* @method \Aws\Result putJobTagging(array $args = [])
|
|
|
127 |
* @method \GuzzleHttp\Promise\Promise putJobTaggingAsync(array $args = [])
|
|
|
128 |
* @method \Aws\Result putMultiRegionAccessPointPolicy(array $args = [])
|
|
|
129 |
* @method \GuzzleHttp\Promise\Promise putMultiRegionAccessPointPolicyAsync(array $args = [])
|
|
|
130 |
* @method \Aws\Result putPublicAccessBlock(array $args = [])
|
|
|
131 |
* @method \GuzzleHttp\Promise\Promise putPublicAccessBlockAsync(array $args = [])
|
|
|
132 |
* @method \Aws\Result putStorageLensConfiguration(array $args = [])
|
|
|
133 |
* @method \GuzzleHttp\Promise\Promise putStorageLensConfigurationAsync(array $args = [])
|
|
|
134 |
* @method \Aws\Result putStorageLensConfigurationTagging(array $args = [])
|
|
|
135 |
* @method \GuzzleHttp\Promise\Promise putStorageLensConfigurationTaggingAsync(array $args = [])
|
|
|
136 |
* @method \Aws\Result submitMultiRegionAccessPointRoutes(array $args = [])
|
|
|
137 |
* @method \GuzzleHttp\Promise\Promise submitMultiRegionAccessPointRoutesAsync(array $args = [])
|
|
|
138 |
* @method \Aws\Result updateJobPriority(array $args = [])
|
|
|
139 |
* @method \GuzzleHttp\Promise\Promise updateJobPriorityAsync(array $args = [])
|
|
|
140 |
* @method \Aws\Result updateJobStatus(array $args = [])
|
|
|
141 |
* @method \GuzzleHttp\Promise\Promise updateJobStatusAsync(array $args = [])
|
|
|
142 |
*/
|
|
|
143 |
class S3ControlClient extends AwsClient
|
|
|
144 |
{
|
|
|
145 |
public static function getArguments()
|
|
|
146 |
{
|
|
|
147 |
$args = parent::getArguments();
|
|
|
148 |
return $args + [
|
|
|
149 |
'use_dual_stack_endpoint' => [
|
|
|
150 |
'type' => 'config',
|
|
|
151 |
'valid' => ['bool'],
|
|
|
152 |
'doc' => 'Set to true to send requests to an S3 Control Dual Stack'
|
|
|
153 |
. ' endpoint by default, which enables IPv6 Protocol.'
|
|
|
154 |
. ' Can be enabled or disabled on individual operations by setting'
|
|
|
155 |
. ' \'@use_dual_stack_endpoint\' to true or false.',
|
|
|
156 |
'default' => false,
|
|
|
157 |
],
|
|
|
158 |
'use_arn_region' => [
|
|
|
159 |
'type' => 'config',
|
|
|
160 |
'valid' => [
|
|
|
161 |
'bool',
|
|
|
162 |
Configuration::class,
|
|
|
163 |
CacheInterface::class,
|
|
|
164 |
'callable'
|
|
|
165 |
],
|
|
|
166 |
'doc' => 'Set to true to allow passed in ARNs to override'
|
|
|
167 |
. ' client region. Accepts...',
|
|
|
168 |
'fn' => [__CLASS__, '_apply_use_arn_region'],
|
|
|
169 |
'default' => [UseArnRegionConfigurationProvider::class, 'defaultProvider'],
|
|
|
170 |
],
|
|
|
171 |
];
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
public static function _apply_use_arn_region($value, array &$args, HandlerList $list)
|
|
|
175 |
{
|
|
|
176 |
if ($value instanceof CacheInterface) {
|
|
|
177 |
$value = UseArnRegionConfigurationProvider::defaultProvider($args);
|
|
|
178 |
}
|
|
|
179 |
if (is_callable($value)) {
|
|
|
180 |
$value = $value();
|
|
|
181 |
}
|
|
|
182 |
if ($value instanceof PromiseInterface) {
|
|
|
183 |
$value = $value->wait();
|
|
|
184 |
}
|
|
|
185 |
if ($value instanceof ConfigurationInterface) {
|
|
|
186 |
$args['use_arn_region'] = $value;
|
|
|
187 |
} else {
|
|
|
188 |
// The Configuration class itself will validate other inputs
|
|
|
189 |
$args['use_arn_region'] = new Configuration($value);
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
/**
|
|
|
194 |
* {@inheritdoc}
|
|
|
195 |
*
|
|
|
196 |
* In addition to the options available to
|
|
|
197 |
* {@see Aws\AwsClient::__construct}, S3ControlClient accepts the following
|
|
|
198 |
* option:
|
|
|
199 |
*
|
|
|
200 |
* - use_dual_stack_endpoint: (bool) Set to true to send requests to an S3
|
|
|
201 |
* Control Dual Stack endpoint by default, which enables IPv6 Protocol.
|
|
|
202 |
* Can be enabled or disabled on individual operations by setting
|
|
|
203 |
* '@use_dual_stack_endpoint\' to true or false. Note:
|
|
|
204 |
* you cannot use it together with an accelerate endpoint.
|
|
|
205 |
*
|
|
|
206 |
* @param array $args
|
|
|
207 |
*/
|
|
|
208 |
public function __construct(array $args)
|
|
|
209 |
{
|
|
|
210 |
parent::__construct($args);
|
|
|
211 |
|
|
|
212 |
if ($this->isUseEndpointV2()) {
|
|
|
213 |
$this->processEndpointV2Model();
|
|
|
214 |
}
|
|
|
215 |
$stack = $this->getHandlerList();
|
|
|
216 |
$stack->appendBuild(
|
|
|
217 |
EndpointArnMiddleware::wrap(
|
|
|
218 |
$this->getApi(),
|
|
|
219 |
$this->getRegion(),
|
|
|
220 |
[
|
|
|
221 |
'use_arn_region' => $this->getConfig('use_arn_region'),
|
|
|
222 |
'dual_stack' =>
|
|
|
223 |
$this->getConfig('use_dual_stack_endpoint')->isUseDualStackEndpoint(),
|
|
|
224 |
'endpoint' => isset($args['endpoint'])
|
|
|
225 |
? $args['endpoint']
|
|
|
226 |
: null,
|
|
|
227 |
'use_fips_endpoint' => $this->getConfig('use_fips_endpoint'),
|
|
|
228 |
],
|
|
|
229 |
$this->isUseEndpointV2()
|
|
|
230 |
),
|
|
|
231 |
's3control.endpoint_arn_middleware'
|
|
|
232 |
);
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
/**
|
|
|
236 |
* Modifies API definition to remove `AccountId`
|
|
|
237 |
* host prefix. This is now handled by the endpoint ruleset.
|
|
|
238 |
*
|
|
|
239 |
* @return void
|
|
|
240 |
*
|
|
|
241 |
* @internal
|
|
|
242 |
*/
|
|
|
243 |
private function processEndpointV2Model()
|
|
|
244 |
{
|
|
|
245 |
$definition = $this->getApi()->getDefinition();
|
|
|
246 |
$this->removeHostPrefix($definition);
|
|
|
247 |
$this->removeRequiredMember($definition);
|
|
|
248 |
$this->getApi()->setDefinition($definition);
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
private function removeHostPrefix(&$definition)
|
|
|
252 |
{
|
|
|
253 |
foreach($definition['operations'] as &$operation) {
|
|
|
254 |
if (isset($operation['endpoint']['hostPrefix'])
|
|
|
255 |
&& $operation['endpoint']['hostPrefix'] === '{AccountId}.'
|
|
|
256 |
) {
|
|
|
257 |
$operation['endpoint']['hostPrefix'] = str_replace(
|
|
|
258 |
'{AccountId}.',
|
|
|
259 |
'',
|
|
|
260 |
$operation['endpoint']['hostPrefix']
|
|
|
261 |
);
|
|
|
262 |
}
|
|
|
263 |
}
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
private function removeRequiredMember(&$definition)
|
|
|
267 |
{
|
|
|
268 |
foreach($definition['shapes'] as &$shape) {
|
|
|
269 |
if (isset($shape['required'])
|
|
|
270 |
) {
|
|
|
271 |
$found = array_search('AccountId', $shape['required']);
|
|
|
272 |
|
|
|
273 |
if ($found !== false) {
|
|
|
274 |
unset($shape['required'][$found]);
|
|
|
275 |
}
|
|
|
276 |
}
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
}
|