vrchatapi-async 1.20.8.dev1__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 (362) hide show
  1. vrchatapi/__init__.py +742 -0
  2. vrchatapi/api/__init__.py +23 -0
  3. vrchatapi/api/authentication_api.py +6253 -0
  4. vrchatapi/api/avatars_api.py +4234 -0
  5. vrchatapi/api/calendar_api.py +4090 -0
  6. vrchatapi/api/economy_api.py +11547 -0
  7. vrchatapi/api/favorites_api.py +2368 -0
  8. vrchatapi/api/files_api.py +6109 -0
  9. vrchatapi/api/friends_api.py +1708 -0
  10. vrchatapi/api/groups_api.py +15085 -0
  11. vrchatapi/api/instances_api.py +1754 -0
  12. vrchatapi/api/inventory_api.py +4333 -0
  13. vrchatapi/api/invite_api.py +3337 -0
  14. vrchatapi/api/jams_api.py +1446 -0
  15. vrchatapi/api/miscellaneous_api.py +2384 -0
  16. vrchatapi/api/notifications_api.py +3624 -0
  17. vrchatapi/api/playermoderation_api.py +1127 -0
  18. vrchatapi/api/prints_api.py +1478 -0
  19. vrchatapi/api/props_api.py +2269 -0
  20. vrchatapi/api/users_api.py +7894 -0
  21. vrchatapi/api/worlds_api.py +6153 -0
  22. vrchatapi/api_client.py +865 -0
  23. vrchatapi/api_response.py +21 -0
  24. vrchatapi/configuration.py +686 -0
  25. vrchatapi/exceptions.py +218 -0
  26. vrchatapi/models/__init__.py +345 -0
  27. vrchatapi/models/account_deletion_log.py +253 -0
  28. vrchatapi/models/add_favorite_request.py +246 -0
  29. vrchatapi/models/add_group_gallery_image_request.py +234 -0
  30. vrchatapi/models/admin_asset_bundle.py +337 -0
  31. vrchatapi/models/admin_unity_package.py +261 -0
  32. vrchatapi/models/age_verification_status.py +38 -0
  33. vrchatapi/models/agreement.py +280 -0
  34. vrchatapi/models/agreement_code.py +36 -0
  35. vrchatapi/models/agreement_request.py +256 -0
  36. vrchatapi/models/agreement_status.py +261 -0
  37. vrchatapi/models/api_config.py +1299 -0
  38. vrchatapi/models/api_config_access_logs_urls.py +258 -0
  39. vrchatapi/models/api_config_announcement.py +217 -0
  40. vrchatapi/models/api_config_audio_config.py +311 -0
  41. vrchatapi/models/api_config_avatar_perf_limiter.py +293 -0
  42. vrchatapi/models/api_config_constants.py +262 -0
  43. vrchatapi/models/api_config_constants_groups.py +306 -0
  44. vrchatapi/models/api_config_constants_instance.py +238 -0
  45. vrchatapi/models/api_config_constants_instancepopulationbrackets.py +262 -0
  46. vrchatapi/models/api_config_constants_instancepopulationbracketscrowded.py +216 -0
  47. vrchatapi/models/api_config_constants_instancepopulationbracketsfew.py +216 -0
  48. vrchatapi/models/api_config_constants_instancepopulationbracketsmany.py +216 -0
  49. vrchatapi/models/api_config_constants_language.py +234 -0
  50. vrchatapi/models/api_config_download_url_list.py +258 -0
  51. vrchatapi/models/api_config_events.py +314 -0
  52. vrchatapi/models/api_config_ios_version.py +216 -0
  53. vrchatapi/models/api_config_min_supported_client_build_number.py +348 -0
  54. vrchatapi/models/api_config_offline_analysis.py +216 -0
  55. vrchatapi/models/api_health.py +248 -0
  56. vrchatapi/models/avatar.py +463 -0
  57. vrchatapi/models/avatar_moderation.py +249 -0
  58. vrchatapi/models/avatar_moderation_created.py +248 -0
  59. vrchatapi/models/avatar_moderation_type.py +36 -0
  60. vrchatapi/models/avatar_performance.py +265 -0
  61. vrchatapi/models/avatar_published_listings_inner.py +271 -0
  62. vrchatapi/models/avatar_style.py +239 -0
  63. vrchatapi/models/avatar_styles.py +231 -0
  64. vrchatapi/models/avatar_unity_package_url_object.py +234 -0
  65. vrchatapi/models/badge.py +308 -0
  66. vrchatapi/models/balance.py +247 -0
  67. vrchatapi/models/ban_group_member_request.py +234 -0
  68. vrchatapi/models/boop_request.py +250 -0
  69. vrchatapi/models/calendar_day_of_week.py +42 -0
  70. vrchatapi/models/calendar_event.py +475 -0
  71. vrchatapi/models/calendar_event_access.py +37 -0
  72. vrchatapi/models/calendar_event_category.py +48 -0
  73. vrchatapi/models/calendar_event_discovery.py +247 -0
  74. vrchatapi/models/calendar_event_discovery_inclusion.py +38 -0
  75. vrchatapi/models/calendar_event_discovery_scope.py +38 -0
  76. vrchatapi/models/calendar_event_frequency.py +39 -0
  77. vrchatapi/models/calendar_event_occurrence_kind.py +38 -0
  78. vrchatapi/models/calendar_event_platform.py +38 -0
  79. vrchatapi/models/calendar_event_recurrence.py +261 -0
  80. vrchatapi/models/calendar_event_recurrence_end.py +246 -0
  81. vrchatapi/models/calendar_event_recurrence_end_type.py +37 -0
  82. vrchatapi/models/calendar_event_user_interest.py +251 -0
  83. vrchatapi/models/change_user_tags_request.py +212 -0
  84. vrchatapi/models/change_world_tags_request.py +212 -0
  85. vrchatapi/models/content_filter.py +40 -0
  86. vrchatapi/models/create_avatar_moderation_request.py +243 -0
  87. vrchatapi/models/create_avatar_request.py +324 -0
  88. vrchatapi/models/create_calendar_event_request.py +385 -0
  89. vrchatapi/models/create_file_request.py +251 -0
  90. vrchatapi/models/create_file_version_request.py +259 -0
  91. vrchatapi/models/create_group_announcement_request.py +253 -0
  92. vrchatapi/models/create_group_gallery_request.py +297 -0
  93. vrchatapi/models/create_group_invite_request.py +242 -0
  94. vrchatapi/models/create_group_post_request.py +267 -0
  95. vrchatapi/models/create_group_request.py +295 -0
  96. vrchatapi/models/create_group_role_request.py +255 -0
  97. vrchatapi/models/create_instance_request.py +384 -0
  98. vrchatapi/models/create_jam_submission_request.py +239 -0
  99. vrchatapi/models/create_listing_request.py +285 -0
  100. vrchatapi/models/create_product_request.py +270 -0
  101. vrchatapi/models/create_prop_request.py +308 -0
  102. vrchatapi/models/create_world_request.py +322 -0
  103. vrchatapi/models/current_user.py +909 -0
  104. vrchatapi/models/current_user_platform_history_inner.py +245 -0
  105. vrchatapi/models/current_user_presence.py +379 -0
  106. vrchatapi/models/decline_group_invite_request.py +211 -0
  107. vrchatapi/models/developer_type.py +39 -0
  108. vrchatapi/models/disable2_fa_result.py +211 -0
  109. vrchatapi/models/discord_details.py +216 -0
  110. vrchatapi/models/dynamic_content_row.py +276 -0
  111. vrchatapi/models/earnings_metrics.py +248 -0
  112. vrchatapi/models/earnings_metrics_totals.py +267 -0
  113. vrchatapi/models/economy_account.py +360 -0
  114. vrchatapi/models/economy_balances.py +221 -0
  115. vrchatapi/models/economy_payout.py +385 -0
  116. vrchatapi/models/economy_payout_eligibility.py +263 -0
  117. vrchatapi/models/economy_payout_list.py +219 -0
  118. vrchatapi/models/economy_payout_status.py +295 -0
  119. vrchatapi/models/equip_inventory_item_request.py +235 -0
  120. vrchatapi/models/error.py +215 -0
  121. vrchatapi/models/favorite.py +251 -0
  122. vrchatapi/models/favorite_group.py +278 -0
  123. vrchatapi/models/favorite_group_limits.py +249 -0
  124. vrchatapi/models/favorite_group_visibility.py +38 -0
  125. vrchatapi/models/favorite_limits.py +265 -0
  126. vrchatapi/models/favorite_type.py +39 -0
  127. vrchatapi/models/favorited_world.py +441 -0
  128. vrchatapi/models/feedback.py +331 -0
  129. vrchatapi/models/file.py +325 -0
  130. vrchatapi/models/file_analysis.py +281 -0
  131. vrchatapi/models/file_analysis_avatar_stats.py +575 -0
  132. vrchatapi/models/file_data.py +279 -0
  133. vrchatapi/models/file_status.py +39 -0
  134. vrchatapi/models/file_upload_url.py +212 -0
  135. vrchatapi/models/file_version.py +254 -0
  136. vrchatapi/models/file_version_upload_status.py +269 -0
  137. vrchatapi/models/finish_file_data_upload_request.py +248 -0
  138. vrchatapi/models/follow_calendar_event_request.py +234 -0
  139. vrchatapi/models/friend_status.py +250 -0
  140. vrchatapi/models/get_group_posts200_response.py +219 -0
  141. vrchatapi/models/get_user_group_instances200_response.py +248 -0
  142. vrchatapi/models/group.py +514 -0
  143. vrchatapi/models/group_access_type.py +38 -0
  144. vrchatapi/models/group_announcement.py +315 -0
  145. vrchatapi/models/group_audit_log_entry.py +287 -0
  146. vrchatapi/models/group_gallery.py +319 -0
  147. vrchatapi/models/group_gallery_file_order.py +211 -0
  148. vrchatapi/models/group_gallery_file_order_request.py +239 -0
  149. vrchatapi/models/group_gallery_image.py +301 -0
  150. vrchatapi/models/group_instance.py +257 -0
  151. vrchatapi/models/group_join_request_action.py +37 -0
  152. vrchatapi/models/group_join_state.py +39 -0
  153. vrchatapi/models/group_member.py +415 -0
  154. vrchatapi/models/group_member_limited_user.py +290 -0
  155. vrchatapi/models/group_member_status.py +41 -0
  156. vrchatapi/models/group_my_member.py +399 -0
  157. vrchatapi/models/group_permission.py +260 -0
  158. vrchatapi/models/group_permissions.py +63 -0
  159. vrchatapi/models/group_post.py +317 -0
  160. vrchatapi/models/group_post_visibility.py +37 -0
  161. vrchatapi/models/group_privacy.py +37 -0
  162. vrchatapi/models/group_role.py +309 -0
  163. vrchatapi/models/group_role_template.py +39 -0
  164. vrchatapi/models/group_role_template_values.py +254 -0
  165. vrchatapi/models/group_role_template_values_roles.py +253 -0
  166. vrchatapi/models/group_search_sort.py +37 -0
  167. vrchatapi/models/group_transferable.py +215 -0
  168. vrchatapi/models/group_transferable_requirements.py +266 -0
  169. vrchatapi/models/group_user_visibility.py +38 -0
  170. vrchatapi/models/image_animation_style.py +62 -0
  171. vrchatapi/models/image_loop_style.py +37 -0
  172. vrchatapi/models/image_mask.py +41 -0
  173. vrchatapi/models/image_purpose.py +46 -0
  174. vrchatapi/models/info_push.py +306 -0
  175. vrchatapi/models/info_push_data.py +288 -0
  176. vrchatapi/models/info_push_data_article.py +215 -0
  177. vrchatapi/models/info_push_data_article_content.py +251 -0
  178. vrchatapi/models/info_push_data_clickable.py +224 -0
  179. vrchatapi/models/instance.py +597 -0
  180. vrchatapi/models/instance_content_settings.py +236 -0
  181. vrchatapi/models/instance_platforms.py +222 -0
  182. vrchatapi/models/instance_region.py +40 -0
  183. vrchatapi/models/instance_short_name_response.py +248 -0
  184. vrchatapi/models/instance_type.py +40 -0
  185. vrchatapi/models/inventory.py +247 -0
  186. vrchatapi/models/inventory_consumption_results.py +255 -0
  187. vrchatapi/models/inventory_default_attributes_value.py +243 -0
  188. vrchatapi/models/inventory_default_attributes_value_validator.py +211 -0
  189. vrchatapi/models/inventory_drop.py +331 -0
  190. vrchatapi/models/inventory_equip_slot.py +39 -0
  191. vrchatapi/models/inventory_flag.py +43 -0
  192. vrchatapi/models/inventory_item.py +420 -0
  193. vrchatapi/models/inventory_item_type.py +42 -0
  194. vrchatapi/models/inventory_metadata.py +287 -0
  195. vrchatapi/models/inventory_notification_details.py +244 -0
  196. vrchatapi/models/inventory_spawn.py +216 -0
  197. vrchatapi/models/inventory_template.py +351 -0
  198. vrchatapi/models/inventory_user_attributes.py +250 -0
  199. vrchatapi/models/invite_message.py +276 -0
  200. vrchatapi/models/invite_message_type.py +39 -0
  201. vrchatapi/models/invite_request.py +243 -0
  202. vrchatapi/models/invite_response.py +235 -0
  203. vrchatapi/models/jam.py +302 -0
  204. vrchatapi/models/jam_state_change_dates.py +276 -0
  205. vrchatapi/models/jam_submission.py +275 -0
  206. vrchatapi/models/join_group_request.py +234 -0
  207. vrchatapi/models/license.py +261 -0
  208. vrchatapi/models/license_action.py +37 -0
  209. vrchatapi/models/license_group.py +235 -0
  210. vrchatapi/models/license_type.py +39 -0
  211. vrchatapi/models/limited_group.py +377 -0
  212. vrchatapi/models/limited_unity_package.py +251 -0
  213. vrchatapi/models/limited_user_friend.py +399 -0
  214. vrchatapi/models/limited_user_groups.py +386 -0
  215. vrchatapi/models/limited_user_instance.py +430 -0
  216. vrchatapi/models/limited_user_search.py +395 -0
  217. vrchatapi/models/limited_world.py +410 -0
  218. vrchatapi/models/mime_type.py +50 -0
  219. vrchatapi/models/model_print.py +299 -0
  220. vrchatapi/models/moderate_user_request.py +217 -0
  221. vrchatapi/models/moderation_report.py +296 -0
  222. vrchatapi/models/mutual_friend.py +302 -0
  223. vrchatapi/models/mutuals.py +217 -0
  224. vrchatapi/models/notification.py +283 -0
  225. vrchatapi/models/notification_detail_invite.py +250 -0
  226. vrchatapi/models/notification_detail_invite_response.py +242 -0
  227. vrchatapi/models/notification_detail_request_invite.py +239 -0
  228. vrchatapi/models/notification_detail_request_invite_response.py +242 -0
  229. vrchatapi/models/notification_detail_vote_to_kick.py +242 -0
  230. vrchatapi/models/notification_type.py +43 -0
  231. vrchatapi/models/notification_v2.py +466 -0
  232. vrchatapi/models/notification_v2_details_boop.py +255 -0
  233. vrchatapi/models/notification_v2_response.py +259 -0
  234. vrchatapi/models/notification_v2_type.py +58 -0
  235. vrchatapi/models/ok_status.py +211 -0
  236. vrchatapi/models/ok_status2.py +234 -0
  237. vrchatapi/models/order_option.py +37 -0
  238. vrchatapi/models/order_option_short.py +37 -0
  239. vrchatapi/models/paginated_calendar_event_list.py +255 -0
  240. vrchatapi/models/paginated_group_audit_log_entry_list.py +255 -0
  241. vrchatapi/models/paginated_moderation_report_list.py +255 -0
  242. vrchatapi/models/past_display_name.py +241 -0
  243. vrchatapi/models/pending2_fa_result.py +239 -0
  244. vrchatapi/models/performance_limiter_info.py +234 -0
  245. vrchatapi/models/performance_ratings.py +41 -0
  246. vrchatapi/models/permission.py +280 -0
  247. vrchatapi/models/permission_data.py +258 -0
  248. vrchatapi/models/platform_build_info.py +242 -0
  249. vrchatapi/models/player_moderation.py +276 -0
  250. vrchatapi/models/player_moderation_type.py +44 -0
  251. vrchatapi/models/print_files.py +239 -0
  252. vrchatapi/models/private_profile.py +267 -0
  253. vrchatapi/models/private_profile_activity.py +292 -0
  254. vrchatapi/models/product.py +389 -0
  255. vrchatapi/models/product_listing.py +538 -0
  256. vrchatapi/models/product_listing_type.py +39 -0
  257. vrchatapi/models/product_listing_variant.py +272 -0
  258. vrchatapi/models/product_purchase.py +571 -0
  259. vrchatapi/models/product_purchase_history.py +256 -0
  260. vrchatapi/models/product_purchase_location_type.py +46 -0
  261. vrchatapi/models/product_purchase_product.py +269 -0
  262. vrchatapi/models/product_purchase_purchase_context.py +250 -0
  263. vrchatapi/models/product_purchase_record.py +312 -0
  264. vrchatapi/models/product_type.py +39 -0
  265. vrchatapi/models/profile_represented_group.py +262 -0
  266. vrchatapi/models/prop.py +358 -0
  267. vrchatapi/models/prop_publish_status.py +234 -0
  268. vrchatapi/models/prop_unity_package.py +269 -0
  269. vrchatapi/models/public_profile.py +398 -0
  270. vrchatapi/models/purchase_context_data.py +251 -0
  271. vrchatapi/models/purchase_product_listing_request.py +281 -0
  272. vrchatapi/models/region.py +42 -0
  273. vrchatapi/models/register_user_account_request.py +278 -0
  274. vrchatapi/models/release_status.py +39 -0
  275. vrchatapi/models/report_category.py +226 -0
  276. vrchatapi/models/report_reason.py +216 -0
  277. vrchatapi/models/represented_group.py +348 -0
  278. vrchatapi/models/request_invite_request.py +235 -0
  279. vrchatapi/models/respond_group_join_request.py +217 -0
  280. vrchatapi/models/respond_notification_v2_request.py +242 -0
  281. vrchatapi/models/response.py +217 -0
  282. vrchatapi/models/reward_badge.py +308 -0
  283. vrchatapi/models/reward_redemption.py +220 -0
  284. vrchatapi/models/reward_redemption_data.py +224 -0
  285. vrchatapi/models/reward_redemption_request.py +211 -0
  286. vrchatapi/models/reward_redemption_result.py +250 -0
  287. vrchatapi/models/search_group_members200_response.py +224 -0
  288. vrchatapi/models/seller_eligibility.py +211 -0
  289. vrchatapi/models/sent_notification.py +278 -0
  290. vrchatapi/models/service_queue_stats.py +234 -0
  291. vrchatapi/models/service_status.py +281 -0
  292. vrchatapi/models/share_inventory_item_direct_request.py +239 -0
  293. vrchatapi/models/sort_option.py +53 -0
  294. vrchatapi/models/sort_option_product_purchase.py +36 -0
  295. vrchatapi/models/store.py +372 -0
  296. vrchatapi/models/store_context.py +249 -0
  297. vrchatapi/models/store_shelf.py +304 -0
  298. vrchatapi/models/store_type.py +38 -0
  299. vrchatapi/models/store_view.py +40 -0
  300. vrchatapi/models/submit_moderation_report_request.py +263 -0
  301. vrchatapi/models/submit_moderation_report_request_details.py +283 -0
  302. vrchatapi/models/subscription.py +301 -0
  303. vrchatapi/models/subscription_period.py +40 -0
  304. vrchatapi/models/success.py +215 -0
  305. vrchatapi/models/success_flag.py +211 -0
  306. vrchatapi/models/tilia_kyc.py +246 -0
  307. vrchatapi/models/tilia_status.py +259 -0
  308. vrchatapi/models/tilia_tos.py +211 -0
  309. vrchatapi/models/token_bundle.py +286 -0
  310. vrchatapi/models/transaction.py +322 -0
  311. vrchatapi/models/transaction_agreement.py +353 -0
  312. vrchatapi/models/transaction_status.py +39 -0
  313. vrchatapi/models/transaction_steam_info.py +271 -0
  314. vrchatapi/models/transaction_steam_wallet_info.py +227 -0
  315. vrchatapi/models/transfer_group_request.py +234 -0
  316. vrchatapi/models/tutorial_status.py +255 -0
  317. vrchatapi/models/two_factor_auth_code.py +211 -0
  318. vrchatapi/models/two_factor_email_code.py +211 -0
  319. vrchatapi/models/two_factor_recovery_codes.py +247 -0
  320. vrchatapi/models/two_factor_recovery_codes_otp_inner.py +216 -0
  321. vrchatapi/models/unity_package.py +360 -0
  322. vrchatapi/models/update_asset_review_notes_request.py +234 -0
  323. vrchatapi/models/update_avatar_request.py +293 -0
  324. vrchatapi/models/update_calendar_event_request.py +365 -0
  325. vrchatapi/models/update_favorite_group_request.py +246 -0
  326. vrchatapi/models/update_group_gallery_request.py +297 -0
  327. vrchatapi/models/update_group_member_request.py +256 -0
  328. vrchatapi/models/update_group_representation_request.py +234 -0
  329. vrchatapi/models/update_group_request.py +300 -0
  330. vrchatapi/models/update_group_role_request.py +255 -0
  331. vrchatapi/models/update_inventory_item_request.py +254 -0
  332. vrchatapi/models/update_invite_message_request.py +211 -0
  333. vrchatapi/models/update_listing_request.py +211 -0
  334. vrchatapi/models/update_product_request.py +261 -0
  335. vrchatapi/models/update_prop_request.py +303 -0
  336. vrchatapi/models/update_tilia_tos_request.py +211 -0
  337. vrchatapi/models/update_user_badge_request.py +216 -0
  338. vrchatapi/models/update_user_note_request.py +239 -0
  339. vrchatapi/models/update_user_request.py +358 -0
  340. vrchatapi/models/update_world_request.py +317 -0
  341. vrchatapi/models/user.py +549 -0
  342. vrchatapi/models/user_credits_eligible.py +216 -0
  343. vrchatapi/models/user_exists.py +242 -0
  344. vrchatapi/models/user_note.py +273 -0
  345. vrchatapi/models/user_note_target_user.py +277 -0
  346. vrchatapi/models/user_state.py +38 -0
  347. vrchatapi/models/user_status.py +40 -0
  348. vrchatapi/models/user_subscription.py +330 -0
  349. vrchatapi/models/user_subscription_eligible.py +274 -0
  350. vrchatapi/models/verify2_fa_email_code_result.py +211 -0
  351. vrchatapi/models/verify2_fa_result.py +216 -0
  352. vrchatapi/models/verify_auth_token_result.py +217 -0
  353. vrchatapi/models/world.py +459 -0
  354. vrchatapi/models/world_metadata.py +216 -0
  355. vrchatapi/models/world_publish_status.py +234 -0
  356. vrchatapi/py.typed +0 -0
  357. vrchatapi/rest.py +303 -0
  358. vrchatapi_async-1.20.8.dev1.dist-info/METADATA +137 -0
  359. vrchatapi_async-1.20.8.dev1.dist-info/RECORD +362 -0
  360. vrchatapi_async-1.20.8.dev1.dist-info/WHEEL +5 -0
  361. vrchatapi_async-1.20.8.dev1.dist-info/licenses/LICENSE +21 -0
  362. vrchatapi_async-1.20.8.dev1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,865 @@
