Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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.
1441 ariadna 14
 * @method \Aws\Result associateAccessGrantsIdentityCenter(array $args = [])
15
 * @method \GuzzleHttp\Promise\Promise associateAccessGrantsIdentityCenterAsync(array $args = [])
16
 * @method \Aws\Result createAccessGrant(array $args = [])
17
 * @method \GuzzleHttp\Promise\Promise createAccessGrantAsync(array $args = [])
18
 * @method \Aws\Result createAccessGrantsInstance(array $args = [])
19
 * @method \GuzzleHttp\Promise\Promise createAccessGrantsInstanceAsync(array $args = [])
20
 * @method \Aws\Result createAccessGrantsLocation(array $args = [])
21
 * @method \GuzzleHttp\Promise\Promise createAccessGrantsLocationAsync(array $args = [])
1 efrain 22
 * @method \Aws\Result createAccessPoint(array $args = [])
23
 * @method \GuzzleHttp\Promise\Promise createAccessPointAsync(array $args = [])
24
 * @method \Aws\Result createAccessPointForObjectLambda(array $args = [])
25
 * @method \GuzzleHttp\Promise\Promise createAccessPointForObjectLambdaAsync(array $args = [])
26
 * @method \Aws\Result createBucket(array $args = [])
27
 * @method \GuzzleHttp\Promise\Promise createBucketAsync(array $args = [])
28
 * @method \Aws\Result createJob(array $args = [])
29
 * @method \GuzzleHttp\Promise\Promise createJobAsync(array $args = [])
30
 * @method \Aws\Result createMultiRegionAccessPoint(array $args = [])
31
 * @method \GuzzleHttp\Promise\Promise createMultiRegionAccessPointAsync(array $args = [])
1441 ariadna 32
 * @method \Aws\Result createStorageLensGroup(array $args = [])
33
 * @method \GuzzleHttp\Promise\Promise createStorageLensGroupAsync(array $args = [])
34
 * @method \Aws\Result deleteAccessGrant(array $args = [])
35
 * @method \GuzzleHttp\Promise\Promise deleteAccessGrantAsync(array $args = [])
36
 * @method \Aws\Result deleteAccessGrantsInstance(array $args = [])
37
 * @method \GuzzleHttp\Promise\Promise deleteAccessGrantsInstanceAsync(array $args = [])
38
 * @method \Aws\Result deleteAccessGrantsInstanceResourcePolicy(array $args = [])
39
 * @method \GuzzleHttp\Promise\Promise deleteAccessGrantsInstanceResourcePolicyAsync(array $args = [])
40
 * @method \Aws\Result deleteAccessGrantsLocation(array $args = [])
41
 * @method \GuzzleHttp\Promise\Promise deleteAccessGrantsLocationAsync(array $args = [])
1 efrain 42
 * @method \Aws\Result deleteAccessPoint(array $args = [])
43
 * @method \GuzzleHttp\Promise\Promise deleteAccessPointAsync(array $args = [])
44
 * @method \Aws\Result deleteAccessPointForObjectLambda(array $args = [])
45
 * @method \GuzzleHttp\Promise\Promise deleteAccessPointForObjectLambdaAsync(array $args = [])
46
 * @method \Aws\Result deleteAccessPointPolicy(array $args = [])
47
 * @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyAsync(array $args = [])
48
 * @method \Aws\Result deleteAccessPointPolicyForObjectLambda(array $args = [])
49
 * @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyForObjectLambdaAsync(array $args = [])
50
 * @method \Aws\Result deleteBucket(array $args = [])
51
 * @method \GuzzleHttp\Promise\Promise deleteBucketAsync(array $args = [])
52
 * @method \Aws\Result deleteBucketLifecycleConfiguration(array $args = [])
53
 * @method \GuzzleHttp\Promise\Promise deleteBucketLifecycleConfigurationAsync(array $args = [])
54
 * @method \Aws\Result deleteBucketPolicy(array $args = [])
55
 * @method \GuzzleHttp\Promise\Promise deleteBucketPolicyAsync(array $args = [])
56
 * @method \Aws\Result deleteBucketReplication(array $args = [])
57
 * @method \GuzzleHttp\Promise\Promise deleteBucketReplicationAsync(array $args = [])
58
 * @method \Aws\Result deleteBucketTagging(array $args = [])
59
 * @method \GuzzleHttp\Promise\Promise deleteBucketTaggingAsync(array $args = [])
60
 * @method \Aws\Result deleteJobTagging(array $args = [])
61
 * @method \GuzzleHttp\Promise\Promise deleteJobTaggingAsync(array $args = [])
