You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -49,6 +49,7 @@ These end points cover creating and managing your companies, data connections, a
49
49
*[Server Selection](#server-selection)
50
50
*[Custom HTTP Client](#custom-http-client)
51
51
*[Authentication](#authentication)
52
+
*[Resource Management](#resource-management)
52
53
*[Debugging](#debugging)
53
54
*[Support](#support)
54
55
@@ -57,6 +58,11 @@ These end points cover creating and managing your companies, data connections, a
57
58
<!-- Start SDK Installation [installation] -->
58
59
## SDK Installation
59
60
61
+
> [!NOTE]
62
+
> **Python version upgrade policy**
63
+
>
64
+
> 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.
65
+
60
66
The SDK can be installed with either *pip* or *poetry* package managers.
61
67
62
68
### PIP
@@ -74,6 +80,37 @@ pip install codat-platform
74
80
```bash
75
81
poetry add codat-platform
76
82
```
83
+
84
+
### Shell and script usage with `uv`
85
+
86
+
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:
87
+
88
+
```shell
89
+
uvx --from codat-platform python
90
+
```
91
+
92
+
It's also possible to write a standalone Python script without needing to set up a whole project like so:
93
+
94
+
```python
95
+
#!/usr/bin/env -S uv run --script
96
+
# /// script
97
+
# requires-python = ">=3.9"
98
+
# dependencies = [
99
+
# "codat-platform",
100
+
# ]
101
+
# ///
102
+
103
+
from codat_platform import CodatPlatform
104
+
105
+
sdk = CodatPlatform(
106
+
# SDK arguments
107
+
)
108
+
109
+
# Rest of script here...
110
+
```
111
+
112
+
Once that is saved to a file, you can run it with `uv run script.py` where
113
+
`script.py` can be replaced with the actual file name.
77
114
<!-- End SDK Installation [installation] -->
78
115
79
116
## Example Usage
@@ -95,26 +132,19 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
res =codat_platform.settings.create_api_key(request={
314
+
res =cp_client.settings.create_api_key(request={
292
315
"name": "azure-invoice-finance-processor",
293
316
})
294
317
@@ -316,10 +339,11 @@ By default, an API error will raise a errors.SDKError exception, which has the f
316
339
317
340
When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `create_api_key_async` method may raise the following exceptions:
res =codat_platform.settings.create_api_key(request={
362
+
res =cp_client.settings.create_api_key(request={
339
363
"name": "azure-invoice-finance-processor",
340
364
})
341
365
@@ -344,6 +368,9 @@ with CodatPlatform(
344
368
# Handle response
345
369
print(res)
346
370
371
+
except errors.ErrorMessage as e:
372
+
# handle e.data: errors.ErrorMessageData
373
+
raise(e)
347
374
except errors.ErrorMessage as e:
348
375
# handle e.data: errors.ErrorMessageData
349
376
raise(e)
@@ -358,7 +385,7 @@ with CodatPlatform(
358
385
359
386
### Override Server URL Per-Client
360
387
361
-
The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
388
+
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:
362
389
```python
363
390
from codat_platform import CodatPlatform
364
391
from codat_platform.models import shared
@@ -368,9 +395,9 @@ with CodatPlatform(
368
395
security=shared.Security(
369
396
auth_header="Basic BASE_64_ENCODED(API_KEY)",
370
397
),
371
-
) ascodat_platform:
398
+
) ascp_client:
372
399
373
-
res =codat_platform.settings.create_api_key(request={
400
+
res =cp_client.settings.create_api_key(request={
374
401
"name": "azure-invoice-finance-processor",
375
402
})
376
403
@@ -483,9 +510,9 @@ with CodatPlatform(
483
510
security=shared.Security(
484
511
auth_header="Basic BASE_64_ENCODED(API_KEY)",
485
512
),
486
-
) ascodat_platform:
513
+
) ascp_client:
487
514
488
-
res =codat_platform.settings.create_api_key(request={
The `CodatPlatform` 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.
0 commit comments