revengai 2.74.0__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 (314) hide show
  1. revengai/__init__.py +647 -0
  2. revengai/api/__init__.py +22 -0
  3. revengai/api/analyses_comments_api.py +1198 -0
  4. revengai/api/analyses_core_api.py +3870 -0
  5. revengai/api/analyses_dynamic_execution_api.py +1884 -0
  6. revengai/api/analyses_results_metadata_api.py +2240 -0
  7. revengai/api/analyses_security_checks_api.py +862 -0
  8. revengai/api/authentication_users_api.py +1323 -0
  9. revengai/api/binaries_api.py +1610 -0
  10. revengai/api/collections_api.py +2167 -0
  11. revengai/api/external_sources_api.py +827 -0
  12. revengai/api/firmware_api.py +592 -0
  13. revengai/api/functions_ai_decompilation_api.py +2592 -0
  14. revengai/api/functions_block_comments_api.py +849 -0
  15. revengai/api/functions_core_api.py +3430 -0
  16. revengai/api/functions_data_types_api.py +1746 -0
  17. revengai/api/functions_decompilation_api.py +1198 -0
  18. revengai/api/functions_renaming_history_api.py +1151 -0
  19. revengai/api/models_api.py +284 -0
  20. revengai/api/search_api.py +1454 -0
  21. revengai/api_client.py +803 -0
  22. revengai/api_response.py +21 -0
  23. revengai/configuration.py +605 -0
  24. revengai/exceptions.py +215 -0
  25. revengai/models/__init__.py +298 -0
  26. revengai/models/addr.py +143 -0
  27. revengai/models/ai_decompilation_rating.py +37 -0
  28. revengai/models/ai_unstrip_request.py +86 -0
  29. revengai/models/analysis_access_info.py +88 -0
  30. revengai/models/analysis_config.py +106 -0
  31. revengai/models/analysis_create_request.py +131 -0
  32. revengai/models/analysis_create_response.py +88 -0
  33. revengai/models/analysis_detail_response.py +121 -0
  34. revengai/models/analysis_function_mapping.py +90 -0
  35. revengai/models/analysis_function_matching_request.py +110 -0
  36. revengai/models/analysis_functions.py +94 -0
  37. revengai/models/analysis_functions_list.py +94 -0
  38. revengai/models/analysis_record.py +128 -0
  39. revengai/models/analysis_scope.py +36 -0
  40. revengai/models/analysis_strings_response.py +96 -0
  41. revengai/models/analysis_tags.py +94 -0
  42. revengai/models/analysis_update_request.py +108 -0
  43. revengai/models/analysis_update_tags_request.py +86 -0
  44. revengai/models/analysis_update_tags_response.py +94 -0
  45. revengai/models/app_api_rest_v2_analyses_enums_dynamic_execution_status.py +38 -0
  46. revengai/models/app_api_rest_v2_analyses_enums_order_by.py +37 -0
  47. revengai/models/app_api_rest_v2_collections_enums_order_by.py +40 -0
  48. revengai/models/app_api_rest_v2_functions_responses_function.py +93 -0
  49. revengai/models/app_api_rest_v2_functions_types_function.py +110 -0
  50. revengai/models/app_services_dynamic_execution_schemas_dynamic_execution_status.py +86 -0
  51. revengai/models/argument.py +99 -0
  52. revengai/models/auto_unstrip_request.py +99 -0
  53. revengai/models/auto_unstrip_response.py +129 -0
  54. revengai/models/base_response.py +124 -0
  55. revengai/models/base_response_analysis_create_response.py +125 -0
  56. revengai/models/base_response_analysis_detail_response.py +125 -0
  57. revengai/models/base_response_analysis_function_mapping.py +125 -0
  58. revengai/models/base_response_analysis_functions.py +125 -0
  59. revengai/models/base_response_analysis_functions_list.py +125 -0
  60. revengai/models/base_response_analysis_strings_response.py +125 -0
  61. revengai/models/base_response_analysis_tags.py +125 -0
  62. revengai/models/base_response_analysis_update_tags_response.py +125 -0
  63. revengai/models/base_response_basic.py +125 -0
  64. revengai/models/base_response_binary_additional_response.py +125 -0
  65. revengai/models/base_response_binary_details_response.py +125 -0
  66. revengai/models/base_response_binary_externals_response.py +125 -0
  67. revengai/models/base_response_binary_search_response.py +125 -0
  68. revengai/models/base_response_block_comments_generation_for_function_response.py +125 -0
  69. revengai/models/base_response_block_comments_overview_generation_response.py +116 -0
  70. revengai/models/base_response_bool.py +121 -0
  71. revengai/models/base_response_callees_caller_functions_response.py +125 -0
  72. revengai/models/base_response_capabilities.py +125 -0
  73. revengai/models/base_response_check_security_checks_task_response.py +125 -0
  74. revengai/models/base_response_child_binaries_response.py +125 -0
  75. revengai/models/base_response_collection_binaries_update_response.py +125 -0
  76. revengai/models/base_response_collection_response.py +125 -0
  77. revengai/models/base_response_collection_search_response.py +125 -0
  78. revengai/models/base_response_collection_tags_update_response.py +125 -0
  79. revengai/models/base_response_comment_response.py +125 -0
  80. revengai/models/base_response_communities.py +125 -0
  81. revengai/models/base_response_created.py +125 -0
  82. revengai/models/base_response_dict.py +121 -0
  83. revengai/models/base_response_dynamic_execution_status.py +125 -0
  84. revengai/models/base_response_external_response.py +125 -0
  85. revengai/models/base_response_function_blocks_response.py +125 -0
  86. revengai/models/base_response_function_capability_response.py +125 -0
  87. revengai/models/base_response_function_data_types.py +125 -0
  88. revengai/models/base_response_function_data_types_list.py +125 -0
  89. revengai/models/base_response_function_search_response.py +125 -0
  90. revengai/models/base_response_function_strings_response.py +125 -0
  91. revengai/models/base_response_function_task_response.py +125 -0
  92. revengai/models/base_response_functions_detail_response.py +125 -0
  93. revengai/models/base_response_generate_function_data_types.py +125 -0
  94. revengai/models/base_response_generation_status_list.py +125 -0
  95. revengai/models/base_response_get_ai_decompilation_rating_response.py +125 -0
  96. revengai/models/base_response_get_ai_decompilation_task.py +125 -0
  97. revengai/models/base_response_get_me_response.py +125 -0
  98. revengai/models/base_response_get_public_user_response.py +125 -0
  99. revengai/models/base_response_list_collection_results.py +125 -0
  100. revengai/models/base_response_list_comment_response.py +129 -0
  101. revengai/models/base_response_list_die_match.py +129 -0
  102. revengai/models/base_response_list_function_name_history.py +129 -0
  103. revengai/models/base_response_list_sbom.py +129 -0
  104. revengai/models/base_response_list_user_activity_response.py +129 -0
  105. revengai/models/base_response_login_response.py +125 -0
  106. revengai/models/base_response_logs.py +125 -0
  107. revengai/models/base_response_models_response.py +125 -0
  108. revengai/models/base_response_network_overview_response.py +125 -0
  109. revengai/models/base_response_params.py +125 -0
  110. revengai/models/base_response_process_dumps.py +125 -0
  111. revengai/models/base_response_process_registry.py +125 -0
  112. revengai/models/base_response_process_tree.py +125 -0
  113. revengai/models/base_response_queued_security_checks_task_response.py +125 -0
  114. revengai/models/base_response_recent.py +125 -0
  115. revengai/models/base_response_security_checks_response.py +125 -0
  116. revengai/models/base_response_status.py +125 -0
  117. revengai/models/base_response_str.py +121 -0
  118. revengai/models/base_response_tag_search_response.py +125 -0
  119. revengai/models/base_response_task_response.py +125 -0
  120. revengai/models/base_response_ttps.py +125 -0
  121. revengai/models/base_response_upload_response.py +125 -0
  122. revengai/models/base_response_vulnerabilities.py +125 -0
  123. revengai/models/basic.py +116 -0
  124. revengai/models/binary_additional_details_data_response.py +112 -0
  125. revengai/models/binary_additional_response.py +105 -0
  126. revengai/models/binary_config.py +108 -0
  127. revengai/models/binary_details_response.py +125 -0
  128. revengai/models/binary_externals_response.py +95 -0
  129. revengai/models/binary_search_response.py +94 -0
  130. revengai/models/binary_search_result.py +108 -0
  131. revengai/models/binary_task_status.py +39 -0
  132. revengai/models/block.py +86 -0
  133. revengai/models/block_comments_generation_for_function_response.py +86 -0
  134. revengai/models/callee_function_info.py +106 -0
  135. revengai/models/callees_caller_functions_response.py +106 -0
  136. revengai/models/caller_function_info.py +106 -0
  137. revengai/models/capabilities.py +94 -0
  138. revengai/models/capability.py +90 -0
  139. revengai/models/check_security_checks_task_response.py +87 -0
  140. revengai/models/child_binaries_response.py +104 -0
  141. revengai/models/code_signature_model.py +98 -0
  142. revengai/models/collection_binaries_update_request.py +86 -0
  143. revengai/models/collection_binaries_update_response.py +94 -0
  144. revengai/models/collection_binary_response.py +97 -0
  145. revengai/models/collection_create_request.py +107 -0
  146. revengai/models/collection_list_item.py +112 -0
  147. revengai/models/collection_response.py +131 -0
  148. revengai/models/collection_response_binaries_inner.py +135 -0
  149. revengai/models/collection_scope.py +38 -0
  150. revengai/models/collection_search_response.py +94 -0
  151. revengai/models/collection_search_result.py +124 -0
  152. revengai/models/collection_tags_update_request.py +86 -0
  153. revengai/models/collection_tags_update_response.py +86 -0
  154. revengai/models/collection_update_request.py +106 -0
  155. revengai/models/comment_base.py +86 -0
  156. revengai/models/comment_response.py +110 -0
  157. revengai/models/comment_update_request.py +86 -0
  158. revengai/models/communities.py +100 -0
  159. revengai/models/community_match_percentages.py +92 -0
  160. revengai/models/confidence_type.py +39 -0
  161. revengai/models/context.py +141 -0
  162. revengai/models/created.py +90 -0
  163. revengai/models/decompilation_comment_context.py +98 -0
  164. revengai/models/die_match.py +92 -0
  165. revengai/models/dynamic_execution_status_input.py +38 -0
  166. revengai/models/elf_dynamic_entry.py +88 -0
  167. revengai/models/elf_import_model.py +88 -0
  168. revengai/models/elf_model.py +179 -0
  169. revengai/models/elf_relocation.py +98 -0
  170. revengai/models/elf_section.py +104 -0
  171. revengai/models/elf_security.py +94 -0
  172. revengai/models/elf_segment.py +102 -0
  173. revengai/models/elf_symbol.py +98 -0
  174. revengai/models/entrypoint_model.py +88 -0
  175. revengai/models/enumeration.py +97 -0
  176. revengai/models/error_model.py +88 -0
  177. revengai/models/export_model.py +88 -0
  178. revengai/models/external_response.py +91 -0
  179. revengai/models/file_format.py +37 -0
  180. revengai/models/file_hashes.py +140 -0
  181. revengai/models/file_metadata.py +96 -0
  182. revengai/models/filters.py +39 -0
  183. revengai/models/function_block_destination_response.py +95 -0
  184. revengai/models/function_block_response.py +109 -0
  185. revengai/models/function_blocks_response.py +121 -0
  186. revengai/models/function_boundary.py +90 -0
  187. revengai/models/function_capability_response.py +86 -0
  188. revengai/models/function_comment_create_request.py +92 -0
  189. revengai/models/function_data_types.py +106 -0
  190. revengai/models/function_data_types_list.py +98 -0
  191. revengai/models/function_data_types_list_item.py +108 -0
  192. revengai/models/function_data_types_params.py +86 -0
  193. revengai/models/function_data_types_status.py +90 -0
  194. revengai/models/function_header.py +112 -0
  195. revengai/models/function_info_input.py +105 -0
  196. revengai/models/function_info_input_func_deps_inner.py +163 -0
  197. revengai/models/function_info_output.py +105 -0
  198. revengai/models/function_list_item.py +96 -0
  199. revengai/models/function_local_variable_response.py +94 -0
  200. revengai/models/function_mapping.py +90 -0
  201. revengai/models/function_mapping_full.py +275 -0
  202. revengai/models/function_match.py +111 -0
  203. revengai/models/function_matching_filters.py +103 -0
  204. revengai/models/function_matching_request.py +114 -0
  205. revengai/models/function_matching_response.py +157 -0
  206. revengai/models/function_name_history.py +99 -0
  207. revengai/models/function_param_response.py +94 -0
  208. revengai/models/function_rename.py +88 -0
  209. revengai/models/function_rename_map.py +90 -0
  210. revengai/models/function_search_response.py +94 -0
  211. revengai/models/function_search_result.py +99 -0
  212. revengai/models/function_source_type.py +39 -0
  213. revengai/models/function_string.py +88 -0
  214. revengai/models/function_strings_response.py +96 -0
  215. revengai/models/function_task_response.py +94 -0
  216. revengai/models/function_task_status.py +39 -0
  217. revengai/models/function_type_input.py +127 -0
  218. revengai/models/function_type_output.py +127 -0
  219. revengai/models/functions_detail_response.py +125 -0
  220. revengai/models/functions_list_rename.py +94 -0
  221. revengai/models/generate_function_data_types.py +94 -0
  222. revengai/models/generation_status_list.py +98 -0
  223. revengai/models/get_ai_decompilation_rating_response.py +94 -0
  224. revengai/models/get_ai_decompilation_task.py +159 -0
  225. revengai/models/get_me_response.py +108 -0
  226. revengai/models/get_public_user_response.py +88 -0
  227. revengai/models/global_variable.py +101 -0
  228. revengai/models/icon_model.py +91 -0
  229. revengai/models/import_model.py +88 -0
  230. revengai/models/inverse_function_map_item.py +99 -0
  231. revengai/models/inverse_string_map_item.py +93 -0
  232. revengai/models/inverse_value.py +86 -0
  233. revengai/models/isa.py +37 -0
  234. revengai/models/list_collection_results.py +94 -0
  235. revengai/models/login_request.py +89 -0
  236. revengai/models/login_response.py +86 -0
  237. revengai/models/logs.py +86 -0
  238. revengai/models/matched_function.py +116 -0
  239. revengai/models/matched_function_suggestion.py +97 -0
  240. revengai/models/meta_model.py +95 -0
  241. revengai/models/model_name.py +40 -0
  242. revengai/models/models_response.py +86 -0
  243. revengai/models/name_confidence.py +89 -0
  244. revengai/models/network_overview_dns.py +98 -0
  245. revengai/models/network_overview_dns_answer.py +88 -0
  246. revengai/models/network_overview_metadata.py +99 -0
  247. revengai/models/network_overview_response.py +104 -0
  248. revengai/models/order.py +36 -0
  249. revengai/models/pagination_model.py +90 -0
  250. revengai/models/params.py +103 -0
  251. revengai/models/pdb_debug_model.py +94 -0
  252. revengai/models/pe_model.py +215 -0
  253. revengai/models/platform.py +36 -0
  254. revengai/models/process.py +103 -0
  255. revengai/models/process_dump.py +96 -0
  256. revengai/models/process_dump_metadata.py +90 -0
  257. revengai/models/process_dumps.py +92 -0
  258. revengai/models/process_dumps_data.py +96 -0
  259. revengai/models/process_registry.py +105 -0
  260. revengai/models/process_tree.py +96 -0
  261. revengai/models/queued_security_checks_task_response.py +86 -0
  262. revengai/models/re_analysis_form.py +101 -0
  263. revengai/models/recent.py +94 -0
  264. revengai/models/registry.py +102 -0
  265. revengai/models/relative_binary_response.py +90 -0
  266. revengai/models/sandbox_options.py +88 -0
  267. revengai/models/sbom.py +96 -0
  268. revengai/models/sbom_package.py +88 -0
  269. revengai/models/scrape_third_party_config.py +86 -0
  270. revengai/models/section_model.py +96 -0
  271. revengai/models/security_checks_response.py +98 -0
  272. revengai/models/security_checks_result.py +103 -0
  273. revengai/models/security_model.py +106 -0
  274. revengai/models/severity_type.py +40 -0
  275. revengai/models/single_code_certificate_model.py +96 -0
  276. revengai/models/single_code_signature_model.py +96 -0
  277. revengai/models/single_pdb_entry_model.py +90 -0
  278. revengai/models/single_section_model.py +98 -0
  279. revengai/models/stack_variable.py +101 -0
  280. revengai/models/status_input.py +40 -0
  281. revengai/models/status_output.py +88 -0
  282. revengai/models/string_functions.py +96 -0
  283. revengai/models/structure.py +117 -0
  284. revengai/models/structure_member.py +99 -0
  285. revengai/models/symbols.py +96 -0
  286. revengai/models/tag.py +86 -0
  287. revengai/models/tag_item.py +95 -0
  288. revengai/models/tag_response.py +88 -0
  289. revengai/models/tag_search_response.py +94 -0
  290. revengai/models/tag_search_result.py +88 -0
  291. revengai/models/task_response.py +94 -0
  292. revengai/models/task_status.py +39 -0
  293. revengai/models/timestamp_model.py +90 -0
  294. revengai/models/ttps.py +92 -0
  295. revengai/models/ttps_attack.py +88 -0
  296. revengai/models/ttps_data.py +96 -0
  297. revengai/models/ttps_element.py +108 -0
  298. revengai/models/ttps_occurance.py +88 -0
  299. revengai/models/type_definition.py +97 -0
  300. revengai/models/update_function_data_types.py +92 -0
  301. revengai/models/upload_file_type.py +38 -0
  302. revengai/models/upload_response.py +91 -0
  303. revengai/models/upsert_ai_decomplation_rating_request.py +94 -0
  304. revengai/models/user_activity_response.py +97 -0
  305. revengai/models/vulnerabilities.py +94 -0
  306. revengai/models/vulnerability.py +113 -0
  307. revengai/models/vulnerability_type.py +40 -0
  308. revengai/models/workspace.py +37 -0
  309. revengai/py.typed +0 -0
  310. revengai/rest.py +257 -0
  311. revengai-2.74.0.dist-info/METADATA +447 -0
  312. revengai-2.74.0.dist-info/RECORD +314 -0
  313. revengai-2.74.0.dist-info/WHEEL +4 -0
  314. revengai-2.74.0.dist-info/licenses/LICENSE.md +19 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Optional, Generic, Mapping, TypeVar
