restpki-ng-python-client 0.9.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 (181) hide show
  1. restpki_ng_python_client/__init__.py +200 -0
  2. restpki_ng_python_client/api/__init__.py +17 -0
  3. restpki_ng_python_client/api/authentication_api.py +2041 -0
  4. restpki_ng_python_client/api/cades_signature_api.py +2376 -0
  5. restpki_ng_python_client/api/document_keys_api.py +1199 -0
  6. restpki_ng_python_client/api/documents_api.py +868 -0
  7. restpki_ng_python_client/api/pades_signature_api.py +1797 -0
  8. restpki_ng_python_client/api/pades_visual_positioning_presets_api.py +869 -0
  9. restpki_ng_python_client/api/pdf_api.py +334 -0
  10. restpki_ng_python_client/api/signature_api.py +624 -0
  11. restpki_ng_python_client/api/signature_inspection_api.py +337 -0
  12. restpki_ng_python_client/api/signature_sessions_api.py +891 -0
  13. restpki_ng_python_client/api/timestamp_api.py +654 -0
  14. restpki_ng_python_client/api/upload_api.py +1124 -0
  15. restpki_ng_python_client/api/xml_signature_api.py +1781 -0
  16. restpki_ng_python_client/api_client.py +741 -0
  17. restpki_ng_python_client/api_response.py +21 -0
  18. restpki_ng_python_client/configuration.py +426 -0
  19. restpki_ng_python_client/exceptions.py +166 -0
  20. restpki_ng_python_client/file_utils.py +122 -0
  21. restpki_ng_python_client/models/__init__.py +165 -0
  22. restpki_ng_python_client/models/allocate_document_key_batch_request.py +96 -0
  23. restpki_ng_python_client/models/allocate_document_key_request.py +93 -0
  24. restpki_ng_python_client/models/attribute_certificate_model.py +141 -0
  25. restpki_ng_python_client/models/audit_package_options.py +90 -0
  26. restpki_ng_python_client/models/authentication_failures.py +45 -0
  27. restpki_ng_python_client/models/authentication_get_response.py +92 -0
  28. restpki_ng_python_client/models/authentication_post_request.py +116 -0
  29. restpki_ng_python_client/models/authentication_post_response.py +98 -0
  30. restpki_ng_python_client/models/authentications_post_request.py +95 -0
  31. restpki_ng_python_client/models/authentications_post_response.py +114 -0
  32. restpki_ng_python_client/models/authentications_post_signed_bytes_request.py +99 -0
  33. restpki_ng_python_client/models/authentications_post_signed_bytes_response.py +98 -0
  34. restpki_ng_python_client/models/auto_positioning_horizontal_directions.py +45 -0
  35. restpki_ng_python_client/models/auto_positioning_vertical_directions.py +45 -0
  36. restpki_ng_python_client/models/blockchains.py +45 -0
  37. restpki_ng_python_client/models/cades_signature_model.py +123 -0
  38. restpki_ng_python_client/models/cades_signature_post_request_v1.py +137 -0
  39. restpki_ng_python_client/models/cades_signature_post_request_v2.py +152 -0
  40. restpki_ng_python_client/models/cades_signature_post_request_v3.py +149 -0
  41. restpki_ng_python_client/models/cades_signature_post_response.py +120 -0
  42. restpki_ng_python_client/models/cades_signature_post_signed_bytes_request.py +92 -0
  43. restpki_ng_python_client/models/cades_signature_post_signed_bytes_response.py +106 -0
  44. restpki_ng_python_client/models/cades_signer_model.py +159 -0
  45. restpki_ng_python_client/models/cades_timestamp_model.py +140 -0
  46. restpki_ng_python_client/models/certificate_model.py +197 -0
  47. restpki_ng_python_client/models/certificate_reference_model.py +99 -0
  48. restpki_ng_python_client/models/certificate_requirement.py +95 -0
  49. restpki_ng_python_client/models/certificate_requirement_types.py +45 -0
  50. restpki_ng_python_client/models/certificate_summary.py +142 -0
  51. restpki_ng_python_client/models/certified_attribute_model.py +94 -0
  52. restpki_ng_python_client/models/certified_attribute_types.py +44 -0
  53. restpki_ng_python_client/models/cms_content_types.py +50 -0
  54. restpki_ng_python_client/models/cms_signature_options.py +109 -0
  55. restpki_ng_python_client/models/color_model.py +98 -0
  56. restpki_ng_python_client/models/commitment_type_model.py +99 -0
  57. restpki_ng_python_client/models/complete_authentication_request.py +93 -0
  58. restpki_ng_python_client/models/complete_authentication_response.py +103 -0
  59. restpki_ng_python_client/models/complete_signature_request.py +95 -0
  60. restpki_ng_python_client/models/complete_signature_request_v2.py +91 -0
  61. restpki_ng_python_client/models/create_signature_session_request.py +161 -0
  62. restpki_ng_python_client/models/create_signature_session_response.py +95 -0
  63. restpki_ng_python_client/models/digest_algorithm_and_value_model.py +103 -0
  64. restpki_ng_python_client/models/digest_algorithms.py +49 -0
  65. restpki_ng_python_client/models/document_file_model.py +137 -0
  66. restpki_ng_python_client/models/document_key_model.py +100 -0
  67. restpki_ng_python_client/models/document_key_query_response.py +110 -0
  68. restpki_ng_python_client/models/document_key_summary.py +100 -0
  69. restpki_ng_python_client/models/document_model.py +150 -0
  70. restpki_ng_python_client/models/document_query_response.py +93 -0
  71. restpki_ng_python_client/models/document_status.py +47 -0
  72. restpki_ng_python_client/models/document_summary.py +128 -0
  73. restpki_ng_python_client/models/error_model_v2.py +120 -0
  74. restpki_ng_python_client/models/file_model.py +114 -0
  75. restpki_ng_python_client/models/file_reference_model.py +137 -0
  76. restpki_ng_python_client/models/full_xml_signature_post_request.py +136 -0
  77. restpki_ng_python_client/models/general_name_choices.py +52 -0
  78. restpki_ng_python_client/models/general_name_model.py +108 -0
  79. restpki_ng_python_client/models/holder_types.py +45 -0
  80. restpki_ng_python_client/models/inspect_signature_failures.py +44 -0
  81. restpki_ng_python_client/models/inspect_signature_request.py +127 -0
  82. restpki_ng_python_client/models/inspect_signature_response.py +131 -0
  83. restpki_ng_python_client/models/multipart_upload_begin_response.py +95 -0
  84. restpki_ng_python_client/models/multipart_upload_end_request.py +95 -0
  85. restpki_ng_python_client/models/name_model.py +205 -0
  86. restpki_ng_python_client/models/namespace_model.py +99 -0
  87. restpki_ng_python_client/models/open_cades_signature_request_model.py +147 -0
  88. restpki_ng_python_client/models/open_signature_request_model.py +145 -0
  89. restpki_ng_python_client/models/open_xml_signature_request_model.py +151 -0
  90. restpki_ng_python_client/models/other_name_model.py +107 -0
  91. restpki_ng_python_client/models/pades_certification_level.py +47 -0
  92. restpki_ng_python_client/models/pades_horizontal_align.py +46 -0
  93. restpki_ng_python_client/models/pades_measurement_units.py +45 -0
  94. restpki_ng_python_client/models/pades_page_optimization_model.py +98 -0
  95. restpki_ng_python_client/models/pades_signature_model.py +113 -0
  96. restpki_ng_python_client/models/pades_signature_post_request_v1.py +167 -0
  97. restpki_ng_python_client/models/pades_signature_post_request_v2.py +171 -0
  98. restpki_ng_python_client/models/pades_signature_post_response.py +120 -0
  99. restpki_ng_python_client/models/pades_signature_post_signed_bytes_request.py +92 -0
  100. restpki_ng_python_client/models/pades_signature_post_signed_bytes_response.py +106 -0
  101. restpki_ng_python_client/models/pades_signer_model.py +168 -0
  102. restpki_ng_python_client/models/pades_size_model.py +89 -0
  103. restpki_ng_python_client/models/pades_text_horizontal_align.py +45 -0
  104. restpki_ng_python_client/models/pades_vertical_align.py +46 -0
  105. restpki_ng_python_client/models/pades_visual_auto_positioning_model.py +106 -0
  106. restpki_ng_python_client/models/pades_visual_image_model.py +105 -0
  107. restpki_ng_python_client/models/pades_visual_positioning_model.py +109 -0
  108. restpki_ng_python_client/models/pades_visual_rectangle_model.py +127 -0
  109. restpki_ng_python_client/models/pades_visual_representation_model.py +103 -0
  110. restpki_ng_python_client/models/pades_visual_text_model.py +111 -0
  111. restpki_ng_python_client/models/page_orientations.py +46 -0
  112. restpki_ng_python_client/models/paper_sizes.py +56 -0
  113. restpki_ng_python_client/models/pdf_add_marks_request.py +117 -0
  114. restpki_ng_python_client/models/pdf_add_marks_response.py +91 -0
  115. restpki_ng_python_client/models/pdf_container_definition.py +208 -0
  116. restpki_ng_python_client/models/pdf_helper.py +43 -0
  117. restpki_ng_python_client/models/pdf_mark_element_model.py +230 -0
  118. restpki_ng_python_client/models/pdf_mark_element_type.py +46 -0
  119. restpki_ng_python_client/models/pdf_mark_image_model.py +98 -0
  120. restpki_ng_python_client/models/pdf_mark_model.py +168 -0
  121. restpki_ng_python_client/models/pdf_mark_page_options.py +47 -0
  122. restpki_ng_python_client/models/pdf_signature_options.py +101 -0
  123. restpki_ng_python_client/models/pdf_text_section_model.py +125 -0
  124. restpki_ng_python_client/models/pdf_text_style.py +46 -0
  125. restpki_ng_python_client/models/pki_brazil_certificate_model.py +159 -0
  126. restpki_ng_python_client/models/pki_brazil_certificate_types.py +54 -0
  127. restpki_ng_python_client/models/pki_italy_certificate_model.py +103 -0
  128. restpki_ng_python_client/models/pki_italy_certificate_types.py +46 -0
  129. restpki_ng_python_client/models/prepare_authentication_request.py +100 -0
  130. restpki_ng_python_client/models/prepare_authentication_response.py +99 -0
  131. restpki_ng_python_client/models/prepare_signature_failures.py +46 -0
  132. restpki_ng_python_client/models/prepare_signature_request.py +133 -0
  133. restpki_ng_python_client/models/prepare_signature_response.py +116 -0
  134. restpki_ng_python_client/models/resource_content_or_reference.py +107 -0
  135. restpki_ng_python_client/models/role_attribute_model.py +114 -0
  136. restpki_ng_python_client/models/session_completion_status.py +89 -0
  137. restpki_ng_python_client/models/signature_algorithm_and_value_model.py +106 -0
  138. restpki_ng_python_client/models/signature_algorithm_identifier.py +88 -0
  139. restpki_ng_python_client/models/signature_algorithms.py +48 -0
  140. restpki_ng_python_client/models/signature_b_stamp_model.py +135 -0
  141. restpki_ng_python_client/models/signature_policy_identifier_model.py +105 -0
  142. restpki_ng_python_client/models/signature_result_model.py +105 -0
  143. restpki_ng_python_client/models/signature_session_document_data.py +128 -0
  144. restpki_ng_python_client/models/signature_session_document_summary.py +138 -0
  145. restpki_ng_python_client/models/signature_session_model.py +126 -0
  146. restpki_ng_python_client/models/signature_session_status.py +49 -0
  147. restpki_ng_python_client/models/signature_types.py +46 -0
  148. restpki_ng_python_client/models/signer_b_stamp_model.py +132 -0
  149. restpki_ng_python_client/models/signer_model.py +187 -0
  150. restpki_ng_python_client/models/signer_summary.py +94 -0
  151. restpki_ng_python_client/models/timestamp_issue_response.py +99 -0
  152. restpki_ng_python_client/models/validation_item_model.py +111 -0
  153. restpki_ng_python_client/models/validation_item_types.py +91 -0
  154. restpki_ng_python_client/models/validation_results_model.py +131 -0
  155. restpki_ng_python_client/models/webhook_event_model.py +94 -0
  156. restpki_ng_python_client/models/webhook_event_types.py +44 -0
  157. restpki_ng_python_client/models/xml_attribute_model.py +107 -0
  158. restpki_ng_python_client/models/xml_element_location_model.py +111 -0
  159. restpki_ng_python_client/models/xml_element_model.py +115 -0
  160. restpki_ng_python_client/models/xml_element_signature_post_request.py +145 -0
  161. restpki_ng_python_client/models/xml_id_attribute_model.py +96 -0
  162. restpki_ng_python_client/models/xml_id_resolution_table_model.py +123 -0
  163. restpki_ng_python_client/models/xml_insertion_options.py +47 -0
  164. restpki_ng_python_client/models/xml_node_name_model.py +96 -0
  165. restpki_ng_python_client/models/xml_signature_model.py +154 -0
  166. restpki_ng_python_client/models/xml_signature_options.py +102 -0
  167. restpki_ng_python_client/models/xml_signature_post_response.py +120 -0
  168. restpki_ng_python_client/models/xml_signature_post_signed_bytes_request.py +92 -0
  169. restpki_ng_python_client/models/xml_signature_post_signed_bytes_response.py +106 -0
  170. restpki_ng_python_client/models/xml_signature_response_model.py +113 -0
  171. restpki_ng_python_client/models/xml_signature_types.py +47 -0
  172. restpki_ng_python_client/models/xml_signed_entity_types.py +46 -0
  173. restpki_ng_python_client/py.typed +0 -0
  174. restpki_ng_python_client/rest.py +231 -0
  175. restpki_ng_python_client/restpki_ng_client.py +458 -0
  176. restpki_ng_python_client/standard_signature_policies.py +24 -0
  177. restpki_ng_python_client/utils.py +80 -0
  178. restpki_ng_python_client-0.9.0.dist-info/METADATA +16 -0
  179. restpki_ng_python_client-0.9.0.dist-info/RECORD +181 -0
  180. restpki_ng_python_client-0.9.0.dist-info/WHEEL +5 -0
  181. restpki_ng_python_client-0.9.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Any, Dict, Optional, Generic, TypeVar
