S3ControlClient.php 9.3 KB

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