immich 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. immich/.openapi-generator/FILES +372 -0
  2. immich/.openapi-generator/VERSION +1 -0
  3. immich/.openapi-generator-ignore +48 -0
  4. immich/__init__.py +3 -0
  5. immich/client/__init__.py +1162 -0
  6. immich/client/api/__init__.py +39 -0
  7. immich/client/api/activities_api.py +1092 -0
  8. immich/client/api/albums_api.py +3228 -0
  9. immich/client/api/api_keys_api.py +1484 -0
  10. immich/client/api/assets_api.py +5834 -0
  11. immich/client/api/authentication_admin_api.py +254 -0
  12. immich/client/api/authentication_api.py +3881 -0
  13. immich/client/api/deprecated_api.py +2199 -0
  14. immich/client/api/download_api.py +603 -0
  15. immich/client/api/duplicates_api.py +743 -0
  16. immich/client/api/faces_api.py +1053 -0
  17. immich/client/api/jobs_api.py +783 -0
  18. immich/client/api/libraries_api.py +2004 -0
  19. immich/client/api/maintenance_admin_api.py +533 -0
  20. immich/client/api/map_api.py +640 -0
  21. immich/client/api/memories_api.py +2250 -0
  22. immich/client/api/notifications_admin_api.py +808 -0
  23. immich/client/api/notifications_api.py +1564 -0
  24. immich/client/api/partners_api.py +1278 -0
  25. immich/client/api/people_api.py +2905 -0
  26. immich/client/api/plugins_api.py +730 -0
  27. immich/client/api/queues_api.py +1292 -0
  28. immich/client/api/search_api.py +3198 -0
  29. immich/client/api/server_api.py +3466 -0
  30. immich/client/api/sessions_api.py +1472 -0
  31. immich/client/api/shared_links_api.py +2177 -0
  32. immich/client/api/stacks_api.py +1769 -0
  33. immich/client/api/sync_api.py +1512 -0
  34. immich/client/api/system_config_api.py +967 -0
  35. immich/client/api/system_metadata_api.py +964 -0
  36. immich/client/api/tags_api.py +2296 -0
  37. immich/client/api/timeline_api.py +1193 -0
  38. immich/client/api/trash_api.py +739 -0
  39. immich/client/api/users_admin_api.py +2607 -0
  40. immich/client/api/users_api.py +3577 -0
  41. immich/client/api/views_api.py +503 -0
  42. immich/client/api/workflows_api.py +1257 -0
  43. immich/client/api_client.py +756 -0
  44. immich/client/api_response.py +20 -0
  45. immich/client/configuration.py +638 -0
  46. immich/client/exceptions.py +222 -0
  47. immich/client/models/__init__.py +424 -0
  48. immich/client/models/activity_create_dto.py +94 -0
  49. immich/client/models/activity_response_dto.py +121 -0
  50. immich/client/models/activity_statistics_response_dto.py +85 -0
  51. immich/client/models/add_users_dto.py +101 -0
  52. immich/client/models/admin_onboarding_update_dto.py +82 -0
  53. immich/client/models/album_response_dto.py +199 -0
  54. immich/client/models/album_statistics_response_dto.py +90 -0
  55. immich/client/models/album_user_add_dto.py +87 -0
  56. immich/client/models/album_user_create_dto.py +87 -0
  57. immich/client/models/album_user_response_dto.py +95 -0
  58. immich/client/models/album_user_role.py +34 -0
  59. immich/client/models/albums_add_assets_dto.py +86 -0
  60. immich/client/models/albums_add_assets_response_dto.py +86 -0
  61. immich/client/models/albums_response.py +83 -0
  62. immich/client/models/albums_update.py +85 -0
  63. immich/client/models/api_key_create_dto.py +87 -0
  64. immich/client/models/api_key_create_response_dto.py +94 -0
  65. immich/client/models/api_key_response_dto.py +102 -0
  66. immich/client/models/api_key_update_dto.py +87 -0
  67. immich/client/models/asset_bulk_delete_dto.py +84 -0
  68. immich/client/models/asset_bulk_update_dto.py +143 -0
  69. immich/client/models/asset_bulk_upload_check_dto.py +98 -0
  70. immich/client/models/asset_bulk_upload_check_item.py +85 -0
  71. immich/client/models/asset_bulk_upload_check_response_dto.py +101 -0
  72. immich/client/models/asset_bulk_upload_check_result.py +126 -0
  73. immich/client/models/asset_copy_dto.py +113 -0
  74. immich/client/models/asset_delta_sync_dto.py +87 -0
  75. immich/client/models/asset_delta_sync_response_dto.py +102 -0
  76. immich/client/models/asset_face_create_dto.py +110 -0
  77. immich/client/models/asset_face_delete_dto.py +82 -0
  78. immich/client/models/asset_face_response_dto.py +125 -0
  79. immich/client/models/asset_face_update_dto.py +96 -0
  80. immich/client/models/asset_face_update_item.py +86 -0
  81. immich/client/models/asset_face_without_person_response_dto.py +111 -0
  82. immich/client/models/asset_full_sync_dto.py +95 -0
  83. immich/client/models/asset_ids_dto.py +83 -0
  84. immich/client/models/asset_ids_response_dto.py +109 -0
  85. immich/client/models/asset_job_name.py +36 -0
  86. immich/client/models/asset_jobs_dto.py +87 -0
  87. immich/client/models/asset_media_response_dto.py +84 -0
  88. immich/client/models/asset_media_size.py +35 -0
  89. immich/client/models/asset_media_status.py +35 -0
  90. immich/client/models/asset_metadata_key.py +33 -0
  91. immich/client/models/asset_metadata_response_dto.py +92 -0
  92. immich/client/models/asset_metadata_upsert_dto.py +101 -0
  93. immich/client/models/asset_metadata_upsert_item_dto.py +84 -0
  94. immich/client/models/asset_ocr_response_dto.py +145 -0
  95. immich/client/models/asset_order.py +34 -0
  96. immich/client/models/asset_response_dto.py +291 -0
  97. immich/client/models/asset_stack_response_dto.py +90 -0
  98. immich/client/models/asset_stats_response_dto.py +90 -0
  99. immich/client/models/asset_type_enum.py +36 -0
  100. immich/client/models/asset_visibility.py +36 -0
  101. immich/client/models/audio_codec.py +36 -0
  102. immich/client/models/auth_status_response_dto.py +100 -0
  103. immich/client/models/avatar_update.py +83 -0
  104. immich/client/models/bulk_id_error_reason.py +36 -0
  105. immich/client/models/bulk_id_response_dto.py +102 -0
  106. immich/client/models/bulk_ids_dto.py +83 -0
  107. immich/client/models/cast_response.py +88 -0
  108. immich/client/models/cast_update.py +82 -0
  109. immich/client/models/change_password_dto.py +101 -0
  110. immich/client/models/check_existing_assets_dto.py +91 -0
  111. immich/client/models/check_existing_assets_response_dto.py +82 -0
  112. immich/client/models/clip_config.py +85 -0
  113. immich/client/models/colorspace.py +34 -0
  114. immich/client/models/contributor_count_response_dto.py +85 -0
  115. immich/client/models/cq_mode.py +35 -0
  116. immich/client/models/create_album_dto.py +112 -0
  117. immich/client/models/create_library_dto.py +103 -0
  118. immich/client/models/create_profile_image_response_dto.py +95 -0
  119. immich/client/models/database_backup_config.py +94 -0
  120. immich/client/models/download_archive_info.py +85 -0
  121. immich/client/models/download_info_dto.py +96 -0
  122. immich/client/models/download_response.py +90 -0
  123. immich/client/models/download_response_dto.py +100 -0
  124. immich/client/models/download_update.py +93 -0
  125. immich/client/models/duplicate_detection_config.py +89 -0
  126. immich/client/models/duplicate_response_dto.py +98 -0
  127. immich/client/models/email_notifications_response.py +90 -0
  128. immich/client/models/email_notifications_update.py +90 -0
  129. immich/client/models/exif_response_dto.py +284 -0
  130. immich/client/models/face_dto.py +83 -0
  131. immich/client/models/facial_recognition_config.py +107 -0
  132. immich/client/models/folders_response.py +92 -0
  133. immich/client/models/folders_update.py +85 -0
  134. immich/client/models/image_format.py +34 -0
  135. immich/client/models/job_create_dto.py +83 -0
  136. immich/client/models/job_name.py +87 -0
  137. immich/client/models/job_settings_dto.py +83 -0
  138. immich/client/models/library_response_dto.py +118 -0
  139. immich/client/models/library_stats_response_dto.py +92 -0
  140. immich/client/models/license_key_dto.py +98 -0
  141. immich/client/models/license_response_dto.py +101 -0
  142. immich/client/models/log_level.py +38 -0
  143. immich/client/models/login_credential_dto.py +85 -0
  144. immich/client/models/login_response_dto.py +109 -0
  145. immich/client/models/logout_response_dto.py +85 -0
  146. immich/client/models/machine_learning_availability_checks_dto.py +90 -0
  147. immich/client/models/maintenance_action.py +34 -0
  148. immich/client/models/maintenance_auth_dto.py +82 -0
  149. immich/client/models/maintenance_login_dto.py +82 -0
  150. immich/client/models/manual_job_name.py +38 -0
  151. immich/client/models/map_marker_response_dto.py +111 -0
  152. immich/client/models/map_reverse_geocode_response_dto.py +105 -0
  153. immich/client/models/memories_response.py +92 -0
  154. immich/client/models/memories_update.py +86 -0
  155. immich/client/models/memory_create_dto.py +112 -0
  156. immich/client/models/memory_response_dto.py +142 -0
  157. immich/client/models/memory_search_order.py +35 -0
  158. immich/client/models/memory_statistics_response_dto.py +82 -0
  159. immich/client/models/memory_type.py +33 -0
  160. immich/client/models/memory_update_dto.py +91 -0
  161. immich/client/models/merge_person_dto.py +83 -0
  162. immich/client/models/metadata_search_dto.py +277 -0
  163. immich/client/models/notification_create_dto.py +120 -0
  164. immich/client/models/notification_delete_all_dto.py +83 -0
  165. immich/client/models/notification_dto.py +112 -0
  166. immich/client/models/notification_level.py +36 -0
  167. immich/client/models/notification_type.py +38 -0
  168. immich/client/models/notification_update_all_dto.py +90 -0
  169. immich/client/models/notification_update_dto.py +88 -0
  170. immich/client/models/o_auth_authorize_response_dto.py +82 -0
  171. immich/client/models/o_auth_callback_dto.py +90 -0
  172. immich/client/models/o_auth_config_dto.py +90 -0
  173. immich/client/models/o_auth_token_endpoint_auth_method.py +34 -0
  174. immich/client/models/ocr_config.py +109 -0
  175. immich/client/models/on_this_day_dto.py +86 -0
  176. immich/client/models/onboarding_dto.py +82 -0
  177. immich/client/models/onboarding_response_dto.py +82 -0
  178. immich/client/models/partner_create_dto.py +83 -0
  179. immich/client/models/partner_direction.py +34 -0
  180. immich/client/models/partner_response_dto.py +108 -0
  181. immich/client/models/partner_update_dto.py +82 -0
  182. immich/client/models/people_response.py +92 -0
  183. immich/client/models/people_response_dto.py +104 -0
  184. immich/client/models/people_update.py +85 -0
  185. immich/client/models/people_update_dto.py +96 -0
  186. immich/client/models/people_update_item.py +128 -0
  187. immich/client/models/permission.py +177 -0
  188. immich/client/models/person_create_dto.py +117 -0
  189. immich/client/models/person_response_dto.py +115 -0
  190. immich/client/models/person_statistics_response_dto.py +82 -0
  191. immich/client/models/person_update_dto.py +125 -0
  192. immich/client/models/person_with_faces_response_dto.py +133 -0
  193. immich/client/models/pin_code_change_dto.py +90 -0
  194. immich/client/models/pin_code_reset_dto.py +85 -0
  195. immich/client/models/pin_code_setup_dto.py +82 -0
  196. immich/client/models/places_response_dto.py +100 -0
  197. immich/client/models/plugin_action_response_dto.py +112 -0
  198. immich/client/models/plugin_context_type.py +35 -0
  199. immich/client/models/plugin_filter_response_dto.py +112 -0
  200. immich/client/models/plugin_response_dto.py +139 -0
  201. immich/client/models/plugin_trigger_response_dto.py +87 -0
  202. immich/client/models/plugin_trigger_type.py +34 -0
  203. immich/client/models/purchase_response.py +88 -0
  204. immich/client/models/purchase_update.py +92 -0
  205. immich/client/models/queue_command.py +37 -0
  206. immich/client/models/queue_command_dto.py +86 -0
  207. immich/client/models/queue_delete_dto.py +85 -0
  208. immich/client/models/queue_job_response_dto.py +93 -0
  209. immich/client/models/queue_job_status.py +38 -0
  210. immich/client/models/queue_name.py +49 -0
  211. immich/client/models/queue_response_dto.py +97 -0
  212. immich/client/models/queue_response_legacy_dto.py +100 -0
  213. immich/client/models/queue_statistics_dto.py +103 -0
  214. immich/client/models/queue_status_legacy_dto.py +85 -0
  215. immich/client/models/queue_update_dto.py +82 -0
  216. immich/client/models/queues_response_legacy_dto.py +242 -0
  217. immich/client/models/random_search_dto.py +234 -0
  218. immich/client/models/ratings_response.py +84 -0
  219. immich/client/models/ratings_update.py +82 -0
  220. immich/client/models/reaction_level.py +34 -0
  221. immich/client/models/reaction_type.py +34 -0
  222. immich/client/models/reverse_geocoding_state_response_dto.py +101 -0
  223. immich/client/models/search_album_response_dto.py +114 -0
  224. immich/client/models/search_asset_response_dto.py +127 -0
  225. immich/client/models/search_explore_item.py +94 -0
  226. immich/client/models/search_explore_response_dto.py +98 -0
  227. immich/client/models/search_facet_count_response_dto.py +85 -0
  228. immich/client/models/search_facet_response_dto.py +103 -0
  229. immich/client/models/search_response_dto.py +100 -0
  230. immich/client/models/search_statistics_response_dto.py +82 -0
  231. immich/client/models/search_suggestion_type.py +38 -0
  232. immich/client/models/server_about_response_dto.py +156 -0
  233. immich/client/models/server_apk_links_dto.py +97 -0
  234. immich/client/models/server_config_dto.py +118 -0
  235. immich/client/models/server_features_dto.py +130 -0
  236. immich/client/models/server_media_types_response_dto.py +90 -0
  237. immich/client/models/server_ping_response.py +87 -0
  238. immich/client/models/server_stats_response_dto.py +119 -0
  239. immich/client/models/server_storage_response_dto.py +108 -0
  240. immich/client/models/server_theme_dto.py +82 -0
  241. immich/client/models/server_version_history_response_dto.py +91 -0
  242. immich/client/models/server_version_response_dto.py +90 -0
  243. immich/client/models/session_create_dto.py +96 -0
  244. immich/client/models/session_create_response_dto.py +120 -0
  245. immich/client/models/session_response_dto.py +117 -0
  246. immich/client/models/session_unlock_dto.py +85 -0
  247. immich/client/models/session_update_dto.py +84 -0
  248. immich/client/models/set_maintenance_mode_dto.py +83 -0
  249. immich/client/models/shared_link_create_dto.py +142 -0
  250. immich/client/models/shared_link_edit_dto.py +134 -0
  251. immich/client/models/shared_link_response_dto.py +173 -0
  252. immich/client/models/shared_link_type.py +34 -0
  253. immich/client/models/shared_links_response.py +92 -0
  254. immich/client/models/shared_links_update.py +85 -0
  255. immich/client/models/sign_up_dto.py +90 -0
  256. immich/client/models/smart_search_dto.py +245 -0
  257. immich/client/models/source_type.py +35 -0
  258. immich/client/models/stack_create_dto.py +86 -0
  259. immich/client/models/stack_response_dto.py +100 -0
  260. immich/client/models/stack_update_dto.py +83 -0
  261. immich/client/models/statistics_search_dto.py +217 -0
  262. immich/client/models/sync_ack_delete_dto.py +83 -0
  263. immich/client/models/sync_ack_dto.py +84 -0
  264. immich/client/models/sync_ack_set_dto.py +83 -0
  265. immich/client/models/sync_album_delete_v1.py +82 -0
  266. immich/client/models/sync_album_to_asset_delete_v1.py +85 -0
  267. immich/client/models/sync_album_to_asset_v1.py +85 -0
  268. immich/client/models/sync_album_user_delete_v1.py +85 -0
  269. immich/client/models/sync_album_user_v1.py +91 -0
  270. immich/client/models/sync_album_v1.py +122 -0
  271. immich/client/models/sync_asset_delete_v1.py +82 -0
  272. immich/client/models/sync_asset_exif_v1.py +296 -0
  273. immich/client/models/sync_asset_face_delete_v1.py +82 -0
  274. immich/client/models/sync_asset_face_v1.py +120 -0
  275. immich/client/models/sync_asset_metadata_delete_v1.py +86 -0
  276. immich/client/models/sync_asset_metadata_v1.py +91 -0
  277. immich/client/models/sync_asset_v1.py +187 -0
  278. immich/client/models/sync_auth_user_v1.py +154 -0
  279. immich/client/models/sync_entity_type.py +79 -0
  280. immich/client/models/sync_memory_asset_delete_v1.py +85 -0
  281. immich/client/models/sync_memory_asset_v1.py +85 -0
  282. immich/client/models/sync_memory_delete_v1.py +82 -0
  283. immich/client/models/sync_memory_v1.py +143 -0
  284. immich/client/models/sync_partner_delete_v1.py +88 -0
  285. immich/client/models/sync_partner_v1.py +90 -0
  286. immich/client/models/sync_person_delete_v1.py +82 -0
  287. immich/client/models/sync_person_v1.py +131 -0
  288. immich/client/models/sync_request_type.py +52 -0
  289. immich/client/models/sync_stack_delete_v1.py +82 -0
  290. immich/client/models/sync_stack_v1.py +101 -0
  291. immich/client/models/sync_stream_dto.py +86 -0
  292. immich/client/models/sync_user_delete_v1.py +82 -0
  293. immich/client/models/sync_user_metadata_delete_v1.py +84 -0
  294. immich/client/models/sync_user_metadata_v1.py +91 -0
  295. immich/client/models/sync_user_v1.py +118 -0
  296. immich/client/models/system_config_backups_dto.py +92 -0
  297. immich/client/models/system_config_dto.py +302 -0
  298. immich/client/models/system_config_f_fmpeg_dto.py +156 -0
  299. immich/client/models/system_config_faces_dto.py +82 -0
  300. immich/client/models/system_config_generated_fullsize_image_dto.py +92 -0
  301. immich/client/models/system_config_generated_image_dto.py +92 -0
  302. immich/client/models/system_config_image_dto.py +124 -0
  303. immich/client/models/system_config_job_dto.py +194 -0
  304. immich/client/models/system_config_library_dto.py +104 -0
  305. immich/client/models/system_config_library_scan_dto.py +85 -0
  306. immich/client/models/system_config_library_watch_dto.py +82 -0
  307. immich/client/models/system_config_logging_dto.py +86 -0
  308. immich/client/models/system_config_machine_learning_dto.py +147 -0
  309. immich/client/models/system_config_map_dto.py +90 -0
  310. immich/client/models/system_config_metadata_dto.py +92 -0
  311. immich/client/models/system_config_new_version_check_dto.py +82 -0
  312. immich/client/models/system_config_nightly_tasks_dto.py +103 -0
  313. immich/client/models/system_config_notifications_dto.py +92 -0
  314. immich/client/models/system_config_o_auth_dto.py +155 -0
  315. immich/client/models/system_config_password_login_dto.py +82 -0
  316. immich/client/models/system_config_reverse_geocoding_dto.py +82 -0
  317. immich/client/models/system_config_server_dto.py +94 -0
  318. immich/client/models/system_config_smtp_dto.py +100 -0
  319. immich/client/models/system_config_smtp_transport_dto.py +107 -0
  320. immich/client/models/system_config_storage_template_dto.py +94 -0
  321. immich/client/models/system_config_template_emails_dto.py +94 -0
  322. immich/client/models/system_config_template_storage_option_dto.py +109 -0
  323. immich/client/models/system_config_templates_dto.py +94 -0
  324. immich/client/models/system_config_theme_dto.py +82 -0
  325. immich/client/models/system_config_trash_dto.py +86 -0
  326. immich/client/models/system_config_user_dto.py +83 -0
  327. immich/client/models/tag_bulk_assets_dto.py +86 -0
  328. immich/client/models/tag_bulk_assets_response_dto.py +82 -0
  329. immich/client/models/tag_create_dto.py +111 -0
  330. immich/client/models/tag_response_dto.py +107 -0
  331. immich/client/models/tag_update_dto.py +87 -0
  332. immich/client/models/tag_upsert_dto.py +82 -0
  333. immich/client/models/tags_response.py +92 -0
  334. immich/client/models/tags_update.py +85 -0
  335. immich/client/models/template_dto.py +82 -0
  336. immich/client/models/template_response_dto.py +83 -0
  337. immich/client/models/test_email_response_dto.py +82 -0
  338. immich/client/models/time_bucket_asset_response_dto.py +195 -0
  339. immich/client/models/time_buckets_response_dto.py +88 -0
  340. immich/client/models/tone_mapping.py +36 -0
  341. immich/client/models/transcode_hw_accel.py +37 -0
  342. immich/client/models/transcode_policy.py +37 -0
  343. immich/client/models/trash_response_dto.py +82 -0
  344. immich/client/models/update_album_dto.py +106 -0
  345. immich/client/models/update_album_user_dto.py +83 -0
  346. immich/client/models/update_asset_dto.py +135 -0
  347. immich/client/models/update_library_dto.py +95 -0
  348. immich/client/models/usage_by_user_dto.py +117 -0
  349. immich/client/models/user_admin_create_dto.py +136 -0
  350. immich/client/models/user_admin_delete_dto.py +82 -0
  351. immich/client/models/user_admin_response_dto.py +176 -0
  352. immich/client/models/user_admin_update_dto.py +141 -0
  353. immich/client/models/user_avatar_color.py +42 -0
  354. immich/client/models/user_license.py +91 -0
  355. immich/client/models/user_metadata_key.py +35 -0
  356. immich/client/models/user_preferences_response_dto.py +186 -0
  357. immich/client/models/user_preferences_update_dto.py +197 -0
  358. immich/client/models/user_response_dto.py +105 -0
  359. immich/client/models/user_status.py +35 -0
  360. immich/client/models/user_update_me_dto.py +98 -0
  361. immich/client/models/validate_access_token_response_dto.py +82 -0
  362. immich/client/models/validate_library_dto.py +93 -0
  363. immich/client/models/validate_library_import_path_response_dto.py +92 -0
  364. immich/client/models/validate_library_response_dto.py +103 -0
  365. immich/client/models/version_check_state_response_dto.py +98 -0
  366. immich/client/models/video_codec.py +36 -0
  367. immich/client/models/video_container.py +36 -0
  368. immich/client/models/workflow_action_item_dto.py +89 -0
  369. immich/client/models/workflow_action_response_dto.py +105 -0
  370. immich/client/models/workflow_create_dto.py +128 -0
  371. immich/client/models/workflow_filter_item_dto.py +89 -0
  372. immich/client/models/workflow_filter_response_dto.py +105 -0
  373. immich/client/models/workflow_response_dto.py +144 -0
  374. immich/client/models/workflow_update_dto.py +128 -0
  375. immich/client/py.typed +0 -0
  376. immich/client/rest.py +199 -0
  377. immich/client_wrapper/__init__.py +15 -0
  378. immich/client_wrapper/assets_api_wrapped.py +87 -0
  379. immich/client_wrapper/download_api_wrapped.py +111 -0
  380. immich/client_wrapper/users_api_wrapped.py +41 -0
  381. immich/py.typed +0 -0
  382. immich/sdk.py +365 -0
  383. immich/utils.py +100 -0
  384. immich-1.2.1.dist-info/METADATA +166 -0
  385. immich-1.2.1.dist-info/RECORD +387 -0
  386. immich-1.2.1.dist-info/WHEEL +4 -0
  387. immich-1.2.1.dist-info/licenses/LICENSE +9 -0