62
 * @method \Aws\Result deleteMultiRegionAccessPoint(array $args = [])
63
 * @method \GuzzleHttp\Promise\Promise deleteMultiRegionAccessPointAsync(array $args = [])
64
 * @method \Aws\Result deletePublicAccessBlock(array $args = [])
65
 * @method \GuzzleHttp\Promise\Promise deletePublicAccessBlockAsync(array $args = [])
66
 * @method \Aws\Result deleteStorageLensConfiguration(array $args = [])
67
 * @method \GuzzleHttp\Promise\Promise deleteStorageLensConfigurationAsync(array $args = [])
68
 * @method \Aws\Result deleteStorageLensConfigurationTagging(array $args = [])
69
 * @method \GuzzleHttp\Promise\Promise deleteStorageLensConfigurationTaggingAsync(array $args = [])
1441 ariadna 70
 * @method \Aws\Result deleteStorageLensGroup(array $args = [])
71
 * @method \GuzzleHttp\Promise\Promise deleteStorageLensGroupAsync(array $args = [])
1 efrain 72
 * @method \Aws\Result describeJob(array $args = [])
73
 * @method \GuzzleHttp\Promise\Promise describeJobAsync(array $args = [])
74
 * @method \Aws\Result describeMultiRegionAccessPointOperation(array $args = [])
75
 * @method \GuzzleHttp\Promise\Promise describeMultiRegionAccessPointOperationAsync(array $args = [])
1441 ariadna 76
 * @method \Aws\Result dissociateAccessGrantsIdentityCenter(array $args = [])
77
 * @method \GuzzleHttp\Promise\Promise dissociateAccessGrantsIdentityCenterAsync(array $args = [])
78
 * @method \Aws\Result getAccessGrant(array $args = [])
79
 * @method \GuzzleHttp\Promise\Promise getAccessGrantAsync(array $args = [])
80
 * @method \Aws\Result getAccessGrantsInstance(array $args = [])
81
 * @method \GuzzleHttp\Promise\Promise getAccessGrantsInstanceAsync(array $args = [])
82
 * @method \Aws\Result getAccessGrantsInstanceForPrefix(array $args = [])
83
 * @method \GuzzleHttp\Promise\Promise getAccessGrantsInstanceForPrefixAsync(array $args = [])
84
 * @method \Aws\Result getAccessGrantsInstanceResourcePolicy(array $args = [])
85
 * @method \GuzzleHttp\Promise\Promise getAccessGrantsInstanceResourcePolicyAsync(array $args = [])
86
 * @method \Aws\Result getAccessGrantsLocation(array $args = [])
87
 * @method \GuzzleHttp\Promise\Promise getAccessGrantsLocationAsync(array $args = [])
1 efrain 88
 * @method \Aws\Result getAccessPoint(array $args = [])
89
 * @method \GuzzleHttp\Promise\Promise getAccessPointAsync(array $args = [])
90
 * @method \Aws\Result getAccessPointConfigurationForObjectLambda(array $args = [])
91
 * @method \GuzzleHttp\Promise\Promise getAccessPointConfigurationForObjectLambdaAsync(array $args = [])
92
 * @method \Aws\Result getAccessPointForObjectLambda(array $args = [])
93
 * @method \GuzzleHttp\Promise\Promise getAccessPointForObjectLambdaAsync(array $args = [])
94
 * @method \Aws\Result getAccessPointPolicy(array $args = [])
95
 * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyAsync(array $args = [])
96
 * @method \Aws\Result getAccessPointPolicyForObjectLambda(array $args = [])
97
 * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyForObjectLambdaAsync(array $args = [])
98
 * @method \Aws\Result getAccessPointPolicyStatus(array $args = [])
99
 * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyStatusAsync(array $args = [])
100
 * @method \Aws\Result getAccessPointPolicyStatusForObjectLambda(array $args = [])
101
 * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyStatusForObjectLambdaAsync(array $args = [])
102
 * @method \Aws\Result getBucket(array $args = [])
103
 * @method \GuzzleHttp\Promise\Promise getBucketAsync(array $args = [])
104
 * @method \Aws\Result getBucketLifecycleConfiguration(array $args = [])
105
 * @method \GuzzleHttp\Promise\Promise getBucketLifecycleConfigurationAsync(array $args = [])
106
 * @method \Aws\Result getBucketPolicy(array $args = [])
107
 * @method \GuzzleHttp\Promise\Promise getBucketPolicyAsync(array $args = [])
108
 * @method \Aws\Result getBucketReplication(array $args = [])
