Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/Api/Operation.php

raw symbols SCIP
1 <?php
2 namespace Aws\Api;
3
4 /**
5 * Represents an API operation.
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 * Returns an associative array of the HTTP attribute of the operation:
42 *
43 * - method: HTTP method of the operation
44 * - requestUri: URI of the request (can include URI template placeholders)
45 *
46 * @return array
47 */
48 public function getHttp()
49 {
50 return $this->definition['http'];
51 }
52
53 /**
54 * Get the input shape of the operation.
55 *
56 * @return StructureShape
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 * Get the output shape of the operation.
73 *
74 * @return StructureShape
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 * Get an array of operation error shapes.
91 *
92 * @return StructureShape[]
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 * Gets static modeled static values used for
112 * endpoint resolution.
113 *
114 * @return array
115 */
116 public function getStaticContextParams()
117 {
118 return $this->staticContextParams;
119 }
120
121 /**
122 * Gets definition of modeled dynamic values used
123 * for endpoint resolution
124 *
125 * @return array
126 */
127 public function getContextParams()
128 {
129 return $this->contextParams;
130 }
131
132 /**
133 * Gets definition of modeled dynamic values used
134 * for endpoint resolution
135 *
136 * @return array
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 }