permitstack 1.0.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.
Files changed (73) hide show
  1. permitstack-1.0.0/PKG-INFO +541 -0
  2. permitstack-1.0.0/README.md +529 -0
  3. permitstack-1.0.0/pyproject.toml +53 -0
  4. permitstack-1.0.0/setup.cfg +4 -0
  5. permitstack-1.0.0/src/permitstack/__init__.py +17 -0
  6. permitstack-1.0.0/src/permitstack/_hooks/__init__.py +4 -0
  7. permitstack-1.0.0/src/permitstack/_hooks/sdkhooks.py +74 -0
  8. permitstack-1.0.0/src/permitstack/_hooks/types.py +112 -0
  9. permitstack-1.0.0/src/permitstack/_version.py +15 -0
  10. permitstack-1.0.0/src/permitstack/basesdk.py +396 -0
  11. permitstack-1.0.0/src/permitstack/bulk_export.py +241 -0
  12. permitstack-1.0.0/src/permitstack/contractors.py +625 -0
  13. permitstack-1.0.0/src/permitstack/errors/__init__.py +39 -0
  14. permitstack-1.0.0/src/permitstack/errors/httpvalidationerror.py +28 -0
  15. permitstack-1.0.0/src/permitstack/errors/no_response_error.py +17 -0
  16. permitstack-1.0.0/src/permitstack/errors/permitstackdefaulterror.py +40 -0
  17. permitstack-1.0.0/src/permitstack/errors/permitstackerror.py +30 -0
  18. permitstack-1.0.0/src/permitstack/errors/responsevalidationerror.py +27 -0
  19. permitstack-1.0.0/src/permitstack/health.py +171 -0
  20. permitstack-1.0.0/src/permitstack/httpclient.py +125 -0
  21. permitstack-1.0.0/src/permitstack/models/__init__.py +158 -0
  22. permitstack-1.0.0/src/permitstack/models/contractorprofile.py +108 -0
  23. permitstack-1.0.0/src/permitstack/models/contractorsearchresponse.py +24 -0
  24. permitstack-1.0.0/src/permitstack/models/contractorsummary.py +57 -0
  25. permitstack-1.0.0/src/permitstack/models/delete_webhookop.py +16 -0
  26. permitstack-1.0.0/src/permitstack/models/export_permits_csvop.py +98 -0
  27. permitstack-1.0.0/src/permitstack/models/get_contractor_permitsop.py +46 -0
  28. permitstack-1.0.0/src/permitstack/models/get_contractorop.py +16 -0
  29. permitstack-1.0.0/src/permitstack/models/get_permitop.py +16 -0
  30. permitstack-1.0.0/src/permitstack/models/get_permits_by_addressop.py +46 -0
  31. permitstack-1.0.0/src/permitstack/models/get_property_historyop.py +18 -0
  32. permitstack-1.0.0/src/permitstack/models/permitcategory.py +27 -0
  33. permitstack-1.0.0/src/permitstack/models/permitdetail.py +164 -0
  34. permitstack-1.0.0/src/permitstack/models/permitsearchresponse.py +24 -0
  35. permitstack-1.0.0/src/permitstack/models/permitstatus.py +16 -0
  36. permitstack-1.0.0/src/permitstack/models/permitsummary.py +121 -0
  37. permitstack-1.0.0/src/permitstack/models/propertytype.py +14 -0
  38. permitstack-1.0.0/src/permitstack/models/search_contractorsop.py +98 -0
  39. permitstack-1.0.0/src/permitstack/models/search_permitsop.py +247 -0
  40. permitstack-1.0.0/src/permitstack/models/security.py +42 -0
  41. permitstack-1.0.0/src/permitstack/models/validationerror.py +57 -0
  42. permitstack-1.0.0/src/permitstack/models/webhookcreate.py +60 -0
  43. permitstack-1.0.0/src/permitstack/permits.py +866 -0
  44. permitstack-1.0.0/src/permitstack/property_history.py +207 -0
  45. permitstack-1.0.0/src/permitstack/py.typed +1 -0
  46. permitstack-1.0.0/src/permitstack/sdk.py +218 -0
  47. permitstack-1.0.0/src/permitstack/sdkconfiguration.py +49 -0
  48. permitstack-1.0.0/src/permitstack/types/__init__.py +21 -0
  49. permitstack-1.0.0/src/permitstack/types/basemodel.py +77 -0
  50. permitstack-1.0.0/src/permitstack/utils/__init__.py +178 -0
  51. permitstack-1.0.0/src/permitstack/utils/annotations.py +79 -0
  52. permitstack-1.0.0/src/permitstack/utils/datetimes.py +23 -0
  53. permitstack-1.0.0/src/permitstack/utils/dynamic_imports.py +54 -0
  54. permitstack-1.0.0/src/permitstack/utils/enums.py +134 -0
  55. permitstack-1.0.0/src/permitstack/utils/eventstreaming.py +309 -0
  56. permitstack-1.0.0/src/permitstack/utils/forms.py +234 -0
  57. permitstack-1.0.0/src/permitstack/utils/headers.py +136 -0
  58. permitstack-1.0.0/src/permitstack/utils/logger.py +27 -0
  59. permitstack-1.0.0/src/permitstack/utils/metadata.py +119 -0
  60. permitstack-1.0.0/src/permitstack/utils/queryparams.py +217 -0
  61. permitstack-1.0.0/src/permitstack/utils/requestbodies.py +66 -0
  62. permitstack-1.0.0/src/permitstack/utils/retries.py +271 -0
  63. permitstack-1.0.0/src/permitstack/utils/security.py +215 -0
  64. permitstack-1.0.0/src/permitstack/utils/serializers.py +225 -0
  65. permitstack-1.0.0/src/permitstack/utils/unmarshal_json_response.py +38 -0
  66. permitstack-1.0.0/src/permitstack/utils/url.py +155 -0
  67. permitstack-1.0.0/src/permitstack/utils/values.py +137 -0
  68. permitstack-1.0.0/src/permitstack/webhooks.py +593 -0
  69. permitstack-1.0.0/src/permitstack.egg-info/PKG-INFO +541 -0
  70. permitstack-1.0.0/src/permitstack.egg-info/SOURCES.txt +71 -0
  71. permitstack-1.0.0/src/permitstack.egg-info/dependency_links.txt +1 -0
  72. permitstack-1.0.0/src/permitstack.egg-info/requires.txt +3 -0
  73. permitstack-1.0.0/src/permitstack.egg-info/top_level.txt +1 -0
