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