109
 * @method \GuzzleHttp\Promise\Promise getBucketReplicationAsync(array $args = [])
110
 * @method \Aws\Result getBucketTagging(array $args = [])
111
 * @method \GuzzleHttp\Promise\Promise getBucketTaggingAsync(array $args = [])
112
 * @method \Aws\Result getBucketVersioning(array $args = [])
113
 * @method \GuzzleHttp\Promise\Promise getBucketVersioningAsync(array $args = [])
1441 ariadna 114
 * @method \Aws\Result getDataAccess(array $args = [])
115
 * @method \GuzzleHttp\Promise\Promise getDataAccessAsync(array $args = [])
1 efrain 116
 * @method \Aws\Result getJobTagging(array $args = [])
117
 * @method \GuzzleHttp\Promise\Promise getJobTaggingAsync(array $args = [])
118
 * @method \Aws\Result getMultiRegionAccessPoint(array $args = [])
119
 * @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointAsync(array $args = [])
120
 * @method \Aws\Result getMultiRegionAccessPointPolicy(array $args = [])
121
 * @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointPolicyAsync(array $args = [])
122
 * @method \Aws\Result getMultiRegionAccessPointPolicyStatus(array $args = [])
123
 * @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointPolicyStatusAsync(array $args = [])
124
 * @method \Aws\Result getMultiRegionAccessPointRoutes(array $args = [])
125
 * @method \GuzzleHttp\Promise\Promise getMultiRegionAccessPointRoutesAsync(array $args = [])
126
 * @method \Aws\Result getPublicAccessBlock(array $args = [])
127
 * @method \GuzzleHttp\Promise\Promise getPublicAccessBlockAsync(array $args = [])
128
 * @method \Aws\Result getStorageLensConfiguration(array $args = [])
129
 * @method \GuzzleHttp\Promise\Promise getStorageLensConfigurationAsync(array $args = [])
130
 * @method \Aws\Result getStorageLensConfigurationTagging(array $args = [])
131
 * @method \GuzzleHttp\Promise\Promise getStorageLensConfigurationTaggingAsync(array $args = [])
1441 ariadna 132
 * @method \Aws\Result getStorageLensGroup(array $args = [])
133
 * @method \GuzzleHttp\Promise\Promise getStorageLensGroupAsync(array $args = [])
134
 * @method \Aws\Result listAccessGrants(array $args = [])
135
 * @method \GuzzleHttp\Promise\Promise listAccessGrantsAsync(array $args = [])
136
 * @method \Aws\Result listAccessGrantsInstances(array $args = [])
137
 * @method \GuzzleHttp\Promise\Promise listAccessGrantsInstancesAsync(array $args = [])
138
 * @method \Aws\Result listAccessGrantsLocations(array $args = [])
139
 * @method \GuzzleHttp\Promise\Promise listAccessGrantsLocationsAsync(array $args = [])
1 efrain 140
 * @method \Aws\Result listAccessPoints(array $args = [])
141
 * @method \GuzzleHttp\Promise\Promise listAccessPointsAsync(array $args = [])
142
 * @method \Aws\Result listAccessPointsForObjectLambda(array $args = [])
143
 * @method \GuzzleHttp\Promise\Promise listAccessPointsForObjectLambdaAsync(array $args = [])
1441 ariadna 144
 * @method \Aws\Result listCallerAccessGrants(array $args = [])
145
 * @method \GuzzleHttp\Promise\Promise listCallerAccessGrantsAsync(array $args = [])
1 efrain 146
 * @method \Aws\Result listJobs(array $args = [])
147
 * @method \GuzzleHttp\Promise\Promise listJobsAsync(array $args = [])
148
 * @method \Aws\Result listMultiRegionAccessPoints(array $args = [])
149
 * @method \GuzzleHttp\Promise\Promise listMultiRegionAccessPointsAsync(array $args = [])
150
 * @method \Aws\Result listRegionalBuckets(array $args = [])
151
 * @method \GuzzleHttp\Promise\Promise listRegionalBucketsAsync(array $args = [])
152
 * @method \Aws\Result listStorageLensConfigurations(array $args = [])
153
 * @method \GuzzleHttp\Promise\Promise listStorageLensConfigurationsAsync(array $args = [])
1441 ariadna 154
 * @method \Aws\Result listStorageLensGroups(array $args = [])
155
 * @method \GuzzleHttp\Promise\Promise listStorageLensGroupsAsync(array $args = [])
156
 * @method \Aws\Result listTagsForResource(array $args = [])
157
 * @method \GuzzleHttp\Promise\Promise listTagsForResourceAsync(array $args = [])
