|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace AsyncAws\S3\Input; |
| 4 | + |
| 5 | +use AsyncAws\Core\Exception\InvalidArgument; |
| 6 | +use AsyncAws\Core\Input; |
| 7 | +use AsyncAws\Core\Request; |
| 8 | +use AsyncAws\Core\Stream\StreamFactory; |
| 9 | + |
| 10 | +final class GetBucketEncryptionRequest extends Input |
| 11 | +{ |
| 12 | + /** |
| 13 | + * The name of the bucket from which the server-side encryption configuration is retrieved. |
| 14 | + * |
| 15 | + * @required |
| 16 | + * |
| 17 | + * @var string|null |
| 18 | + */ |
| 19 | + private $bucket; |
| 20 | + |
| 21 | + /** |
| 22 | + * The account ID of the expected bucket owner. If the bucket is owned by a different account, the request will fail |
| 23 | + * with an HTTP `403 (Access Denied)` error. |
| 24 | + * |
| 25 | + * @var string|null |
| 26 | + */ |
| 27 | + private $expectedBucketOwner; |
| 28 | + |
| 29 | + /** |
| 30 | + * @param array{ |
| 31 | + * Bucket?: string, |
| 32 | + * ExpectedBucketOwner?: string, |
| 33 | + * @region?: string, |
| 34 | + * } $input |
| 35 | + */ |
| 36 | + public function __construct(array $input = []) |
| 37 | + { |
| 38 | + $this->bucket = $input['Bucket'] ?? null; |
| 39 | + $this->expectedBucketOwner = $input['ExpectedBucketOwner'] ?? null; |
| 40 | + parent::__construct($input); |
| 41 | + } |
| 42 | + |
| 43 | + public static function create($input): self |
| 44 | + { |
| 45 | + return $input instanceof self ? $input : new self($input); |
| 46 | + } |
| 47 | + |
| 48 | + public function getBucket(): ?string |
| 49 | + { |
| 50 | + return $this->bucket; |
| 51 | + } |
| 52 | + |
| 53 | + public function getExpectedBucketOwner(): ?string |
| 54 | + { |
| 55 | + return $this->expectedBucketOwner; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * @internal |
| 60 | + */ |
| 61 | + public function request(): Request |
| 62 | + { |
| 63 | + // Prepare headers |
| 64 | + $headers = ['content-type' => 'application/xml']; |
| 65 | + if (null !== $this->expectedBucketOwner) { |
| 66 | + $headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner; |
| 67 | + } |
| 68 | + |
| 69 | + // Prepare query |
| 70 | + $query = []; |
| 71 | + |
| 72 | + // Prepare URI |
| 73 | + $uri = []; |
| 74 | + if (null === $v = $this->bucket) { |
| 75 | + throw new InvalidArgument(sprintf('Missing parameter "Bucket" for "%s". The value cannot be null.', __CLASS__)); |
| 76 | + } |
| 77 | + $uri['Bucket'] = $v; |
| 78 | + $uriString = '/' . rawurlencode($uri['Bucket']) . '?encryption'; |
| 79 | + |
| 80 | + // Prepare Body |
| 81 | + $body = ''; |
| 82 | + |
| 83 | + // Return the Request |
| 84 | + return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body)); |
| 85 | + } |
| 86 | + |
| 87 | + public function setBucket(?string $value): self |
| 88 | + { |
| 89 | + $this->bucket = $value; |
| 90 | + |
| 91 | + return $this; |
| 92 | + } |
| 93 | + |
| 94 | + public function setExpectedBucketOwner(?string $value): self |
| 95 | + { |
| 96 | + $this->expectedBucketOwner = $value; |
| 97 | + |
| 98 | + return $this; |
| 99 | + } |
| 100 | +} |
0 commit comments