|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace AsyncAws\Ssm\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 DeleteParametersRequest extends Input |
| 11 | +{ |
| 12 | + /** |
| 13 | + * The names of the parameters to delete. After deleting a parameter, wait for at least 30 seconds to create a parameter |
| 14 | + * with the same name. |
| 15 | + * |
| 16 | + * @required |
| 17 | + * |
| 18 | + * @var string[]|null |
| 19 | + */ |
| 20 | + private $names; |
| 21 | + |
| 22 | + /** |
| 23 | + * @param array{ |
| 24 | + * Names?: string[], |
| 25 | + * @region?: string, |
| 26 | + * } $input |
| 27 | + */ |
| 28 | + public function __construct(array $input = []) |
| 29 | + { |
| 30 | + $this->names = $input['Names'] ?? null; |
| 31 | + parent::__construct($input); |
| 32 | + } |
| 33 | + |
| 34 | + public static function create($input): self |
| 35 | + { |
| 36 | + return $input instanceof self ? $input : new self($input); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @return string[] |
| 41 | + */ |
| 42 | + public function getNames(): array |
| 43 | + { |
| 44 | + return $this->names ?? []; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @internal |
| 49 | + */ |
| 50 | + public function request(): Request |
| 51 | + { |
| 52 | + // Prepare headers |
| 53 | + $headers = [ |
| 54 | + 'Content-Type' => 'application/x-amz-json-1.1', |
| 55 | + 'X-Amz-Target' => 'AmazonSSM.DeleteParameters', |
| 56 | + ]; |
| 57 | + |
| 58 | + // Prepare query |
| 59 | + $query = []; |
| 60 | + |
| 61 | + // Prepare URI |
| 62 | + $uriString = '/'; |
| 63 | + |
| 64 | + // Prepare Body |
| 65 | + $bodyPayload = $this->requestBody(); |
| 66 | + $body = empty($bodyPayload) ? '{}' : json_encode($bodyPayload, 4194304); |
| 67 | + |
| 68 | + // Return the Request |
| 69 | + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($body)); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * @param string[] $value |
| 74 | + */ |
| 75 | + public function setNames(array $value): self |
| 76 | + { |
| 77 | + $this->names = $value; |
| 78 | + |
| 79 | + return $this; |
| 80 | + } |
| 81 | + |
| 82 | + private function requestBody(): array |
| 83 | + { |
| 84 | + $payload = []; |
| 85 | + if (null === $v = $this->names) { |
| 86 | + throw new InvalidArgument(sprintf('Missing parameter "Names" for "%s". The value cannot be null.', __CLASS__)); |
| 87 | + } |
| 88 | + |
| 89 | + $index = -1; |
| 90 | + $payload['Names'] = []; |
| 91 | + foreach ($v as $listValue) { |
| 92 | + ++$index; |
| 93 | + $payload['Names'][$index] = $listValue; |
| 94 | + } |
| 95 | + |
| 96 | + return $payload; |
| 97 | + } |
| 98 | +} |
0 commit comments