5
+ from pydantic import Field, StrictInt, StrictStr, 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[Dict[StrictStr, StrictStr]] = 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,426 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rest PKI Core API
5
+
6
+ <b><i>Para Português, <a href=\"https://docs.lacunasoftware.com/pt-br/articles/rest-pki/core/integration/get-started\">clique aqui</a></i></b> <p> <a href=\"https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/\">Rest PKI Core</a> is an upcoming version of <a href=\"https://docs.lacunasoftware.com/en-us/articles/rest-pki/\">Rest PKI</a> that will have extended compatibility with environments and databases. </p> <p> In addition to Windows Server (which is already supported by Rest PKI), Rest PKI Core will also run on <b>Linux</b> (Debian- and RedHat-based distributions) and on <b>Docker</b>. As for database servers, in addition to SQL Server, <b>PostgreSQL</b> will also be supported. </p> <p> <b>Before getting started, see the integration overview on the <a href=\"https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/\">Integration Guide</a></b> </p> <p> For questions regarding the usage of this API, please reach us at <a href=\"https://lacuna.help/\">lacuna.help</a> </p> <h2>Parameters</h2> <p> You will need the following parameters: </p> <ul> <li><b>Endpoint</b>: address of the Rest PKI Core instance that will be used</li> <li><b>API Key</b>: authorization key for using the API</li> </ul> <p> The <span class=\"model\">endpoint</span> must be prefixed to all relative URLs mentioned here. As for the <span class=\"model\">API Key</span>, see how to use it below. </p> <h2>Authentication</h2> <p> The API key must be sent on the <span class=\"model\">X-Api-Key</span> header on each request: </p> <!-- unfortunately, class \"example microlight\" doesn't seem to work here --> <pre style=\"font-size: 12px; padding: 10px; border-radius: 4px; background: #41444e; font-weight: 600; color: #fff;\"> X-Api-Key: yourapp|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </pre> <h2>HTTP Codes</h2> <p> The APIs will return the following HTTP codes: </p> <table> <thead> <tr> <th>Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><strong class=\"model-title\">200 (OK)</strong></td> <td>Request processed successfully. The response is different for each API, please refer to the operation's documentation</td> </tr> <tr> <td><strong class=\"model-title\">400 (Bad Request)</strong></td> <td>Syntax error. For instance, when a required field was not provided</td> </tr> <tr> <td><strong class=\"model-title\">401 (Unauthorized)</strong></td> <td>API key not provided or invalid</td> </tr> <tr> <td><strong class=\"model-title\">403 (Forbidden)</strong></td> <td>API key is valid, but the application has insufficient permissions to complete the requested operation</td> </tr> <tr> <td><strong class=\"model-title\">422 (Unprocessable Entity)</strong></td> <td>API error. The response body is an <a href=\"#model-ErrorModelV2\" class=\"model\">ErrorModelV2</a> </tr> <tr> <td><strong class=\"model-title\">500 (Internal Server Error)</strong></td> <td>An unexpected error occurred. The <span class=\"model\">exceptionCode</span> contained on the response body may be of help for our support team during diagnostic.</td> </tr> </tbody> </table> <h3>Error Codes</h3> <p> Some of the error codes returned in the <span class=\"model\">code</span> field of an <a href=\"#model-ErrorModelV2\" class=\"model\">ErrorModelV2</a> (body of responses with HTTP status code 422) are provided below*: </p> <table> <thead> <tr> <th>Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td class=\"model\">DocumentNotFound</td> <td>A referenced document was not found (check the document ID)</td> </tr> <tr> <td class=\"model\">SecurityContextNotFound</td> <td>A referenced security context was not found (check the security context ID)</td> </tr> <tr> <td class=\"model\">SignatureSessionNotFound</td> <td>A referenced signature session was not found (check the signature session ID)</td> </tr> <tr> <td class=\"model\">BadSignatureSessionOperation</td> <td>The operation is invalid for the current signature session or document status. For instance, trying to await the session's completion if it is still <span class=\"model\">Pending</span> results in this error</td> </tr> <tr> <td class=\"model\">BackgroundProcessing</td> <td>The operation cannot be completed at this time because the resource is being processed in background</td> </tr> <tr> <td class=\"model\">SignatureSessionTokenRequired</td> <td>The signature session token was not passed on the <span class=\"model\">X-Signature-Session-Token</span> request header</td> </tr> <tr> <td class=\"model\">BadSignatureSessionToken</td> <td>An invalid signature session token was passed on the <span class=\"model\">X-Signature-Session-Token</span> request header. Check your application for possible corruption of the session token, which may contain characters <span class=\"code\">-</span> (hyphen) and <span class=\"code\">_</span> (underscore)</td> </tr> <tr> <td class=\"model\">ExpiredSignatureSessionToken</td> <td>An expired signature session token was passed on the <span class=\"model\">X-Signature-Session-Token</span> request header. Signature session tokens are normally valid for 4 hours.</td> </tr> </tbody> </table> <p style=\"font-size: 0.9em\"> *The codes shown above are the most common error codes. Nonetheless, this list is not comprehensive. New codes may be added anytime without previous warning. </p> <h2>Culture / Internationalization (i18n)</h2> <p>The <span class=\"model\">Accept-Language</span> request header is observed by this API. The following cultures are supported:</p> <ul> <li><span class=\"code\">en-US</span> (or simply <span class=\"code\">en</span>)</li> <li><span class=\"code\">pt-BR</span> (or simply <span class=\"code\">pt</span>)</li> </ul> <p><i>Notice: error messages are not affected by this header and therefore should not be displayed to users, being better suited for logging.</i></p>
7
+
8
+ The version of the OpenAPI document: 2.1.2
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ import copy
16
+ import logging
17
+ import sys
18
+ import urllib3
19
+
20
+ import http.client as httplib
21
+
22
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
23
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
24
+ 'minimum', 'exclusiveMinimum', 'maxLength',
25
+ 'minLength', 'pattern', 'maxItems', 'minItems'
26
+ }
27
+
28
+ class Configuration:
29
+ """This class contains various settings of the API client.
30
+
31
+ :param host: Base url.
32
+ :param api_key: Dict to store API key(s).
33
+ Each entry in the dict specifies an API key.
34
+ The dict key is the name of the security scheme in the OAS specification.
35
+ The dict value is the API key secret.
36
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
37
+ The dict key is the name of the security scheme in the OAS specification.
38
+ The dict value is an API key prefix when generating the auth data.
39
+ :param username: Username for HTTP basic authentication.
40
+ :param password: Password for HTTP basic authentication.
41
+ :param access_token: Access token.
42
+ :param server_index: Index to servers configuration.
43
+ :param server_variables: Mapping with string values to replace variables in
44
+ templated server configuration. The validation of enums is performed for
45
+ variables with defined enum values before.
46
+ :param server_operation_index: Mapping from operation ID to an index to server
47
+ configuration.
48
+ :param server_operation_variables: Mapping from operation ID to a mapping with
49
+ string values to replace variables in templated server configuration.
50
+ The validation of enums is performed for variables with defined enum
51
+ values before.
52
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
53
+ in PEM format.
54
+
55
+ """
56
+
57
+ _default = None
58
+
59
+ def __init__(self, host=None,
60
+ api_key=None, api_key_prefix=None,
61
+ username=None, password=None,
62
+ access_token=None,
63
+ server_index=None, server_variables=None,
64
+ server_operation_index=None, server_operation_variables=None,
65
+ ssl_ca_cert=None,
66
+ ) -> None:
67
+ """Constructor
68
+ """
69
+ self._base_path = "http://localhost" if host is None else host
70
+ """Default Base url
71
+ """
72
+ self.server_index = 0 if server_index is None and host is None else server_index
73
+ self.server_operation_index = server_operation_index or {}
74
+ """Default server index
75
+ """
76
+ self.server_variables = server_variables or {}
77
+ self.server_operation_variables = server_operation_variables or {}
78
+ """Default server variables
79
+ """
80
+ self.temp_folder_path = None
81
+ """Temp file folder for downloading files
82
+ """
83
+ # Authentication Settings
84
+ self.api_key = {}
85
+ if api_key:
86
+ self.api_key = api_key
87
+ """dict to store API key(s)
88
+ """
89
+ self.api_key_prefix = {}
90
+ if api_key_prefix:
91
+ self.api_key_prefix = api_key_prefix
92
+ """dict to store API prefix (e.g. Bearer)
93
+ """
94
+ self.refresh_api_key_hook = None
95
+ """function hook to refresh API key if expired
96
+ """
97
+ self.username = username
98
+ """Username for HTTP basic authentication
99
+ """
100
+ self.password = password
101
+ """Password for HTTP basic authentication
102
+ """
103
+ self.access_token = access_token
104
+ """Access token
105
+ """
106
+ self.logger = {}
107
+ """Logging Settings
108
+ """
109
+ self.logger["package_logger"] = logging.getLogger("restpki_ng_python_client")
110
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
111
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
112
+ """Log format
113
+ """
114
+ self.logger_stream_handler = None
115
+ """Log stream handler
116
+ """
117
+ self.logger_file_handler = None
118
+ """Log file handler
119
+ """
120
+ self.logger_file = None
121
+ """Debug file location
122
+ """
123
+ self.debug = False
124
+ """Debug switch
125
+ """
126
+
127
+ self.verify_ssl = True
128
+ """SSL/TLS verification
129
+ Set this to false to skip verifying SSL certificate when calling API
130
+ from https server.
131
+ """
132
+ self.ssl_ca_cert = ssl_ca_cert
133
+ """Set this to customize the certificate file to verify the peer.
134
+ """
135
+ self.cert_file = None
136
+ """client certificate file
137
+ """
138
+ self.key_file = None
139
+ """client key file
140
+ """
141
+ self.assert_hostname = None
142
+ """Set this to True/False to enable/disable SSL hostname verification.
143
+ """
144
+ self.tls_server_name = None
145
+ """SSL/TLS Server Name Indication (SNI)
146
+ Set this to the SNI value expected by the server.
147
+ """
148
+
149
+
150
+ self.proxy = None
151
+ """Proxy URL
152
+ """
153
+ self.proxy_headers = None
154
+ """Proxy headers
155
+ """
156
+ self.safe_chars_for_path_param = ''
157
+ """Safe chars for path_param
158
+ """
159
+ self.retries = None
160
+ """Adding retries to override urllib3 default value 3
161
+ """
162
+ # Enable client side validation
163
+ self.client_side_validation = True
164
+
165
+ self.socket_options = None
166
+ """Options to pass down to the underlying urllib3 socket
167
+ """
168
+
169
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
170
+ """datetime format
171
+ """
172
+
173
+ self.date_format = "%Y-%m-%d"
174
+ """date format
175
+ """
176
+
177
+ def __deepcopy__(self, memo):
178
+ cls = self.__class__
179
+ result = cls.__new__(cls)
180
+ memo[id(self)] = result
181
+ for k, v in self.__dict__.items():
182
+ if k not in ('logger', 'logger_file_handler'):
183
+ setattr(result, k, copy.deepcopy(v, memo))
184
+ # shallow copy of loggers
185
+ result.logger = copy.copy(self.logger)
186
+ # use setters to configure loggers
187
+ result.logger_file = self.logger_file
188
+ result.debug = self.debug
189
+ return result
190
+
191
+ def __setattr__(self, name, value):
192
+ object.__setattr__(self, name, value)
193
+
194
+ @classmethod
195
+ def set_default(cls, default):
196
+ """Set default instance of configuration.
197
+
198
+ It stores default configuration, which can be
199
+ returned by get_default_copy method.
200
+
201
+ :param default: object of Configuration
202
+ """
203
+ cls._default = default
204
+
205
+ @classmethod
206
+ def get_default_copy(cls):
207
+ """Deprecated. Please use `get_default` instead.
208
+
209
+ Deprecated. Please use `get_default` instead.
210
+
211
+ :return: The configuration object.
212
+ """
213
+ return cls.get_default()
214
+
215
+ @classmethod
216
+ def get_default(cls):
217
+ """Return the default configuration.
218
+
219
+ This method returns newly created, based on default constructor,
220
+ object of Configuration class or returns a copy of default
221
+ configuration.
222
+
223
+ :return: The configuration object.
224
+ """
225
+ if cls._default is None:
226
+ cls._default = Configuration()
227
+ return cls._default
228
+
229
+ @property
230
+ def logger_file(self):
231
+ """The logger file.
232
+
233
+ If the logger_file is None, then add stream handler and remove file
234
+ handler. Otherwise, add file handler and remove stream handler.
235
+
236
+ :param value: The logger_file path.
237
+ :type: str
238
+ """
239
+ return self.__logger_file
240
+
241
+ @logger_file.setter
242
+ def logger_file(self, value):
243
+ """The logger file.
244
+
245
+ If the logger_file is None, then add stream handler and remove file
246
+ handler. Otherwise, add file handler and remove stream handler.
247
+
248
+ :param value: The logger_file path.
249
+ :type: str
250
+ """
251
+ self.__logger_file = value
252
+ if self.__logger_file:
253
+ # If set logging file,
254
+ # then add file handler and remove stream handler.
255
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
256
+ self.logger_file_handler.setFormatter(self.logger_formatter)
257
+ for _, logger in self.logger.items():
258
+ logger.addHandler(self.logger_file_handler)
259
+
260
+ @property
261
+ def debug(self):
262
+ """Debug status
263
+
264
+ :param value: The debug status, True or False.
265
+ :type: bool
266
+ """
267
+ return self.__debug
268
+
269
+ @debug.setter
270
+ def debug(self, value):
271
+ """Debug status
272
+
273
+ :param value: The debug status, True or False.
274
+ :type: bool
275
+ """
276
+ self.__debug = value
277
+ if self.__debug:
278
+ # if debug status is True, turn on debug logging
279
+ for _, logger in self.logger.items():
280
+ logger.setLevel(logging.DEBUG)
281
+ # turn on httplib debug
282
+ httplib.HTTPConnection.debuglevel = 1
283
+ else:
284
+ # if debug status is False, turn off debug logging,
285
+ # setting log level to default `logging.WARNING`
286
+ for _, logger in self.logger.items():
287
+ logger.setLevel(logging.WARNING)
288
+ # turn off httplib debug
289
+ httplib.HTTPConnection.debuglevel = 0
290
+
291
+ @property
292
+ def logger_format(self):
293
+ """The logger format.
294
+
295
+ The logger_formatter will be updated when sets logger_format.
296
+
297
+ :param value: The format string.
298
+ :type: str
299
+ """
300
+ return self.__logger_format
301
+
302
+ @logger_format.setter
303
+ def logger_format(self, value):
304
+ """The logger format.
305
+
306
+ The logger_formatter will be updated when sets logger_format.
307
+
308
+ :param value: The format string.
309
+ :type: str
310
+ """
311
+ self.__logger_format = value
312
+ self.logger_formatter = logging.Formatter(self.__logger_format)
313
+
314
+ def get_api_key_with_prefix(self, identifier, alias=None):
315
+ """Gets API key (with prefix if set).
316
+
317
+ :param identifier: The identifier of apiKey.
318
+ :param alias: The alternative identifier of apiKey.
319
+ :return: The token for api key authentication.
320
+ """
321
+ if self.refresh_api_key_hook is not None:
322
+ self.refresh_api_key_hook(self)
323
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
324
+ if key:
325
+ prefix = self.api_key_prefix.get(identifier)
326
+ if prefix:
327
+ return "%s %s" % (prefix, key)
328
+ else:
329
+ return key
330
+
331
+ def get_basic_auth_token(self):
332
+ """Gets HTTP basic authentication header (string).
333
+
334
+ :return: The token for basic HTTP authentication.
335
+ """
336
+ username = ""
337
+ if self.username is not None:
338
+ username = self.username
339
+ password = ""
340
+ if self.password is not None:
341
+ password = self.password
342
+ return urllib3.util.make_headers(
343
+ basic_auth=username + ':' + password
344
+ ).get('authorization')
345
+
346
+ def auth_settings(self):
347
+ """Gets Auth Settings dict for api client.
348
+
349
+ :return: The Auth Settings information dict.
350
+ """
351
+ auth = {}
352
+ return auth
353
+
354
+ def to_debug_report(self):
355
+ """Gets the essential information for debugging.
356
+
357
+ :return: The report for debugging.
358
+ """
359
+ return "Python SDK Debug Report:\n"\
360
+ "OS: {env}\n"\
361
+ "Python Version: {pyversion}\n"\
362
+ "Version of the API: 2.1.2\n"\
363
+ "SDK Package Version: 0.9.0".\
364
+ format(env=sys.platform, pyversion=sys.version)
365
+
366
+ def get_host_settings(self):
367
+ """Gets an array of host settings
368
+
369
+ :return: An array of host settings
370
+ """
371
+ return [
372
+ {
373
+ 'url': "",
374
+ 'description': "No description provided",
375
+ }
376
+ ]
377
+
378
+ def get_host_from_settings(self, index, variables=None, servers=None):
379
+ """Gets host URL based on the index and variables
380
+ :param index: array index of the host settings
381
+ :param variables: hash of variable and the corresponding value
382
+ :param servers: an array of host settings or None
383
+ :return: URL based on host settings
384
+ """
385
+ if index is None:
386
+ return self._base_path
387
+
388
+ variables = {} if variables is None else variables
389
+ servers = self.get_host_settings() if servers is None else servers
390
+
391
+ try:
392
+ server = servers[index]
393
+ except IndexError:
394
+ raise ValueError(
395
+ "Invalid index {0} when selecting the host settings. "
396
+ "Must be less than {1}".format(index, len(servers)))
397
+
398
+ url = server['url']
399
+
400
+ # go through variables and replace placeholders
401
+ for variable_name, variable in server.get('variables', {}).items():
402
+ used_value = variables.get(
403
+ variable_name, variable['default_value'])
404
+
405
+ if 'enum_values' in variable \
406
+ and used_value not in variable['enum_values']:
407
+ raise ValueError(
408
+ "The variable `{0}` in the host URL has invalid value "
409
+ "{1}. Must be {2}.".format(
410
+ variable_name, variables[variable_name],
411
+ variable['enum_values']))
412
+
413
+ url = url.replace("{" + variable_name + "}", used_value)
414
+
415
+ return url
416
+
417
+ @property
418
+ def host(self):
419
+ """Return generated host."""
420
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
421
+
422
+ @host.setter
423
+ def host(self, value):
424
+ """Fix base path."""
425
+ self._base_path = value
426
+ self.server_index = None
@@ -0,0 +1,166 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Rest PKI Core API
5
+
6
+ <b><i>Para Português, <a href=\"https://docs.lacunasoftware.com/pt-br/articles/rest-pki/core/integration/get-started\">clique aqui</a></i></b> <p> <a href=\"https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/\">Rest PKI Core</a> is an upcoming version of <a href=\"https://docs.lacunasoftware.com/en-us/articles/rest-pki/\">Rest PKI</a> that will have extended compatibility with environments and databases. </p> <p> In addition to Windows Server (which is already supported by Rest PKI), Rest PKI Core will also run on <b>Linux</b> (Debian- and RedHat-based distributions) and on <b>Docker</b>. As for database servers, in addition to SQL Server, <b>PostgreSQL</b> will also be supported. </p> <p> <b>Before getting started, see the integration overview on the <a href=\"https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/\">Integration Guide</a></b> </p> <p> For questions regarding the usage of this API, please reach us at <a href=\"https://lacuna.help/\">lacuna.help</a> </p> <h2>Parameters</h2> <p> You will need the following parameters: </p> <ul> <li><b>Endpoint</b>: address of the Rest PKI Core instance that will be used</li> <li><b>API Key</b>: authorization key for using the API</li> </ul> <p> The <span class=\"model\">endpoint</span> must be prefixed to all relative URLs mentioned here. As for the <span class=\"model\">API Key</span>, see how to use it below. </p> <h2>Authentication</h2> <p> The API key must be sent on the <span class=\"model\">X-Api-Key</span> header on each request: </p> <!-- unfortunately, class \"example microlight\" doesn't seem to work here --> <pre style=\"font-size: 12px; padding: 10px; border-radius: 4px; background: #41444e; font-weight: 600; color: #fff;\"> X-Api-Key: yourapp|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </pre> <h2>HTTP Codes</h2> <p> The APIs will return the following HTTP codes: </p> <table> <thead> <tr> <th>Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><strong class=\"model-title\">200 (OK)</strong></td> <td>Request processed successfully. The response is different for each API, please refer to the operation's documentation</td> </tr> <tr> <td><strong class=\"model-title\">400 (Bad Request)</strong></td> <td>Syntax error. For instance, when a required field was not provided</td> </tr> <tr> <td><strong class=\"model-title\">401 (Unauthorized)</strong></td> <td>API key not provided or invalid</td> </tr> <tr> <td><strong class=\"model-title\">403 (Forbidden)</strong></td> <td>API key is valid, but the application has insufficient permissions to complete the requested operation</td> </tr> <tr> <td><strong class=\"model-title\">422 (Unprocessable Entity)</strong></td> <td>API error. The response body is an <a href=\"#model-ErrorModelV2\" class=\"model\">ErrorModelV2</a> </tr> <tr> <td><strong class=\"model-title\">500 (Internal Server Error)</strong></td> <td>An unexpected error occurred. The <span class=\"model\">exceptionCode</span> contained on the response body may be of help for our support team during diagnostic.</td> </tr> </tbody> </table> <h3>Error Codes</h3> <p> Some of the error codes returned in the <span class=\"model\">code</span> field of an <a href=\"#model-ErrorModelV2\" class=\"model\">ErrorModelV2</a> (body of responses with HTTP status code 422) are provided below*: </p> <table> <thead> <tr> <th>Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td class=\"model\">DocumentNotFound</td> <td>A referenced document was not found (check the document ID)</td> </tr> <tr> <td class=\"model\">SecurityContextNotFound</td> <td>A referenced security context was not found (check the security context ID)</td> </tr> <tr> <td class=\"model\">SignatureSessionNotFound</td> <td>A referenced signature session was not found (check the signature session ID)</td> </tr> <tr> <td class=\"model\">BadSignatureSessionOperation</td> <td>The operation is invalid for the current signature session or document status. For instance, trying to await the session's completion if it is still <span class=\"model\">Pending</span> results in this error</td> </tr> <tr> <td class=\"model\">BackgroundProcessing</td> <td>The operation cannot be completed at this time because the resource is being processed in background</td> </tr> <tr> <td class=\"model\">SignatureSessionTokenRequired</td> <td>The signature session token was not passed on the <span class=\"model\">X-Signature-Session-Token</span> request header</td> </tr> <tr> <td class=\"model\">BadSignatureSessionToken</td> <td>An invalid signature session token was passed on the <span class=\"model\">X-Signature-Session-Token</span> request header. Check your application for possible corruption of the session token, which may contain characters <span class=\"code\">-</span> (hyphen) and <span class=\"code\">_</span> (underscore)</td> </tr> <tr> <td class=\"model\">ExpiredSignatureSessionToken</td> <td>An expired signature session token was passed on the <span class=\"model\">X-Signature-Session-Token</span> request header. Signature session tokens are normally valid for 4 hours.</td> </tr> </tbody> </table> <p style=\"font-size: 0.9em\"> *The codes shown above are the most common error codes. Nonetheless, this list is not comprehensive. New codes may be added anytime without previous warning. </p> <h2>Culture / Internationalization (i18n)</h2> <p>The <span class=\"model\">Accept-Language</span> request header is observed by this API. The following cultures are supported:</p> <ul> <li><span class=\"code\">en-US</span> (or simply <span class=\"code\">en</span>)</li> <li><span class=\"code\">pt-BR</span> (or simply <span class=\"code\">pt</span>)</li> </ul> <p><i>Notice: error messages are not affected by this header and therefore should not be displayed to users, being better suited for logging.</i></p>
7
+
8
+ The version of the OpenAPI document: 2.1.2
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ class OpenApiException(Exception):
16
+ """The base exception class for all OpenAPIExceptions"""
17
+
18
+
19
+ class ApiTypeError(OpenApiException, TypeError):
20
+ def __init__(self, msg, path_to_item=None, valid_classes=None,
21
+ key_type=None) -> None:
22
+ """ Raises an exception for TypeErrors
23
+
24
+ Args:
25
+ msg (str): the exception message
26
+
27
+ Keyword Args:
28
+ path_to_item (list): a list of keys an indices to get to the
29
+ current_item
30
+ None if unset
31
+ valid_classes (tuple): the primitive classes that current item
32
+ should be an instance of
33
+ None if unset
34
+ key_type (bool): False if our value is a value in a dict
35
+ True if it is a key in a dict
36
+ False if our item is an item in a list
37
+ None if unset
38
+ """
39
+ self.path_to_item = path_to_item
40
+ self.valid_classes = valid_classes
41
+ self.key_type = key_type
42
+ full_msg = msg
43
+ if path_to_item:
44
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
45
+ super(ApiTypeError, self).__init__(full_msg)
46
+
47
+
48
+ class ApiValueError(OpenApiException, ValueError):
49
+ def __init__(self, msg, path_to_item=None) -> None:
50
+ """
51
+ Args:
52
+ msg (str): the exception message
53
+
54
+ Keyword Args:
55
+ path_to_item (list) the path to the exception in the
56
+ received_data dict. None if unset
57
+ """
58
+
59
+ self.path_to_item = path_to_item
60
+ full_msg = msg
61
+ if path_to_item:
62
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
63
+ super(ApiValueError, self).__init__(full_msg)
64
+
65
+
66
+ class ApiAttributeError(OpenApiException, AttributeError):
67
+ def __init__(self, msg, path_to_item=None) -> None:
68
+ """
69
+ Raised when an attribute reference or assignment fails.
70
+
71
+ Args:
72
+ msg (str): the exception message
73
+
74
+ Keyword Args:
75
+ path_to_item (None/list) the path to the exception in the
76
+ received_data dict
77
+ """
78
+ self.path_to_item = path_to_item
79
+ full_msg = msg
80
+ if path_to_item:
81
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
82
+ super(ApiAttributeError, self).__init__(full_msg)
83
+
84
+
85
+ class ApiKeyError(OpenApiException, KeyError):
86
+ def __init__(self, msg, path_to_item=None) -> None:
87
+ """
88
+ Args:
89
+ msg (str): the exception message
90
+
91
+ Keyword Args:
92
+ path_to_item (None/list) the path to the exception in the
93
+ received_data dict
94
+ """
95
+ self.path_to_item = path_to_item
96
+ full_msg = msg
97
+ if path_to_item:
98
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
99
+ super(ApiKeyError, self).__init__(full_msg)
100
+
101
+
102
+ class ApiException(OpenApiException):
103
+
104
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
105
+ if http_resp:
106
+ self.status = http_resp.status
107
+ self.reason = http_resp.reason
108
+ self.body = http_resp.data.decode('utf-8')
109
+ self.headers = http_resp.getheaders()
110
+ else:
111
+ self.status = status
112
+ self.reason = reason
113
+ self.body = None
114
+ self.headers = None
115
+
116
+ def __str__(self):
117
+ """Custom error messages for exception"""
118
+ error_message = "({0})\n"\
119
+ "Reason: {1}\n".format(self.status, self.reason)
120
+ if self.headers:
121
+ error_message += "HTTP response headers: {0}\n".format(
122
+ self.headers)
123
+
124
+ if self.body:
125
+ error_message += "HTTP response body: {0}\n".format(self.body)
126
+
127
+ return error_message
128
+
129
+ class BadRequestException(ApiException):
130
+
131
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
132
+ super(BadRequestException, self).__init__(status, reason, http_resp)
133
+
134
+ class NotFoundException(ApiException):
135
+
136
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
137
+ super(NotFoundException, self).__init__(status, reason, http_resp)
138
+
139
+
140
+ class UnauthorizedException(ApiException):
141
+
142
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
143
+ super(UnauthorizedException, self).__init__(status, reason, http_resp)
144
+
145
+
146
+ class ForbiddenException(ApiException):
147
+
148
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
149
+ super(ForbiddenException, self).__init__(status, reason, http_resp)
150
+
151
+
152
+ class ServiceException(ApiException):
153
+
154
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
155
+ super(ServiceException, self).__init__(status, reason, http_resp)
156
+
157
+
158
+ def render_path(path_to_item):
159
+ """Returns a string representation of a path"""
160
+ result = ""
161
+ for pth in path_to_item:
162
+ if isinstance(pth, int):
163
+ result += "[{0}]".format(pth)
164
+ else:
165
+ result += "['{0}']".format(pth)
166
+ return result