5
+ from pydantic import Field, StrictInt, StrictBytes, BaseModel
6
+
7
+ T = TypeVar("T")
8
+
9
+ class ApiResponse(BaseModel, Generic[T]):
10
+ """
11
+ API response object
12
+ """
13
+
14
+ status_code: StrictInt = Field(description="HTTP status code")
15
+ headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
18
+
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
@@ -0,0 +1,605 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ RevEng.AI API
5
+
6
+ RevEng.AI is Similarity Search Engine for executable binaries
7
+
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+
14
+ import copy
15
+ import http.client as httplib
16
+ import logging
17
+ from logging import FileHandler
18
+ import multiprocessing
19
+ import sys
20
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
21
+ from typing_extensions import NotRequired, Self
22
+
23
+ import urllib3
24
+
25
+
26
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
27
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
28
+ 'minimum', 'exclusiveMinimum', 'maxLength',
29
+ 'minLength', 'pattern', 'maxItems', 'minItems'
30
+ }
31
+
32
+ ServerVariablesT = Dict[str, str]
33
+
34
+ GenericAuthSetting = TypedDict(
35
+ "GenericAuthSetting",
36
+ {
37
+ "type": str,
38
+ "in": str,
39
+ "key": str,
40
+ "value": str,
41
+ },
42
+ )
43
+
44
+
45
+ OAuth2AuthSetting = TypedDict(
46
+ "OAuth2AuthSetting",
47
+ {
48
+ "type": Literal["oauth2"],
49
+ "in": Literal["header"],
50
+ "key": Literal["Authorization"],
51
+ "value": str,
52
+ },
53
+ )
54
+
55
+
56
+ APIKeyAuthSetting = TypedDict(
57
+ "APIKeyAuthSetting",
58
+ {
59
+ "type": Literal["api_key"],
60
+ "in": str,
61
+ "key": str,
62
+ "value": Optional[str],
63
+ },
64
+ )
65
+
66
+
67
+ BasicAuthSetting = TypedDict(
68
+ "BasicAuthSetting",
69
+ {
70
+ "type": Literal["basic"],
71
+ "in": Literal["header"],
72
+ "key": Literal["Authorization"],
73
+ "value": Optional[str],
74
+ },
75
+ )
76
+
77
+
78
+ BearerFormatAuthSetting = TypedDict(
79
+ "BearerFormatAuthSetting",
80
+ {
81
+ "type": Literal["bearer"],
82
+ "in": Literal["header"],
83
+ "format": Literal["JWT"],
84
+ "key": Literal["Authorization"],
85
+ "value": str,
86
+ },
87
+ )
88
+
89
+
90
+ BearerAuthSetting = TypedDict(
91
+ "BearerAuthSetting",
92
+ {
93
+ "type": Literal["bearer"],
94
+ "in": Literal["header"],
95
+ "key": Literal["Authorization"],
96
+ "value": str,
97
+ },
98
+ )
99
+
100
+
101
+ HTTPSignatureAuthSetting = TypedDict(
102
+ "HTTPSignatureAuthSetting",
103
+ {
104
+ "type": Literal["http-signature"],
105
+ "in": Literal["header"],
106
+ "key": Literal["Authorization"],
107
+ "value": None,
108
+ },
109
+ )
110
+
111
+
112
+ AuthSettings = TypedDict(
113
+ "AuthSettings",
114
+ {
115
+ "APIKey": APIKeyAuthSetting,
116
+ },
117
+ total=False,
118
+ )
119
+
120
+
121
+ class HostSettingVariable(TypedDict):
122
+ description: str
123
+ default_value: str
124
+ enum_values: List[str]
125
+
126
+
127
+ class HostSetting(TypedDict):
128
+ url: str
129
+ description: str
130
+ variables: NotRequired[Dict[str, HostSettingVariable]]
131
+
132
+
133
+ class Configuration:
134
+ """This class contains various settings of the API client.
135
+
136
+ :param host: Base url.
137
+ :param ignore_operation_servers
138
+ Boolean to ignore operation servers for the API client.
139
+ Config will use `host` as the base url regardless of the operation servers.
140
+ :param api_key: Dict to store API key(s).
141
+ Each entry in the dict specifies an API key.
142
+ The dict key is the name of the security scheme in the OAS specification.
143
+ The dict value is the API key secret.
144
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
145
+ The dict key is the name of the security scheme in the OAS specification.
146
+ The dict value is an API key prefix when generating the auth data.
147
+ :param username: Username for HTTP basic authentication.
148
+ :param password: Password for HTTP basic authentication.
149
+ :param access_token: Access token.
150
+ :param server_index: Index to servers configuration.
151
+ :param server_variables: Mapping with string values to replace variables in
152
+ templated server configuration. The validation of enums is performed for
153
+ variables with defined enum values before.
154
+ :param server_operation_index: Mapping from operation ID to an index to server
155
+ configuration.
156
+ :param server_operation_variables: Mapping from operation ID to a mapping with
157
+ string values to replace variables in templated server configuration.
158
+ The validation of enums is performed for variables with defined enum
159
+ values before.
160
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
161
+ in PEM format.
162
+ :param retries: Number of retries for API requests.
163
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
164
+ in PEM (str) or DER (bytes) format.
165
+ :param cert_file: the path to a client certificate file, for mTLS.
166
+ :param key_file: the path to a client key file, for mTLS.
167
+
168
+ :Example:
169
+
170
+ API Key Authentication Example.
171
+ Given the following security scheme in the OpenAPI specification:
172
+ components:
173
+ securitySchemes:
174
+ cookieAuth: # name for the security scheme
175
+ type: apiKey
176
+ in: cookie
177
+ name: JSESSIONID # cookie name
178
+
179
+ You can programmatically set the cookie:
180
+
181
+ conf = revengai.Configuration(
182
+ api_key={'cookieAuth': 'abc123'}
183
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
184
+ )
185
+
186
+ The following cookie will be added to the HTTP request:
187
+ Cookie: JSESSIONID abc123
188
+ """
189
+
190
+ _default: ClassVar[Optional[Self]] = None
191
+
192
+ def __init__(
193
+ self,
194
+ host: Optional[str]=None,
195
+ api_key: Optional[Dict[str, str]]=None,
196
+ api_key_prefix: Optional[Dict[str, str]]=None,
197
+ username: Optional[str]=None,
198
+ password: Optional[str]=None,
199
+ access_token: Optional[str]=None,
200
+ server_index: Optional[int]=None,
201
+ server_variables: Optional[ServerVariablesT]=None,
202
+ server_operation_index: Optional[Dict[int, int]]=None,
203
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
204
+ ignore_operation_servers: bool=False,
205
+ ssl_ca_cert: Optional[str]=None,
206
+ retries: Optional[int] = None,
207
+ ca_cert_data: Optional[Union[str, bytes]] = None,
208
+ cert_file: Optional[str]=None,
209
+ key_file: Optional[str]=None,
210
+ *,
211
+ debug: Optional[bool] = None,
212
+ ) -> None:
213
+ """Constructor
214
+ """
215
+ self._base_path = "https://api.reveng.ai" if host is None else host
216
+ """Default Base url
217
+ """
218
+ self.server_index = 0 if server_index is None and host is None else server_index
219
+ self.server_operation_index = server_operation_index or {}
220
+ """Default server index
221
+ """
222
+ self.server_variables = server_variables or {}
223
+ self.server_operation_variables = server_operation_variables or {}
224
+ """Default server variables
225
+ """
226
+ self.ignore_operation_servers = ignore_operation_servers
227
+ """Ignore operation servers
228
+ """
229
+ self.temp_folder_path = None
230
+ """Temp file folder for downloading files
231
+ """
232
+ # Authentication Settings
233
+ self.api_key = {}
234
+ if api_key:
235
+ self.api_key = api_key
236
+ """dict to store API key(s)
237
+ """
238
+ self.api_key_prefix = {}
239
+ if api_key_prefix:
240
+ self.api_key_prefix = api_key_prefix
241
+ """dict to store API prefix (e.g. Bearer)
242
+ """
243
+ self.refresh_api_key_hook = None
244
+ """function hook to refresh API key if expired
245
+ """
246
+ self.username = username
247
+ """Username for HTTP basic authentication
248
+ """
249
+ self.password = password
250
+ """Password for HTTP basic authentication
251
+ """
252
+ self.access_token = access_token
253
+ """Access token
254
+ """
255
+ self.logger = {}
256
+ """Logging Settings
257
+ """
258
+ self.logger["package_logger"] = logging.getLogger("revengai")
259
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
260
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
261
+ """Log format
262
+ """
263
+ self.logger_stream_handler = None
264
+ """Log stream handler
265
+ """
266
+ self.logger_file_handler: Optional[FileHandler] = None
267
+ """Log file handler
268
+ """
269
+ self.logger_file = None
270
+ """Debug file location
271
+ """
272
+ if debug is not None:
273
+ self.debug = debug
274
+ else:
275
+ self.__debug = False
276
+ """Debug switch
277
+ """
278
+
279
+ self.verify_ssl = True
280
+ """SSL/TLS verification
281
+ Set this to false to skip verifying SSL certificate when calling API
282
+ from https server.
283
+ """
284
+ self.ssl_ca_cert = ssl_ca_cert
285
+ """Set this to customize the certificate file to verify the peer.
286
+ """
287
+ self.ca_cert_data = ca_cert_data
288
+ """Set this to verify the peer using PEM (str) or DER (bytes)
289
+ certificate data.
290
+ """
291
+ self.cert_file = cert_file
292
+ """client certificate file
293
+ """
294
+ self.key_file = key_file
295
+ """client key file
296
+ """
297
+ self.assert_hostname = None
298
+ """Set this to True/False to enable/disable SSL hostname verification.
299
+ """
300
+ self.tls_server_name = None
301
+ """SSL/TLS Server Name Indication (SNI)
302
+ Set this to the SNI value expected by the server.
303
+ """
304
+
305
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
306
+ """urllib3 connection pool's maximum number of connections saved
307
+ per pool. urllib3 uses 1 connection as default value, but this is
308
+ not the best value when you are making a lot of possibly parallel
309
+ requests to the same host, which is often the case here.
310
+ cpu_count * 5 is used as default value to increase performance.
311
+ """
312
+
313
+ self.proxy: Optional[str] = None
314
+ """Proxy URL
315
+ """
316
+ self.proxy_headers = None
317
+ """Proxy headers
318
+ """
319
+ self.safe_chars_for_path_param = ''
320
+ """Safe chars for path_param
321
+ """
322
+ self.retries = retries
323
+ """Adding retries to override urllib3 default value 3
324
+ """
325
+ # Enable client side validation
326
+ self.client_side_validation = True
327
+
328
+ self.socket_options = None
329
+ """Options to pass down to the underlying urllib3 socket
330
+ """
331
+
332
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
333
+ """datetime format
334
+ """
335
+
336
+ self.date_format = "%Y-%m-%d"
337
+ """date format
338
+ """
339
+
340
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
341
+ cls = self.__class__
342
+ result = cls.__new__(cls)
343
+ memo[id(self)] = result
344
+ for k, v in self.__dict__.items():
345
+ if k not in ('logger', 'logger_file_handler'):
346
+ setattr(result, k, copy.deepcopy(v, memo))
347
+ # shallow copy of loggers
348
+ result.logger = copy.copy(self.logger)
349
+ # use setters to configure loggers
350
+ result.logger_file = self.logger_file
351
+ result.debug = self.debug
352
+ return result
353
+
354
+ def __setattr__(self, name: str, value: Any) -> None:
355
+ object.__setattr__(self, name, value)
356
+
357
+ @classmethod
358
+ def set_default(cls, default: Optional[Self]) -> None:
359
+ """Set default instance of configuration.
360
+
361
+ It stores default configuration, which can be
362
+ returned by get_default_copy method.
363
+
364
+ :param default: object of Configuration
365
+ """
366
+ cls._default = default
367
+
368
+ @classmethod
369
+ def get_default_copy(cls) -> Self:
370
+ """Deprecated. Please use `get_default` instead.
371
+
372
+ Deprecated. Please use `get_default` instead.
373
+
374
+ :return: The configuration object.
375
+ """
376
+ return cls.get_default()
377
+
378
+ @classmethod
379
+ def get_default(cls) -> Self:
380
+ """Return the default configuration.
381
+
382
+ This method returns newly created, based on default constructor,
383
+ object of Configuration class or returns a copy of default
384
+ configuration.
385
+
386
+ :return: The configuration object.
387
+ """
388
+ if cls._default is None:
389
+ cls._default = cls()
390
+ return cls._default
391
+
392
+ @property
393
+ def logger_file(self) -> Optional[str]:
394
+ """The logger file.
395
+
396
+ If the logger_file is None, then add stream handler and remove file
397
+ handler. Otherwise, add file handler and remove stream handler.
398
+
399
+ :param value: The logger_file path.
400
+ :type: str
401
+ """
402
+ return self.__logger_file
403
+
404
+ @logger_file.setter
405
+ def logger_file(self, value: Optional[str]) -> None:
406
+ """The logger file.
407
+
408
+ If the logger_file is None, then add stream handler and remove file
409
+ handler. Otherwise, add file handler and remove stream handler.
410
+
411
+ :param value: The logger_file path.
412
+ :type: str
413
+ """
414
+ self.__logger_file = value
415
+ if self.__logger_file:
416
+ # If set logging file,
417
+ # then add file handler and remove stream handler.
418
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
419
+ self.logger_file_handler.setFormatter(self.logger_formatter)
420
+ for _, logger in self.logger.items():
421
+ logger.addHandler(self.logger_file_handler)
422
+
423
+ @property
424
+ def debug(self) -> bool:
425
+ """Debug status
426
+
427
+ :param value: The debug status, True or False.
428
+ :type: bool
429
+ """
430
+ return self.__debug
431
+
432
+ @debug.setter
433
+ def debug(self, value: bool) -> None:
434
+ """Debug status
435
+
436
+ :param value: The debug status, True or False.
437
+ :type: bool
438
+ """
439
+ self.__debug = value
440
+ if self.__debug:
441
+ # if debug status is True, turn on debug logging
442
+ for _, logger in self.logger.items():
443
+ logger.setLevel(logging.DEBUG)
444
+ # turn on httplib debug
445
+ httplib.HTTPConnection.debuglevel = 1
446
+ else:
447
+ # if debug status is False, turn off debug logging,
448
+ # setting log level to default `logging.WARNING`
449
+ for _, logger in self.logger.items():
450
+ logger.setLevel(logging.WARNING)
451
+ # turn off httplib debug
452
+ httplib.HTTPConnection.debuglevel = 0
453
+
454
+ @property
455
+ def logger_format(self) -> str:
456
+ """The logger format.
457
+
458
+ The logger_formatter will be updated when sets logger_format.
459
+
460
+ :param value: The format string.
461
+ :type: str
462
+ """
463
+ return self.__logger_format
464
+
465
+ @logger_format.setter
466
+ def logger_format(self, value: str) -> None:
467
+ """The logger format.
468
+
469
+ The logger_formatter will be updated when sets logger_format.
470
+
471
+ :param value: The format string.
472
+ :type: str
473
+ """
474
+ self.__logger_format = value
475
+ self.logger_formatter = logging.Formatter(self.__logger_format)
476
+
477
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
478
+ """Gets API key (with prefix if set).
479
+
480
+ :param identifier: The identifier of apiKey.
481
+ :param alias: The alternative identifier of apiKey.
482
+ :return: The token for api key authentication.
483
+ """
484
+ if self.refresh_api_key_hook is not None:
485
+ self.refresh_api_key_hook(self)
486
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
487
+ if key:
488
+ prefix = self.api_key_prefix.get(identifier)
489
+ if prefix:
490
+ return "%s %s" % (prefix, key)
491
+ else:
492
+ return key
493
+
494
+ return None
495
+
496
+ def get_basic_auth_token(self) -> Optional[str]:
497
+ """Gets HTTP basic authentication header (string).
498
+
499
+ :return: The token for basic HTTP authentication.
500
+ """
501
+ username = ""
502
+ if self.username is not None:
503
+ username = self.username
504
+ password = ""
505
+ if self.password is not None:
506
+ password = self.password
507
+ return urllib3.util.make_headers(
508
+ basic_auth=username + ':' + password
509
+ ).get('authorization')
510
+
511
+ def auth_settings(self)-> AuthSettings:
512
+ """Gets Auth Settings dict for api client.
513
+
514
+ :return: The Auth Settings information dict.
515
+ """
516
+ auth: AuthSettings = {}
517
+ if 'APIKey' in self.api_key:
518
+ auth['APIKey'] = {
519
+ 'type': 'api_key',
520
+ 'in': 'header',
521
+ 'key': 'Authorization',
522
+ 'value': self.get_api_key_with_prefix(
523
+ 'APIKey',
524
+ ),
525
+ }
526
+ return auth
527
+
528
+ def to_debug_report(self) -> str:
529
+ """Gets the essential information for debugging.
530
+
531
+ :return: The report for debugging.
532
+ """
533
+ return "Python SDK Debug Report:\n"\
534
+ "OS: {env}\n"\
535
+ "Python Version: {pyversion}\n"\
536
+ "Version of the API: v2.74.0\n"\
537
+ "SDK Package Version: v2.74.0".\
538
+ format(env=sys.platform, pyversion=sys.version)
539
+
540
+ def get_host_settings(self) -> List[HostSetting]:
541
+ """Gets an array of host settings
542
+
543
+ :return: An array of host settings
544
+ """
545
+ return [
546
+ {
547
+ 'url': "https://api.reveng.ai",
548
+ 'description': "Production",
549
+ }
550
+ ]
551
+
552
+ def get_host_from_settings(
553
+ self,
554
+ index: Optional[int],
555
+ variables: Optional[ServerVariablesT]=None,
556
+ servers: Optional[List[HostSetting]]=None,
557
+ ) -> str:
558
+ """Gets host URL based on the index and variables
559
+ :param index: array index of the host settings
560
+ :param variables: hash of variable and the corresponding value
561
+ :param servers: an array of host settings or None
562
+ :return: URL based on host settings
563
+ """
564
+ if index is None:
565
+ return self._base_path
566
+
567
+ variables = {} if variables is None else variables
568
+ servers = self.get_host_settings() if servers is None else servers
569
+
570
+ try:
571
+ server = servers[index]
572
+ except IndexError:
573
+ raise ValueError(
574
+ "Invalid index {0} when selecting the host settings. "
575
+ "Must be less than {1}".format(index, len(servers)))
576
+
577
+ url = server['url']
578
+
579
+ # go through variables and replace placeholders
580
+ for variable_name, variable in server.get('variables', {}).items():
581
+ used_value = variables.get(
582
+ variable_name, variable['default_value'])
583
+
584
+ if 'enum_values' in variable \
585
+ and used_value not in variable['enum_values']:
586
+ raise ValueError(
587
+ "The variable `{0}` in the host URL has invalid value "
588
+ "{1}. Must be {2}.".format(
589
+ variable_name, variables[variable_name],
590
+ variable['enum_values']))
591
+
592
+ url = url.replace("{" + variable_name + "}", used_value)
593
+
594
+ return url
595
+
596
+ @property
597
+ def host(self) -> str:
598
+ """Return generated host."""
599
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
600
+
601
+ @host.setter
602
+ def host(self, value: str) -> None:
603
+ """Fix base path."""
604
+ self._base_path = value
605
+ self.server_index = None