factpulse 1.0.6__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 (131) hide show
  1. factpulse/__init__.py +280 -0
  2. factpulse/api/__init__.py +13 -0
  3. factpulse/api/afnorpdppa_api.py +284 -0
  4. factpulse/api/afnorpdppa_directory_service_api.py +799 -0
  5. factpulse/api/afnorpdppa_flow_service_api.py +1075 -0
  6. factpulse/api/chorus_pro_api.py +4506 -0
  7. factpulse/api/processing_endpoints_unifis_api.py +592 -0
  8. factpulse/api/sant_api.py +281 -0
  9. factpulse/api/signature_lectronique_api.py +1358 -0
  10. factpulse/api/traitement_facture_api.py +3439 -0
  11. factpulse/api/utilisateur_api.py +282 -0
  12. factpulse/api_client.py +804 -0
  13. factpulse/api_response.py +21 -0
  14. factpulse/configuration.py +585 -0
  15. factpulse/exceptions.py +216 -0
  16. factpulse/models/__init__.py +124 -0
  17. factpulse/models/adresse_electronique.py +90 -0
  18. factpulse/models/adresse_postale.py +120 -0
  19. factpulse/models/body_ajouter_fichier_api_v1_chorus_pro_transverses_ajouter_fichier_post.py +104 -0
  20. factpulse/models/body_completer_facture_api_v1_chorus_pro_factures_completer_post.py +104 -0
  21. factpulse/models/body_lister_services_structure_api_v1_chorus_pro_structures_id_structure_cpp_services_get.py +102 -0
  22. factpulse/models/body_rechercher_factures_destinataire_api_v1_chorus_pro_factures_rechercher_destinataire_post.py +104 -0
  23. factpulse/models/body_rechercher_factures_fournisseur_api_v1_chorus_pro_factures_rechercher_fournisseur_post.py +104 -0
  24. factpulse/models/body_recycler_facture_api_v1_chorus_pro_factures_recycler_post.py +104 -0
  25. factpulse/models/body_telecharger_groupe_factures_api_v1_chorus_pro_factures_telecharger_groupe_post.py +104 -0
  26. factpulse/models/body_traiter_facture_recue_api_v1_chorus_pro_factures_traiter_facture_recue_post.py +104 -0
  27. factpulse/models/body_valideur_consulter_facture_api_v1_chorus_pro_factures_valideur_consulter_post.py +104 -0
  28. factpulse/models/body_valideur_rechercher_factures_api_v1_chorus_pro_factures_valideur_rechercher_post.py +104 -0
  29. factpulse/models/body_valideur_traiter_facture_api_v1_chorus_pro_factures_valideur_traiter_post.py +104 -0
  30. factpulse/models/cadre_de_facturation.py +102 -0
  31. factpulse/models/categorie_tva.py +44 -0
  32. factpulse/models/certificate_info_response.py +114 -0
  33. factpulse/models/chorus_pro_credentials.py +95 -0
  34. factpulse/models/code_cadre_facturation.py +39 -0
  35. factpulse/models/code_raison_reduction.py +42 -0
  36. factpulse/models/consulter_facture_request.py +98 -0
  37. factpulse/models/consulter_facture_response.py +142 -0
  38. factpulse/models/consulter_structure_request.py +100 -0
  39. factpulse/models/consulter_structure_response.py +142 -0
  40. factpulse/models/credentials_afnor.py +106 -0
  41. factpulse/models/credentials_chorus_pro.py +115 -0
  42. factpulse/models/destinataire.py +116 -0
  43. factpulse/models/destination.py +140 -0
  44. factpulse/models/destination_afnor.py +127 -0
  45. factpulse/models/destination_chorus_pro.py +108 -0
  46. factpulse/models/direction_flux.py +37 -0
  47. factpulse/models/donnees_facture_simplifiees.py +124 -0
  48. factpulse/models/facture_enrichie_info_input.py +123 -0
  49. factpulse/models/facture_enrichie_info_output.py +133 -0
  50. factpulse/models/facture_factur_x.py +173 -0
  51. factpulse/models/flux_resume.py +131 -0
  52. factpulse/models/format_sortie.py +37 -0
  53. factpulse/models/fournisseur.py +146 -0
  54. factpulse/models/generate_certificate_request.py +118 -0
  55. factpulse/models/generate_certificate_response.py +106 -0
  56. factpulse/models/http_validation_error.py +95 -0
  57. factpulse/models/information_signature_api.py +122 -0
  58. factpulse/models/ligne_de_poste.py +188 -0
  59. factpulse/models/ligne_de_poste_montant_remise_ht.py +145 -0
  60. factpulse/models/ligne_de_poste_montant_total_ligne_ht.py +145 -0
  61. factpulse/models/ligne_de_poste_taux_tva_manuel.py +145 -0
  62. factpulse/models/ligne_de_tva.py +118 -0
  63. factpulse/models/mode_depot.py +38 -0
  64. factpulse/models/mode_paiement.py +41 -0
  65. factpulse/models/montant_ht_total.py +139 -0
  66. factpulse/models/montant_total.py +138 -0
  67. factpulse/models/montant_total_acompte.py +145 -0
  68. factpulse/models/montant_total_montant_remise_globale_ttc.py +145 -0
  69. factpulse/models/montant_ttc_total.py +139 -0
  70. factpulse/models/montant_tva.py +139 -0
  71. factpulse/models/montantapayer.py +139 -0
  72. factpulse/models/montantbaseht.py +139 -0
  73. factpulse/models/montanthttotal.py +139 -0
  74. factpulse/models/montantttctotal.py +139 -0
  75. factpulse/models/montanttva.py +139 -0
  76. factpulse/models/montanttva1.py +139 -0
  77. factpulse/models/montantunitaireht.py +139 -0
  78. factpulse/models/obtenir_id_chorus_pro_request.py +100 -0
  79. factpulse/models/obtenir_id_chorus_pro_response.py +98 -0
  80. factpulse/models/options_processing.py +103 -0
  81. factpulse/models/parametres_signature.py +133 -0
  82. factpulse/models/parametres_structure.py +91 -0
  83. factpulse/models/pdf_factur_x_info.py +91 -0
  84. factpulse/models/pdp_credentials.py +93 -0
  85. factpulse/models/piece_jointe_complementaire.py +95 -0
  86. factpulse/models/profil_api.py +39 -0
  87. factpulse/models/profil_flux.py +38 -0
  88. factpulse/models/quantite.py +139 -0
  89. factpulse/models/quota_info.py +95 -0
  90. factpulse/models/rechercher_services_response.py +101 -0
  91. factpulse/models/rechercher_structure_request.py +119 -0
  92. factpulse/models/rechercher_structure_response.py +101 -0
  93. factpulse/models/references.py +124 -0
  94. factpulse/models/reponse_healthcheck_afnor.py +91 -0
  95. factpulse/models/reponse_recherche_flux.py +101 -0
  96. factpulse/models/reponse_soumission_flux.py +109 -0
  97. factpulse/models/reponse_tache.py +87 -0
  98. factpulse/models/reponse_validation_erreur.py +87 -0
  99. factpulse/models/reponse_validation_succes.py +87 -0
  100. factpulse/models/requete_recherche_flux.py +143 -0
  101. factpulse/models/requete_soumission_flux.py +123 -0
  102. factpulse/models/resultat_afnor.py +105 -0
  103. factpulse/models/resultat_chorus_pro.py +101 -0
  104. factpulse/models/resultat_validation_pdfapi.py +169 -0
  105. factpulse/models/scheme_id.py +40 -0
  106. factpulse/models/service_structure.py +93 -0
  107. factpulse/models/signature_info.py +101 -0
  108. factpulse/models/soumettre_facture_complete_request.py +116 -0
  109. factpulse/models/soumettre_facture_complete_response.py +145 -0
  110. factpulse/models/soumettre_facture_request.py +164 -0
  111. factpulse/models/soumettre_facture_response.py +103 -0
  112. factpulse/models/statut_acquittement.py +38 -0
  113. factpulse/models/statut_facture.py +96 -0
  114. factpulse/models/statut_tache.py +99 -0
  115. factpulse/models/structure_info.py +95 -0
  116. factpulse/models/syntaxe_flux.py +40 -0
  117. factpulse/models/tauxmanuel.py +139 -0
  118. factpulse/models/type_facture.py +37 -0
  119. factpulse/models/type_flux.py +40 -0
  120. factpulse/models/type_tva.py +39 -0
  121. factpulse/models/unite.py +41 -0
  122. factpulse/models/utilisateur.py +128 -0
  123. factpulse/models/validation_error.py +99 -0
  124. factpulse/models/validation_error_loc_inner.py +138 -0
  125. factpulse/py.typed +0 -0
  126. factpulse/rest.py +258 -0
  127. factpulse-1.0.6.dist-info/METADATA +182 -0
  128. factpulse-1.0.6.dist-info/RECORD +131 -0
  129. factpulse-1.0.6.dist-info/WHEEL +5 -0
  130. factpulse-1.0.6.dist-info/licenses/LICENSE +21 -0
  131. factpulse-1.0.6.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 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,585 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ API REST FactPulse
