S3ControlClient.php 19 KB

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