@@ -0,0 +1,756 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Immich
5
+
6
+ Immich API
7
+
8
+ The version of the OpenAPI document: 2.4.1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+ import datetime
15
+ from dateutil.parser import parse
16
+ from enum import Enum
17
+ import decimal
18
+ import json
19
+ import mimetypes
20
+ import os
21
+ import re
22
+ import tempfile
23
+ import uuid
24
+
25
+ from urllib.parse import quote
26
+ from typing import Tuple, Optional, List, Dict, Union
27
+ from pydantic import SecretStr
28
+
29
+ from immich.client.configuration import Configuration
30
+ from immich.client.api_response import ApiResponse, T as ApiResponseT
31
+ import immich.client.models
32
+ from immich.client import rest
33
+ from immich.client.exceptions import ApiValueError, ApiException
34
+
35
+ RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
36
+
37
+
38
+ class ApiClient:
39
+ """Generic API client for OpenAPI client library builds.
40
+
41
+ OpenAPI generic API client. This client handles the client-
42
+ server communication, and is invariant across implementations. Specifics of
43
+ the methods and models for each application are generated from the OpenAPI
44
+ templates.
45
+
46
+ :param configuration: .Configuration object for this client
47
+ :param header_name: a header to pass when making calls to the API.
48
+ :param header_value: a header value to pass when making calls to
49
+ the API.
50
+ :param cookie: a cookie to include in the header when making calls
51
+ to the API
52
+ """
53
+
54
+ PRIMITIVE_TYPES = (float, bool, bytes, str, int)
55
+ NATIVE_TYPES_MAPPING = {
56
+ "int": int,
57
+ "long": int, # TODO remove as only py3 is supported?
58
+ "float": float,
59
+ "str": str,
60
+ "bool": bool,
61
+ "date": datetime.date,
62
+ "datetime": datetime.datetime,
63
+ "decimal": decimal.Decimal,
64
+ "object": object,
65
+ }
66
+ _pool = None
67
+
68
+ def __init__(
69
+ self, configuration=None, header_name=None, header_value=None, cookie=None
70
+ ) -> None:
71
+ # use default configuration if none is provided
72
+ if configuration is None:
73
+ configuration = Configuration.get_default()
74
+ self.configuration = configuration
75
+
76
+ self.rest_client = rest.RESTClientObject(configuration)
77
+ self.default_headers = {}
78
+ if header_name is not None:
79
+ self.default_headers[header_name] = header_value
80
+ self.cookie = cookie
81
+ # Set default User-Agent.
82
+ self.user_agent = "OpenAPI-Generator/1.0.0/python"
83
+ self.client_side_validation = configuration.client_side_validation
84
+
85
+ async def __aenter__(self):
86
+ return self
87
+
88
+ async def __aexit__(self, exc_type, exc_value, traceback):
89
+ await self.close()
90
+
91
+ async def close(self):
92
+ await self.rest_client.close()
93
+
94
+ @property
95
+ def user_agent(self):
96
+ """User agent for this API client"""
97
+ return self.default_headers["User-Agent"]
98
+
99
+ @user_agent.setter
100
+ def user_agent(self, value):
101
+ self.default_headers["User-Agent"] = value
102
+
103
+ def set_default_header(self, header_name, header_value):
104
+ self.default_headers[header_name] = header_value
105
+
106
+ _default = None
107
+
108
+ @classmethod
109
+ def get_default(cls):
110
+ """Return new instance of ApiClient.
111
+
112
+ This method returns newly created, based on default constructor,
113
+ object of ApiClient class or returns a copy of default
114
+ ApiClient.
115
+
116
+ :return: The ApiClient object.
117
+ """
118
+ if cls._default is None:
119
+ cls._default = ApiClient()
120
+ return cls._default
121
+
122
+ @classmethod
123
+ def set_default(cls, default):
124
+ """Set default instance of ApiClient.
125
+
126
+ It stores default ApiClient.
127
+
128
+ :param default: object of ApiClient.
129
+ """
130
+ cls._default = default
131
+
132
+ def param_serialize(
133
+ self,
134
+ method,
135
+ resource_path,
136
+ path_params=None,
137
+ query_params=None,
138
+ header_params=None,
139
+ body=None,
140
+ post_params=None,
141
+ files=None,
142
+ auth_settings=None,
143
+ collection_formats=None,
144
+ _host=None,
145
+ _request_auth=None,
146
+ ) -> RequestSerialized:
147
+ """Builds the HTTP request params needed by the request.
148
+ :param method: Method to call.
149
+ :param resource_path: Path to method endpoint.
150
+ :param path_params: Path parameters in the url.
151
+ :param query_params: Query parameters in the url.
152
+ :param header_params: Header parameters to be
153
+ placed in the request header.
154
+ :param body: Request body.
155
+ :param post_params dict: Request post form parameters,
156
+ for `application/x-www-form-urlencoded`, `multipart/form-data`.
157
+ :param auth_settings list: Auth Settings names for the request.
158
+ :param files dict: key -> filename, value -> filepath,
159
+ for `multipart/form-data`.
160
+ :param collection_formats: dict of collection formats for path, query,
161
+ header, and post parameters.
162
+ :param _request_auth: set to override the auth_settings for an a single
163
+ request; this effectively ignores the authentication
164
+ in the spec for a single request.
165
+ :return: tuple of form (path, http_method, query_params, header_params,
166
+ body, post_params, files)
167
+ """
168
+
169
+ config = self.configuration
170
+
171
+ # header parameters
172
+ header_params = header_params or {}
173
+ header_params.update(self.default_headers)
174
+ if self.cookie:
175
+ header_params["Cookie"] = self.cookie
176
+ if header_params:
177
+ header_params = self.sanitize_for_serialization(header_params)
178
+ header_params = dict(
179
+ self.parameters_to_tuples(header_params, collection_formats)
180
+ )
181
+
182
+ # path parameters
183
+ if path_params:
184
+ path_params = self.sanitize_for_serialization(path_params)
185
+ path_params = self.parameters_to_tuples(path_params, collection_formats)
186
+ for k, v in path_params:
187
+ # specified safe chars, encode everything
188
+ resource_path = resource_path.replace(
189
+ "{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param)
190
+ )
191
+
192
+ # post parameters
193
+ if post_params or files:
194
+ post_params = post_params if post_params else []
195
+ post_params = self.sanitize_for_serialization(post_params)
196
+ post_params = self.parameters_to_tuples(post_params, collection_formats)
197
+ if files:
198
+ post_params.extend(self.files_parameters(files))
199
+
200
+ # auth setting
201
+ self.update_params_for_auth(
202
+ header_params,
203
+ query_params,
204
+ auth_settings,
205
+ resource_path,
206
+ method,
207
+ body,
208
+ request_auth=_request_auth,
209
+ )
210
+
211
+ # body
212
+ if body:
213
+ body = self.sanitize_for_serialization(body)
214
+
215
+ # request url
216
+ if _host is None or self.configuration.ignore_operation_servers:
217
+ url = self.configuration.host + resource_path
218
+ else:
219
+ # use server/host defined in path or operation instead
220
+ url = _host + resource_path
221
+
222
+ # query parameters
223
+ if query_params:
224
+ query_params = self.sanitize_for_serialization(query_params)
225
+ url_query = self.parameters_to_url_query(query_params, collection_formats)
226
+ url += "?" + url_query
227
+
228
+ return method, url, header_params, body, post_params
229
+
230
+ async def call_api(
231
+ self,
232
+ method,
233
+ url,
234
+ header_params=None,
235
+ body=None,
236
+ post_params=None,
237
+ _request_timeout=None,
238
+ ) -> rest.RESTResponse:
239
+ """Makes the HTTP request (synchronous)
240
+ :param method: Method to call.
241
+ :param url: Path to method endpoint.
242
+ :param header_params: Header parameters to be
243
+ placed in the request header.
244
+ :param body: Request body.
245
+ :param post_params dict: Request post form parameters,
246
+ for `application/x-www-form-urlencoded`, `multipart/form-data`.
247
+ :param _request_timeout: timeout setting for this request.
248
+ :return: RESTResponse
249
+ """
250
+
251
+ try:
252
+ # perform request and return response
253
+ response_data = await self.rest_client.request(
254
+ method,
255
+ url,
256
+ headers=header_params,
257
+ body=body,
258
+ post_params=post_params,
259
+ _request_timeout=_request_timeout,
260
+ )
261
+
262
+ except ApiException as e:
263
+ raise e
264
+
265
+ return response_data
266
+
267
+ def response_deserialize(
268
+ self,
269
+ response_data: rest.RESTResponse,
270
+ response_types_map: Optional[Dict[str, ApiResponseT]] = None,
271
+ ) -> ApiResponse[ApiResponseT]:
272
+ """Deserializes response into an object.
273
+ :param response_data: RESTResponse object to be deserialized.
274
+ :param response_types_map: dict of response types.
275
+ :return: ApiResponse
276
+ """
277
+
278
+ msg = "RESTResponse.read() must be called before passing it to response_deserialize()"
279
+ assert response_data.data is not None, msg
280
+
281
+ response_type = response_types_map.get(str(response_data.status), None)
282
+ if (
283
+ not response_type
284
+ and isinstance(response_data.status, int)
285
+ and 100 <= response_data.status <= 599
286
+ ):
287
+ # if not found, look for '1XX', '2XX', etc.
288
+ response_type = response_types_map.get(
289
+ str(response_data.status)[0] + "XX", None
290
+ )
291
+
292
+ # deserialize response data
293
+ response_text = None
294
+ return_data = None
295
+ try:
296
+ if response_type == "bytearray":
297
+ return_data = response_data.data
298
+ elif response_type == "file":
299
+ return_data = self.__deserialize_file(response_data)
300
+ elif response_type is not None:
301
+ match = None
302
+ content_type = response_data.headers.get("content-type")
303
+ if content_type is not None:
304
+ match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
305
+ encoding = match.group(1) if match else "utf-8"
306
+ response_text = response_data.data.decode(encoding)
307
+ return_data = self.deserialize(
308
+ response_text, response_type, content_type
309
+ )
310
+ finally:
311
+ if not 200 <= response_data.status <= 299:
312
+ raise ApiException.from_response(
313
+ http_resp=response_data,
314
+ body=response_text,
315
+ data=return_data,
316
+ )
317
+
318
+ return ApiResponse(
319
+ status_code=response_data.status,
320
+ data=return_data,
321
+ headers=response_data.headers,
322
+ raw_data=response_data.data,
323
+ )
324
+
325
+ def sanitize_for_serialization(self, obj):
326
+ """Builds a JSON POST object.
327
+
328
+ If obj is None, return None.
329
+ If obj is SecretStr, return obj.get_secret_value()
330
+ If obj is str, int, long, float, bool, return directly.
331
+ If obj is datetime.datetime, datetime.date
332
+ convert to string in iso8601 format.
333
+ If obj is decimal.Decimal return string representation.
334
+ If obj is list, sanitize each element in the list.
335
+ If obj is dict, return the dict.
336
+ If obj is OpenAPI model, return the properties dict.
337
+
338
+ :param obj: The data to serialize.
339
+ :return: The serialized form of data.
340
+ """
341
+ if obj is None:
342
+ return None
343
+ elif isinstance(obj, Enum):
344
+ return obj.value
345
+ elif isinstance(obj, SecretStr):
346
+ return obj.get_secret_value()
347
+ elif isinstance(obj, self.PRIMITIVE_TYPES):
348
+ return obj
349
+ elif isinstance(obj, uuid.UUID):
350
+ return str(obj)
351
+ elif isinstance(obj, list):
352
+ return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj]
353
+ elif isinstance(obj, tuple):
354
+ return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj)
355
+ elif isinstance(obj, (datetime.datetime, datetime.date)):
356
+ return obj.isoformat()
357
+ elif isinstance(obj, decimal.Decimal):
358
+ return str(obj)
359
+
360
+ elif isinstance(obj, dict):
361
+ obj_dict = obj
362
+ else:
363
+ # Convert model obj to dict except
364
+ # attributes `openapi_types`, `attribute_map`
365
+ # and attributes which value is not None.
366
+ # Convert attribute name to json key in
367
+ # model definition for request.
368
+ if hasattr(obj, "to_dict") and callable(getattr(obj, "to_dict")):
369
+ obj_dict = obj.to_dict()
370
+ else:
371
+ obj_dict = obj.__dict__
372
+
373
+ if isinstance(obj_dict, list):
374
+ # here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
375
+ return self.sanitize_for_serialization(obj_dict)
376
+
377
+ return {
378
+ key: self.sanitize_for_serialization(val) for key, val in obj_dict.items()
379
+ }
380
+
381
+ def deserialize(
382
+ self, response_text: str, response_type: str, content_type: Optional[str]
383
+ ):
384
+ """Deserializes response into an object.
385
+
386
+ :param response: RESTResponse object to be deserialized.
387
+ :param response_type: class literal for
388
+ deserialized object, or string of class name.
389
+ :param content_type: content type of response.
390
+
391
+ :return: deserialized object.
392
+ """
393
+
394
+ # fetch data from response object
395
+ if content_type is None:
396
+ try:
397
+ data = json.loads(response_text)
398
+ except ValueError:
399
+ data = response_text
400
+ elif re.match(
401
+ r"^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)",
402
+ content_type,
403
+ re.IGNORECASE,
404
+ ):
405
+ if response_text == "":
406
+ data = ""
407
+ else:
408
+ data = json.loads(response_text)
409
+ elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
410
+ data = response_text
411
+ else:
412
+ raise ApiException(
413
+ status=0, reason="Unsupported content type: {0}".format(content_type)
414
+ )
415
+
416
+ return self.__deserialize(data, response_type)
417
+
418
+ def __deserialize(self, data, klass):
419
+ """Deserializes dict, list, str into an object.
420
+
421
+ :param data: dict, list or str.
422
+ :param klass: class literal, or string of class name.
423
+
424
+ :return: object.
425
+ """
426
+ if data is None:
427
+ return None
428
+
429
+ if isinstance(klass, str):
430
+ if klass.startswith("List["):
431
+ m = re.match(r"List\[(.*)]", klass)
432
+ assert m is not None, "Malformed List type definition"
433
+ sub_kls = m.group(1)
434
+ return [self.__deserialize(sub_data, sub_kls) for sub_data in data]
435
+
436
+ if klass.startswith("Dict["):
437
+ m = re.match(r"Dict\[([^,]*), (.*)]", klass)
438
+ assert m is not None, "Malformed Dict type definition"
439
+ sub_kls = m.group(2)
440
+ return {k: self.__deserialize(v, sub_kls) for k, v in data.items()}
441
+
442
+ # convert str to class
443
+ if klass in self.NATIVE_TYPES_MAPPING:
444
+ klass = self.NATIVE_TYPES_MAPPING[klass]
445
+ else:
446
+ klass = getattr(immich.client.models, klass)
447
+
448
+ if klass in self.PRIMITIVE_TYPES:
449
+ return self.__deserialize_primitive(data, klass)
450
+ elif klass is object:
451
+ return self.__deserialize_object(data)
452
+ elif klass is datetime.date:
453
+ return self.__deserialize_date(data)
454
+ elif klass is datetime.datetime:
455
+ return self.__deserialize_datetime(data)
456
+ elif klass is decimal.Decimal:
457
+ return decimal.Decimal(data)
458
+ elif issubclass(klass, Enum):
459
+ return self.__deserialize_enum(data, klass)
460
+ else:
461
+ return self.__deserialize_model(data, klass)
462
+
463
+ def parameters_to_tuples(self, params, collection_formats):
464
+ """Get parameters as list of tuples, formatting collections.
465
+
466
+ :param params: Parameters as dict or list of two-tuples
467
+ :param dict collection_formats: Parameter collection formats
468
+ :return: Parameters as list of tuples, collections formatted
469
+ """
470
+ new_params: List[Tuple[str, str]] = []
471
+ if collection_formats is None:
472
+ collection_formats = {}
473
+ for k, v in params.items() if isinstance(params, dict) else params:
474
+ if k in collection_formats:
475
+ collection_format = collection_formats[k]
476
+ if collection_format == "multi":
477
+ new_params.extend((k, value) for value in v)
478
+ else:
479
+ if collection_format == "ssv":
480
+ delimiter = " "
481
+ elif collection_format == "tsv":
482
+ delimiter = "\t"
483
+ elif collection_format == "pipes":
484
+ delimiter = "|"
485
+ else: # csv is the default
486
+ delimiter = ","
487
+ new_params.append((k, delimiter.join(str(value) for value in v)))
488
+ else:
489
+ new_params.append((k, v))
490
+ return new_params
491
+
492
+ def parameters_to_url_query(self, params, collection_formats):
493
+ """Get parameters as list of tuples, formatting collections.
494
+
495
+ :param params: Parameters as dict or list of two-tuples
496
+ :param dict collection_formats: Parameter collection formats
497
+ :return: URL query string (e.g. a=Hello%20World&b=123)
498
+ """
499
+ new_params: List[Tuple[str, str]] = []
500
+ if collection_formats is None:
501
+ collection_formats = {}
502
+ for k, v in params.items() if isinstance(params, dict) else params:
503
+ if isinstance(v, bool):
504
+ v = str(v).lower()
505
+ if isinstance(v, (int, float)):
506
+ v = str(v)
507
+ if isinstance(v, dict):
508
+ v = json.dumps(v)
509
+
510
+ if k in collection_formats:
511
+ collection_format = collection_formats[k]
512
+ if collection_format == "multi":
513
+ new_params.extend((k, quote(str(value))) for value in v)
514
+ else:
515
+ if collection_format == "ssv":
516
+ delimiter = " "
517
+ elif collection_format == "tsv":
518
+ delimiter = "\t"
519
+ elif collection_format == "pipes":
520
+ delimiter = "|"
521
+ else: # csv is the default
522
+ delimiter = ","
523
+ new_params.append(
524
+ (k, delimiter.join(quote(str(value)) for value in v))
525
+ )
526
+ else:
527
+ new_params.append((k, quote(str(v))))
528
+
529
+ return "&".join(["=".join(map(str, item)) for item in new_params])
530
+
531
+ def files_parameters(
532
+ self,
533
+ files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]],
534
+ ):
535
+ """Builds form parameters.
536
+
537
+ :param files: File parameters.
538
+ :return: Form parameters with files.
539
+ """
540
+ params = []
541
+ for k, v in files.items():
542
+ if isinstance(v, str):
543
+ with open(v, "rb") as f:
544
+ filename = os.path.basename(f.name)
545
+ filedata = f.read()
546
+ elif isinstance(v, bytes):
547
+ filename = k
548
+ filedata = v
549
+ elif isinstance(v, tuple):
550
+ filename, filedata = v
551
+ elif isinstance(v, list):
552
+ for file_param in v:
553
+ params.extend(self.files_parameters({k: file_param}))
554
+ continue
555
+ else:
556
+ raise ValueError("Unsupported file value")
557
+ mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream"
558
+ params.append(tuple([k, tuple([filename, filedata, mimetype])]))
559
+ return params
560
+
561
+ def select_header_accept(self, accepts: List[str]) -> Optional[str]:
562
+ """Returns `Accept` based on an array of accepts provided.
563
+
564
+ :param accepts: List of headers.
565
+ :return: Accept (e.g. application/json).
566
+ """
567
+ if not accepts:
568
+ return None
569
+
570
+ for accept in accepts:
571
+ if re.search("json", accept, re.IGNORECASE):
572
+ return accept
573
+
574
+ return accepts[0]
575
+
576
+ def select_header_content_type(self, content_types):
577
+ """Returns `Content-Type` based on an array of content_types provided.
578
+
579
+ :param content_types: List of content-types.
580
+ :return: Content-Type (e.g. application/json).
581
+ """
582
+ if not content_types:
583
+ return None
584
+
585
+ for content_type in content_types:
586
+ if re.search("json", content_type, re.IGNORECASE):
587
+ return content_type
588
+
589
+ return content_types[0]
590
+
591
+ def update_params_for_auth(
592
+ self,
593
+ headers,
594
+ queries,
595
+ auth_settings,
596
+ resource_path,
597
+ method,
598
+ body,
599
+ request_auth=None,
600
+ ) -> None:
601
+ """Updates header and query params based on authentication setting.
602
+
603
+ :param headers: Header parameters dict to be updated.
604
+ :param queries: Query parameters tuple list to be updated.
605
+ :param auth_settings: Authentication setting identifiers list.
606
+ :resource_path: A string representation of the HTTP request resource path.
607
+ :method: A string representation of the HTTP request method.
608
+ :body: A object representing the body of the HTTP request.
609
+ The object type is the return value of sanitize_for_serialization().
610
+ :param request_auth: if set, the provided settings will
611
+ override the token in the configuration.
612
+ """
613
+ if not auth_settings:
614
+ return
615
+
616
+ if request_auth:
617
+ self._apply_auth_params(
618
+ headers, queries, resource_path, method, body, request_auth
619
+ )
620
+ else:
621
+ for auth in auth_settings:
622
+ auth_setting = self.configuration.auth_settings().get(auth)
623
+ if auth_setting:
624
+ self._apply_auth_params(
625
+ headers, queries, resource_path, method, body, auth_setting
626
+ )
627
+
628
+ def _apply_auth_params(
629
+ self, headers, queries, resource_path, method, body, auth_setting
630
+ ) -> None:
631
+ """Updates the request parameters based on a single auth_setting
632
+
633
+ :param headers: Header parameters dict to be updated.
634
+ :param queries: Query parameters tuple list to be updated.
635
+ :resource_path: A string representation of the HTTP request resource path.
636
+ :method: A string representation of the HTTP request method.
637
+ :body: A object representing the body of the HTTP request.
638
+ The object type is the return value of sanitize_for_serialization().
639
+ :param auth_setting: auth settings for the endpoint
640
+ """
641
+ if auth_setting["in"] == "cookie":
642
+ headers["Cookie"] = auth_setting["value"]
643
+ elif auth_setting["in"] == "header":
644
+ if auth_setting["type"] != "http-signature":
645
+ headers[auth_setting["key"]] = auth_setting["value"]
646
+ elif auth_setting["in"] == "query":
647
+ queries.append((auth_setting["key"], auth_setting["value"]))
648
+ else:
649
+ raise ApiValueError("Authentication token must be in `query` or `header`")
650
+
651
+ def __deserialize_file(self, response):
652
+ """Deserializes body to file
653
+
654
+ Saves response body into a file in a temporary folder,
655
+ using the filename from the `Content-Disposition` header if provided.
656
+
657
+ handle file downloading
658
+ save response body into a tmp file and return the instance
659
+
660
+ :param response: RESTResponse.
661
+ :return: file path.
662
+ """
663
+ fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
664
+ os.close(fd)
665
+ os.remove(path)
666
+
667
+ content_disposition = response.headers.get("Content-Disposition")
668
+ if content_disposition:
669
+ m = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition)
670
+ assert m is not None, "Unexpected 'content-disposition' header value"
671
+ filename = m.group(1)
672
+ path = os.path.join(os.path.dirname(path), filename)
673
+
674
+ with open(path, "wb") as f:
675
+ f.write(response.data)
676
+
677
+ return path
678
+
679
+ def __deserialize_primitive(self, data, klass):
680
+ """Deserializes string to primitive type.
681
+
682
+ :param data: str.
683
+ :param klass: class literal.
684
+
685
+ :return: int, long, float, str, bool.
686
+ """
687
+ try:
688
+ return klass(data)
689
+ except UnicodeEncodeError:
690
+ return str(data)
691
+ except TypeError:
692
+ return data
693
+
694
+ def __deserialize_object(self, value):
695
+ """Return an original value.
696
+
697
+ :return: object.
698
+ """
699
+ return value
700
+
701
+ def __deserialize_date(self, string):
702
+ """Deserializes string to date.
703
+
704
+ :param string: str.
705
+ :return: date.
706
+ """
707
+ try:
708
+ return parse(string).date()
709
+ except ImportError:
710
+ return string
711
+ except ValueError:
712
+ raise rest.ApiException(
713
+ status=0, reason="Failed to parse `{0}` as date object".format(string)
714
+ )
715
+
716
+ def __deserialize_datetime(self, string):
717
+ """Deserializes string to datetime.
718
+
719
+ The string should be in iso8601 datetime format.
720
+
721
+ :param string: str.
722
+ :return: datetime.
723
+ """
724
+ try:
725
+ return parse(string)
726
+ except ImportError:
727
+ return string
728
+ except ValueError:
729
+ raise rest.ApiException(
730
+ status=0,
731
+ reason=("Failed to parse `{0}` as datetime object".format(string)),
732
+ )
733
+
734
+ def __deserialize_enum(self, data, klass):
735
+ """Deserializes primitive type to enum.
736
+
737
+ :param data: primitive type.
738
+ :param klass: class literal.
739
+ :return: enum value.
740
+ """
741
+ try:
742
+ return klass(data)
743
+ except ValueError:
744
+ raise rest.ApiException(
745
+ status=0, reason=("Failed to parse `{0}` as `{1}`".format(data, klass))
746
+ )
747
+
748
+ def __deserialize_model(self, data, klass):
749
+ """Deserializes list or dict to model.
750
+
751
+ :param data: dict, list.
752
+ :param klass: class literal.
753
+ :return: model object.
754
+ """
755
+
756
+ return klass.from_dict(data)