158
 * @method \Aws\Result putAccessGrantsInstanceResourcePolicy(array $args = [])
159
 * @method \GuzzleHttp\Promise\Promise putAccessGrantsInstanceResourcePolicyAsync(array $args = [])
1 efrain 160
 * @method \Aws\Result putAccessPointConfigurationForObjectLambda(array $args = [])
161
 * @method \GuzzleHttp\Promise\Promise putAccessPointConfigurationForObjectLambdaAsync(array $args = [])
162
 * @method \Aws\Result putAccessPointPolicy(array $args = [])
163
 * @method \GuzzleHttp\Promise\Promise putAccessPointPolicyAsync(array $args = [])
164
 * @method \Aws\Result putAccessPointPolicyForObjectLambda(array $args = [])
165
 * @method \GuzzleHttp\Promise\Promise putAccessPointPolicyForObjectLambdaAsync(array $args = [])
166
 * @method \Aws\Result putBucketLifecycleConfiguration(array $args = [])
167
 * @method \GuzzleHttp\Promise\Promise putBucketLifecycleConfigurationAsync(array $args = [])
168
 * @method \Aws\Result putBucketPolicy(array $args = [])
169
 * @method \GuzzleHttp\Promise\Promise putBucketPolicyAsync(array $args = [])
170
 * @method \Aws\Result putBucketReplication(array $args = [])
171
 * @method \GuzzleHttp\Promise\Promise putBucketReplicationAsync(array $args = [])
172
 * @method \Aws\Result putBucketTagging(array $args = [])
173
 * @method \GuzzleHttp\Promise\Promise putBucketTaggingAsync(array $args = [])
174
 * @method \Aws\Result putBucketVersioning(array $args = [])
175
 * @method \GuzzleHttp\Promise\Promise putBucketVersioningAsync(array $args = [])
176
 * @method \Aws\Result putJobTagging(array $args = [])
177
 * @method \GuzzleHttp\Promise\Promise putJobTaggingAsync(array $args = [])
178
 * @method \Aws\Result putMultiRegionAccessPointPolicy(array $args = [])
179
 * @method \GuzzleHttp\Promise\Promise putMultiRegionAccessPointPolicyAsync(array $args = [])
180
 * @method \Aws\Result putPublicAccessBlock(array $args = [])
181
 * @method \GuzzleHttp\Promise\Promise putPublicAccessBlockAsync(array $args = [])
182
 * @method \Aws\Result putStorageLensConfiguration(array $args = [])
183
 * @method \GuzzleHttp\Promise\Promise putStorageLensConfigurationAsync(array $args = [])
184
 * @method \Aws\Result putStorageLensConfigurationTagging(array $args = [])
185
 * @method \GuzzleHttp\Promise\Promise putStorageLensConfigurationTaggingAsync(array $args = [])
186
 * @method \Aws\Result submitMultiRegionAccessPointRoutes(array $args = [])
187
 * @method \GuzzleHttp\Promise\Promise submitMultiRegionAccessPointRoutesAsync(array $args = [])
1441 ariadna 188
 * @method \Aws\Result tagResource(array $args = [])
189
 * @method \GuzzleHttp\Promise\Promise tagResourceAsync(array $args = [])
190
 * @method \Aws\Result untagResource(array $args = [])
191
 * @method \GuzzleHttp\Promise\Promise untagResourceAsync(array $args = [])
192
 * @method \Aws\Result updateAccessGrantsLocation(array $args = [])
193
 * @method \GuzzleHttp\Promise\Promise updateAccessGrantsLocationAsync(array $args = [])
1 efrain 194
 * @method \Aws\Result updateJobPriority(array $args = [])
195
 * @method \GuzzleHttp\Promise\Promise updateJobPriorityAsync(array $args = [])
196
 * @method \Aws\Result updateJobStatus(array $args = [])
197
 * @method \GuzzleHttp\Promise\Promise updateJobStatusAsync(array $args = [])
1441 ariadna 198
 * @method \Aws\Result updateStorageLensGroup(array $args = [])
199
 * @method \GuzzleHttp\Promise\Promise updateStorageLensGroupAsync(array $args = [])
1 efrain 200
 */