5
+
6
+ API REST pour la facturation électronique en France : Factur-X, AFNOR PDP/PA, signatures électroniques. ## 🎯 Fonctionnalités principales ### 📄 Génération de factures Factur-X - **Formats** : XML seul ou PDF/A-3 avec XML embarqué - **Profils** : MINIMUM, BASIC, EN16931, EXTENDED - **Normes** : EN 16931 (directive UE 2014/55), ISO 19005-3 (PDF/A-3), CII (UN/CEFACT) - **🆕 Format simplifié** : Génération à partir de SIRET + auto-enrichissement (API Chorus Pro + Recherche Entreprises) ### ✅ Validation et conformité - **Validation XML** : Schematron (45 à 210+ règles selon profil) - **Validation PDF** : PDF/A-3, métadonnées XMP Factur-X, signatures électroniques - **VeraPDF** : Validation stricte PDF/A (146+ règles ISO 19005-3) - **Traitement asynchrone** : Support Celery pour validations lourdes (VeraPDF) ### 📡 Intégration AFNOR PDP/PA (XP Z12-013) - **Soumission de flux** : Envoi de factures vers Plateformes de Dématérialisation Partenaires - **Recherche de flux** : Consultation des factures soumises - **Téléchargement** : Récupération des PDF/A-3 avec XML - **Directory Service** : Recherche d'entreprises (SIREN/SIRET) - **Multi-client** : Support de plusieurs configs PDP par utilisateur (stored credentials ou zero-storage) ### ✍️ Signature électronique PDF - **Standards** : PAdES-B-B, PAdES-B-T (horodatage RFC 3161), PAdES-B-LT (archivage long terme) - **Niveaux eIDAS** : SES (auto-signé), AdES (CA commerciale), QES (PSCO) - **Validation** : Vérification intégrité cryptographique et certificats - **Génération de certificats** : Certificats X.509 auto-signés pour tests ### 🔄 Traitement asynchrone - **Celery** : Génération, validation et signature asynchrones - **Polling** : Suivi d'état via `/taches/{id_tache}/statut` - **Pas de timeout** : Idéal pour gros fichiers ou validations lourdes ## 🔒 Authentification Toutes les requêtes nécessitent un **token JWT** dans le header Authorization : ``` Authorization: Bearer YOUR_JWT_TOKEN ``` ### Comment obtenir un token JWT ? #### 🔑 Méthode 1 : API `/api/token/` (Recommandée) **URL :** `https://www.factpulse.fr/api/token/` Cette méthode est **recommandée** pour l'intégration dans vos applications et workflows CI/CD. **Prérequis :** Avoir défini un mot de passe sur votre compte **Pour les utilisateurs inscrits via email/password :** - Vous avez déjà un mot de passe, utilisez-le directement **Pour les utilisateurs inscrits via OAuth (Google/GitHub) :** - Vous devez d'abord définir un mot de passe sur : https://www.factpulse.fr/accounts/password/set/ - Une fois le mot de passe créé, vous pourrez utiliser l'API **Exemple de requête :** ```bash curl -X POST https://www.factpulse.fr/api/token/ \\ -H \"Content-Type: application/json\" \\ -d '{ \"username\": \"votre_email@example.com\", \"password\": \"votre_mot_de_passe\" }' ``` **Réponse :** ```json { \"access\": \"eyJ0eXAiOiJKV1QiLCJhbGc...\", // Token d'accès (validité: 30 min) \"refresh\": \"eyJ0eXAiOiJKV1QiLCJhbGc...\" // Token de rafraîchissement (validité: 7 jours) } ``` **Avantages :** - ✅ Automatisation complète (CI/CD, scripts) - ✅ Gestion programmatique des tokens - ✅ Support du refresh token pour renouveler automatiquement l'accès - ✅ Intégration facile dans n'importe quel langage/outil #### 🖥️ Méthode 2 : Génération via Dashboard (Alternative) **URL :** https://www.factpulse.fr/dashboard/ Cette méthode convient pour des tests rapides ou une utilisation occasionnelle via l'interface graphique. **Fonctionnement :** - Connectez-vous au dashboard - Utilisez les boutons \"Generate Test Token\" ou \"Generate Production Token\" - Fonctionne pour **tous** les utilisateurs (OAuth et email/password), sans nécessiter de mot de passe **Types de tokens :** - **Token Test** : Validité 24h, quota 1000 appels/jour (gratuit) - **Token Production** : Validité 7 jours, quota selon votre forfait **Avantages :** - ✅ Rapide pour tester l'API - ✅ Aucun mot de passe requis - ✅ Interface visuelle simple **Inconvénients :** - ❌ Nécessite une action manuelle - ❌ Pas de refresh token - ❌ Moins adapté pour l'automatisation ### 📚 Documentation complète Pour plus d'informations sur l'authentification et l'utilisation de l'API : https://www.factpulse.fr/documentation-api/
7
+
8
+ The version of the OpenAPI document: 1.0.0
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 http.client as httplib
17
+ import logging
18
+ from logging import FileHandler
19
+ import multiprocessing
20
+ import sys
21
+ from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
22
+ from typing_extensions import NotRequired, Self
23
+
24
+ import urllib3
25
+
26
+
27
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
28
+ 'multipleOf', 'maximum', 'exclusiveMaximum',
29
+ 'minimum', 'exclusiveMinimum', 'maxLength',
30
+ 'minLength', 'pattern', 'maxItems', 'minItems'
31
+ }
32
+
33
+ ServerVariablesT = Dict[str, str]
34
+
35
+ GenericAuthSetting = TypedDict(
36
+ "GenericAuthSetting",
37
+ {
38
+ "type": str,
39
+ "in": str,
40
+ "key": str,
41
+ "value": str,
42
+ },
43
+ )
44
+
45
+
46
+ OAuth2AuthSetting = TypedDict(
47
+ "OAuth2AuthSetting",
48
+ {
49
+ "type": Literal["oauth2"],
50
+ "in": Literal["header"],
51
+ "key": Literal["Authorization"],
52
+ "value": str,
53
+ },
54
+ )
55
+
56
+
57
+ APIKeyAuthSetting = TypedDict(
58
+ "APIKeyAuthSetting",
59
+ {
60
+ "type": Literal["api_key"],
61
+ "in": str,
62
+ "key": str,
63
+ "value": Optional[str],
64
+ },
65
+ )
66
+
67
+
68
+ BasicAuthSetting = TypedDict(
69
+ "BasicAuthSetting",
70
+ {
71
+ "type": Literal["basic"],
72
+ "in": Literal["header"],
73
+ "key": Literal["Authorization"],
74
+ "value": Optional[str],
75
+ },
76
+ )
77
+
78
+
79
+ BearerFormatAuthSetting = TypedDict(
80
+ "BearerFormatAuthSetting",
81
+ {
82
+ "type": Literal["bearer"],
83
+ "in": Literal["header"],
84
+ "format": Literal["JWT"],
85
+ "key": Literal["Authorization"],
86
+ "value": str,
87
+ },
88
+ )
89
+
90
+
91
+ BearerAuthSetting = TypedDict(
92
+ "BearerAuthSetting",
93
+ {
94
+ "type": Literal["bearer"],
95
+ "in": Literal["header"],
96
+ "key": Literal["Authorization"],
97
+ "value": str,
98
+ },
99
+ )
100
+
101
+
102
+ HTTPSignatureAuthSetting = TypedDict(
103
+ "HTTPSignatureAuthSetting",
104
+ {
105
+ "type": Literal["http-signature"],
106
+ "in": Literal["header"],
107
+ "key": Literal["Authorization"],
108
+ "value": None,
109
+ },
110
+ )
111
+
112
+
113
+ AuthSettings = TypedDict(
114
+ "AuthSettings",
115
+ {
116
+ "HTTPBearer": BearerAuthSetting,
117
+ },
118
+ total=False,
119
+ )
120
+
121
+
122
+ class HostSettingVariable(TypedDict):
123
+ description: str
124
+ default_value: str
125
+ enum_values: List[str]
126
+
127
+
128
+ class HostSetting(TypedDict):
129
+ url: str
130
+ description: str
131
+ variables: NotRequired[Dict[str, HostSettingVariable]]
132
+
133
+
134
+ class Configuration:
135
+ """This class contains various settings of the API client.
136
+
137
+ :param host: Base url.
138
+ :param ignore_operation_servers
139
+ Boolean to ignore operation servers for the API client.
140
+ Config will use `host` as the base url regardless of the operation servers.
141
+ :param api_key: Dict to store API key(s).
142
+ Each entry in the dict specifies an API key.
143
+ The dict key is the name of the security scheme in the OAS specification.
144
+ The dict value is the API key secret.
145
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
146
+ The dict key is the name of the security scheme in the OAS specification.
147
+ The dict value is an API key prefix when generating the auth data.
148
+ :param username: Username for HTTP basic authentication.
149
+ :param password: Password for HTTP basic authentication.
150
+ :param access_token: Access token.
151
+ :param server_index: Index to servers configuration.
152
+ :param server_variables: Mapping with string values to replace variables in
153
+ templated server configuration. The validation of enums is performed for
154
+ variables with defined enum values before.
155
+ :param server_operation_index: Mapping from operation ID to an index to server
156
+ configuration.
157
+ :param server_operation_variables: Mapping from operation ID to a mapping with
158
+ string values to replace variables in templated server configuration.
159
+ The validation of enums is performed for variables with defined enum
160
+ values before.
161
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
162
+ in PEM format.
163
+ :param retries: Number of retries for API requests.
164
+ :param ca_cert_data: verify the peer using concatenated CA certificate data
165
+ in PEM (str) or DER (bytes) format.
166
+ :param cert_file: the path to a client certificate file, for mTLS.
167
+ :param key_file: the path to a client key file, for mTLS.
168
+
169
+ :Example:
170
+ """
171
+
172
+ _default: ClassVar[Optional[Self]] = None
173
+
174
+ def __init__(
175
+ self,
176
+ host: Optional[str]=None,
177
+ api_key: Optional[Dict[str, str]]=None,
178
+ api_key_prefix: Optional[Dict[str, str]]=None,
179
+ username: Optional[str]=None,
180
+ password: Optional[str]=None,
181
+ access_token: Optional[str]=None,
182
+ server_index: Optional[int]=None,
183
+ server_variables: Optional[ServerVariablesT]=None,
184
+ server_operation_index: Optional[Dict[int, int]]=None,
185
+ server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
186
+ ignore_operation_servers: bool=False,
187
+ ssl_ca_cert: Optional[str]=None,
188
+ retries: Optional[int] = None,
189
+ ca_cert_data: Optional[Union[str, bytes]] = None,
190
+ cert_file: Optional[str]=None,
191
+ key_file: Optional[str]=None,
192
+ *,
193
+ debug: Optional[bool] = None,
194
+ ) -> None:
195
+ """Constructor
196
+ """
197
+ self._base_path = "http://localhost" if host is None else host
198
+ """Default Base url
199
+ """
200
+ self.server_index = 0 if server_index is None and host is None else server_index
201
+ self.server_operation_index = server_operation_index or {}
202
+ """Default server index
203
+ """
204
+ self.server_variables = server_variables or {}
205
+ self.server_operation_variables = server_operation_variables or {}
206
+ """Default server variables
207
+ """
208
+ self.ignore_operation_servers = ignore_operation_servers
209
+ """Ignore operation servers
210
+ """
211
+ self.temp_folder_path = None
212
+ """Temp file folder for downloading files
213
+ """
214
+ # Authentication Settings
215
+ self.api_key = {}
216
+ if api_key:
217
+ self.api_key = api_key
218
+ """dict to store API key(s)
219
+ """
220
+ self.api_key_prefix = {}
221
+ if api_key_prefix:
222
+ self.api_key_prefix = api_key_prefix
223
+ """dict to store API prefix (e.g. Bearer)
224
+ """
225
+ self.refresh_api_key_hook = None
226
+ """function hook to refresh API key if expired
227
+ """
228
+ self.username = username
229
+ """Username for HTTP basic authentication
230
+ """
231
+ self.password = password
232
+ """Password for HTTP basic authentication
233
+ """
234
+ self.access_token = access_token
235
+ """Access token
236
+ """
237
+ self.logger = {}
238
+ """Logging Settings
239
+ """
240
+ self.logger["package_logger"] = logging.getLogger("factpulse")
241
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
242
+ self.logger_format = '%(asctime)s %(levelname)s %(message)s'
243
+ """Log format
244
+ """
245
+ self.logger_stream_handler = None
246
+ """Log stream handler
247
+ """
248
+ self.logger_file_handler: Optional[FileHandler] = None
249
+ """Log file handler
250
+ """
251
+ self.logger_file = None
252
+ """Debug file location
253
+ """
254
+ if debug is not None:
255
+ self.debug = debug
256
+ else:
257
+ self.__debug = False
258
+ """Debug switch
259
+ """
260
+
261
+ self.verify_ssl = True
262
+ """SSL/TLS verification
263
+ Set this to false to skip verifying SSL certificate when calling API
264
+ from https server.
265
+ """
266
+ self.ssl_ca_cert = ssl_ca_cert
267
+ """Set this to customize the certificate file to verify the peer.
268
+ """
269
+ self.ca_cert_data = ca_cert_data
270
+ """Set this to verify the peer using PEM (str) or DER (bytes)
271
+ certificate data.
272
+ """
273
+ self.cert_file = cert_file
274
+ """client certificate file
275
+ """
276
+ self.key_file = key_file
277
+ """client key file
278
+ """
279
+ self.assert_hostname = None
280
+ """Set this to True/False to enable/disable SSL hostname verification.
281
+ """
282
+ self.tls_server_name = None
283
+ """SSL/TLS Server Name Indication (SNI)
284
+ Set this to the SNI value expected by the server.
285
+ """
286
+
287
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
288
+ """urllib3 connection pool's maximum number of connections saved
289
+ per pool. urllib3 uses 1 connection as default value, but this is
290
+ not the best value when you are making a lot of possibly parallel
291
+ requests to the same host, which is often the case here.
292
+ cpu_count * 5 is used as default value to increase performance.
293
+ """
294
+
295
+ self.proxy: Optional[str] = None
296
+ """Proxy URL
297
+ """
298
+ self.proxy_headers = None
299
+ """Proxy headers
300
+ """
301
+ self.safe_chars_for_path_param = ''
302
+ """Safe chars for path_param
303
+ """
304
+ self.retries = retries
305
+ """Adding retries to override urllib3 default value 3
306
+ """
307
+ # Enable client side validation
308
+ self.client_side_validation = True
309
+
310
+ self.socket_options = None
311
+ """Options to pass down to the underlying urllib3 socket
312
+ """
313
+
314
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
315
+ """datetime format
316
+ """
317
+
318
+ self.date_format = "%Y-%m-%d"
319
+ """date format
320
+ """
321
+
322
+ def __deepcopy__(self, memo: Dict[int, Any]) -> Self:
323
+ cls = self.__class__
324
+ result = cls.__new__(cls)
325
+ memo[id(self)] = result
326
+ for k, v in self.__dict__.items():
327
+ if k not in ('logger', 'logger_file_handler'):
328
+ setattr(result, k, copy.deepcopy(v, memo))
329
+ # shallow copy of loggers
330
+ result.logger = copy.copy(self.logger)
331
+ # use setters to configure loggers
332
+ result.logger_file = self.logger_file
333
+ result.debug = self.debug
334
+ return result
335
+
336
+ def __setattr__(self, name: str, value: Any) -> None:
337
+ object.__setattr__(self, name, value)
338
+
339
+ @classmethod
340
+ def set_default(cls, default: Optional[Self]) -> None:
341
+ """Set default instance of configuration.
342
+
343
+ It stores default configuration, which can be
344
+ returned by get_default_copy method.
345
+
346
+ :param default: object of Configuration
347
+ """
348
+ cls._default = default
349
+
350
+ @classmethod
351
+ def get_default_copy(cls) -> Self:
352
+ """Deprecated. Please use `get_default` instead.
353
+
354
+ Deprecated. Please use `get_default` instead.
355
+
356
+ :return: The configuration object.
357
+ """
358
+ return cls.get_default()
359
+
360
+ @classmethod
361
+ def get_default(cls) -> Self:
362
+ """Return the default configuration.
363
+
364
+ This method returns newly created, based on default constructor,
365
+ object of Configuration class or returns a copy of default
366
+ configuration.
367
+
368
+ :return: The configuration object.
369
+ """
370
+ if cls._default is None:
371
+ cls._default = cls()
372
+ return cls._default
373
+
374
+ @property
375
+ def logger_file(self) -> Optional[str]:
376
+ """The logger file.
377
+
378
+ If the logger_file is None, then add stream handler and remove file
379
+ handler. Otherwise, add file handler and remove stream handler.
380
+
381
+ :param value: The logger_file path.
382
+ :type: str
383
+ """
384
+ return self.__logger_file
385
+
386
+ @logger_file.setter
387
+ def logger_file(self, value: Optional[str]) -> None:
388
+ """The logger file.
389
+
390
+ If the logger_file is None, then add stream handler and remove file
391
+ handler. Otherwise, add file handler and remove stream handler.
392
+
393
+ :param value: The logger_file path.
394
+ :type: str
395
+ """
396
+ self.__logger_file = value
397
+ if self.__logger_file:
398
+ # If set logging file,
399
+ # then add file handler and remove stream handler.
400
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
401
+ self.logger_file_handler.setFormatter(self.logger_formatter)
402
+ for _, logger in self.logger.items():
403
+ logger.addHandler(self.logger_file_handler)
404
+
405
+ @property
406
+ def debug(self) -> bool:
407
+ """Debug status
408
+
409
+ :param value: The debug status, True or False.
410
+ :type: bool
411
+ """
412
+ return self.__debug
413
+
414
+ @debug.setter
415
+ def debug(self, value: bool) -> None:
416
+ """Debug status
417
+
418
+ :param value: The debug status, True or False.
419
+ :type: bool
420
+ """
421
+ self.__debug = value
422
+ if self.__debug:
423
+ # if debug status is True, turn on debug logging
424
+ for _, logger in self.logger.items():
425
+ logger.setLevel(logging.DEBUG)
426
+ # turn on httplib debug
427
+ httplib.HTTPConnection.debuglevel = 1
428
+ else:
429
+ # if debug status is False, turn off debug logging,
430
+ # setting log level to default `logging.WARNING`
431
+ for _, logger in self.logger.items():
432
+ logger.setLevel(logging.WARNING)
433
+ # turn off httplib debug
434
+ httplib.HTTPConnection.debuglevel = 0
435
+
436
+ @property
437
+ def logger_format(self) -> str:
438
+ """The logger format.
439
+
440
+ The logger_formatter will be updated when sets logger_format.
441
+
442
+ :param value: The format string.
443
+ :type: str
444
+ """
445
+ return self.__logger_format
446
+
447
+ @logger_format.setter
448
+ def logger_format(self, value: str) -> None:
449
+ """The logger format.
450
+
451
+ The logger_formatter will be updated when sets logger_format.
452
+
453
+ :param value: The format string.
454
+ :type: str
455
+ """
456
+ self.__logger_format = value
457
+ self.logger_formatter = logging.Formatter(self.__logger_format)
458
+
459
+ def get_api_key_with_prefix(self, identifier: str, alias: Optional[str]=None) -> Optional[str]:
460
+ """Gets API key (with prefix if set).
461
+
462
+ :param identifier: The identifier of apiKey.
463
+ :param alias: The alternative identifier of apiKey.
464
+ :return: The token for api key authentication.
465
+ """
466
+ if self.refresh_api_key_hook is not None:
467
+ self.refresh_api_key_hook(self)
468
+ key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
469
+ if key:
470
+ prefix = self.api_key_prefix.get(identifier)
471
+ if prefix:
472
+ return "%s %s" % (prefix, key)
473
+ else:
474
+ return key
475
+
476
+ return None
477
+
478
+ def get_basic_auth_token(self) -> Optional[str]:
479
+ """Gets HTTP basic authentication header (string).
480
+
481
+ :return: The token for basic HTTP authentication.
482
+ """
483
+ username = ""
484
+ if self.username is not None:
485
+ username = self.username
486
+ password = ""
487
+ if self.password is not None:
488
+ password = self.password
489
+ return urllib3.util.make_headers(
490
+ basic_auth=username + ':' + password
491
+ ).get('authorization')
492
+
493
+ def auth_settings(self)-> AuthSettings:
494
+ """Gets Auth Settings dict for api client.
495
+
496
+ :return: The Auth Settings information dict.
497
+ """
498
+ auth: AuthSettings = {}
499
+ if self.access_token is not None:
500
+ auth['HTTPBearer'] = {
501
+ 'type': 'bearer',
502
+ 'in': 'header',
503
+ 'key': 'Authorization',
504
+ 'value': 'Bearer ' + self.access_token
505
+ }
506
+ return auth
507
+
508
+ def to_debug_report(self) -> str:
509
+ """Gets the essential information for debugging.
510
+
511
+ :return: The report for debugging.
512
+ """
513
+ return "Python SDK Debug Report:\n"\
514
+ "OS: {env}\n"\
515
+ "Python Version: {pyversion}\n"\
516
+ "Version of the API: 1.0.0\n"\
517
+ "SDK Package Version: 1.0.6".\
518
+ format(env=sys.platform, pyversion=sys.version)
519
+
520
+ def get_host_settings(self) -> List[HostSetting]:
521
+ """Gets an array of host settings
522
+
523
+ :return: An array of host settings
524
+ """
525
+ return [
526
+ {
527
+ 'url': "",
528
+ 'description': "No description provided",
529
+ }
530
+ ]
531
+
532
+ def get_host_from_settings(
533
+ self,
534
+ index: Optional[int],
535
+ variables: Optional[ServerVariablesT]=None,
536
+ servers: Optional[List[HostSetting]]=None,
537
+ ) -> str:
538
+ """Gets host URL based on the index and variables
539
+ :param index: array index of the host settings
540
+ :param variables: hash of variable and the corresponding value
541
+ :param servers: an array of host settings or None
542
+ :return: URL based on host settings
543
+ """
544
+ if index is None:
545
+ return self._base_path
546
+
547
+ variables = {} if variables is None else variables
548
+ servers = self.get_host_settings() if servers is None else servers
549
+
550
+ try:
551
+ server = servers[index]
552
+ except IndexError:
553
+ raise ValueError(
554
+ "Invalid index {0} when selecting the host settings. "
555
+ "Must be less than {1}".format(index, len(servers)))
556
+
557
+ url = server['url']
558
+
559
+ # go through variables and replace placeholders
560
+ for variable_name, variable in server.get('variables', {}).items():
561
+ used_value = variables.get(
562
+ variable_name, variable['default_value'])
563
+
564
+ if 'enum_values' in variable \
565
+ and used_value not in variable['enum_values']:
566
+ raise ValueError(
567
+ "The variable `{0}` in the host URL has invalid value "
568
+ "{1}. Must be {2}.".format(
569
+ variable_name, variables[variable_name],
570
+ variable['enum_values']))
571
+
572
+ url = url.replace("{" + variable_name + "}", used_value)
573
+
574
+ return url
575
+
576
+ @property
577
+ def host(self) -> str:
578
+ """Return generated host."""
579
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
580
+
581
+ @host.setter
582
+ def host(self, value: str) -> None:
583
+ """Fix base path."""
584
+ self._base_path = value
585
+ self.server_index = None