databunkerpro 0.1.0__tar.gz

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 securitybunker
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,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: databunkerpro
3
+ Version: 0.1.0
4
+ Summary: Python client library for DatabunkerPro API
5
+ Home-page: https://github.com/yourusername/databunkerpro-python
6
+ Author: Your Name
7
+ Author-email: your.email@example.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Requires-Python: >=3.7
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: requests>=2.25.1
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=6.0; extra == "dev"
23
+ Requires-Dist: pytest-cov>=2.0; extra == "dev"
24
+ Requires-Dist: black>=21.0; extra == "dev"
25
+ Requires-Dist: isort>=5.0; extra == "dev"
26
+ Requires-Dist: mypy>=0.910; extra == "dev"
27
+ Requires-Dist: types-requests; extra == "dev"
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: license-file
35
+ Dynamic: provides-extra
36
+ Dynamic: requires-dist
37
+ Dynamic: requires-python
38
+ Dynamic: summary
39
+
40
+ # DatabunkerPro Python Client
41
+
42
+ A Python client library for interacting with the DatabunkerPro API. This library provides a simple and intuitive interface for managing user data, tokens, and other DatabunkerPro features.
43
+
44
+ ## Installation
45
+
46
+ You can install the package using pip:
47
+
48
+ ```bash
49
+ pip install databunkerpro
50
+ ```
51
+
52
+ Or install directly from GitHub:
53
+
54
+ ```bash
55
+ pip install git+https://github.com/yourusername/databunkerpro-python.git
56
+ ```
57
+
58
+ ## Quick Start
59
+
60
+ ```python
61
+ from databunkerpro import DatabunkerproAPI
62
+
63
+ # Initialize the client
64
+ api = DatabunkerproAPI(
65
+ base_url="https://pro.databunker.org",
66
+ x_bunker_token="your-api-token",
67
+ x_bunker_tenant="your-tenant-name"
68
+ )
69
+
70
+ # Create a new user
71
+ user_data = {
72
+ "email": "user@example.com",
73
+ "name": "John Doe",
74
+ "phone": "+1234567890"
75
+ }
76
+ result = api.create_user(user_data)
77
+ print(f"Created user with token: {result['token']}")
78
+
79
+ # Get user information
80
+ user = api.get_user("email", "user@example.com")
81
+ print(f"User profile: {user['profile']}")
82
+
83
+ # Update user information
84
+ update_data = {
85
+ "name": "John Updated",
86
+ "phone": "+0987654321"
87
+ }
88
+ api.update_user("email", "user@example.com", update_data)
89
+
90
+ # Create a token for sensitive data
91
+ token_result = api.create_token("creditcard", "4111111111111111")
92
+ print(f"Created token: {token_result['token']}")
93
+ ```
94
+
95
+ ## Features
96
+
97
+ - User Management (create, read, update, delete)
98
+ - Token Management
99
+ - System Statistics
100
+ - Type hints and comprehensive documentation
101
+ - Error handling and validation
102
+
103
+ ## Development
104
+
105
+ To set up the development environment:
106
+
107
+ 1. Clone the repository:
108
+ ```bash
109
+ git clone https://github.com/yourusername/databunkerpro-python.git
110
+ cd databunkerpro-python
111
+ ```
112
+
113
+ 2. Install development dependencies:
114
+ ```bash
115
+ pip install -e ".[dev]"
116
+ ```
117
+
118
+ 3. Run tests:
119
+ ```bash
120
+ pytest
121
+ ```
122
+
123
+ ## Contributing
124
+
125
+ Contributions are welcome! Please feel free to submit a Pull Request.
126
+
127
+ 1. Fork the repository
128
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
129
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
130
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
131
+ 5. Open a Pull Request
132
+
133
+ ## License
134
+
135
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
136
+
137
+ ## Support
138
+
139
+ If you encounter any issues or have questions, please [open an issue](https://github.com/yourusername/databunkerpro-python/issues) on GitHub.
140
+
141
+ ## API Documentation
142
+
143
+ For detailed API documentation, please visit the [DatabunkerPro API Documentation](https://docs.databunker.org).
@@ -0,0 +1,104 @@
1
+ # DatabunkerPro Python Client
2
+
3
+ A Python client library for interacting with the DatabunkerPro API. This library provides a simple and intuitive interface for managing user data, tokens, and other DatabunkerPro features.
4
+
5
+ ## Installation
6
+
7
+ You can install the package using pip:
8
+
9
+ ```bash
10
+ pip install databunkerpro
11
+ ```
12
+
13
+ Or install directly from GitHub:
14
+
15
+ ```bash
16
+ pip install git+https://github.com/yourusername/databunkerpro-python.git
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```python
22
+ from databunkerpro import DatabunkerproAPI
23
+
24
+ # Initialize the client
25
+ api = DatabunkerproAPI(
26
+ base_url="https://pro.databunker.org",
27
+ x_bunker_token="your-api-token",
28
+ x_bunker_tenant="your-tenant-name"
29
+ )
30
+
31
+ # Create a new user
32
+ user_data = {
33
+ "email": "user@example.com",
34
+ "name": "John Doe",
35
+ "phone": "+1234567890"
36
+ }
37
+ result = api.create_user(user_data)
38
+ print(f"Created user with token: {result['token']}")
39
+
40
+ # Get user information
41
+ user = api.get_user("email", "user@example.com")
42
+ print(f"User profile: {user['profile']}")
43
+
44
+ # Update user information
45
+ update_data = {
46
+ "name": "John Updated",
47
+ "phone": "+0987654321"
48
+ }
49
+ api.update_user("email", "user@example.com", update_data)
50
+
51
+ # Create a token for sensitive data
52
+ token_result = api.create_token("creditcard", "4111111111111111")
53
+ print(f"Created token: {token_result['token']}")
54
+ ```
55
+
56
+ ## Features
57
+
58
+ - User Management (create, read, update, delete)
59
+ - Token Management
60
+ - System Statistics
61
+ - Type hints and comprehensive documentation
62
+ - Error handling and validation
63
+
64
+ ## Development
65
+
66
+ To set up the development environment:
67
+
68
+ 1. Clone the repository:
69
+ ```bash
70
+ git clone https://github.com/yourusername/databunkerpro-python.git
71
+ cd databunkerpro-python
72
+ ```
73
+
74
+ 2. Install development dependencies:
75
+ ```bash
76
+ pip install -e ".[dev]"
77
+ ```
78
+
79
+ 3. Run tests:
80
+ ```bash
81
+ pytest
82
+ ```
83
+
84
+ ## Contributing
85
+
86
+ Contributions are welcome! Please feel free to submit a Pull Request.
87
+
88
+ 1. Fork the repository
89
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
90
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
91
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
92
+ 5. Open a Pull Request
93
+
94
+ ## License
95
+
96
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
97
+
98
+ ## Support
99
+
100
+ If you encounter any issues or have questions, please [open an issue](https://github.com/yourusername/databunkerpro-python/issues) on GitHub.
101
+
102
+ ## API Documentation
103
+
104
+ For detailed API documentation, please visit the [DatabunkerPro API Documentation](https://docs.databunker.org).
@@ -0,0 +1,9 @@
1
+ """
2
+ DatabunkerPro Python Client Library
3
+ A Python client library for interacting with the DatabunkerPro API.
4
+ """
5
+
6
+ from .api import DatabunkerproAPI
7
+
8
+ __version__ = "0.1.0"
9
+ __all__ = ["DatabunkerproAPI"]
@@ -0,0 +1,250 @@
1
+ """
2
+ DatabunkerPro API Client
3
+ Main implementation of the DatabunkerPro API client.
4
+ """
5
+
6
+ import json
7
+ from datetime import datetime
8
+ from typing import Any, Dict, List, Optional, Union
9
+
10
+ import requests
11
+
12
+
13
+ class DatabunkerproAPI:
14
+ """Main client class for interacting with the DatabunkerPro API."""
15
+
16
+ def __init__(
17
+ self, base_url: str, x_bunker_token: str = "", x_bunker_tenant: str = ""
18
+ ):
19
+ """
20
+ Initialize the DatabunkerPro API client.
21
+
22
+ Args:
23
+ base_url (str): The base URL of the DatabunkerPro API
24
+ x_bunker_token (str, optional): The X-Bunker-Token for authentication
25
+ x_bunker_tenant (str, optional): The X-Bunker-Tenant identifier
26
+ """
27
+ self.base_url = base_url.rstrip("/")
28
+ self.x_bunker_token = x_bunker_token
29
+ self.x_bunker_tenant = x_bunker_tenant
30
+
31
+ def _make_request(
32
+ self,
33
+ endpoint: str,
34
+ method: str = "POST",
35
+ data: Optional[Dict[str, Any]] = None,
36
+ request_metadata: Optional[Dict[str, Any]] = None,
37
+ ) -> Dict[str, Any]:
38
+ """
39
+ Make a request to the DatabunkerPro API.
40
+
41
+ Args:
42
+ endpoint (str): The API endpoint to call
43
+ method (str, optional): The HTTP method to use. Defaults to "POST"
44
+ data (Dict[str, Any], optional): The data to send in the request body
45
+ request_metadata (Dict[str, Any], optional): Additional metadata to include in the request
46
+
47
+ Returns:
48
+ Dict[str, Any]: The API response
49
+
50
+ Raises:
51
+ Exception: If the API request fails
52
+ """
53
+ headers = {"Content-Type": "application/json"}
54
+
55
+ if self.x_bunker_token:
56
+ headers["X-Bunker-Token"] = self.x_bunker_token
57
+ if self.x_bunker_tenant:
58
+ headers["X-Bunker-Tenant"] = self.x_bunker_tenant
59
+
60
+ url = f"{self.base_url}/v2/{endpoint}"
61
+
62
+ if data or request_metadata:
63
+ body_data = data.copy() if data else {}
64
+ if request_metadata:
65
+ body_data["request_metadata"] = request_metadata
66
+ body = json.dumps(body_data)
67
+ else:
68
+ body = None
69
+
70
+ try:
71
+ response = requests.request(method, url, headers=headers, data=body)
72
+ response.raise_for_status()
73
+ result: Dict[str, Any] = response.json()
74
+
75
+ if not response.ok:
76
+ if result.get("status"):
77
+ return result
78
+ else:
79
+ return {
80
+ "status": "error",
81
+ "message": result.get("message", "API request failed"),
82
+ }
83
+
84
+ return result
85
+ except requests.exceptions.RequestException as e:
86
+ return {"status": "error", "message": f"Error making request: {str(e)}"}
87
+
88
+ def create_user(
89
+ self,
90
+ profile: Dict[str, Any],
91
+ options: Optional[Dict[str, Any]] = None,
92
+ request_metadata: Optional[Dict[str, Any]] = None,
93
+ ) -> Dict[str, Any]:
94
+ """
95
+ Create a new user in DatabunkerPro.
96
+
97
+ Args:
98
+ profile (Dict[str, Any]): User profile data
99
+ options (Dict[str, Any], optional): Additional options for user creation
100
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
101
+
102
+ Returns:
103
+ Dict[str, Any]: The API response
104
+ """
105
+ data = {"profile": profile}
106
+ if options:
107
+ data.update(options)
108
+ return self._make_request("UserCreate", "POST", data, request_metadata)
109
+
110
+ def get_user(
111
+ self,
112
+ mode: str,
113
+ identity: str,
114
+ request_metadata: Optional[Dict[str, Any]] = None,
115
+ ) -> Dict[str, Any]:
116
+ """
117
+ Get user information from DatabunkerPro.
118
+
119
+ Args:
120
+ mode (str): The identification mode (e.g., 'email', 'phone', 'token')
121
+ identity (str): The user's identifier
122
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
123
+
124
+ Returns:
125
+ Dict[str, Any]: The API response
126
+ """
127
+ return self._make_request(
128
+ "UserGet", "POST", {"mode": mode, "identity": identity}, request_metadata
129
+ )
130
+
131
+ def update_user(
132
+ self,
133
+ mode: str,
134
+ identity: str,
135
+ profile: Dict[str, Any],
136
+ request_metadata: Optional[Dict[str, Any]] = None,
137
+ ) -> Dict[str, Any]:
138
+ """
139
+ Update user information in DatabunkerPro.
140
+
141
+ Args:
142
+ mode (str): The identification mode (e.g., 'email', 'phone', 'token')
143
+ identity (str): The user's identifier
144
+ profile (Dict[str, Any]): Updated user profile data
145
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
146
+
147
+ Returns:
148
+ Dict[str, Any]: The API response
149
+ """
150
+ return self._make_request(
151
+ "UserUpdate",
152
+ "POST",
153
+ {"mode": mode, "identity": identity, "profile": profile},
154
+ request_metadata,
155
+ )
156
+
157
+ def delete_user(
158
+ self,
159
+ mode: str,
160
+ identity: str,
161
+ request_metadata: Optional[Dict[str, Any]] = None,
162
+ ) -> Dict[str, Any]:
163
+ """
164
+ Delete a user from DatabunkerPro.
165
+
166
+ Args:
167
+ mode (str): The identification mode (e.g., 'email', 'phone', 'token')
168
+ identity (str): The user's identifier
169
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
170
+
171
+ Returns:
172
+ Dict[str, Any]: The API response
173
+ """
174
+ return self._make_request(
175
+ "UserDelete", "POST", {"mode": mode, "identity": identity}, request_metadata
176
+ )
177
+
178
+ def get_system_stats(
179
+ self, request_metadata: Optional[Dict[str, Any]] = None
180
+ ) -> Dict[str, Any]:
181
+ """
182
+ Get system statistics from DatabunkerPro.
183
+
184
+ Args:
185
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
186
+
187
+ Returns:
188
+ Dict[str, Any]: The API response containing system statistics
189
+ """
190
+ return self._make_request(
191
+ "SystemGetSystemStats", "POST", None, request_metadata
192
+ )
193
+
194
+ def create_token(
195
+ self,
196
+ token_type: str,
197
+ record: str,
198
+ options: Optional[Dict[str, Any]] = None,
199
+ request_metadata: Optional[Dict[str, Any]] = None,
200
+ ) -> Dict[str, Any]:
201
+ """
202
+ Create a token for sensitive data.
203
+
204
+ Args:
205
+ token_type (str): Type of token (e.g., 'creditcard')
206
+ record (str): The sensitive data to tokenize
207
+ options (Dict[str, Any], optional): Additional options for token creation
208
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
209
+
210
+ Returns:
211
+ Dict[str, Any]: The API response
212
+ """
213
+ data = {"tokentype": token_type, "record": record}
214
+ if options:
215
+ data.update(options)
216
+ return self._make_request("TokenCreate", "POST", data, request_metadata)
217
+
218
+ def get_token(
219
+ self, token: str, request_metadata: Optional[Dict[str, Any]] = None
220
+ ) -> Dict[str, Any]:
221
+ """
222
+ Get token information from DatabunkerPro.
223
+
224
+ Args:
225
+ token (str): The token to retrieve
226
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
227
+
228
+ Returns:
229
+ Dict[str, Any]: The API response
230
+ """
231
+ return self._make_request(
232
+ "TokenGet", "POST", {"token": token}, request_metadata
233
+ )
234
+
235
+ def delete_token(
236
+ self, token: str, request_metadata: Optional[Dict[str, Any]] = None
237
+ ) -> Dict[str, Any]:
238
+ """
239
+ Delete a token from DatabunkerPro.
240
+
241
+ Args:
242
+ token (str): The token to delete
243
+ request_metadata (Dict[str, Any], optional): Additional metadata for the request
244
+
245
+ Returns:
246
+ Dict[str, Any]: The API response
247
+ """
248
+ return self._make_request(
249
+ "TokenDelete", "POST", {"token": token}, request_metadata
250
+ )
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: databunkerpro
3
+ Version: 0.1.0
4
+ Summary: Python client library for DatabunkerPro API
5
+ Home-page: https://github.com/yourusername/databunkerpro-python
6
+ Author: Your Name
7
+ Author-email: your.email@example.com
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.7
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Requires-Python: >=3.7
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: requests>=2.25.1
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=6.0; extra == "dev"
23
+ Requires-Dist: pytest-cov>=2.0; extra == "dev"
24
+ Requires-Dist: black>=21.0; extra == "dev"
25
+ Requires-Dist: isort>=5.0; extra == "dev"
26
+ Requires-Dist: mypy>=0.910; extra == "dev"
27
+ Requires-Dist: types-requests; extra == "dev"
28
+ Dynamic: author
29
+ Dynamic: author-email
30
+ Dynamic: classifier
31
+ Dynamic: description
32
+ Dynamic: description-content-type
33
+ Dynamic: home-page
34
+ Dynamic: license-file
35
+ Dynamic: provides-extra
36
+ Dynamic: requires-dist
37
+ Dynamic: requires-python
38
+ Dynamic: summary
39
+
40
+ # DatabunkerPro Python Client
41
+
42
+ A Python client library for interacting with the DatabunkerPro API. This library provides a simple and intuitive interface for managing user data, tokens, and other DatabunkerPro features.
43
+
44
+ ## Installation
45
+
46
+ You can install the package using pip:
47
+
48
+ ```bash
49
+ pip install databunkerpro
50
+ ```
51
+
52
+ Or install directly from GitHub:
53
+
54
+ ```bash
55
+ pip install git+https://github.com/yourusername/databunkerpro-python.git
56
+ ```
57
+
58
+ ## Quick Start
59
+
60
+ ```python
61
+ from databunkerpro import DatabunkerproAPI
62
+
63
+ # Initialize the client
64
+ api = DatabunkerproAPI(
65
+ base_url="https://pro.databunker.org",
66
+ x_bunker_token="your-api-token",
67
+ x_bunker_tenant="your-tenant-name"
68
+ )
69
+
70
+ # Create a new user
71
+ user_data = {
72
+ "email": "user@example.com",
73
+ "name": "John Doe",
74
+ "phone": "+1234567890"
75
+ }
76
+ result = api.create_user(user_data)
77
+ print(f"Created user with token: {result['token']}")
78
+
79
+ # Get user information
80
+ user = api.get_user("email", "user@example.com")
81
+ print(f"User profile: {user['profile']}")
82
+
83
+ # Update user information
84
+ update_data = {
85
+ "name": "John Updated",
86
+ "phone": "+0987654321"
87
+ }
88
+ api.update_user("email", "user@example.com", update_data)
89
+
90
+ # Create a token for sensitive data
91
+ token_result = api.create_token("creditcard", "4111111111111111")
92
+ print(f"Created token: {token_result['token']}")
93
+ ```
94
+
95
+ ## Features
96
+
97
+ - User Management (create, read, update, delete)
98
+ - Token Management
99
+ - System Statistics
100
+ - Type hints and comprehensive documentation
101
+ - Error handling and validation
102
+
103
+ ## Development
104
+
105
+ To set up the development environment:
106
+
107
+ 1. Clone the repository:
108
+ ```bash
109
+ git clone https://github.com/yourusername/databunkerpro-python.git
110
+ cd databunkerpro-python
111
+ ```
112
+
113
+ 2. Install development dependencies:
114
+ ```bash
115
+ pip install -e ".[dev]"
116
+ ```
117
+
118
+ 3. Run tests:
119
+ ```bash
120
+ pytest
121
+ ```
122
+
123
+ ## Contributing
124
+
125
+ Contributions are welcome! Please feel free to submit a Pull Request.
126
+
127
+ 1. Fork the repository
128
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
129
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
130
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
131
+ 5. Open a Pull Request
132
+
133
+ ## License
134
+
135
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
136
+
137
+ ## Support
138
+
139
+ If you encounter any issues or have questions, please [open an issue](https://github.com/yourusername/databunkerpro-python/issues) on GitHub.
140
+
141
+ ## API Documentation
142
+
143
+ For detailed API documentation, please visit the [DatabunkerPro API Documentation](https://docs.databunker.org).
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ databunkerpro/__init__.py
6
+ databunkerpro/api.py
7
+ databunkerpro.egg-info/PKG-INFO
8
+ databunkerpro.egg-info/SOURCES.txt
9
+ databunkerpro.egg-info/dependency_links.txt
10
+ databunkerpro.egg-info/requires.txt
11
+ databunkerpro.egg-info/top_level.txt
12
+ tests/test_api.py
@@ -0,0 +1,9 @@
1
+ requests>=2.25.1
2
+
3
+ [dev]
4
+ pytest>=6.0
5
+ pytest-cov>=2.0
6
+ black>=21.0
7
+ isort>=5.0
8
+ mypy>=0.910
9
+ types-requests
@@ -0,0 +1 @@
1
+ databunkerpro
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.black]
6
+ line-length = 88
7
+ target-version = ['py37', 'py38', 'py39', 'py310']
8
+ include = '\.pyi?$'
9
+
10
+ [tool.isort]
11
+ profile = "black"
12
+ multi_line_output = 3
13
+ include_trailing_comma = true
14
+ force_grid_wrap = 0
15
+ use_parentheses = true
16
+ line_length = 88
17
+
18
+ [tool.mypy]
19
+ python_version = "3.8"
20
+ warn_return_any = true
21
+ warn_unused_configs = true
22
+ disallow_untyped_defs = true
23
+ disallow_incomplete_defs = true
24
+ check_untyped_defs = true
25
+ disallow_untyped_decorators = true
26
+ no_implicit_optional = true
27
+ warn_redundant_casts = true
28
+ warn_unused_ignores = true
29
+ warn_no_return = true
30
+ warn_unreachable = true
31
+
32
+ [[tool.mypy.overrides]]
33
+ module = ["tests.*"]
34
+ disallow_untyped_defs = false
35
+ disallow_incomplete_defs = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,41 @@
1
+ from setuptools import find_packages, setup
2
+
3
+ with open("README.md", "r", encoding="utf-8") as fh:
4
+ long_description = fh.read()
5
+
6
+ setup(
7
+ name="databunkerpro",
8
+ version="0.1.0",
9
+ author="Your Name",
10
+ author_email="your.email@example.com",
11
+ description="Python client library for DatabunkerPro API",
12
+ long_description=long_description,
13
+ long_description_content_type="text/markdown",
14
+ url="https://github.com/yourusername/databunkerpro-python",
15
+ packages=find_packages(),
16
+ classifiers=[
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.7",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ ],
27
+ python_requires=">=3.7",
28
+ install_requires=[
29
+ "requests>=2.25.1",
30
+ ],
31
+ extras_require={
32
+ "dev": [
33
+ "pytest>=6.0",
34
+ "pytest-cov>=2.0",
35
+ "black>=21.0",
36
+ "isort>=5.0",
37
+ "mypy>=0.910",
38
+ "types-requests",
39
+ ],
40
+ },
41
+ )
@@ -0,0 +1,114 @@
1
+ """
2
+ Tests for the DatabunkerPro API client.
3
+ """
4
+
5
+ import os
6
+ import random
7
+ import unittest
8
+
9
+ import requests
10
+
11
+ from databunkerpro import DatabunkerproAPI
12
+
13
+
14
+ class TestDatabunkerproAPI(unittest.TestCase):
15
+ """Test cases for the DatabunkerPro API client."""
16
+
17
+ @classmethod
18
+ def setUpClass(cls):
19
+ """Set up test environment before running tests."""
20
+ # Try to get credentials from environment first
21
+ cls.api_url = os.getenv("DATABUNKER_API_URL", "https://pro.databunker.org")
22
+ cls.api_token = os.getenv("DATABUNKER_API_TOKEN", "")
23
+ cls.tenant_name = os.getenv("DATABUNKER_TENANT_NAME", "")
24
+
25
+ # If credentials are not in environment, try to get them from sandbox server
26
+ if not all([cls.api_token, cls.tenant_name]):
27
+ try:
28
+ response = requests.get(
29
+ "https://databunker.org/api/newtenant.php", verify=False
30
+ )
31
+ if response.ok:
32
+ data = response.json()
33
+ if data and data.get("status") == "ok":
34
+ cls.tenant_name = data["tenantname"]
35
+ cls.api_token = data["xtoken"]
36
+ print(
37
+ "\nSuccessfully connected to DatabunkerPro sandbox server"
38
+ )
39
+ print(f"Tenant: {cls.tenant_name}")
40
+ print(f"API URL: {cls.api_url}")
41
+ else:
42
+ raise unittest.SkipTest(
43
+ "Failed to get credentials from sandbox server"
44
+ )
45
+ else:
46
+ raise unittest.SkipTest("Failed to connect to sandbox server")
47
+ except Exception as e:
48
+ raise unittest.SkipTest(f"Failed to get credentials: {str(e)}")
49
+
50
+ # Initialize API client
51
+ cls.api = DatabunkerproAPI(cls.api_url, cls.api_token, cls.tenant_name)
52
+
53
+ # Test connection
54
+ try:
55
+ result = cls.api.get_system_stats()
56
+ if not (isinstance(result, dict) and result.get("status") == "ok"):
57
+ raise unittest.SkipTest("Failed to connect to DatabunkerPro server")
58
+ except Exception as e:
59
+ raise unittest.SkipTest(
60
+ f"Failed to connect to DatabunkerPro server: {str(e)}"
61
+ )
62
+
63
+ def test_create_user(self):
64
+ """Test user creation."""
65
+ user_data = {
66
+ "email": f"test{random.randint(1000, 999999)}@example.com",
67
+ "name": f"Test User {random.randint(1000, 999999)}",
68
+ "phone": str(random.randint(1000, 999999)),
69
+ }
70
+ result = self.api.create_user(user_data)
71
+ self.assertIsInstance(result, dict)
72
+ self.assertEqual(result.get("status"), "ok")
73
+ self.assertIn("token", result)
74
+ return user_data["email"]
75
+
76
+ def test_get_user(self):
77
+ """Test user retrieval."""
78
+ email = self.test_create_user()
79
+ result = self.api.get_user("email", email)
80
+ self.assertIsInstance(result, dict)
81
+ self.assertEqual(result.get("status"), "ok")
82
+ self.assertIn("profile", result)
83
+ return email
84
+
85
+ def test_update_user(self):
86
+ """Test user update."""
87
+ email = self.test_get_user()
88
+ update_data = {"name": "Updated Test User", "phone": "+9876543210"}
89
+ result = self.api.update_user("email", email, update_data)
90
+ self.assertIsInstance(result, dict)
91
+ self.assertEqual(result.get("status"), "ok")
92
+
93
+ # Verify the update
94
+ updated_user = self.api.get_user("email", email)
95
+ self.assertEqual(updated_user["profile"]["name"], update_data["name"])
96
+ self.assertEqual(updated_user["profile"]["phone"], update_data["phone"])
97
+
98
+ def test_delete_user(self):
99
+ """Test user deletion."""
100
+ email = self.test_create_user()
101
+ result = self.api.delete_user("email", email)
102
+ self.assertIsInstance(result, dict)
103
+ self.assertEqual(result.get("status"), "ok")
104
+
105
+ def test_get_system_stats(self):
106
+ """Test getting system statistics."""
107
+ result = self.api.get_system_stats()
108
+ self.assertIsInstance(result, dict)
109
+ self.assertEqual(result.get("status"), "ok")
110
+ self.assertIn("stats", result)
111
+
112
+
113
+ if __name__ == "__main__":
114
+ unittest.main()