201
class S3ControlClient extends AwsClient
202
{
203
    public static function getArguments()
204
    {
205
        $args = parent::getArguments();
206
        return $args + [
207
            'use_dual_stack_endpoint' => [
208
                'type' => 'config',
209
                'valid' => ['bool'],
210
                'doc' => 'Set to true to send requests to an S3 Control Dual Stack'
211
                    . ' endpoint by default, which enables IPv6 Protocol.'
212
                    . ' Can be enabled or disabled on individual operations by setting'
213
                    . ' \'@use_dual_stack_endpoint\' to true or false.',
214
                'default' => false,
215
            ],
216
            'use_arn_region' => [
217
                'type'    => 'config',
218
                'valid'   => [
219
                    'bool',
220
                    Configuration::class,
221
                    CacheInterface::class,
222
                    'callable'
223
                ],
224
                'doc'     => 'Set to true to allow passed in ARNs to override'
225
                    . ' client region. Accepts...',
226
                'fn' => [__CLASS__, '_apply_use_arn_region'],
227
                'default' => [UseArnRegionConfigurationProvider::class, 'defaultProvider'],
228
            ],
229
        ];
230
    }
231
 
232
    public static function _apply_use_arn_region($value, array &$args, HandlerList $list)
233
    {
234
        if ($value instanceof CacheInterface) {
235
            $value = UseArnRegionConfigurationProvider::defaultProvider($args);
236
        }
237
        if (is_callable($value)) {
238
            $value = $value();
239
        }
240
        if ($value instanceof PromiseInterface) {
241
            $value = $value->wait();
242
        }
243
        if ($value instanceof ConfigurationInterface) {
244
            $args['use_arn_region'] = $value;
245
        } else {
246
            // The Configuration class itself will validate other inputs
247
            $args['use_arn_region'] = new Configuration($value);
248
        }
249
    }
250
 
251
    /**
252
     * {@inheritdoc}
253
     *
254
     * In addition to the options available to
255
     * {@see Aws\AwsClient::__construct}, S3ControlClient accepts the following
256
     * option:
257
     *
258
     * - use_dual_stack_endpoint: (bool) Set to true to send requests to an S3
259
     *   Control Dual Stack endpoint by default, which enables IPv6 Protocol.
260
     *   Can be enabled or disabled on individual operations by setting
261
     *   '@use_dual_stack_endpoint\' to true or false. Note:
262
     *   you cannot use it together with an accelerate endpoint.
263
     *
264
     * @param array $args
265
     */
266
    public function __construct(array $args)
267
    {
268
        parent::__construct($args);
269
 
270
        if ($this->isUseEndpointV2()) {
271
            $this->processEndpointV2Model();
1441 ariadna 272
        } else {
273
            $stack = $this->getHandlerList();
274
            $stack->appendBuild(
275
                EndpointArnMiddleware::wrap(
276
                    $this->getApi(),
277
                    $this->getRegion(),
278
                    [
279
                        'use_arn_region' => $this->getConfig('use_arn_region'),
280
                        'dual_stack' =>
281
                            $this->getConfig('use_dual_stack_endpoint')->isUseDualStackEndpoint(),
282
                        'endpoint' => isset($args['endpoint'])
283
                            ? $args['endpoint']
284
                            : null,
285
                        'use_fips_endpoint' => $this->getConfig('use_fips_endpoint'),
286
                    ],
287
                    $this->isUseEndpointV2()
288
                ),
289
                's3control.endpoint_arn_middleware'
290
            );
1 efrain 291
        }
292
    }
293
 
294
    /**
295
     * Modifies API definition to remove `AccountId`
296
     * host prefix.  This is now handled by the endpoint ruleset.
297
     *
298
     * @return void
299
     *
300
     * @internal
301
     */
302
    private function processEndpointV2Model()
303
    {
304
        $definition = $this->getApi()->getDefinition();
305
        $this->removeHostPrefix($definition);
306
        $this->removeRequiredMember($definition);
307
        $this->getApi()->setDefinition($definition);
308
    }
309
 
310
    private function removeHostPrefix(&$definition)
311
    {
312
        foreach($definition['operations'] as &$operation) {
313
            if (isset($operation['endpoint']['hostPrefix'])
314
                && $operation['endpoint']['hostPrefix'] === '{AccountId}.'
315
            ) {
316
                $operation['endpoint']['hostPrefix'] = str_replace(
317
                    '{AccountId}.',
318
                    '',
319
                    $operation['endpoint']['hostPrefix']
320
                );
321
            }
322
        }
323
    }
324
 
325
    private function removeRequiredMember(&$definition)
326
    {
327
        foreach($definition['shapes'] as &$shape) {
328
            if (isset($shape['required'])
329
            ) {
330
                $found = array_search('AccountId', $shape['required']);
331
 
332
                if ($found !== false) {
333
                    unset($shape['required'][$found]);
334
                }
335
            }
336
        }
337
    }
338
}