@@ -0,0 +1,541 @@
1
+ Metadata-Version: 2.4
2
+ Name: permitstack
3
+ Version: 1.0.0
4
+ Summary: Official Python SDK for the PermitStack building permit data API. Search 15.6M+ US building permits across 54 cities.
5
+ Author-email: PermitStack <support@aisaasfactory.io>
6
+ License: Apache-2.0
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: httpcore>=1.0.9
10
+ Requires-Dist: httpx>=0.28.1
11
+ Requires-Dist: pydantic>=2.11.2
12
+
13
+ # permitstack
14
+
15
+ Developer-friendly & type-safe Python SDK specifically catered to leverage *permitstack* API.
16
+
17
+ [![Built by Speakeasy](https://img.shields.io/badge/Built_by-SPEAKEASY-374151?style=for-the-badge&labelColor=f3f4f6)](https://www.speakeasy.com/?utm_source=permitstack&utm_campaign=python)
18
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=for-the-badge&labelColor=eff6ff)](https://opensource.org/licenses/Apache-2.0)
19
+
20
+
21
+
22
+ <!-- Start Summary [summary] -->
23
+ ## Summary
24
+
25
+ PermitStack:
26
+ ## PermitStack Building Permit API
27
+
28
+ Access 15.59M+ building permits across 54 U.S. cities and counties, updated daily from official open data portals.
29
+
30
+ ### Getting started
31
+ 1. Sign up at [permit-stack.com](https://permit-stack.com/#pricing) for a free API key (1,000 req/day)
32
+ 2. Pass your key as `X-API-Key` header on every request
33
+ 3. See the `/v1/permits/search` endpoint to get started
34
+
35
+ ### Rate limits
36
+ Tier | Requests/min | Requests/day
37
+ -----------|--------------|-------------
38
+ Free | 30 | 1,000
39
+ Developer | 60 | 10,000
40
+ Startup | 200 | 100,000
41
+ Growth | 500 | 500,000
42
+
43
+ ### Support
44
+ support@aisaasfactory.io
45
+ <!-- End Summary [summary] -->
46
+
47
+ <!-- Start Table of Contents [toc] -->
48
+ ## Table of Contents
49
+ <!-- $toc-max-depth=2 -->
50
+ * [permitstack](#permitstack)
51
+ * [PermitStack Building Permit API](#permitstack-building-permit-api)
52
+ * [SDK Installation](#sdk-installation)
53
+ * [IDE Support](#ide-support)
54
+ * [SDK Example Usage](#sdk-example-usage)
55
+ * [Authentication](#authentication)
56
+ * [Available Resources and Operations](#available-resources-and-operations)
57
+ * [Retries](#retries)
58
+ * [Error Handling](#error-handling)
59
+ * [Server Selection](#server-selection)
60
+ * [Custom HTTP Client](#custom-http-client)
61
+ * [Resource Management](#resource-management)
62
+ * [Debugging](#debugging)
63
+ * [Development](#development)
64
+ * [Maturity](#maturity)
65
+ * [Contributions](#contributions)
66
+
67
+ <!-- End Table of Contents [toc] -->
68
+
69
+ <!-- Start SDK Installation [installation] -->
70
+ ## SDK Installation
71
+
72
+ > [!TIP]
73
+ > To finish publishing your SDK to PyPI you must [run your first generation action](https://www.speakeasy.com/docs/github-setup#step-by-step-guide).
74
+
75
+
76
+ > [!NOTE]
77
+ > **Python version upgrade policy**
78
+ >
79
+ > Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
80
+
81
+ The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
82
+
83
+ ### uv
84
+
85
+ *uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
86
+
87
+ ```bash
88
+ uv add git+<UNSET>.git
89
+ ```
90
+
91
+ ### PIP
92
+
93
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
94
+
95
+ ```bash
96
+ pip install git+<UNSET>.git
97
+ ```
98
+
99
+ ### Poetry
100
+
101
+ *Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
102
+
103
+ ```bash
104
+ poetry add git+<UNSET>.git
105
+ ```
106
+
107
+ ### Shell and script usage with `uv`
108
+
109
+ You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
110
+
111
+ ```shell
112
+ uvx --from permitstack python
113
+ ```
114
+
115
+ It's also possible to write a standalone Python script without needing to set up a whole project like so:
116
+
117
+ ```python
118
+ #!/usr/bin/env -S uv run --script
119
+ # /// script
120
+ # requires-python = ">=3.10"
121
+ # dependencies = [
122
+ # "permitstack",
123
+ # ]
124
+ # ///
125
+
126
+ from permitstack import Permitstack
127
+
128
+ sdk = Permitstack(
129
+ # SDK arguments
130
+ )
131
+
132
+ # Rest of script here...
133
+ ```
134
+
135
+ Once that is saved to a file, you can run it with `uv run script.py` where
136
+ `script.py` can be replaced with the actual file name.
137
+ <!-- End SDK Installation [installation] -->
138
+
139
+ <!-- Start IDE Support [idesupport] -->
140
+ ## IDE Support
141
+
142
+ ### PyCharm
143
+
144
+ Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
145
+
146
+ - [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
147
+ <!-- End IDE Support [idesupport] -->
148
+
149
+ <!-- Start SDK Example Usage [usage] -->
150
+ ## SDK Example Usage
151
+
152
+ ### Example
153
+
154
+ ```python
155
+ # Synchronous Example
156
+ import os
157
+ from permitstack import Permitstack
158
+
159
+
160
+ with Permitstack(
161
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
162
+ ) as p_client:
163
+
164
+ res = p_client.health.health_check()
165
+
166
+ # Handle response
167
+ print(res)
168
+ ```
169
+
170
+ </br>
171
+
172
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
173
+
174
+ ```python
175
+ # Asynchronous Example
176
+ import asyncio
177
+ import os
178
+ from permitstack import Permitstack
179
+
180
+ async def main():
181
+
182
+ async with Permitstack(
183
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
184
+ ) as p_client:
185
+
186
+ res = await p_client.health.health_check_async()
187
+
188
+ # Handle response
189
+ print(res)
190
+
191
+ asyncio.run(main())
192
+ ```
193
+ <!-- End SDK Example Usage [usage] -->
194
+
195
+ <!-- Start Authentication [security] -->
196
+ ## Authentication
197
+
198
+ ### Per-Client Security Schemes
199
+
200
+ This SDK supports the following security scheme globally:
201
+
202
+ | Name | Type | Scheme | Environment Variable |
203
+ | --------- | ------ | ------- | --------------------- |
204
+ | `api_key` | apiKey | API key | `PERMITSTACK_API_KEY` |
205
+
206
+ To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
207
+ ```python
208
+ import os
209
+ from permitstack import Permitstack
210
+
211
+
212
+ with Permitstack(
213
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
214
+ ) as p_client:
215
+
216
+ res = p_client.health.health_check()
217
+
218
+ # Handle response
219
+ print(res)
220
+
221
+ ```
222
+ <!-- End Authentication [security] -->
223
+
224
+ <!-- Start Available Resources and Operations [operations] -->
225
+ ## Available Resources and Operations
226
+
227
+ <details open>
228
+ <summary>Available methods</summary>
229
+
230
+ ### [BulkExport](docs/sdks/bulkexport/README.md)
231
+
232
+ * [export_permits_csv](docs/sdks/bulkexport/README.md#export_permits_csv) - Export Permits Csv
233
+
234
+ ### [Contractors](docs/sdks/contractors/README.md)
235
+
236
+ * [search_contractors](docs/sdks/contractors/README.md#search_contractors) - Search Contractors
237
+ * [get_contractor](docs/sdks/contractors/README.md#get_contractor) - Get Contractor
238
+ * [get_contractor_permits](docs/sdks/contractors/README.md#get_contractor_permits) - Get Contractor Permits
239
+
240
+ ### [Health](docs/sdks/health/README.md)
241
+
242
+ * [health_check](docs/sdks/health/README.md#health_check) - Health Check
243
+
244
+ ### [Permits](docs/sdks/permits/README.md)
245
+
246
+ * [search_permits](docs/sdks/permits/README.md#search_permits) - Search Permits
247
+ * [get_permit](docs/sdks/permits/README.md#get_permit) - Get Permit
248
+ * [get_permits_by_address](docs/sdks/permits/README.md#get_permits_by_address) - Get Permits By Address
249
+ * [get_coverage_stats](docs/sdks/permits/README.md#get_coverage_stats) - Get Coverage Stats
250
+
251
+ ### [PropertyHistory](docs/sdks/propertyhistory/README.md)
252
+
253
+ * [get_property_history](docs/sdks/propertyhistory/README.md#get_property_history) - Get Property History
254
+
255
+ ### [Webhooks](docs/sdks/webhooks/README.md)
256
+
257
+ * [list_webhooks](docs/sdks/webhooks/README.md#list_webhooks) - List Webhooks
258
+ * [create_webhook](docs/sdks/webhooks/README.md#create_webhook) - Create Webhook
259
+ * [delete_webhook](docs/sdks/webhooks/README.md#delete_webhook) - Delete Webhook
260
+
261
+ </details>
262
+ <!-- End Available Resources and Operations [operations] -->
263
+
264
+ <!-- Start Retries [retries] -->
265
+ ## Retries
266
+
267
+ Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
268
+
269
+ To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
270
+ ```python
271
+ import os
272
+ from permitstack import Permitstack
273
+ from permitstack.utils import BackoffStrategy, RetryConfig
274
+
275
+
276
+ with Permitstack(
277
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
278
+ ) as p_client:
279
+
280
+ res = p_client.health.health_check(,
281
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
282
+
283
+ # Handle response
284
+ print(res)
285
+
286
+ ```
287
+
288
+ If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
289
+ ```python
290
+ import os
291
+ from permitstack import Permitstack
292
+ from permitstack.utils import BackoffStrategy, RetryConfig
293
+
294
+
295
+ with Permitstack(
296
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
297
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
298
+ ) as p_client:
299
+
300
+ res = p_client.health.health_check()
301
+
302
+ # Handle response
303
+ print(res)
304
+
305
+ ```
306
+ <!-- End Retries [retries] -->
307
+
308
+ <!-- Start Error Handling [errors] -->
309
+ ## Error Handling
310
+
311
+ [`PermitstackError`](./src/permitstack/errors/permitstackerror.py) is the base class for all HTTP error responses. It has the following properties:
312
+
313
+ | Property | Type | Description |
314
+ | ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
315
+ | `err.message` | `str` | Error message |
316
+ | `err.status_code` | `int` | HTTP response status code eg `404` |
317
+ | `err.headers` | `httpx.Headers` | HTTP response headers |
318
+ | `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
319
+ | `err.raw_response` | `httpx.Response` | Raw HTTP response |
320
+ | `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |
321
+
322
+ ### Example
323
+ ```python
324
+ import os
325
+ from permitstack import Permitstack, errors
326
+
327
+
328
+ with Permitstack(
329
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
330
+ ) as p_client:
331
+ res = None
332
+ try:
333
+
334
+ res = p_client.permits.search_permits(radius_miles=5, page=1, per_page=25)
335
+
336
+ # Handle response
337
+ print(res)
338
+
339
+
340
+ except errors.PermitstackError as e:
341
+ # The base class for HTTP error responses
342
+ print(e.message)
343
+ print(e.status_code)
344
+ print(e.body)
345
+ print(e.headers)
346
+ print(e.raw_response)
347
+
348
+ # Depending on the method different errors may be thrown
349
+ if isinstance(e, errors.HTTPValidationError):
350
+ print(e.data.detail) # Optional[List[models.ValidationError]]
351
+ ```
352
+
353
+ ### Error Classes
354
+ **Primary error:**
355
+ * [`PermitstackError`](./src/permitstack/errors/permitstackerror.py): The base class for HTTP error responses.
356
+
357
+ <details><summary>Less common errors (6)</summary>
358
+
359
+ <br />
360
+
361
+ **Network errors:**
362
+ * [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
363
+ * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
364
+ * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
365
+
366
+
367
+ **Inherit from [`PermitstackError`](./src/permitstack/errors/permitstackerror.py)**:
368
+ * [`HTTPValidationError`](./src/permitstack/errors/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 10 of 13 methods.*
369
+ * [`ResponseValidationError`](./src/permitstack/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
370
+
371
+ </details>
372
+
373
+ \* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
374
+ <!-- End Error Handling [errors] -->
375
+
376
+ <!-- Start Server Selection [server] -->
377
+ ## Server Selection
378
+
379
+ ### Override Server URL Per-Client
380
+
381
+ The default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
382
+ ```python
383
+ import os
384
+ from permitstack import Permitstack
385
+
386
+
387
+ with Permitstack(
388
+ server_url="https://api.permit-stack.com",
389
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
390
+ ) as p_client:
391
+
392
+ res = p_client.health.health_check()
393
+
394
+ # Handle response
395
+ print(res)
396
+
397
+ ```
398
+ <!-- End Server Selection [server] -->
399
+
400
+ <!-- Start Custom HTTP Client [http-client] -->
401
+ ## Custom HTTP Client
402
+
403
+ The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
404
+ Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
405
+ This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
406
+
407
+ For example, you could specify a header for every request that this sdk makes as follows:
408
+ ```python
409
+ from permitstack import Permitstack
410
+ import httpx
411
+
412
+ http_client = httpx.Client(headers={"x-custom-header": "someValue"})
413
+ s = Permitstack(client=http_client)
414
+ ```
415
+
416
+ or you could wrap the client with your own custom logic:
417
+ ```python
418
+ from permitstack import Permitstack
419
+ from permitstack.httpclient import AsyncHttpClient
420
+ import httpx
421
+
422
+ class CustomClient(AsyncHttpClient):
423
+ client: AsyncHttpClient
424
+
425
+ def __init__(self, client: AsyncHttpClient):
426
+ self.client = client
427
+
428
+ async def send(
429
+ self,
430
+ request: httpx.Request,
431
+ *,
432
+ stream: bool = False,
433
+ auth: Union[
434
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
435
+ ] = httpx.USE_CLIENT_DEFAULT,
436
+ follow_redirects: Union[
437
+ bool, httpx._client.UseClientDefault
438
+ ] = httpx.USE_CLIENT_DEFAULT,
439
+ ) -> httpx.Response:
440
+ request.headers["Client-Level-Header"] = "added by client"
441
+
442
+ return await self.client.send(
443
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
444
+ )
445
+
446
+ def build_request(
447
+ self,
448
+ method: str,
449
+ url: httpx._types.URLTypes,
450
+ *,
451
+ content: Optional[httpx._types.RequestContent] = None,
452
+ data: Optional[httpx._types.RequestData] = None,
453
+ files: Optional[httpx._types.RequestFiles] = None,
454
+ json: Optional[Any] = None,
455
+ params: Optional[httpx._types.QueryParamTypes] = None,
456
+ headers: Optional[httpx._types.HeaderTypes] = None,
457
+ cookies: Optional[httpx._types.CookieTypes] = None,
458
+ timeout: Union[
459
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
460
+ ] = httpx.USE_CLIENT_DEFAULT,
461
+ extensions: Optional[httpx._types.RequestExtensions] = None,
462
+ ) -> httpx.Request:
463
+ return self.client.build_request(
464
+ method,
465
+ url,
466
+ content=content,
467
+ data=data,
468
+ files=files,
469
+ json=json,
470
+ params=params,
471
+ headers=headers,
472
+ cookies=cookies,
473
+ timeout=timeout,
474
+ extensions=extensions,
475
+ )
476
+
477
+ s = Permitstack(async_client=CustomClient(httpx.AsyncClient()))
478
+ ```
479
+ <!-- End Custom HTTP Client [http-client] -->
480
+
481
+ <!-- Start Resource Management [resource-management] -->
482
+ ## Resource Management
483
+
484
+ The `Permitstack` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
485
+
486
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
487
+
488
+ ```python
489
+ import os
490
+ from permitstack import Permitstack
491
+ def main():
492
+
493
+ with Permitstack(
494
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
495
+ ) as p_client:
496
+ # Rest of application here...
497
+
498
+
499
+ # Or when using async:
500
+ async def amain():
501
+
502
+ async with Permitstack(
503
+ api_key=os.getenv("PERMITSTACK_API_KEY", ""),
504
+ ) as p_client:
505
+ # Rest of application here...
506
+ ```
507
+ <!-- End Resource Management [resource-management] -->
508
+
509
+ <!-- Start Debugging [debug] -->
510
+ ## Debugging
511
+
512
+ You can setup your SDK to emit debug logs for SDK requests and responses.
513
+
514
+ You can pass your own logger class directly into your SDK.
515
+ ```python
516
+ from permitstack import Permitstack
517
+ import logging
518
+
519
+ logging.basicConfig(level=logging.DEBUG)
520
+ s = Permitstack(debug_logger=logging.getLogger("permitstack"))
521
+ ```
522
+
523
+ You can also enable a default debug logger by setting an environment variable `PERMITSTACK_DEBUG` to true.
524
+ <!-- End Debugging [debug] -->
525
+
526
+ <!-- Placeholder for Future Speakeasy SDK Sections -->
527
+
528
+ # Development
529
+
530
+ ## Maturity
531
+
532
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
533
+ to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
534
+ looking for the latest version.
535
+
536
+ ## Contributions
537
+
538
+ While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
539
+ We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
540
+
541
+ ### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=permitstack&utm_campaign=python)