| 1 |
<?php |
| 2 |
|
| 3 |
namespace Dudlewebs\WPMCS\s3\Aws\Api; |
| 4 |
|
| 5 |
/** |
| 6 |
* Represents an API operation. |
| 7 |
*/ |
| 8 |
class Operation extends AbstractModel |
| 9 |
{ |
| 10 |
private $input; |
| 11 |
private $output; |
| 12 |
private $errors; |
| 13 |
private $staticContextParams = []; |
| 14 |
private $contextParams; |
| 15 |
private $operationContextParams = []; |
| 16 |
public function __construct(array $definition, ShapeMap $shapeMap) |
| 17 |
{ |
| 18 |
$definition['type'] = 'structure'; |
| 19 |
if (!isset($definition['http']['method'])) { |
| 20 |
$definition['http']['method'] = 'POST'; |
| 21 |
} |
| 22 |
if (!isset($definition['http']['requestUri'])) { |
| 23 |
$definition['http']['requestUri'] = '/'; |
| 24 |
} |
| 25 |
if (isset($definition['staticContextParams'])) { |
| 26 |
$this->staticContextParams = $definition['staticContextParams']; |
| 27 |
} |
| 28 |
if (isset($definition['operationContextParams'])) { |
| 29 |
$this->operationContextParams = $definition['operationContextParams']; |
| 30 |
} |
| 31 |
parent::__construct($definition, $shapeMap); |
| 32 |
$this->contextParams = $this->setContextParams(); |
| 33 |
} |
| 34 |
/** |
| 35 |
* Returns an associative array of the HTTP attribute of the operation: |
| 36 |
* |
| 37 |
* - method: HTTP method of the operation |
| 38 |
* - requestUri: URI of the request (can include URI template placeholders) |
| 39 |
* |
| 40 |
* @return array |
| 41 |
*/ |
| 42 |
public function getHttp() |
| 43 |
{ |
| 44 |
return $this->definition['http']; |
| 45 |
} |
| 46 |
/** |
| 47 |
* Get the input shape of the operation. |
| 48 |
* |
| 49 |
* @return StructureShape |
| 50 |
*/ |
| 51 |
public function getInput() |
| 52 |
{ |
| 53 |
if (!$this->input) { |
| 54 |
if ($input = $this['input']) { |
| 55 |
$this->input = $this->shapeFor($input); |
| 56 |
} else { |
| 57 |
$this->input = new StructureShape([], $this->shapeMap); |
| 58 |
} |
| 59 |
} |
| 60 |
return $this->input; |
| 61 |
} |
| 62 |
/** |
| 63 |
* Get the output shape of the operation. |
| 64 |
* |
| 65 |
* @return StructureShape |
| 66 |
*/ |
| 67 |
public function getOutput() |
| 68 |
{ |
| 69 |
if (!$this->output) { |
| 70 |
if ($output = $this['output']) { |
| 71 |
$this->output = $this->shapeFor($output); |
| 72 |
} else { |
| 73 |
$this->output = new StructureShape([], $this->shapeMap); |
| 74 |
} |
| 75 |
} |
| 76 |
return $this->output; |
| 77 |
} |
| 78 |
/** |
| 79 |
* Get an array of operation error shapes. |
| 80 |
* |
| 81 |
* @return Shape[] |
| 82 |
*/ |
| 83 |
public function getErrors() |
| 84 |
{ |
| 85 |
if ($this->errors === null) { |
| 86 |
if ($errors = $this['errors']) { |
| 87 |
foreach ($errors as $key => $error) { |
| 88 |
$errors[$key] = $this->shapeFor($error); |
| 89 |
} |
| 90 |
$this->errors = $errors; |
| 91 |
} else { |
| 92 |
$this->errors = []; |
| 93 |
} |
| 94 |
} |
| 95 |
return $this->errors; |
| 96 |
} |
| 97 |
/** |
| 98 |
* Gets static modeled static values used for |
| 99 |
* endpoint resolution. |
| 100 |
* |
| 101 |
* @return array |
| 102 |
*/ |
| 103 |
public function getStaticContextParams() |
| 104 |
{ |
| 105 |
return $this->staticContextParams; |
| 106 |
} |
| 107 |
/** |
| 108 |
* Gets definition of modeled dynamic values used |
| 109 |
* for endpoint resolution |
| 110 |
* |
| 111 |
* @return array |
| 112 |
*/ |
| 113 |
public function getContextParams() |
| 114 |
{ |
| 115 |
return $this->contextParams; |
| 116 |
} |
| 117 |
/** |
| 118 |
* Gets definition of modeled dynamic values used |
| 119 |
* for endpoint resolution |
| 120 |
* |
| 121 |
* @return array |
| 122 |
*/ |
| 123 |
public function getOperationContextParams() : array |
| 124 |
{ |
| 125 |
return $this->operationContextParams; |
| 126 |
} |
| 127 |
private function setContextParams() |
| 128 |
{ |
| 129 |
$members = $this->getInput()->getMembers(); |
| 130 |
$contextParams = []; |
| 131 |
foreach ($members as $name => $shape) { |
| 132 |
if (!empty($contextParam = $shape->getContextParam())) { |
| 133 |
$contextParams[$contextParam['name']] = ['shape' => $name, 'type' => $shape->getType()]; |
| 134 |
} |
| 135 |
} |
| 136 |
return $contextParams; |
| 137 |
} |
| 138 |
} |
| 139 |
|