|
3 | 3 | namespace AsyncAws\Lambda\Input; |
4 | 4 |
|
5 | 5 | use AsyncAws\Core\Exception\InvalidArgument; |
| 6 | +use AsyncAws\Core\Request; |
| 7 | +use AsyncAws\Core\Stream\StreamFactory; |
6 | 8 | use AsyncAws\Lambda\Enum\Runtime; |
7 | 9 |
|
8 | 10 | class PublishLayerVersionRequest |
@@ -102,77 +104,21 @@ public function getLicenseInfo(): ?string |
102 | 104 | /** |
103 | 105 | * @internal |
104 | 106 | */ |
105 | | - public function requestBody(): string |
106 | | - { |
107 | | - $payload = []; |
108 | | - $indices = new \stdClass(); |
109 | | - if (null !== $v = $this->Description) { |
110 | | - $payload['Description'] = $v; |
111 | | - } |
112 | | - |
113 | | - if (null !== $this->Content) { |
114 | | - (static function (LayerVersionContentInput $input) use (&$payload) { |
115 | | - if (null !== $v = $input->getS3Bucket()) { |
116 | | - $payload['Content']['S3Bucket'] = $v; |
117 | | - } |
118 | | - |
119 | | - if (null !== $v = $input->getS3Key()) { |
120 | | - $payload['Content']['S3Key'] = $v; |
121 | | - } |
122 | | - |
123 | | - if (null !== $v = $input->getS3ObjectVersion()) { |
124 | | - $payload['Content']['S3ObjectVersion'] = $v; |
125 | | - } |
126 | | - |
127 | | - if (null !== $v = $input->getZipFile()) { |
128 | | - $payload['Content']['ZipFile'] = base64_encode($v); |
129 | | - } |
130 | | - })($this->Content); |
131 | | - } |
132 | | - |
133 | | - (static function (array $input) use (&$payload, $indices) { |
134 | | - $indices->kea6f923 = -1; |
135 | | - foreach ($input as $value) { |
136 | | - ++$indices->kea6f923; |
137 | | - $payload['CompatibleRuntimes'][$indices->kea6f923] = $value; |
138 | | - } |
139 | | - })($this->CompatibleRuntimes); |
140 | | - if (null !== $v = $this->LicenseInfo) { |
141 | | - $payload['LicenseInfo'] = $v; |
142 | | - } |
143 | | - |
144 | | - return json_encode($payload); |
145 | | - } |
146 | | - |
147 | | - /** |
148 | | - * @internal |
149 | | - */ |
150 | | - public function requestHeaders(): array |
| 107 | + public function request(): Request |
151 | 108 | { |
| 109 | + // Prepare headers |
152 | 110 | $headers = ['content-type' => 'application/json']; |
153 | 111 |
|
154 | | - return $headers; |
155 | | - } |
156 | | - |
157 | | - /** |
158 | | - * @internal |
159 | | - */ |
160 | | - public function requestQuery(): array |
161 | | - { |
| 112 | + // Prepare query |
162 | 113 | $query = []; |
163 | 114 |
|
164 | | - return $query; |
165 | | - } |
166 | | - |
167 | | - /** |
168 | | - * @internal |
169 | | - */ |
170 | | - public function requestUri(): string |
171 | | - { |
| 115 | + // Prepare URI |
172 | 116 | $uri = []; |
173 | 117 | $uri['LayerName'] = $this->LayerName ?? ''; |
| 118 | + $uriString = "/2018-10-31/layers/{$uri['LayerName']}/versions"; |
174 | 119 |
|
175 | | - return "/2018-10-31/layers/{$uri['LayerName']}/versions"; |
| 120 | + // Return the Request |
| 121 | + return new Request('POST', $uriString, $query, $headers, StreamFactory::create($this->requestBody())); |
176 | 122 | } |
177 | 123 |
|
178 | 124 | /** |
@@ -230,4 +176,46 @@ public function validate(): void |
230 | 176 | } |
231 | 177 | } |
232 | 178 | } |
| 179 | + |
| 180 | + private function requestBody(): string |
| 181 | + { |
| 182 | + $payload = []; |
| 183 | + $indices = new \stdClass(); |
| 184 | + if (null !== $v = $this->Description) { |
| 185 | + $payload['Description'] = $v; |
| 186 | + } |
| 187 | + |
| 188 | + if (null !== $this->Content) { |
| 189 | + (static function (LayerVersionContentInput $input) use (&$payload) { |
| 190 | + if (null !== $v = $input->getS3Bucket()) { |
| 191 | + $payload['Content']['S3Bucket'] = $v; |
| 192 | + } |
| 193 | + |
| 194 | + if (null !== $v = $input->getS3Key()) { |
| 195 | + $payload['Content']['S3Key'] = $v; |
| 196 | + } |
| 197 | + |
| 198 | + if (null !== $v = $input->getS3ObjectVersion()) { |
| 199 | + $payload['Content']['S3ObjectVersion'] = $v; |
| 200 | + } |
| 201 | + |
| 202 | + if (null !== $v = $input->getZipFile()) { |
| 203 | + $payload['Content']['ZipFile'] = base64_encode($v); |
| 204 | + } |
| 205 | + })($this->Content); |
| 206 | + } |
| 207 | + |
| 208 | + (static function (array $input) use (&$payload, $indices) { |
| 209 | + $indices->kea6f923 = -1; |
| 210 | + foreach ($input as $value) { |
| 211 | + ++$indices->kea6f923; |
| 212 | + $payload['CompatibleRuntimes'][$indices->kea6f923] = $value; |
| 213 | + } |
| 214 | + })($this->CompatibleRuntimes); |
| 215 | + if (null !== $v = $this->LicenseInfo) { |
| 216 | + $payload['LicenseInfo'] = $v; |
| 217 | + } |
| 218 | + |
| 219 | + return json_encode($payload); |
| 220 | + } |
233 | 221 | } |
0 commit comments