|
16 | 16 | * |
17 | 17 | * API for the Catrobat Share Platform |
18 | 18 | * |
19 | | - * The version of the OpenAPI document: v1.0.37 |
| 19 | + * The version of the OpenAPI document: v1.0.39 |
20 | 20 | * Contact: webmaster@catrobat.org |
21 | 21 | * Generated by: https://github.com/openapitools/openapi-generator.git |
22 | 22 | */ |
|
50 | 50 | class MediaLibraryController extends Controller |
51 | 51 | { |
52 | 52 | /** |
53 | | - * Operation mediaFileSearchGet. |
| 53 | + * Operation mediaFileIdGet. |
| 54 | + * |
| 55 | + * Get the information of a specific media file |
| 56 | + * |
| 57 | + * @param Request $request the Symfony request to handle |
| 58 | + * @param mixed $id |
| 59 | + * |
| 60 | + * @return Response the Symfony response |
| 61 | + */ |
| 62 | + public function mediaFileIdGetAction(Request $request, $id) |
| 63 | + { |
| 64 | + // Figure out what data format to return to the client |
| 65 | + $produces = ['application/json']; |
| 66 | + // Figure out what the client accepts |
| 67 | + $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*'; |
| 68 | + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); |
| 69 | + if (null === $responseFormat) |
| 70 | + { |
| 71 | + return new Response('', 406); |
| 72 | + } |
| 73 | + |
| 74 | + // Handle authentication |
| 75 | + |
| 76 | + // Read out all input parameter values into variables |
| 77 | + |
| 78 | + // Use the default value if no value was provided |
| 79 | + |
| 80 | + // Deserialize the input values that needs it |
| 81 | + try |
| 82 | + { |
| 83 | + $id = $this->deserialize($id, 'int', 'string'); |
| 84 | + } |
| 85 | + catch (SerializerRuntimeException $exception) |
| 86 | + { |
| 87 | + return $this->createBadRequestResponse($exception->getMessage()); |
| 88 | + } |
| 89 | + |
| 90 | + // Validate the input values |
| 91 | + $asserts = []; |
| 92 | + $asserts[] = new Assert\NotNull(); |
| 93 | + $asserts[] = new Assert\Type('int'); |
| 94 | + $response = $this->validate($id, $asserts); |
| 95 | + if ($response instanceof Response) |
| 96 | + { |
| 97 | + return $response; |
| 98 | + } |
| 99 | + |
| 100 | + try |
| 101 | + { |
| 102 | + $handler = $this->getApiHandler(); |
| 103 | + |
| 104 | + // Make the call to the business logic |
| 105 | + $responseCode = 200; |
| 106 | + $responseHeaders = []; |
| 107 | + $result = $handler->mediaFileIdGet($id, $responseCode, $responseHeaders); |
| 108 | + |
| 109 | + // Find default response message |
| 110 | + $message = 'OK'; |
| 111 | + |
| 112 | + // Find a more specific message, if available |
| 113 | + switch ($responseCode) { |
| 114 | + case 200: |
| 115 | + $message = 'OK'; |
| 116 | + break; |
| 117 | + case 400: |
| 118 | + $message = 'BAD Request - invalid or missing required parameters'; |
| 119 | + break; |
| 120 | + case 406: |
| 121 | + $message = 'Not Acceptable - client must accept application/json as content type'; |
| 122 | + break; |
| 123 | + } |
| 124 | + |
| 125 | + return new Response( |
| 126 | + null !== $result ? $this->serialize($result, $responseFormat) : '', |
| 127 | + $responseCode, |
| 128 | + array_merge( |
| 129 | + $responseHeaders, |
| 130 | + [ |
| 131 | + 'Content-Type' => $responseFormat, |
| 132 | + 'X-OpenAPI-Message' => $message, |
| 133 | + ] |
| 134 | + ) |
| 135 | + ); |
| 136 | + } |
| 137 | + catch (Exception $fallthrough) |
| 138 | + { |
| 139 | + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Operation mediaFilesGet. |
| 145 | + * |
| 146 | + * Get *all* content of the media library. |
| 147 | + * |
| 148 | + * @param Request $request the Symfony request to handle |
| 149 | + * |
| 150 | + * @return Response the Symfony response |
| 151 | + */ |
| 152 | + public function mediaFilesGetAction(Request $request) |
| 153 | + { |
| 154 | + // Figure out what data format to return to the client |
| 155 | + $produces = ['application/json']; |
| 156 | + // Figure out what the client accepts |
| 157 | + $clientAccepts = $request->headers->has('Accept') ? $request->headers->get('Accept') : '*/*'; |
| 158 | + $responseFormat = $this->getOutputFormat($clientAccepts, $produces); |
| 159 | + if (null === $responseFormat) |
| 160 | + { |
| 161 | + return new Response('', 406); |
| 162 | + } |
| 163 | + |
| 164 | + // Handle authentication |
| 165 | + |
| 166 | + // Read out all input parameter values into variables |
| 167 | + $limit = $request->query->get('limit'); |
| 168 | + $offset = $request->query->get('offset'); |
| 169 | + $flavor = $request->query->get('flavor'); |
| 170 | + |
| 171 | + // Use the default value if no value was provided |
| 172 | + |
| 173 | + // Deserialize the input values that needs it |
| 174 | + try |
| 175 | + { |
| 176 | + $limit = $this->deserialize($limit, 'int', 'string'); |
| 177 | + $offset = $this->deserialize($offset, 'int', 'string'); |
| 178 | + $flavor = $this->deserialize($flavor, 'string', 'string'); |
| 179 | + } |
| 180 | + catch (SerializerRuntimeException $exception) |
| 181 | + { |
| 182 | + return $this->createBadRequestResponse($exception->getMessage()); |
| 183 | + } |
| 184 | + |
| 185 | + // Validate the input values |
| 186 | + $asserts = []; |
| 187 | + $asserts[] = new Assert\Type('int'); |
| 188 | + $asserts[] = new Assert\GreaterThanOrEqual(0); |
| 189 | + $response = $this->validate($limit, $asserts); |
| 190 | + if ($response instanceof Response) |
| 191 | + { |
| 192 | + return $response; |
| 193 | + } |
| 194 | + $asserts = []; |
| 195 | + $asserts[] = new Assert\Type('int'); |
| 196 | + $asserts[] = new Assert\GreaterThanOrEqual(0); |
| 197 | + $response = $this->validate($offset, $asserts); |
| 198 | + if ($response instanceof Response) |
| 199 | + { |
| 200 | + return $response; |
| 201 | + } |
| 202 | + $asserts = []; |
| 203 | + $asserts[] = new Assert\Choice(['pocketcode', 'pocketalice', 'pocketgalaxy', 'pocketphiro', 'phirocode', 'luna', 'create@school', 'embroidery', 'arduino']); |
| 204 | + $asserts[] = new Assert\Type('string'); |
| 205 | + $response = $this->validate($flavor, $asserts); |
| 206 | + if ($response instanceof Response) |
| 207 | + { |
| 208 | + return $response; |
| 209 | + } |
| 210 | + |
| 211 | + try |
| 212 | + { |
| 213 | + $handler = $this->getApiHandler(); |
| 214 | + |
| 215 | + // Make the call to the business logic |
| 216 | + $responseCode = 200; |
| 217 | + $responseHeaders = []; |
| 218 | + $result = $handler->mediaFilesGet($limit, $offset, $flavor, $responseCode, $responseHeaders); |
| 219 | + |
| 220 | + // Find default response message |
| 221 | + $message = 'OK'; |
| 222 | + |
| 223 | + // Find a more specific message, if available |
| 224 | + switch ($responseCode) { |
| 225 | + case 200: |
| 226 | + $message = 'OK'; |
| 227 | + break; |
| 228 | + case 400: |
| 229 | + $message = 'BAD Request - invalid or missing required parameters'; |
| 230 | + break; |
| 231 | + case 406: |
| 232 | + $message = 'Not Acceptable - client must accept application/json as content type'; |
| 233 | + break; |
| 234 | + } |
| 235 | + |
| 236 | + return new Response( |
| 237 | + null !== $result ? $this->serialize($result, $responseFormat) : '', |
| 238 | + $responseCode, |
| 239 | + array_merge( |
| 240 | + $responseHeaders, |
| 241 | + [ |
| 242 | + 'Content-Type' => $responseFormat, |
| 243 | + 'X-OpenAPI-Message' => $message, |
| 244 | + ] |
| 245 | + ) |
| 246 | + ); |
| 247 | + } |
| 248 | + catch (Exception $fallthrough) |
| 249 | + { |
| 250 | + return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); |
| 251 | + } |
| 252 | + } |
| 253 | + |
| 254 | + /** |
| 255 | + * Operation mediaFilesSearchGet. |
54 | 256 | * |
55 | 257 | * Search for mediafiles associated with keywords |
56 | 258 | * |
57 | 259 | * @param Request $request the Symfony request to handle |
58 | 260 | * |
59 | 261 | * @return Response the Symfony response |
60 | 262 | */ |
61 | | - public function mediaFileSearchGetAction(Request $request) |
| 263 | + public function mediaFilesSearchGetAction(Request $request) |
62 | 264 | { |
63 | 265 | // Figure out what data format to return to the client |
64 | 266 | $produces = ['application/json']; |
@@ -143,7 +345,7 @@ public function mediaFileSearchGetAction(Request $request) |
143 | 345 | // Make the call to the business logic |
144 | 346 | $responseCode = 200; |
145 | 347 | $responseHeaders = []; |
146 | | - $result = $handler->mediaFileSearchGet($query_string, $flavor, $limit, $offset, $package_name, $responseCode, $responseHeaders); |
| 348 | + $result = $handler->mediaFilesSearchGet($query_string, $flavor, $limit, $offset, $package_name, $responseCode, $responseHeaders); |
147 | 349 |
|
148 | 350 | // Find default response message |
149 | 351 | $message = 'OK'; |
|
0 commit comments