apiverve-csrparser 1.2.3__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.
@@ -0,0 +1,3 @@
1
+ from .apiClient import CsrparserAPIClient, CsrparserAPIClientError
2
+
3
+ __all__ = ['CsrparserAPIClient', 'CsrparserAPIClientError']
@@ -0,0 +1,250 @@
1
+ import re
2
+ from typing import Dict, Optional, Any, List
3
+ from dataclasses import dataclass
4
+ import requests
5
+
6
+
7
+ class CsrparserAPIClientError(Exception):
8
+ """Custom exception for API client errors"""
9
+ def __init__(self, message: str, status_code: Optional[int] = None, response: Optional[Dict] = None):
10
+ self.message = message
11
+ self.status_code = status_code
12
+ self.response = response
13
+ super().__init__(self.message)
14
+
15
+
16
+ class ValidationError(CsrparserAPIClientError):
17
+ """Custom exception for parameter validation errors"""
18
+ def __init__(self, errors: List[str]):
19
+ self.errors = errors
20
+ message = f"Validation failed: {' '.join(errors)}"
21
+ super().__init__(message)
22
+
23
+
24
+ class CsrparserAPIClient:
25
+ # Validation rules for parameters (generated from schema)
26
+ VALIDATION_RULES = {
27
+ "csr": {"type": "string", "required": True}
28
+ }
29
+
30
+ # Format validation patterns
31
+ FORMAT_PATTERNS = {
32
+ 'email': r'^[^\s@]+@[^\s@]+\.[^\s@]+$',
33
+ 'url': r'^https?://.+',
34
+ 'ip': r'^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$',
35
+ 'date': r'^\d{4}-\d{2}-\d{2}$',
36
+ 'hexColor': r'^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$'
37
+ }
38
+
39
+ def __init__(self, api_key: str, secure: bool = True, debug: bool = False):
40
+ """
41
+ Initialize the CsrparserAPIClient with the API key and optional settings
42
+
43
+ :param api_key: Your APIVerve API key
44
+ :param secure: Deprecated. Always set to True
45
+ :param debug: Enable debug logging (default: False)
46
+ :raises CsrparserAPIClientError: If API key is invalid
47
+ """
48
+
49
+ self._validate_api_key(api_key)
50
+
51
+ self.api_key = api_key
52
+ self.secure = secure
53
+ self.debug = debug
54
+ self.base_url = 'https://api.apiverve.com/v1/csrparser'
55
+ self.headers = {
56
+ 'x-api-key': self.api_key,
57
+ 'auth-mode': 'pypi-package'
58
+ }
59
+
60
+ # Create a session for connection pooling
61
+ self.session = requests.Session()
62
+ self.session.headers.update(self.headers)
63
+
64
+ def _validate_api_key(self, api_key: str) -> None:
65
+ """
66
+ Validate the API key format
67
+
68
+ :param api_key: API key to validate
69
+ :raises CsrparserAPIClientError: If API key is invalid
70
+ """
71
+ if not api_key or not api_key.strip():
72
+ raise CsrparserAPIClientError(
73
+ "API key is required. Get your API key at: https://apiverve.com"
74
+ )
75
+
76
+ # Check format (GUID, prefixed keys like apv_xxx, or alphanumeric)
77
+ if not re.match(r'^[a-zA-Z0-9_-]+$', api_key):
78
+ raise CsrparserAPIClientError(
79
+ "Invalid API key format. API key should only contain letters, numbers, hyphens, and underscores. "
80
+ "Get your API key at: https://apiverve.com"
81
+ )
82
+
83
+ def _log(self, message: str) -> None:
84
+ """
85
+ Log a debug message if debug mode is enabled
86
+
87
+ :param message: Message to log
88
+ """
89
+ if self.debug:
90
+ print(f"[CsrparserAPIClient DEBUG] {message}")
91
+
92
+ def _validate_params(self, params: Optional[Dict[str, Any]]) -> None:
93
+ """
94
+ Validate parameters against schema rules
95
+
96
+ :param params: Parameters to validate
97
+ :raises ValidationError: If validation fails
98
+ """
99
+ if not self.VALIDATION_RULES:
100
+ return
101
+
102
+ errors = []
103
+ params = params or {}
104
+
105
+ for param_name, rules in self.VALIDATION_RULES.items():
106
+ value = params.get(param_name)
107
+
108
+ # Check required
109
+ if rules.get('required') and (value is None or value == ''):
110
+ errors.append(f"Required parameter [{param_name}] is missing.")
111
+ continue
112
+
113
+ # Skip validation if value is not provided and not required
114
+ if value is None:
115
+ continue
116
+
117
+ param_type = rules.get('type', 'string')
118
+
119
+ # Type validation
120
+ if param_type in ('integer', 'number'):
121
+ try:
122
+ num_value = float(value) if param_type == 'number' else int(value)
123
+
124
+ # Min/max validation
125
+ if 'min' in rules and num_value < rules['min']:
126
+ errors.append(f"Parameter [{param_name}] must be at least {rules['min']}.")
127
+ if 'max' in rules and num_value > rules['max']:
128
+ errors.append(f"Parameter [{param_name}] must be at most {rules['max']}.")
129
+ except (ValueError, TypeError):
130
+ errors.append(f"Parameter [{param_name}] must be a valid {param_type}.")
131
+ continue
132
+
133
+ elif param_type == 'string':
134
+ if not isinstance(value, str):
135
+ errors.append(f"Parameter [{param_name}] must be a string.")
136
+ continue
137
+
138
+ # Length validation
139
+ if 'minLength' in rules and len(value) < rules['minLength']:
140
+ errors.append(f"Parameter [{param_name}] must be at least {rules['minLength']} characters.")
141
+ if 'maxLength' in rules and len(value) > rules['maxLength']:
142
+ errors.append(f"Parameter [{param_name}] must be at most {rules['maxLength']} characters.")
143
+
144
+ # Format validation
145
+ if 'format' in rules and rules['format'] in self.FORMAT_PATTERNS:
146
+ pattern = self.FORMAT_PATTERNS[rules['format']]
147
+ if not re.match(pattern, value, re.IGNORECASE):
148
+ errors.append(f"Parameter [{param_name}] must be a valid {rules['format']}.")
149
+
150
+ elif param_type == 'boolean':
151
+ if not isinstance(value, bool) and value not in ('true', 'false', True, False):
152
+ errors.append(f"Parameter [{param_name}] must be a boolean.")
153
+
154
+ elif param_type == 'array':
155
+ if not isinstance(value, list):
156
+ errors.append(f"Parameter [{param_name}] must be an array.")
157
+
158
+ # Enum validation
159
+ if 'enum' in rules and value not in rules['enum']:
160
+ errors.append(f"Parameter [{param_name}] must be one of: {', '.join(map(str, rules['enum']))}.")
161
+
162
+ if errors:
163
+ raise ValidationError(errors)
164
+
165
+ def execute(self, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: # Returns CSRParserData in 'data' field
166
+ """
167
+ Execute the API request
168
+
169
+ :param params: API parameters (optional)
170
+ :return: API response as a dictionary
171
+ :raises CsrparserAPIClientError: If the request fails or returns an error
172
+ :raises ValidationError: If parameter validation fails
173
+ """
174
+
175
+ # Validate parameters against schema rules
176
+ self._validate_params(params)
177
+
178
+ method = "POST"
179
+
180
+ self._log(f"Making {method} request to {self.base_url}")
181
+ if params:
182
+ self._log(f"Parameters: {params}")
183
+
184
+ try:
185
+ if method.upper() == 'POST':
186
+ self._log("Sending POST request with JSON body")
187
+ response = self.session.post(self.base_url, json=params, timeout=30)
188
+ else:
189
+ self._log("Sending GET request with query parameters")
190
+ response = self.session.get(self.base_url, params=params, timeout=30)
191
+
192
+ self._log(f"Response status code: {response.status_code}")
193
+
194
+ # Try to parse JSON response
195
+ try:
196
+ response_data = response.json()
197
+ except ValueError as e:
198
+ raise CsrparserAPIClientError(
199
+ f"Invalid JSON response from API: {str(e)}",
200
+ status_code=response.status_code
201
+ )
202
+
203
+ # Check for API-level errors in the response
204
+ if response_data.get('status') == 'error':
205
+ error_message = response_data.get('error', 'Unknown API error')
206
+ self._log(f"API returned error: {error_message}")
207
+ raise CsrparserAPIClientError(
208
+ error_message,
209
+ status_code=response.status_code,
210
+ response=response_data
211
+ )
212
+
213
+ # Check HTTP status code
214
+ if not response.ok:
215
+ error_message = response_data.get('error', f"HTTP {response.status_code} error")
216
+ self._log(f"HTTP error: {error_message}")
217
+ raise CsrparserAPIClientError(
218
+ error_message,
219
+ status_code=response.status_code,
220
+ response=response_data
221
+ )
222
+
223
+ self._log("Request successful")
224
+ return response_data
225
+
226
+ except requests.exceptions.Timeout as e:
227
+ self._log(f"Request timeout: {str(e)}")
228
+ raise CsrparserAPIClientError(f"Request timeout: {str(e)}")
229
+ except requests.exceptions.ConnectionError as e:
230
+ self._log(f"Connection error: {str(e)}")
231
+ raise CsrparserAPIClientError(f"Connection error: {str(e)}")
232
+ except requests.exceptions.RequestException as e:
233
+ self._log(f"Request exception: {str(e)}")
234
+ raise CsrparserAPIClientError(f"Request failed: {str(e)}")
235
+
236
+
237
+ def close(self) -> None:
238
+ """
239
+ Close the session and release resources
240
+ """
241
+ self._log("Closing session")
242
+ self.session.close()
243
+
244
+ def __enter__(self):
245
+ """Context manager entry"""
246
+ return self
247
+
248
+ def __exit__(self, exc_type, exc_val, exc_tb):
249
+ """Context manager exit"""
250
+ self.close()
@@ -0,0 +1,3 @@
1
+ class CsrparserCSRParserAPIError(Exception):
2
+ """A custom exception for API errors"""
3
+ pass
@@ -0,0 +1,26 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ import os
4
+ lib_folder = os.path.dirname(os.path.realpath(__file__))
5
+ requirements_file = os.path.join(lib_folder, 'requirements.txt')
6
+ install_requires = ["requests >= 2.25.1", "setuptools >= 56.0.0"]
7
+ if os.path.exists(requirements_file):
8
+ with open(requirements_file, 'r') as f:
9
+ install_requires = f.read().splitlines()
10
+
11
+ setup(
12
+ name='apiverve_csrparser',
13
+ version='1.2.3',
14
+ packages=find_packages(),
15
+ include_package_data=True,
16
+ install_requires=install_requires,
17
+ description='CSR Parser extracts and analyzes information from Certificate Signing Requests (CSRs), providing detailed subject information, public key details, and fingerprints.',
18
+ author='APIVerve',
19
+ author_email='hello@apiverve.com',
20
+ url='https://apiverve.com/marketplace/csrparser?utm_source=pypi&utm_medium=referral&utm_content=homepage',
21
+ classifiers=[
22
+ 'Programming Language :: Python :: 3',
23
+ 'Operating System :: OS Independent',
24
+ ],
25
+ python_requires='>=3.6',
26
+ )
@@ -0,0 +1,21 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='apiverve_csrparser',
5
+ version='1.2.3',
6
+ packages=find_packages(),
7
+ include_package_data=True,
8
+ install_requires=[
9
+ 'requests',
10
+ 'setuptools'
11
+ ],
12
+ description='CSR Parser extracts and analyzes information from Certificate Signing Requests (CSRs), providing detailed subject information, public key details, and fingerprints.',
13
+ author='APIVerve',
14
+ author_email='hello@apiverve.com',
15
+ url='https://apiverve.com/marketplace/csrparser?utm_source=pypi&utm_medium=referral&utm_content=homepage',
16
+ classifiers=[
17
+ 'Programming Language :: Python :: 3',
18
+ 'Operating System :: OS Independent',
19
+ ],
20
+ python_requires='>=3.6',
21
+ )
@@ -0,0 +1 @@
1
+ # Initialize test module
@@ -0,0 +1,19 @@
1
+ import unittest
2
+ from apiverve_csrparser.apiClient import CsrparserAPIClient
3
+
4
+ class TestClient(unittest.TestCase):
5
+
6
+ def setUp(self):
7
+ self.api_key = 'test_api_key'
8
+ self.client = CsrparserAPIClient(self.api_key)
9
+
10
+ def test_get(self):
11
+ # Assuming there's an endpoint 'test_endpoint' for testing purposes
12
+ try:
13
+ response = self.client.get('test_endpoint')
14
+ self.assertIsInstance(response, dict)
15
+ except Exception as e:
16
+ self.fail(f"GET request failed with exception {e}")
17
+
18
+ if __name__ == '__main__':
19
+ unittest.main()
@@ -0,0 +1,422 @@
1
+ Metadata-Version: 2.4
2
+ Name: apiverve-csrparser
3
+ Version: 1.2.3
4
+ Summary: CSR Parser extracts and analyzes information from Certificate Signing Requests (CSRs), providing detailed subject information, public key details, and fingerprints.
5
+ Author-email: APIVerve <hello@apiverve.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://apiverve.com/marketplace/csrparser?utm_source=pypi&utm_medium=referral&utm_content=homepage
8
+ Project-URL: Documentation, https://docs.apiverve.com/ref/csrparser?utm_source=pypi&utm_medium=referral&utm_content=docs
9
+ Project-URL: Repository, https://github.com/apiverve/csrparser-api
10
+ Project-URL: Twitter, https://twitter.com/apivervehq
11
+ Keywords: csr parser,certificate signing request,ssl certificate,x509,pem format
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Internet :: WWW/HTTP
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Natural Language :: English
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests>=2.25.0
23
+ Dynamic: license-file
24
+
25
+ CSR Parser API
26
+ ============
27
+
28
+ CSR Parser extracts and analyzes information from Certificate Signing Requests (CSRs), providing detailed subject information, public key details, and fingerprints.
29
+
30
+
31
+ [![PyPI version](https://img.shields.io/pypi/v/apiverve-csrparser.svg)](https://pypi.org/project/apiverve-csrparser/)
32
+
33
+ This is a Python wrapper for the [CSR Parser API](https://apiverve.com/marketplace/csrparser?utm_source=pypi&utm_medium=referral&utm_content=readme)
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ Using `pip`:
40
+
41
+ ```bash
42
+ pip install apiverve-csrparser
43
+ ```
44
+
45
+ Using `pip3`:
46
+
47
+ ```bash
48
+ pip3 install apiverve-csrparser
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Configuration
54
+
55
+ Before using the CSR Parser API client, you have to setup your account and obtain your API Key.
56
+ You can get it by signing up at [https://apiverve.com](https://apiverve.com?utm_source=pypi&utm_medium=referral&utm_content=readme)
57
+
58
+ ---
59
+
60
+ ## Quick Start
61
+
62
+ Here's a simple example to get you started quickly:
63
+
64
+ ```python
65
+ from apiverve_csrparser.apiClient import CsrparserAPIClient
66
+
67
+ # Initialize the client with your APIVerve API key
68
+ api = CsrparserAPIClient("[YOUR_API_KEY]")
69
+
70
+ query = { "csr": "-----BEGIN CERTIFICATE REQUEST-----
71
+ MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
72
+ FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO
73
+ BgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG
74
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo
75
+ T/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP
76
+ XFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb
77
+ U86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M
78
+ sel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh
79
+ 9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ
80
+ KoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+
81
+ 5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM
82
+ H3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW
83
+ KqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD
84
+ vVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj
85
+ rJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=
86
+ -----END CERTIFICATE REQUEST-----" }
87
+
88
+ try:
89
+ # Make the API call
90
+ result = api.execute(query)
91
+
92
+ # Print the result
93
+ print(result)
94
+ except Exception as e:
95
+ print(f"Error: {e}")
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Usage
101
+
102
+ The CSR Parser API documentation is found here: [https://docs.apiverve.com/ref/csrparser](https://docs.apiverve.com/ref/csrparser?utm_source=pypi&utm_medium=referral&utm_content=readme).
103
+ You can find parameters, example responses, and status codes documented here.
104
+
105
+ ### Setup
106
+
107
+ ```python
108
+ # Import the client module
109
+ from apiverve_csrparser.apiClient import CsrparserAPIClient
110
+
111
+ # Initialize the client with your APIVerve API key
112
+ api = CsrparserAPIClient("[YOUR_API_KEY]")
113
+ ```
114
+
115
+ ---
116
+
117
+ ## Perform Request
118
+
119
+ Using the API client, you can perform requests to the API.
120
+
121
+ ###### Define Query
122
+
123
+ ```python
124
+ query = { "csr": "-----BEGIN CERTIFICATE REQUEST-----
125
+ MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
126
+ FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO
127
+ BgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG
128
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo
129
+ T/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP
130
+ XFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb
131
+ U86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M
132
+ sel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh
133
+ 9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ
134
+ KoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+
135
+ 5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM
136
+ H3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW
137
+ KqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD
138
+ vVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj
139
+ rJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=
140
+ -----END CERTIFICATE REQUEST-----" }
141
+ ```
142
+
143
+ ###### Simple Request
144
+
145
+ ```python
146
+ # Make a request to the API
147
+ result = api.execute(query)
148
+
149
+ # Print the result
150
+ print(result)
151
+ ```
152
+
153
+ ###### Example Response
154
+
155
+ ```json
156
+ {
157
+ "status": "ok",
158
+ "error": null,
159
+ "data": {
160
+ "version": "v1",
161
+ "subject": {
162
+ "common_name": "example.com",
163
+ "organization": "Example Co",
164
+ "organizational_unit": "DevTeam",
165
+ "locality": "San Francisco",
166
+ "state": "California",
167
+ "country": "US",
168
+ "email": null
169
+ },
170
+ "public_key": {
171
+ "algorithm": "RSA",
172
+ "size_bits": 2048,
173
+ "exponent": 65537
174
+ },
175
+ "signature_algorithm": "SHA256withRSA",
176
+ "extensions": [],
177
+ "fingerprints": {
178
+ "sha1": "05:E5:65:28:8A:47:01:D3:05:EA:3B:3F:F5:DC:C7:42:BF:06:E2:5F",
179
+ "sha256": "E0:0B:C1:59:A3:9E:F9:96:13:7B:CE:98:BC:8F:A1:49:62:4D:2E:CF:85:D5:36:2C:DD:46:9E:96:CF:92:A3:AF",
180
+ "md5": "27:C7:EC:94:73:34:E3:B7:3F:F6:FD:3E:0A:81:EA:3D"
181
+ },
182
+ "pem": "-----BEGIN CERTIFICATE REQUEST-----\nMIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx\nFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO\nBgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG\n9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo\nT/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP\nXFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb\nU86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M\nsel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh\n9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ\nKoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+\n5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM\nH3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW\nKqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD\nvVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj\nrJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=\n-----END CERTIFICATE REQUEST-----",
183
+ "size_bytes": 704,
184
+ "format": "PEM",
185
+ "is_valid": true,
186
+ "security_assessment": {
187
+ "is_weak_key": false,
188
+ "is_deprecated_signature": false,
189
+ "key_strength": "acceptable"
190
+ }
191
+ }
192
+ }
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Error Handling
198
+
199
+ The API client provides comprehensive error handling through the `CsrparserAPIClientError` exception. Here are some examples:
200
+
201
+ ### Basic Error Handling
202
+
203
+ ```python
204
+ from apiverve_csrparser.apiClient import CsrparserAPIClient, CsrparserAPIClientError
205
+
206
+ api = CsrparserAPIClient("[YOUR_API_KEY]")
207
+
208
+ query = { "csr": "-----BEGIN CERTIFICATE REQUEST-----
209
+ MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
210
+ FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO
211
+ BgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG
212
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo
213
+ T/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP
214
+ XFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb
215
+ U86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M
216
+ sel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh
217
+ 9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ
218
+ KoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+
219
+ 5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM
220
+ H3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW
221
+ KqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD
222
+ vVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj
223
+ rJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=
224
+ -----END CERTIFICATE REQUEST-----" }
225
+
226
+ try:
227
+ result = api.execute(query)
228
+ print("Success!")
229
+ print(result)
230
+ except CsrparserAPIClientError as e:
231
+ print(f"API Error: {e.message}")
232
+ if e.status_code:
233
+ print(f"Status Code: {e.status_code}")
234
+ if e.response:
235
+ print(f"Response: {e.response}")
236
+ ```
237
+
238
+ ### Handling Specific Error Types
239
+
240
+ ```python
241
+ from apiverve_csrparser.apiClient import CsrparserAPIClient, CsrparserAPIClientError
242
+
243
+ api = CsrparserAPIClient("[YOUR_API_KEY]")
244
+
245
+ query = { "csr": "-----BEGIN CERTIFICATE REQUEST-----
246
+ MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
247
+ FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO
248
+ BgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG
249
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo
250
+ T/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP
251
+ XFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb
252
+ U86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M
253
+ sel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh
254
+ 9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ
255
+ KoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+
256
+ 5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM
257
+ H3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW
258
+ KqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD
259
+ vVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj
260
+ rJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=
261
+ -----END CERTIFICATE REQUEST-----" }
262
+
263
+ try:
264
+ result = api.execute(query)
265
+
266
+ # Check for successful response
267
+ if result.get('status') == 'success':
268
+ print("Request successful!")
269
+ print(result.get('data'))
270
+ else:
271
+ print(f"API returned an error: {result.get('error')}")
272
+
273
+ except CsrparserAPIClientError as e:
274
+ # Handle API client errors
275
+ if e.status_code == 401:
276
+ print("Unauthorized: Invalid API key")
277
+ elif e.status_code == 429:
278
+ print("Rate limit exceeded")
279
+ elif e.status_code >= 500:
280
+ print("Server error - please try again later")
281
+ else:
282
+ print(f"API error: {e.message}")
283
+ except Exception as e:
284
+ # Handle unexpected errors
285
+ print(f"Unexpected error: {str(e)}")
286
+ ```
287
+
288
+ ### Using Context Manager (Recommended)
289
+
290
+ The client supports the context manager protocol for automatic resource cleanup:
291
+
292
+ ```python
293
+ from apiverve_csrparser.apiClient import CsrparserAPIClient, CsrparserAPIClientError
294
+
295
+ query = { "csr": "-----BEGIN CERTIFICATE REQUEST-----
296
+ MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
297
+ FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO
298
+ BgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG
299
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo
300
+ T/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP
301
+ XFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb
302
+ U86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M
303
+ sel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh
304
+ 9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ
305
+ KoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+
306
+ 5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM
307
+ H3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW
308
+ KqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD
309
+ vVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj
310
+ rJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=
311
+ -----END CERTIFICATE REQUEST-----" }
312
+
313
+ # Using context manager ensures proper cleanup
314
+ with CsrparserAPIClient("[YOUR_API_KEY]") as api:
315
+ try:
316
+ result = api.execute(query)
317
+ print(result)
318
+ except CsrparserAPIClientError as e:
319
+ print(f"Error: {e.message}")
320
+ # Session is automatically closed here
321
+ ```
322
+
323
+ ---
324
+
325
+ ## Advanced Features
326
+
327
+ ### Debug Mode
328
+
329
+ Enable debug logging to see detailed request and response information:
330
+
331
+ ```python
332
+ from apiverve_csrparser.apiClient import CsrparserAPIClient
333
+
334
+ # Enable debug mode
335
+ api = CsrparserAPIClient("[YOUR_API_KEY]", debug=True)
336
+
337
+ query = { "csr": "-----BEGIN CERTIFICATE REQUEST-----
338
+ MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
339
+ FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO
340
+ BgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG
341
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo
342
+ T/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP
343
+ XFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb
344
+ U86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M
345
+ sel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh
346
+ 9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ
347
+ KoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+
348
+ 5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM
349
+ H3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW
350
+ KqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD
351
+ vVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj
352
+ rJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=
353
+ -----END CERTIFICATE REQUEST-----" }
354
+
355
+ # Debug information will be printed to console
356
+ result = api.execute(query)
357
+ ```
358
+
359
+ ### Manual Session Management
360
+
361
+ If you need to manually manage the session lifecycle:
362
+
363
+ ```python
364
+ from apiverve_csrparser.apiClient import CsrparserAPIClient
365
+
366
+ api = CsrparserAPIClient("[YOUR_API_KEY]")
367
+
368
+ query = { "csr": "-----BEGIN CERTIFICATE REQUEST-----
369
+ MIICvDCCAaQCAQAwdzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWEx
370
+ FjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkV4YW1wbGUgQ28xEDAO
371
+ BgNVBAsMB0RldlRlYW0xFDASBgNVBAMMC2V4YW1wbGUuY29tMIIBIjANBgkqhkiG
372
+ 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjd/RepiCLQ5/HfKynijcPdiwygrSgxQeTKPo
373
+ T/WiEaRTaUToW9uDUeiIHK83Tgn2+TIONpMoLJRNG+zslpHybWhVVWNlamkrlRwP
374
+ XFQJzsxDN5+TQugILatLsp680SgMNyyPtDIpT3niiNuQ4NFepQLvQTbjXgj1celb
375
+ U86CCeJzYengTF0ZE9Ra+/SsRTA+oy0fNLChNMc2DBaybccxwV2rNWvlvPdhfB7M
376
+ sel3sw/x2hsbWoYC/kudzYmoDPZKX+XOhCkFwUgwib8V4hbjVLcOYsPBJcROYpRh
377
+ 9d5g7xdRlbF1I7dHsCRKnsvkIONtwKQmJ2v/UPqYahjtm2TPUQIDAQABoAAwDQYJ
378
+ KoZIhvcNAQELBQADggEBAFEHOsN2SkB3qFBMk9JR5IDoh8rSUKj/310DOwilOQm+
379
+ 5lAwRfcFMYCl9yf4IV+XPPfvT3ahzUFfi8Fc98CDeIxAhEwtuZFlE7LA5+/F4HXM
380
+ H3gzqTFwOZq+Wa2m029/BvcyII830h4Z+gU68R52px7O7wYSbAR/n7t1fh2bxzmW
381
+ KqqjrvCpHoMVpgcm9y2bYTj+HLxgX4/uADFvotQppOWZi0ctam+if3Kqb3Kd2MFD
382
+ vVHZp9NwEoqNPxmFEzcyOk2y1PYhhRja7rjdC6bdAqj6JRt+WSzStvgx7aEsxBQj
383
+ rJCMi+GypGf9xQUfCJBhTDQVQ3fmCKTfddDeeVbJBrA=
384
+ -----END CERTIFICATE REQUEST-----" }
385
+
386
+ try:
387
+ result = api.execute(query)
388
+ print(result)
389
+ finally:
390
+ # Manually close the session when done
391
+ api.close()
392
+ ```
393
+
394
+ ---
395
+
396
+ ## Customer Support
397
+
398
+ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/contact?utm_source=pypi&utm_medium=referral&utm_content=readme).
399
+
400
+ ---
401
+
402
+ ## Updates
403
+ Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
404
+
405
+ ---
406
+
407
+ ## Legal
408
+
409
+ All usage of the APIVerve website, API, and services is subject to the [APIVerve Terms of Service](https://apiverve.com/terms?utm_source=pypi&utm_medium=referral&utm_content=readme) and all legal documents and agreements.
410
+
411
+ ---
412
+
413
+ ## License
414
+ Licensed under the MIT License (MIT)
415
+
416
+ Copyright (&copy;) 2026 APIVerve, and EvlarSoft LLC
417
+
418
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
419
+
420
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
421
+
422
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ apiverve_csrparser/__init__.py,sha256=ML40PhDRceL_XrhIa6CD3gsc5aGTml5Yvv3AxhgdHEE,127
2
+ apiverve_csrparser/apiClient.py,sha256=PbhyPPDn1qP4cXiAR-W_Zjz7yPuMOangLfhpcjRHmgA,9686
3
+ apiverve_csrparser/exceptions.py,sha256=dIAb9TITpDBCS_0zt7vgkXaTs6JqsjmwMobefC7Aw6c,98
4
+ apiverve_csrparser/setup.py,sha256=uLIFfLyEZZP2Oq0catMFi61wRac4n6TPRblDGfLEg-M,1039
5
+ apiverve_csrparser/setup_dep.py,sha256=21HDS25NIQUqEI7jbDIvnJUdtNySTWoOCPyMYDsZ7kE,742
6
+ apiverve_csrparser/tests/__init__.py,sha256=5_6uOnBkgWAawI5-lr0N2cZ_UVvIGJ7NCh4XT5KF47o,25
7
+ apiverve_csrparser/tests/test_api.py,sha256=LEmc7YymTBmhOZGDVsDi3G9v4CgwqGRT16yNxt_Xlyg,592
8
+ apiverve_csrparser-1.2.3.dist-info/licenses/LICENSE,sha256=V5x7AJRnWqzyPdD_hz1UOO2zYKZGOdRWdXElPTdwxwE,1092
9
+ apiverve_csrparser-1.2.3.dist-info/METADATA,sha256=tPNjgrKMzz9cTeTiCxoC_GsAcSlDgN2bb72ilgwB1rE,16921
10
+ apiverve_csrparser-1.2.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
11
+ apiverve_csrparser-1.2.3.dist-info/top_level.txt,sha256=l4nMoMXck13cMh34hYRHTuwIK32u8nMkNjeuggFivOQ,19
12
+ apiverve_csrparser-1.2.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 APIVerve and EvlarSoft LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ apiverve_csrparser