new-admin-api/vendor/async-aws/s3/src/Input/GetObjectAclRequest.php

184 lines
4.5 KiB
PHP

<?php
namespace AsyncAws\S3\Input;
use AsyncAws\Core\Exception\InvalidArgument;
use AsyncAws\Core\Input;
use AsyncAws\Core\Request;
use AsyncAws\Core\Stream\StreamFactory;
use AsyncAws\S3\Enum\RequestPayer;
final class GetObjectAclRequest extends Input
{
/**
* The bucket name that contains the object for which to get the ACL information.
*
* @required
*
* @var string|null
*/
private $bucket;
/**
* The key of the object for which to get the ACL information.
*
* @required
*
* @var string|null
*/
private $key;
/**
* VersionId used to reference a specific version of the object.
*
* @var string|null
*/
private $versionId;
/**
* @var RequestPayer::*|null
*/
private $requestPayer;
/**
* The account ID of the expected bucket owner. If the bucket is owned by a different account, the request fails with
* the HTTP status code `403 Forbidden` (access denied).
*
* @var string|null
*/
private $expectedBucketOwner;
/**
* @param array{
* Bucket?: string,
* Key?: string,
* VersionId?: string,
* RequestPayer?: RequestPayer::*,
* ExpectedBucketOwner?: string,
* @region?: string,
* } $input
*/
public function __construct(array $input = [])
{
$this->bucket = $input['Bucket'] ?? null;
$this->key = $input['Key'] ?? null;
$this->versionId = $input['VersionId'] ?? null;
$this->requestPayer = $input['RequestPayer'] ?? null;
$this->expectedBucketOwner = $input['ExpectedBucketOwner'] ?? null;
parent::__construct($input);
}
public static function create($input): self
{
return $input instanceof self ? $input : new self($input);
}
public function getBucket(): ?string
{
return $this->bucket;
}
public function getExpectedBucketOwner(): ?string
{
return $this->expectedBucketOwner;
}
public function getKey(): ?string
{
return $this->key;
}
/**
* @return RequestPayer::*|null
*/
public function getRequestPayer(): ?string
{
return $this->requestPayer;
}
public function getVersionId(): ?string
{
return $this->versionId;
}
/**
* @internal
*/
public function request(): Request
{
// Prepare headers
$headers = ['content-type' => 'application/xml'];
if (null !== $this->requestPayer) {
if (!RequestPayer::exists($this->requestPayer)) {
throw new InvalidArgument(sprintf('Invalid parameter "RequestPayer" for "%s". The value "%s" is not a valid "RequestPayer".', __CLASS__, $this->requestPayer));
}
$headers['x-amz-request-payer'] = $this->requestPayer;
}
if (null !== $this->expectedBucketOwner) {
$headers['x-amz-expected-bucket-owner'] = $this->expectedBucketOwner;
}
// Prepare query
$query = [];
if (null !== $this->versionId) {
$query['versionId'] = $this->versionId;
}
// Prepare URI
$uri = [];
if (null === $v = $this->bucket) {
throw new InvalidArgument(sprintf('Missing parameter "Bucket" for "%s". The value cannot be null.', __CLASS__));
}
$uri['Bucket'] = $v;
if (null === $v = $this->key) {
throw new InvalidArgument(sprintf('Missing parameter "Key" for "%s". The value cannot be null.', __CLASS__));
}
$uri['Key'] = $v;
$uriString = '/' . rawurlencode($uri['Bucket']) . '/' . str_replace('%2F', '/', rawurlencode($uri['Key'])) . '?acl';
// Prepare Body
$body = '';
// Return the Request
return new Request('GET', $uriString, $query, $headers, StreamFactory::create($body));
}
public function setBucket(?string $value): self
{
$this->bucket = $value;
return $this;
}
public function setExpectedBucketOwner(?string $value): self
{
$this->expectedBucketOwner = $value;
return $this;
}
public function setKey(?string $value): self
{
$this->key = $value;
return $this;
}
/**
* @param RequestPayer::*|null $value
*/
public function setRequestPayer(?string $value): self
{
$this->requestPayer = $value;
return $this;
}
public function setVersionId(?string $value): self
{
$this->versionId = $value;
return $this;
}
}