1
+ """
2
+ VRChat API Documentation
3
+
4
+
5
+ The version of the OpenAPI document: 1.20.8
6
+ Contact: vrchatapi.lpv0t@aries.fyi
7
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
8
+
9
+ Do not edit the class manually.
10
+ """ # noqa: E501
11
+
12
+
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, Any
27
+ from pydantic import SecretStr
28
+
29
+ from vrchatapi.configuration import Configuration
30
+ from vrchatapi.api_response import ApiResponse, T as ApiResponseT
31
+ import vrchatapi.models
32
+ from vrchatapi import rest
33
+ from vrchatapi.exceptions import (
34
+ ApiValueError,
35
+ ApiException,
36
+ BadRequestException,
37
+ UnauthorizedException,
38
+ ForbiddenException,
39
+ NotFoundException,
40
+ ServiceException
41
+ )
42
+
43
+
44
+ _OPENAPI_GENERATOR_TO_DICT = "_openapi_generator_to_dict"
45
+
46
+
47
+ def _get_openapi_to_dict(value: Any) -> Any:
48
+ # Reciprocal function references preserve inherited generated methods
49
+ # without reserving model member names. Checking both directions also
50
+ # rejects overrides whose decorators copy function attributes.
51
+ to_dict = getattr(value, "to_dict", None)
52
+ type_to_dict = getattr(type(value), "to_dict", None)
53
+ if (
54
+ not callable(to_dict)
55
+ or getattr(to_dict, "__func__", None) is not type_to_dict
56
+ ):
57
+ return None
58
+
59
+ openapi_to_dict = getattr(
60
+ type_to_dict, _OPENAPI_GENERATOR_TO_DICT, None
61
+ )
62
+ if (
63
+ not callable(openapi_to_dict)
64
+ or getattr(
65
+ openapi_to_dict,
66
+ _OPENAPI_GENERATOR_TO_DICT,
67
+ None,
68
+ ) is not type_to_dict
69
+ ):
70
+ return None
71
+ return openapi_to_dict
72
+
73
+
74
+ RequestSerialized = Tuple[str, str, Dict[str, str], Optional[str], List[str]]
75
+
76
+ class ApiClient:
77
+ """Generic API client for OpenAPI client library builds.
78
+
79
+ OpenAPI generic API client. This client handles the client-
80
+ server communication, and is invariant across implementations. Specifics of
81
+ the methods and models for each application are generated from the OpenAPI
82
+ templates.
83
+
84
+ :param configuration: .Configuration object for this client
85
+ :param header_name: a header to pass when making calls to the API.
86
+ :param header_value: a header value to pass when making calls to
87
+ the API.
88
+ :param cookie: a cookie to include in the header when making calls
89
+ to the API
90
+ """
91
+
92
+ PRIMITIVE_TYPES = (float, bool, bytes, str, int)
93
+ NATIVE_TYPES_MAPPING = {
94
+ 'int': int,
95
+ 'long': int, # TODO remove as only py3 is supported?
96
+ 'float': float,
97
+ 'str': str,
98
+ 'bool': bool,
99
+ 'date': datetime.date,
100
+ 'datetime': datetime.datetime,
101
+ 'decimal': decimal.Decimal,
102
+ 'UUID': uuid.UUID,
103
+ 'object': object,
104
+ }
105
+ _pool = None
106
+
107
+ def __init__(
108
+ self,
109
+ configuration=None,
110
+ header_name=None,
111
+ header_value=None,
112
+ cookie=None
113
+ ) -> None:
114
+ # use default configuration if none is provided
115
+ if configuration is None:
116
+ configuration = Configuration.get_default()
117
+ self.configuration = configuration
118
+
119
+ self.rest_client = rest.RESTClientObject(configuration)
120
+ self.default_headers = {}
121
+ if header_name is not None:
122
+ self.default_headers[header_name] = header_value
123
+ self.cookie = cookie
124
+ # Set default User-Agent.
125
+ self.user_agent = 'vrchatapi-py'
126
+ self.client_side_validation = configuration.client_side_validation
127
+
128
+ async def __aenter__(self):
129
+ return self
130
+
131
+ async def __aexit__(self, exc_type, exc_value, traceback):
132
+ await self.close()
133
+
134
+ async def close(self):
135
+ await self.rest_client.close()
136
+
137
+ @property
138
+ def user_agent(self):
139
+ """User agent for this API client"""
140
+ return self.default_headers['User-Agent']
141
+
142
+ @user_agent.setter
143
+ def user_agent(self, value):
144
+ self.default_headers['User-Agent'] = value
145
+
146
+ def set_default_header(self, header_name, header_value):
147
+ self.default_headers[header_name] = header_value
148
+
149
+
150
+ _default = None
151
+
152
+ @classmethod
153
+ def get_default(cls):
154
+ """Return new instance of ApiClient.
155
+
156
+ This method returns newly created, based on default constructor,
157
+ object of ApiClient class or returns a copy of default
158
+ ApiClient.
159
+
160
+ :return: The ApiClient object.
161
+ """
162
+ if cls._default is None:
163
+ cls._default = ApiClient()
164
+ return cls._default
165
+
166
+ @classmethod
167
+ def set_default(cls, default):
168
+ """Set default instance of ApiClient.
169
+
170
+ It stores default ApiClient.
171
+
172
+ :param default: object of ApiClient.
173
+ """
174
+ cls._default = default
175
+
176
+ def param_serialize(
177
+ self,
178
+ method,
179
+ resource_path,
180
+ path_params=None,
181
+ query_params=None,
182
+ header_params=None,
183
+ body=None,
184
+ post_params=None,
185
+ files=None, auth_settings=None,
186
+ collection_formats=None,
187
+ _host=None,
188
+ _request_auth=None
189
+ ) -> RequestSerialized:
190
+
191
+ """Builds the HTTP request params needed by the request.
192
+ :param method: Method to call.
193
+ :param resource_path: Path to method endpoint.
194
+ :param path_params: Path parameters in the url.
195
+ :param query_params: Query parameters in the url.
196
+ :param header_params: Header parameters to be
197
+ placed in the request header.
198
+ :param body: Request body.
199
+ :param post_params dict: Request post form parameters,
200
+ for `application/x-www-form-urlencoded`, `multipart/form-data`.
201
+ :param auth_settings list: Auth Settings names for the request.
202
+ :param files dict: key -> filename, value -> filepath,
203
+ for `multipart/form-data`.
204
+ :param collection_formats: dict of collection formats for path, query,
205
+ header, and post parameters.
206
+ :param _request_auth: set to override the auth_settings for an a single
207
+ request; this effectively ignores the authentication
208
+ in the spec for a single request.
209
+ :return: tuple of form (path, http_method, query_params, header_params,
210
+ body, post_params, files)
211
+ """
212
+
213
+ config = self.configuration
214
+
215
+ # header parameters
216
+ header_params = header_params or {}
217
+ header_params.update(self.default_headers)
218
+ if self.cookie:
219
+ header_params['Cookie'] = self.cookie
220
+ if header_params:
221
+ header_params = self.sanitize_for_serialization(header_params)
222
+ header_params = dict(
223
+ self.parameters_to_tuples(header_params,collection_formats)
224
+ )
225
+
226
+ # path parameters
227
+ if path_params:
228
+ path_params = self.sanitize_for_serialization(path_params)
229
+ path_params = self.parameters_to_tuples(
230
+ path_params,
231
+ collection_formats
232
+ )
233
+ for k, v in path_params:
234
+ # specified safe chars, encode everything
235
+ resource_path = resource_path.replace(
236
+ '{%s}' % k,
237
+ quote(str(v), safe=config.safe_chars_for_path_param)
238
+ )
239
+
240
+ # post parameters
241
+ if post_params or files:
242
+ post_params = post_params if post_params else []
243
+ post_params = self.sanitize_for_serialization(post_params)
244
+ post_params = self.parameters_to_tuples(
245
+ post_params,
246
+ collection_formats
247
+ )
248
+ if files:
249
+ post_params.extend(self.files_parameters(files))
250
+
251
+ # auth setting
252
+ self.update_params_for_auth(
253
+ header_params,
254
+ query_params,
255
+ auth_settings,
256
+ resource_path,
257
+ method,
258
+ body,
259
+ request_auth=_request_auth
260
+ )
261
+
262
+ # body
263
+ if body:
264
+ body = self.sanitize_for_serialization(body)
265
+
266
+ # request url
267
+ if _host is None or self.configuration.ignore_operation_servers:
268
+ url = self.configuration.host + resource_path
269
+ else:
270
+ # use server/host defined in path or operation instead
271
+ url = _host + resource_path
272
+
273
+ # query parameters
274
+ if query_params:
275
+ query_params = self.sanitize_for_serialization(query_params)
276
+ url_query = self.parameters_to_url_query(
277
+ query_params,
278
+ collection_formats
279
+ )
280
+ url += "?" + url_query
281
+
282
+ return method, url, header_params, body, post_params
283
+
284
+
285
+ async def call_api(
286
+ self,
287
+ method,
288
+ url,
289
+ header_params=None,
290
+ body=None,
291
+ post_params=None,
292
+ _request_timeout=None
293
+ ) -> rest.RESTResponse:
294
+ """Makes the HTTP request (synchronous)
295
+ :param method: Method to call.
296
+ :param url: Path to method endpoint.
297
+ :param header_params: Header parameters to be
298
+ placed in the request header.
299
+ :param body: Request body.
300
+ :param post_params dict: Request post form parameters,
301
+ for `application/x-www-form-urlencoded`, `multipart/form-data`.
302
+ :param _request_timeout: timeout setting for this request.
303
+ :return: RESTResponse
304
+ """
305
+
306
+ try:
307
+ # perform request and return response
308
+ response_data = await self.rest_client.request(
309
+ method, url,
310
+ headers=header_params,
311
+ body=body, post_params=post_params,
312
+ _request_timeout=_request_timeout
313
+ )
314
+
315
+ except ApiException as e:
316
+ raise e
317
+
318
+ return response_data
319
+
320
+ def response_deserialize(
321
+ self,
322
+ response_data: rest.RESTResponse,
323
+ response_types_map: Optional[Dict[str, ApiResponseT]]=None
324
+ ) -> ApiResponse[ApiResponseT]:
325
+ """Deserializes response into an object.
326
+ :param response_data: RESTResponse object to be deserialized.
327
+ :param response_types_map: dict of response types.
328
+ :return: ApiResponse
329
+ """
330
+
331
+ msg = "RESTResponse.read() must be called before passing it to response_deserialize()"
332
+ assert response_data.data is not None, msg
333
+
334
+ # VRChatAPI: Make 2FA required errors readable
335
+ if re.match(rb'{"\w{21}":\["totp","otp"]}', response_data.data) is not None:
336
+ response_data.reason = "2 Factor Authentication verification is required"
337
+ raise UnauthorizedException(http_resp=response_data)
338
+ elif re.match(rb'{"\w{21}":\["emailOtp"]}', response_data.data) is not None:
339
+ response_data.reason = "Email 2 Factor Authentication verification is required"
340
+ raise UnauthorizedException(http_resp=response_data)
341
+
342
+ response_type = response_types_map.get(str(response_data.status), None)
343
+ if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599:
344
+ # if not found, look for '1XX', '2XX', etc.
345
+ response_type = response_types_map.get(str(response_data.status)[0] + "XX", None)
346
+
347
+ # If the response_type has not matched (eg. did not match the previous if statements) and the default response is available, use it.
348
+ if response_type is None and str(response_data.status) not in response_types_map \
349
+ and (not isinstance(response_data.status, int) or not 100 <= response_data.status <= 599 or str(response_data.status)[0] + "XX" not in response_types_map) \
350
+ and 'default' in response_types_map:
351
+ response_type = response_types_map['default']
352
+
353
+ # deserialize response data
354
+ response_text = None
355
+ return_data = None
356
+ try:
357
+ if response_type in ("bytearray", "bytes"):
358
+ return_data = response_data.data
359
+ elif response_type == "file":
360
+ return_data = self.__deserialize_file(response_data)
361
+ elif response_type is not None:
362
+ match = None
363
+ content_type = response_data.headers.get('content-type')
364
+ if content_type is not None:
365
+ match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
366
+ encoding = match.group(1) if match else "utf-8"
367
+ response_text = response_data.data.decode(encoding)
368
+ return_data = self.deserialize(response_text, response_type, content_type)
369
+ finally:
370
+ if not 200 <= response_data.status <= 299:
371
+ raise ApiException.from_response(
372
+ http_resp=response_data,
373
+ body=response_text,
374
+ data=return_data,
375
+ )
376
+
377
+ return ApiResponse(
378
+ status_code = response_data.status,
379
+ data = return_data,
380
+ headers = response_data.headers,
381
+ raw_data = response_data.data
382
+ )
383
+
384
+ def sanitize_for_serialization(self, obj):
385
+ """Builds a JSON POST object.
386
+
387
+ If obj is None, return None.
388
+ If obj is SecretStr, return obj.get_secret_value()
389
+ If obj is str, int, long, float, bool, return directly.
390
+ If obj is datetime.datetime, datetime.date
391
+ convert to string in iso8601 format.
392
+ If obj is decimal.Decimal return string representation.
393
+ If obj is list, sanitize each element in the list.
394
+ If obj is dict, return the dict.
395
+ If obj is OpenAPI model, return the properties dict.
396
+
397
+ :param obj: The data to serialize.
398
+ :return: The serialized form of data.
399
+ """
400
+ if obj is None:
401
+ return None
402
+ elif isinstance(obj, Enum):
403
+ return obj.value
404
+ elif isinstance(obj, SecretStr):
405
+ return obj.get_secret_value()
406
+ elif isinstance(obj, self.PRIMITIVE_TYPES):
407
+ return obj
408
+ elif isinstance(obj, uuid.UUID):
409
+ return str(obj)
410
+ elif isinstance(obj, list):
411
+ return [
412
+ self.sanitize_for_serialization(sub_obj) for sub_obj in obj
413
+ ]
414
+ elif isinstance(obj, tuple):
415
+ return tuple(
416
+ self.sanitize_for_serialization(sub_obj) for sub_obj in obj
417
+ )
418
+ elif isinstance(obj, (datetime.datetime, datetime.date)):
419
+ return obj.isoformat()
420
+ elif isinstance(obj, decimal.Decimal):
421
+ return str(obj)
422
+ elif isinstance(obj, dict):
423
+ return {
424
+ key: self.sanitize_for_serialization(val)
425
+ for key, val in obj.items()
426
+ }
427
+
428
+ # Convert model obj to dict except
429
+ # attributes `openapi_types`, `attribute_map`
430
+ # and attributes which value is not None.
431
+ # Convert attribute name to json key in
432
+ # model definition for request.
433
+ to_dict = getattr(obj, 'to_dict', None)
434
+ to_openapi_dict = _get_openapi_to_dict(obj)
435
+ if to_openapi_dict is not None:
436
+ obj_dict = to_openapi_dict(obj)
437
+ elif callable(to_dict):
438
+ obj_dict = to_dict()
439
+ else:
440
+ obj_dict = obj.__dict__
441
+
442
+ return self.sanitize_for_serialization(obj_dict)
443
+
444
+
445
+ def deserialize(self, response_text: str, response_type: str, content_type: Optional[str]):
446
+ """Deserializes response into an object.
447
+
448
+ :param response: RESTResponse object to be deserialized.
449
+ :param response_type: class literal for
450
+ deserialized object, or string of class name.
451
+ :param content_type: content type of response.
452
+
453
+ :return: deserialized object.
454
+ """
455
+
456
+ # fetch data from response object
457
+ if content_type is None:
458
+ try:
459
+ data = json.loads(response_text)
460
+ except ValueError:
461
+ data = response_text
462
+ elif re.match(r'^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE):
463
+ if response_text == "":
464
+ data = ""
465
+ else:
466
+ data = json.loads(response_text)
467
+ elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE):
468
+ data = response_text
469
+ else:
470
+ raise ApiException(
471
+ status=0,
472
+ reason="Unsupported content type: {0}".format(content_type)
473
+ )
474
+
475
+ return self.__deserialize(data, response_type)
476
+
477
+ def __deserialize(self, data, klass):
478
+ """Deserializes dict, list, str into an object.
479
+
480
+ :param data: dict, list or str.
481
+ :param klass: class literal, or string of class name.
482
+
483
+ :return: object.
484
+ """
485
+ if data is None:
486
+ return None
487
+
488
+ if isinstance(klass, str):
489
+ if klass.startswith('List['):
490
+ m = re.match(r'List\[(.*)]', klass)
491
+ assert m is not None, "Malformed List type definition"
492
+ sub_kls = m.group(1)
493
+ return [self.__deserialize(sub_data, sub_kls)
494
+ for sub_data in data]
495
+
496
+ if klass.startswith('Dict['):
497
+ m = re.match(r'Dict\[([^,]*), (.*)]', klass)
498
+ assert m is not None, "Malformed Dict type definition"
499
+ sub_kls = m.group(2)
500
+ return {k: self.__deserialize(v, sub_kls)
501
+ for k, v in data.items()}
502
+
503
+ # convert str to class
504
+ if klass in self.NATIVE_TYPES_MAPPING:
505
+ klass = self.NATIVE_TYPES_MAPPING[klass]
506
+ else:
507
+ klass = getattr(vrchatapi.models, klass)
508
+
509
+ if klass in self.PRIMITIVE_TYPES:
510
+ return self.__deserialize_primitive(data, klass)
511
+ elif klass is object:
512
+ return self.__deserialize_object(data)
513
+ elif klass is datetime.date:
514
+ return self.__deserialize_date(data)
515
+ elif klass is datetime.datetime:
516
+ return self.__deserialize_datetime(data)
517
+ elif klass is decimal.Decimal:
518
+ return decimal.Decimal(data)
519
+ elif klass is uuid.UUID:
520
+ return uuid.UUID(data)
521
+ elif issubclass(klass, Enum):
522
+ return self.__deserialize_enum(data, klass)
523
+ else:
524
+ return self.__deserialize_model(data, klass)
525
+
526
+ def parameters_to_tuples(self, params, collection_formats):
527
+ """Get parameters as list of tuples, formatting collections.
528
+
529
+ :param params: Parameters as dict or list of two-tuples
530
+ :param dict collection_formats: Parameter collection formats
531
+ :return: Parameters as list of tuples, collections formatted
532
+ """
533
+ new_params: List[Tuple[str, str]] = []
534
+ if collection_formats is None:
535
+ collection_formats = {}
536
+ for k, v in params.items() if isinstance(params, dict) else params:
537
+ if k in collection_formats:
538
+ collection_format = collection_formats[k]
539
+ if collection_format == 'multi':
540
+ new_params.extend((k, value) for value in v)
541
+ else:
542
+ if collection_format == 'ssv':
543
+ delimiter = ' '
544
+ elif collection_format == 'tsv':
545
+ delimiter = '\t'
546
+ elif collection_format == 'pipes':
547
+ delimiter = '|'
548
+ else: # csv is the default
549
+ delimiter = ','
550
+ new_params.append(
551
+ (k, delimiter.join(str(value) for value in v)))
552
+ else:
553
+ new_params.append((k, v))
554
+ return new_params
555
+
556
+ def parameters_to_url_query(self, params, collection_formats):
557
+ """Get parameters as list of tuples, formatting collections.
558
+
559
+ :param params: Parameters as dict or list of two-tuples
560
+ :param dict collection_formats: Parameter collection formats
561
+ :return: URL query string (e.g. a=Hello%20World&b=123)
562
+ """
563
+ new_params: List[Tuple[str, str]] = []
564
+ if collection_formats is None:
565
+ collection_formats = {}
566
+ for k, v in params.items() if isinstance(params, dict) else params:
567
+ if isinstance(v, bool):
568
+ v = str(v).lower()
569
+ if isinstance(v, (int, float)):
570
+ v = str(v)
571
+ if isinstance(v, dict):
572
+ v = json.dumps(v)
573
+
574
+ if k in collection_formats:
575
+ collection_format = collection_formats[k]
576
+ if collection_format == 'multi':
577
+ new_params.extend((k, quote(str(value))) for value in v)
578
+ else:
579
+ if collection_format == 'ssv':
580
+ delimiter = ' '
581
+ elif collection_format == 'tsv':
582
+ delimiter = '\t'
583
+ elif collection_format == 'pipes':
584
+ delimiter = '|'
585
+ else: # csv is the default
586
+ delimiter = ','
587
+ new_params.append(
588
+ (k, delimiter.join(quote(str(value)) for value in v))
589
+ )
590
+ else:
591
+ new_params.append((k, quote(str(v))))
592
+
593
+ return "&".join(["=".join(map(str, item)) for item in new_params])
594
+
595
+ def files_parameters(
596
+ self,
597
+ files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]],
598
+ ):
599
+ """Builds form parameters.
600
+
601
+ :param files: File parameters.
602
+ :return: Form parameters with files.
603
+ """
604
+ params = []
605
+ for k, v in files.items():
606
+ if isinstance(v, str):
607
+ with open(v, 'rb') as f:
608
+ filename = os.path.basename(f.name)
609
+ filedata = f.read()
610
+ elif isinstance(v, bytes):
611
+ filename = k
612
+ filedata = v
613
+ elif isinstance(v, tuple):
614
+ filename, filedata = v
615
+ elif isinstance(v, list):
616
+ for file_param in v:
617
+ params.extend(self.files_parameters({k: file_param}))
618
+ continue
619
+ else:
620
+ raise ValueError("Unsupported file value")
621
+ mimetype = (
622
+ mimetypes.guess_type(filename)[0]
623
+ or 'application/octet-stream'
624
+ )
625
+ params.append(
626
+ tuple([k, tuple([filename, filedata, mimetype])])
627
+ )
628
+ return params
629
+
630
+ def select_header_accept(self, accepts: List[str]) -> Optional[str]:
631
+ """Returns `Accept` based on an array of accepts provided.
632
+
633
+ :param accepts: List of headers.
634
+ :return: Accept (e.g. application/json).
635
+ """
636
+ if not accepts:
637
+ return None
638
+
639
+ for accept in accepts:
640
+ if re.search('json', accept, re.IGNORECASE):
641
+ return accept
642
+
643
+ return accepts[0]
644
+
645
+ def select_header_content_type(self, content_types):
646
+ """Returns `Content-Type` based on an array of content_types provided.
647
+
648
+ :param content_types: List of content-types.
649
+ :return: Content-Type (e.g. application/json).
650
+ """
651
+ if not content_types:
652
+ return None
653
+
654
+ for content_type in content_types:
655
+ if re.search('json', content_type, re.IGNORECASE):
656
+ return content_type
657
+
658
+ return content_types[0]
659
+
660
+ def update_params_for_auth(
661
+ self,
662
+ headers,
663
+ queries,
664
+ auth_settings,
665
+ resource_path,
666
+ method,
667
+ body,
668
+ request_auth=None
669
+ ) -> None:
670
+ """Updates header and query params based on authentication setting.
671
+
672
+ :param headers: Header parameters dict to be updated.
673
+ :param queries: Query parameters tuple list to be updated.
674
+ :param auth_settings: Authentication setting identifiers list.
675
+ :resource_path: A string representation of the HTTP request resource path.
676
+ :method: A string representation of the HTTP request method.
677
+ :body: A object representing the body of the HTTP request.
678
+ The object type is the return value of sanitize_for_serialization().
679
+ :param request_auth: if set, the provided settings will
680
+ override the token in the configuration.
681
+ """
682
+ if not auth_settings:
683
+ return
684
+
685
+ if request_auth:
686
+ self._apply_auth_params(
687
+ headers,
688
+ queries,
689
+ resource_path,
690
+ method,
691
+ body,
692
+ request_auth
693
+ )
694
+ else:
695
+ for auth in auth_settings:
696
+ auth_setting = self.configuration.auth_settings().get(auth)
697
+ if auth_setting:
698
+ self._apply_auth_params(
699
+ headers,
700
+ queries,
701
+ resource_path,
702
+ method,
703
+ body,
704
+ auth_setting
705
+ )
706
+
707
+ def _apply_auth_params(
708
+ self,
709
+ headers,
710
+ queries,
711
+ resource_path,
712
+ method,
713
+ body,
714
+ auth_setting
715
+ ) -> None:
716
+ """Updates the request parameters based on a single auth_setting
717
+
718
+ :param headers: Header parameters dict to be updated.
719
+ :param queries: Query parameters tuple list to be updated.
720
+ :resource_path: A string representation of the HTTP request resource path.
721
+ :method: A string representation of the HTTP request method.
722
+ :body: A object representing the body of the HTTP request.
723
+ The object type is the return value of sanitize_for_serialization().
724
+ :param auth_setting: auth settings for the endpoint
725
+ """
726
+ if auth_setting['in'] == 'cookie':
727
+ if not 'Cookie' in headers:
728
+ headers['Cookie'] = ""
729
+ else:
730
+ headers['Cookie'] += "; "
731
+ # Account for cookie value containing spaces and special characters
732
+ cookie_value = str(auth_setting['value'])
733
+ if not re.match("^\".*\"$", cookie_value):
734
+ cookie_value = cookie_value.replace("\"", "\\\"")
735
+ cookie_value = f"\"{cookie_value}\""
736
+ headers['Cookie'] += f"{auth_setting['key']}={cookie_value}"
737
+ elif auth_setting['in'] == 'header':
738
+ if auth_setting['type'] != 'http-signature':
739
+ headers[auth_setting['key']] = auth_setting['value']
740
+ elif auth_setting['in'] == 'query':
741
+ queries.append((auth_setting['key'], auth_setting['value']))
742
+ else:
743
+ raise ApiValueError(
744
+ 'Authentication token must be in `query` or `header`'
745
+ )
746
+
747
+ def __deserialize_file(self, response):
748
+ """Deserializes body to file
749
+
750
+ Saves response body into a file in a temporary folder,
751
+ using the filename from the `Content-Disposition` header if provided.
752
+
753
+ handle file downloading
754
+ save response body into a tmp file and return the instance
755
+
756
+ :param response: RESTResponse.
757
+ :return: file path.
758
+ """
759
+ fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path)
760
+ os.close(fd)
761
+ os.remove(path)
762
+
763
+ content_disposition = response.headers.get("Content-Disposition")
764
+ if content_disposition:
765
+ m = re.search(
766
+ r'filename=[\'"]?([^\'"\s]+)[\'"]?',
767
+ content_disposition
768
+ )
769
+ assert m is not None, "Unexpected 'content-disposition' header value"
770
+ filename = os.path.basename(m.group(1)) # Strip any directory traversal
771
+ if filename in ("", ".", ".."): # fall back to tmp filename
772
+ filename = os.path.basename(path)
773
+ path = os.path.join(os.path.dirname(path), filename)
774
+
775
+ with open(path, "wb") as f:
776
+ f.write(response.data)
777
+
778
+ return path
779
+
780
+ def __deserialize_primitive(self, data, klass):
781
+ """Deserializes string to primitive type.
782
+
783
+ :param data: str.
784
+ :param klass: class literal.
785
+
786
+ :return: int, long, float, str, bool.
787
+ """
788
+ try:
789
+ return klass(data)
790
+ except UnicodeEncodeError:
791
+ return str(data)
792
+ except TypeError:
793
+ return data
794
+
795
+ def __deserialize_object(self, value):
796
+ """Return an original value.
797
+
798
+ :return: object.
799
+ """
800
+ return value
801
+
802
+ def __deserialize_date(self, string):
803
+ """Deserializes string to date.
804
+
805
+ :param string: str.
806
+ :return: date.
807
+ """
808
+ try:
809
+ return parse(string).date()
810
+ except ImportError:
811
+ return string
812
+ except ValueError:
813
+ raise rest.ApiException(
814
+ status=0,
815
+ reason="Failed to parse `{0}` as date object".format(string)
816
+ )
817
+
818
+ def __deserialize_datetime(self, string):
819
+ """Deserializes string to datetime.
820
+
821
+ The string should be in iso8601 datetime format.
822
+
823
+ :param string: str.
824
+ :return: datetime.
825
+ """
826
+ try:
827
+ return parse(string)
828
+ except ImportError:
829
+ return string
830
+ except ValueError:
831
+ raise rest.ApiException(
832
+ status=0,
833
+ reason=(
834
+ "Failed to parse `{0}` as datetime object"
835
+ .format(string)
836
+ )
837
+ )
838
+
839
+ def __deserialize_enum(self, data, klass):
840
+ """Deserializes primitive type to enum.
841
+
842
+ :param data: primitive type.
843
+ :param klass: class literal.
844
+ :return: enum value.
845
+ """
846
+ try:
847
+ return klass(data)
848
+ except ValueError:
849
+ raise rest.ApiException(
850
+ status=0,
851
+ reason=(
852
+ "Failed to parse `{0}` as `{1}`"
853
+ .format(data, klass)
854
+ )
855
+ )
856
+
857
+ def __deserialize_model(self, data, klass):
858
+ """Deserializes list or dict to model.
859
+
860
+ :param data: dict, list.
861
+ :param klass: class literal.
862
+ :return: model object.
863
+ """
864
+
865
+ return klass.from_dict(data)