api_client.dart 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. //
  2. // AUTO-GENERATED FILE, DO NOT MODIFY!
  3. //
  4. // @dart=2.12
  5. // ignore_for_file: unused_element, unused_import
  6. // ignore_for_file: always_put_required_named_parameters_first
  7. // ignore_for_file: constant_identifier_names
  8. // ignore_for_file: lines_longer_than_80_chars
  9. part of openapi.api;
  10. class ApiClient {
  11. ApiClient({this.basePath = '/api', this.authentication,});
  12. final String basePath;
  13. final Authentication? authentication;
  14. var _client = Client();
  15. final _defaultHeaderMap = <String, String>{};
  16. /// Returns the current HTTP [Client] instance to use in this class.
  17. ///
  18. /// The return value is guaranteed to never be null.
  19. Client get client => _client;
  20. /// Requests to use a new HTTP [Client] in this class.
  21. set client(Client newClient) {
  22. _client = newClient;
  23. }
  24. Map<String, String> get defaultHeaderMap => _defaultHeaderMap;
  25. void addDefaultHeader(String key, String value) {
  26. _defaultHeaderMap[key] = value;
  27. }
  28. // We don't use a Map<String, String> for queryParams.
  29. // If collectionFormat is 'multi', a key might appear multiple times.
  30. Future<Response> invokeAPI(
  31. String path,
  32. String method,
  33. List<QueryParam> queryParams,
  34. Object? body,
  35. Map<String, String> headerParams,
  36. Map<String, String> formParams,
  37. String? contentType,
  38. ) async {
  39. await authentication?.applyToParams(queryParams, headerParams);
  40. headerParams.addAll(_defaultHeaderMap);
  41. if (contentType != null) {
  42. headerParams['Content-Type'] = contentType;
  43. }
  44. final urlEncodedQueryParams = queryParams.map((param) => '$param');
  45. final queryString = urlEncodedQueryParams.isNotEmpty ? '?${urlEncodedQueryParams.join('&')}' : '';
  46. final uri = Uri.parse('$basePath$path$queryString');
  47. try {
  48. // Special case for uploading a single file which isn't a 'multipart/form-data'.
  49. if (
  50. body is MultipartFile && (contentType == null ||
  51. !contentType.toLowerCase().startsWith('multipart/form-data'))
  52. ) {
  53. final request = StreamedRequest(method, uri);
  54. request.headers.addAll(headerParams);
  55. request.contentLength = body.length;
  56. body.finalize().listen(
  57. request.sink.add,
  58. onDone: request.sink.close,
  59. // ignore: avoid_types_on_closure_parameters
  60. onError: (Object error, StackTrace trace) => request.sink.close(),
  61. cancelOnError: true,
  62. );
  63. final response = await _client.send(request);
  64. return Response.fromStream(response);
  65. }
  66. if (body is MultipartRequest) {
  67. final request = MultipartRequest(method, uri);
  68. request.fields.addAll(body.fields);
  69. request.files.addAll(body.files);
  70. request.headers.addAll(body.headers);
  71. request.headers.addAll(headerParams);
  72. final response = await _client.send(request);
  73. return Response.fromStream(response);
  74. }
  75. final msgBody = contentType == 'application/x-www-form-urlencoded'
  76. ? formParams
  77. : await serializeAsync(body);
  78. final nullableHeaderParams = headerParams.isEmpty ? null : headerParams;
  79. switch(method) {
  80. case 'POST': return await _client.post(uri, headers: nullableHeaderParams, body: msgBody,);
  81. case 'PUT': return await _client.put(uri, headers: nullableHeaderParams, body: msgBody,);
  82. case 'DELETE': return await _client.delete(uri, headers: nullableHeaderParams, body: msgBody,);
  83. case 'PATCH': return await _client.patch(uri, headers: nullableHeaderParams, body: msgBody,);
  84. case 'HEAD': return await _client.head(uri, headers: nullableHeaderParams,);
  85. case 'GET': return await _client.get(uri, headers: nullableHeaderParams,);
  86. }
  87. } on SocketException catch (error, trace) {
  88. throw ApiException.withInner(
  89. HttpStatus.badRequest,
  90. 'Socket operation failed: $method $path',
  91. error,
  92. trace,
  93. );
  94. } on TlsException catch (error, trace) {
  95. throw ApiException.withInner(
  96. HttpStatus.badRequest,
  97. 'TLS/SSL communication failed: $method $path',
  98. error,
  99. trace,
  100. );
  101. } on IOException catch (error, trace) {
  102. throw ApiException.withInner(
  103. HttpStatus.badRequest,
  104. 'I/O operation failed: $method $path',
  105. error,
  106. trace,
  107. );
  108. } on ClientException catch (error, trace) {
  109. throw ApiException.withInner(
  110. HttpStatus.badRequest,
  111. 'HTTP connection failed: $method $path',
  112. error,
  113. trace,
  114. );
  115. } on Exception catch (error, trace) {
  116. throw ApiException.withInner(
  117. HttpStatus.badRequest,
  118. 'Exception occurred: $method $path',
  119. error,
  120. trace,
  121. );
  122. }
  123. throw ApiException(
  124. HttpStatus.badRequest,
  125. 'Invalid HTTP operation: $method $path',
  126. );
  127. }
  128. Future<dynamic> deserializeAsync(String json, String targetType, {bool growable = false,}) =>
  129. // ignore: deprecated_member_use_from_same_package
  130. deserialize(json, targetType, growable: growable);
  131. @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use deserializeAsync() instead.')
  132. Future<dynamic> deserialize(String json, String targetType, {bool growable = false,}) async {
  133. // Remove all spaces. Necessary for regular expressions as well.
  134. targetType = targetType.replaceAll(' ', ''); // ignore: parameter_assignments
  135. // If the expected target type is String, nothing to do...
  136. return targetType == 'String'
  137. ? json
  138. : _deserialize(await compute((String j) => jsonDecode(j), json), targetType, growable: growable);
  139. }
  140. // ignore: deprecated_member_use_from_same_package
  141. Future<String> serializeAsync(Object? value) async => serialize(value);
  142. @Deprecated('Scheduled for removal in OpenAPI Generator 6.x. Use serializeAsync() instead.')
  143. String serialize(Object? value) => value == null ? '' : json.encode(value);
  144. static dynamic _deserialize(dynamic value, String targetType, {bool growable = false}) {
  145. try {
  146. switch (targetType) {
  147. case 'String':
  148. return value is String ? value : value.toString();
  149. case 'int':
  150. return value is int ? value : int.parse('$value');
  151. case 'double':
  152. return value is double ? value : double.parse('$value');
  153. case 'bool':
  154. if (value is bool) {
  155. return value;
  156. }
  157. final valueString = '$value'.toLowerCase();
  158. return valueString == 'true' || valueString == '1';
  159. case 'DateTime':
  160. return value is DateTime ? value : DateTime.tryParse(value);
  161. case 'APIKeyCreateDto':
  162. return APIKeyCreateDto.fromJson(value);
  163. case 'APIKeyCreateResponseDto':
  164. return APIKeyCreateResponseDto.fromJson(value);
  165. case 'APIKeyResponseDto':
  166. return APIKeyResponseDto.fromJson(value);
  167. case 'APIKeyUpdateDto':
  168. return APIKeyUpdateDto.fromJson(value);
  169. case 'AddAssetsDto':
  170. return AddAssetsDto.fromJson(value);
  171. case 'AddAssetsResponseDto':
  172. return AddAssetsResponseDto.fromJson(value);
  173. case 'AddUsersDto':
  174. return AddUsersDto.fromJson(value);
  175. case 'AdminSignupResponseDto':
  176. return AdminSignupResponseDto.fromJson(value);
  177. case 'AlbumCountResponseDto':
  178. return AlbumCountResponseDto.fromJson(value);
  179. case 'AlbumResponseDto':
  180. return AlbumResponseDto.fromJson(value);
  181. case 'AllJobStatusResponseDto':
  182. return AllJobStatusResponseDto.fromJson(value);
  183. case 'AssetBulkUploadCheckDto':
  184. return AssetBulkUploadCheckDto.fromJson(value);
  185. case 'AssetBulkUploadCheckItem':
  186. return AssetBulkUploadCheckItem.fromJson(value);
  187. case 'AssetBulkUploadCheckResponseDto':
  188. return AssetBulkUploadCheckResponseDto.fromJson(value);
  189. case 'AssetBulkUploadCheckResult':
  190. return AssetBulkUploadCheckResult.fromJson(value);
  191. case 'AssetCountByTimeBucket':
  192. return AssetCountByTimeBucket.fromJson(value);
  193. case 'AssetCountByTimeBucketResponseDto':
  194. return AssetCountByTimeBucketResponseDto.fromJson(value);
  195. case 'AssetFileUploadResponseDto':
  196. return AssetFileUploadResponseDto.fromJson(value);
  197. case 'AssetIdsDto':
  198. return AssetIdsDto.fromJson(value);
  199. case 'AssetIdsResponseDto':
  200. return AssetIdsResponseDto.fromJson(value);
  201. case 'AssetResponseDto':
  202. return AssetResponseDto.fromJson(value);
  203. case 'AssetStatsResponseDto':
  204. return AssetStatsResponseDto.fromJson(value);
  205. case 'AssetTypeEnum':
  206. return AssetTypeEnumTypeTransformer().decode(value);
  207. case 'AudioCodec':
  208. return AudioCodecTypeTransformer().decode(value);
  209. case 'AuthDeviceResponseDto':
  210. return AuthDeviceResponseDto.fromJson(value);
  211. case 'BulkIdResponseDto':
  212. return BulkIdResponseDto.fromJson(value);
  213. case 'ChangePasswordDto':
  214. return ChangePasswordDto.fromJson(value);
  215. case 'CheckDuplicateAssetDto':
  216. return CheckDuplicateAssetDto.fromJson(value);
  217. case 'CheckDuplicateAssetResponseDto':
  218. return CheckDuplicateAssetResponseDto.fromJson(value);
  219. case 'CheckExistingAssetsDto':
  220. return CheckExistingAssetsDto.fromJson(value);
  221. case 'CheckExistingAssetsResponseDto':
  222. return CheckExistingAssetsResponseDto.fromJson(value);
  223. case 'CreateAlbumDto':
  224. return CreateAlbumDto.fromJson(value);
  225. case 'CreateProfileImageResponseDto':
  226. return CreateProfileImageResponseDto.fromJson(value);
  227. case 'CreateTagDto':
  228. return CreateTagDto.fromJson(value);
  229. case 'CreateUserDto':
  230. return CreateUserDto.fromJson(value);
  231. case 'CuratedLocationsResponseDto':
  232. return CuratedLocationsResponseDto.fromJson(value);
  233. case 'CuratedObjectsResponseDto':
  234. return CuratedObjectsResponseDto.fromJson(value);
  235. case 'DeleteAssetDto':
  236. return DeleteAssetDto.fromJson(value);
  237. case 'DeleteAssetResponseDto':
  238. return DeleteAssetResponseDto.fromJson(value);
  239. case 'DeleteAssetStatus':
  240. return DeleteAssetStatusTypeTransformer().decode(value);
  241. case 'DownloadArchiveInfo':
  242. return DownloadArchiveInfo.fromJson(value);
  243. case 'DownloadResponseDto':
  244. return DownloadResponseDto.fromJson(value);
  245. case 'ExifResponseDto':
  246. return ExifResponseDto.fromJson(value);
  247. case 'GetAssetByTimeBucketDto':
  248. return GetAssetByTimeBucketDto.fromJson(value);
  249. case 'GetAssetCountByTimeBucketDto':
  250. return GetAssetCountByTimeBucketDto.fromJson(value);
  251. case 'ImportAssetDto':
  252. return ImportAssetDto.fromJson(value);
  253. case 'JobCommand':
  254. return JobCommandTypeTransformer().decode(value);
  255. case 'JobCommandDto':
  256. return JobCommandDto.fromJson(value);
  257. case 'JobCountsDto':
  258. return JobCountsDto.fromJson(value);
  259. case 'JobName':
  260. return JobNameTypeTransformer().decode(value);
  261. case 'JobSettingsDto':
  262. return JobSettingsDto.fromJson(value);
  263. case 'JobStatusDto':
  264. return JobStatusDto.fromJson(value);
  265. case 'LoginCredentialDto':
  266. return LoginCredentialDto.fromJson(value);
  267. case 'LoginResponseDto':
  268. return LoginResponseDto.fromJson(value);
  269. case 'LogoutResponseDto':
  270. return LogoutResponseDto.fromJson(value);
  271. case 'MapMarkerResponseDto':
  272. return MapMarkerResponseDto.fromJson(value);
  273. case 'MemoryLaneResponseDto':
  274. return MemoryLaneResponseDto.fromJson(value);
  275. case 'MergePersonDto':
  276. return MergePersonDto.fromJson(value);
  277. case 'OAuthCallbackDto':
  278. return OAuthCallbackDto.fromJson(value);
  279. case 'OAuthConfigDto':
  280. return OAuthConfigDto.fromJson(value);
  281. case 'OAuthConfigResponseDto':
  282. return OAuthConfigResponseDto.fromJson(value);
  283. case 'PeopleResponseDto':
  284. return PeopleResponseDto.fromJson(value);
  285. case 'PersonResponseDto':
  286. return PersonResponseDto.fromJson(value);
  287. case 'PersonUpdateDto':
  288. return PersonUpdateDto.fromJson(value);
  289. case 'QueueStatusDto':
  290. return QueueStatusDto.fromJson(value);
  291. case 'RemoveAssetsDto':
  292. return RemoveAssetsDto.fromJson(value);
  293. case 'SearchAlbumResponseDto':
  294. return SearchAlbumResponseDto.fromJson(value);
  295. case 'SearchAssetDto':
  296. return SearchAssetDto.fromJson(value);
  297. case 'SearchAssetResponseDto':
  298. return SearchAssetResponseDto.fromJson(value);
  299. case 'SearchConfigResponseDto':
  300. return SearchConfigResponseDto.fromJson(value);
  301. case 'SearchExploreItem':
  302. return SearchExploreItem.fromJson(value);
  303. case 'SearchExploreResponseDto':
  304. return SearchExploreResponseDto.fromJson(value);
  305. case 'SearchFacetCountResponseDto':
  306. return SearchFacetCountResponseDto.fromJson(value);
  307. case 'SearchFacetResponseDto':
  308. return SearchFacetResponseDto.fromJson(value);
  309. case 'SearchResponseDto':
  310. return SearchResponseDto.fromJson(value);
  311. case 'ServerInfoResponseDto':
  312. return ServerInfoResponseDto.fromJson(value);
  313. case 'ServerMediaTypesResponseDto':
  314. return ServerMediaTypesResponseDto.fromJson(value);
  315. case 'ServerPingResponse':
  316. return ServerPingResponse.fromJson(value);
  317. case 'ServerStatsResponseDto':
  318. return ServerStatsResponseDto.fromJson(value);
  319. case 'ServerVersionReponseDto':
  320. return ServerVersionReponseDto.fromJson(value);
  321. case 'SharedLinkCreateDto':
  322. return SharedLinkCreateDto.fromJson(value);
  323. case 'SharedLinkEditDto':
  324. return SharedLinkEditDto.fromJson(value);
  325. case 'SharedLinkResponseDto':
  326. return SharedLinkResponseDto.fromJson(value);
  327. case 'SharedLinkType':
  328. return SharedLinkTypeTypeTransformer().decode(value);
  329. case 'SignUpDto':
  330. return SignUpDto.fromJson(value);
  331. case 'SmartInfoResponseDto':
  332. return SmartInfoResponseDto.fromJson(value);
  333. case 'SystemConfigDto':
  334. return SystemConfigDto.fromJson(value);
  335. case 'SystemConfigFFmpegDto':
  336. return SystemConfigFFmpegDto.fromJson(value);
  337. case 'SystemConfigJobDto':
  338. return SystemConfigJobDto.fromJson(value);
  339. case 'SystemConfigOAuthDto':
  340. return SystemConfigOAuthDto.fromJson(value);
  341. case 'SystemConfigPasswordLoginDto':
  342. return SystemConfigPasswordLoginDto.fromJson(value);
  343. case 'SystemConfigStorageTemplateDto':
  344. return SystemConfigStorageTemplateDto.fromJson(value);
  345. case 'SystemConfigTemplateStorageOptionDto':
  346. return SystemConfigTemplateStorageOptionDto.fromJson(value);
  347. case 'TagResponseDto':
  348. return TagResponseDto.fromJson(value);
  349. case 'TagTypeEnum':
  350. return TagTypeEnumTypeTransformer().decode(value);
  351. case 'ThumbnailFormat':
  352. return ThumbnailFormatTypeTransformer().decode(value);
  353. case 'TimeGroupEnum':
  354. return TimeGroupEnumTypeTransformer().decode(value);
  355. case 'TranscodePolicy':
  356. return TranscodePolicyTypeTransformer().decode(value);
  357. case 'UpdateAlbumDto':
  358. return UpdateAlbumDto.fromJson(value);
  359. case 'UpdateAssetDto':
  360. return UpdateAssetDto.fromJson(value);
  361. case 'UpdateTagDto':
  362. return UpdateTagDto.fromJson(value);
  363. case 'UpdateUserDto':
  364. return UpdateUserDto.fromJson(value);
  365. case 'UsageByUserDto':
  366. return UsageByUserDto.fromJson(value);
  367. case 'UserCountResponseDto':
  368. return UserCountResponseDto.fromJson(value);
  369. case 'UserResponseDto':
  370. return UserResponseDto.fromJson(value);
  371. case 'ValidateAccessTokenResponseDto':
  372. return ValidateAccessTokenResponseDto.fromJson(value);
  373. case 'VideoCodec':
  374. return VideoCodecTypeTransformer().decode(value);
  375. default:
  376. dynamic match;
  377. if (value is List && (match = _regList.firstMatch(targetType)?.group(1)) != null) {
  378. return value
  379. .map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
  380. .toList(growable: growable);
  381. }
  382. if (value is Set && (match = _regSet.firstMatch(targetType)?.group(1)) != null) {
  383. return value
  384. .map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,))
  385. .toSet();
  386. }
  387. if (value is Map && (match = _regMap.firstMatch(targetType)?.group(1)) != null) {
  388. return Map<String, dynamic>.fromIterables(
  389. value.keys.cast<String>(),
  390. value.values.map<dynamic>((dynamic v) => _deserialize(v, match, growable: growable,)),
  391. );
  392. }
  393. }
  394. } on Exception catch (error, trace) {
  395. throw ApiException.withInner(HttpStatus.internalServerError, 'Exception during deserialization.', error, trace,);
  396. }
  397. throw ApiException(HttpStatus.internalServerError, 'Could not find a suitable class for deserialization',);
  398. }
  399. }
  400. /// Primarily intended for use in an isolate.
  401. class DeserializationMessage {
  402. const DeserializationMessage({
  403. required this.json,
  404. required this.targetType,
  405. this.growable = false,
  406. });
  407. /// The JSON value to deserialize.
  408. final String json;
  409. /// Target type to deserialize to.
  410. final String targetType;
  411. /// Whether to make deserialized lists or maps growable.
  412. final bool growable;
  413. }
  414. /// Primarily intended for use in an isolate.
  415. Future<dynamic> deserializeAsync(DeserializationMessage message) async {
  416. // Remove all spaces. Necessary for regular expressions as well.
  417. final targetType = message.targetType.replaceAll(' ', '');
  418. // If the expected target type is String, nothing to do...
  419. return targetType == 'String'
  420. ? message.json
  421. : ApiClient._deserialize(
  422. jsonDecode(message.json),
  423. targetType,
  424. growable: message.growable,
  425. );
  426. }
  427. /// Primarily intended for use in an isolate.
  428. Future<String> serializeAsync(Object? value) async => value == null ? '' : json.encode(value);