/libraries/fabrik/vendor/aws/aws-sdk-php/src/S3Control/S3ControlClient.php

https://github.com/trob/fabrik · PHP · 206 lines · 85 code · 4 blank · 117 comment · 5 complexity · 4e28711821ffc7bb9258052e3d0b80f5 MD5 · raw file

  1. <?php
  2. namespace Aws\S3Control;
  3. use Aws\AwsClient;
  4. use Aws\CacheInterface;
  5. use Aws\HandlerList;
  6. use Aws\S3\UseArnRegion\Configuration;
  7. use Aws\S3\UseArnRegion\ConfigurationInterface;
  8. use Aws\S3\UseArnRegion\ConfigurationProvider as UseArnRegionConfigurationProvider;
  9. use GuzzleHttp\Promise\PromiseInterface;
  10. /**
  11. * This client is used to interact with the **AWS S3 Control** service.
  12. * @method \Aws\Result createAccessPoint(array $args = [])
  13. * @method \GuzzleHttp\Promise\Promise createAccessPointAsync(array $args = [])
  14. * @method \Aws\Result createAccessPointForObjectLambda(array $args = [])
  15. * @method \GuzzleHttp\Promise\Promise createAccessPointForObjectLambdaAsync(array $args = [])
  16. * @method \Aws\Result createBucket(array $args = [])
  17. * @method \GuzzleHttp\Promise\Promise createBucketAsync(array $args = [])
  18. * @method \Aws\Result createJob(array $args = [])
  19. * @method \GuzzleHttp\Promise\Promise createJobAsync(array $args = [])
  20. * @method \Aws\Result deleteAccessPoint(array $args = [])
  21. * @method \GuzzleHttp\Promise\Promise deleteAccessPointAsync(array $args = [])
  22. * @method \Aws\Result deleteAccessPointForObjectLambda(array $args = [])
  23. * @method \GuzzleHttp\Promise\Promise deleteAccessPointForObjectLambdaAsync(array $args = [])
  24. * @method \Aws\Result deleteAccessPointPolicy(array $args = [])
  25. * @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyAsync(array $args = [])
  26. * @method \Aws\Result deleteAccessPointPolicyForObjectLambda(array $args = [])
  27. * @method \GuzzleHttp\Promise\Promise deleteAccessPointPolicyForObjectLambdaAsync(array $args = [])
  28. * @method \Aws\Result deleteBucket(array $args = [])
  29. * @method \GuzzleHttp\Promise\Promise deleteBucketAsync(array $args = [])
  30. * @method \Aws\Result deleteBucketLifecycleConfiguration(array $args = [])
  31. * @method \GuzzleHttp\Promise\Promise deleteBucketLifecycleConfigurationAsync(array $args = [])
  32. * @method \Aws\Result deleteBucketPolicy(array $args = [])
  33. * @method \GuzzleHttp\Promise\Promise deleteBucketPolicyAsync(array $args = [])
  34. * @method \Aws\Result deleteBucketTagging(array $args = [])
  35. * @method \GuzzleHttp\Promise\Promise deleteBucketTaggingAsync(array $args = [])
  36. * @method \Aws\Result deleteJobTagging(array $args = [])
  37. * @method \GuzzleHttp\Promise\Promise deleteJobTaggingAsync(array $args = [])
  38. * @method \Aws\Result deletePublicAccessBlock(array $args = [])
  39. * @method \GuzzleHttp\Promise\Promise deletePublicAccessBlockAsync(array $args = [])
  40. * @method \Aws\Result deleteStorageLensConfiguration(array $args = [])
  41. * @method \GuzzleHttp\Promise\Promise deleteStorageLensConfigurationAsync(array $args = [])
  42. * @method \Aws\Result deleteStorageLensConfigurationTagging(array $args = [])
  43. * @method \GuzzleHttp\Promise\Promise deleteStorageLensConfigurationTaggingAsync(array $args = [])
  44. * @method \Aws\Result describeJob(array $args = [])
  45. * @method \GuzzleHttp\Promise\Promise describeJobAsync(array $args = [])
  46. * @method \Aws\Result getAccessPoint(array $args = [])
  47. * @method \GuzzleHttp\Promise\Promise getAccessPointAsync(array $args = [])
  48. * @method \Aws\Result getAccessPointConfigurationForObjectLambda(array $args = [])
  49. * @method \GuzzleHttp\Promise\Promise getAccessPointConfigurationForObjectLambdaAsync(array $args = [])
  50. * @method \Aws\Result getAccessPointForObjectLambda(array $args = [])
  51. * @method \GuzzleHttp\Promise\Promise getAccessPointForObjectLambdaAsync(array $args = [])
  52. * @method \Aws\Result getAccessPointPolicy(array $args = [])
  53. * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyAsync(array $args = [])
  54. * @method \Aws\Result getAccessPointPolicyForObjectLambda(array $args = [])
  55. * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyForObjectLambdaAsync(array $args = [])
  56. * @method \Aws\Result getAccessPointPolicyStatus(array $args = [])
  57. * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyStatusAsync(array $args = [])
  58. * @method \Aws\Result getAccessPointPolicyStatusForObjectLambda(array $args = [])
  59. * @method \GuzzleHttp\Promise\Promise getAccessPointPolicyStatusForObjectLambdaAsync(array $args = [])
  60. * @method \Aws\Result getBucket(array $args = [])
  61. * @method \GuzzleHttp\Promise\Promise getBucketAsync(array $args = [])
  62. * @method \Aws\Result getBucketLifecycleConfiguration(array $args = [])
  63. * @method \GuzzleHttp\Promise\Promise getBucketLifecycleConfigurationAsync(array $args = [])
  64. * @method \Aws\Result getBucketPolicy(array $args = [])
  65. * @method \GuzzleHttp\Promise\Promise getBucketPolicyAsync(array $args = [])
  66. * @method \Aws\Result getBucketTagging(array $args = [])
  67. * @method \GuzzleHttp\Promise\Promise getBucketTaggingAsync(array $args = [])
  68. * @method \Aws\Result getJobTagging(array $args = [])
  69. * @method \GuzzleHttp\Promise\Promise getJobTaggingAsync(array $args = [])
  70. * @method \Aws\Result getPublicAccessBlock(array $args = [])
  71. * @method \GuzzleHttp\Promise\Promise getPublicAccessBlockAsync(array $args = [])
  72. * @method \Aws\Result getStorageLensConfiguration(array $args = [])
  73. * @method \GuzzleHttp\Promise\Promise getStorageLensConfigurationAsync(array $args = [])
  74. * @method \Aws\Result getStorageLensConfigurationTagging(array $args = [])
  75. * @method \GuzzleHttp\Promise\Promise getStorageLensConfigurationTaggingAsync(array $args = [])
  76. * @method \Aws\Result listAccessPoints(array $args = [])
  77. * @method \GuzzleHttp\Promise\Promise listAccessPointsAsync(array $args = [])
  78. * @method \Aws\Result listAccessPointsForObjectLambda(array $args = [])
  79. * @method \GuzzleHttp\Promise\Promise listAccessPointsForObjectLambdaAsync(array $args = [])
  80. * @method \Aws\Result listJobs(array $args = [])
  81. * @method \GuzzleHttp\Promise\Promise listJobsAsync(array $args = [])
  82. * @method \Aws\Result listRegionalBuckets(array $args = [])
  83. * @method \GuzzleHttp\Promise\Promise listRegionalBucketsAsync(array $args = [])
  84. * @method \Aws\Result listStorageLensConfigurations(array $args = [])
  85. * @method \GuzzleHttp\Promise\Promise listStorageLensConfigurationsAsync(array $args = [])
  86. * @method \Aws\Result putAccessPointConfigurationForObjectLambda(array $args = [])
  87. * @method \GuzzleHttp\Promise\Promise putAccessPointConfigurationForObjectLambdaAsync(array $args = [])
  88. * @method \Aws\Result putAccessPointPolicy(array $args = [])
  89. * @method \GuzzleHttp\Promise\Promise putAccessPointPolicyAsync(array $args = [])
  90. * @method \Aws\Result putAccessPointPolicyForObjectLambda(array $args = [])
  91. * @method \GuzzleHttp\Promise\Promise putAccessPointPolicyForObjectLambdaAsync(array $args = [])
  92. * @method \Aws\Result putBucketLifecycleConfiguration(array $args = [])
  93. * @method \GuzzleHttp\Promise\Promise putBucketLifecycleConfigurationAsync(array $args = [])
  94. * @method \Aws\Result putBucketPolicy(array $args = [])
  95. * @method \GuzzleHttp\Promise\Promise putBucketPolicyAsync(array $args = [])
  96. * @method \Aws\Result putBucketTagging(array $args = [])
  97. * @method \GuzzleHttp\Promise\Promise putBucketTaggingAsync(array $args = [])
  98. * @method \Aws\Result putJobTagging(array $args = [])
  99. * @method \GuzzleHttp\Promise\Promise putJobTaggingAsync(array $args = [])
  100. * @method \Aws\Result putPublicAccessBlock(array $args = [])
  101. * @method \GuzzleHttp\Promise\Promise putPublicAccessBlockAsync(array $args = [])
  102. * @method \Aws\Result putStorageLensConfiguration(array $args = [])
  103. * @method \GuzzleHttp\Promise\Promise putStorageLensConfigurationAsync(array $args = [])
  104. * @method \Aws\Result putStorageLensConfigurationTagging(array $args = [])
  105. * @method \GuzzleHttp\Promise\Promise putStorageLensConfigurationTaggingAsync(array $args = [])
  106. * @method \Aws\Result updateJobPriority(array $args = [])
  107. * @method \GuzzleHttp\Promise\Promise updateJobPriorityAsync(array $args = [])
  108. * @method \Aws\Result updateJobStatus(array $args = [])
  109. * @method \GuzzleHttp\Promise\Promise updateJobStatusAsync(array $args = [])
  110. */
  111. class S3ControlClient extends AwsClient
  112. {
  113. public static function getArguments()
  114. {
  115. $args = parent::getArguments();
  116. return $args + [
  117. 'use_dual_stack_endpoint' => [
  118. 'type' => 'config',
  119. 'valid' => ['bool'],
  120. 'doc' => 'Set to true to send requests to an S3 Control Dual Stack'
  121. . ' endpoint by default, which enables IPv6 Protocol.'
  122. . ' Can be enabled or disabled on individual operations by setting'
  123. . ' \'@use_dual_stack_endpoint\' to true or false.',
  124. 'default' => false,
  125. ],
  126. 'use_arn_region' => [
  127. 'type' => 'config',
  128. 'valid' => [
  129. 'bool',
  130. Configuration::class,
  131. CacheInterface::class,
  132. 'callable'
  133. ],
  134. 'doc' => 'Set to true to allow passed in ARNs to override'
  135. . ' client region. Accepts...',
  136. 'fn' => [__CLASS__, '_apply_use_arn_region'],
  137. 'default' => [UseArnRegionConfigurationProvider::class, 'defaultProvider'],
  138. ],
  139. ];
  140. }
  141. public static function _apply_use_arn_region($value, array &$args, HandlerList $list)
  142. {
  143. if ($value instanceof CacheInterface) {
  144. $value = UseArnRegionConfigurationProvider::defaultProvider($args);
  145. }
  146. if (is_callable($value)) {
  147. $value = $value();
  148. }
  149. if ($value instanceof PromiseInterface) {
  150. $value = $value->wait();
  151. }
  152. if ($value instanceof ConfigurationInterface) {
  153. $args['use_arn_region'] = $value;
  154. } else {
  155. // The Configuration class itself will validate other inputs
  156. $args['use_arn_region'] = new Configuration($value);
  157. }
  158. }
  159. /**
  160. * {@inheritdoc}
  161. *
  162. * In addition to the options available to
  163. * {@see Aws\AwsClient::__construct}, S3ControlClient accepts the following
  164. * option:
  165. *
  166. * - use_dual_stack_endpoint: (bool) Set to true to send requests to an S3
  167. * Control Dual Stack endpoint by default, which enables IPv6 Protocol.
  168. * Can be enabled or disabled on individual operations by setting
  169. * '@use_dual_stack_endpoint\' to true or false. Note:
  170. * you cannot use it together with an accelerate endpoint.
  171. *
  172. * @param array $args
  173. */
  174. public function __construct(array $args)
  175. {
  176. parent::__construct($args);
  177. $stack = $this->getHandlerList();
  178. $stack->appendBuild(
  179. S3ControlEndpointMiddleware::wrap(
  180. $this->getRegion(),
  181. [
  182. 'dual_stack' => $this->getConfig('use_dual_stack_endpoint'),
  183. ]
  184. ),
  185. 's3control.endpoint_middleware'
  186. );
  187. $stack->appendBuild(
  188. EndpointArnMiddleware::wrap(
  189. $this->getApi(),
  190. $this->getRegion(),
  191. [
  192. 'use_arn_region' => $this->getConfig('use_arn_region'),
  193. 'dual_stack' => $this->getConfig('use_dual_stack_endpoint'),
  194. 'endpoint' => isset($args['endpoint'])
  195. ? $args['endpoint']
  196. : null
  197. ]
  198. ),
  199. 's3control.endpoint_arn_middleware'
  200. );
  201. }
  202. }