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
Copy file name to clipboardExpand all lines: sdks/python/README.md
+51-69Lines changed: 51 additions & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,10 +45,6 @@ Outpost API: The Outpost API is a REST-based JSON API for managing tenants, dest
45
45
<!-- Start SDK Installation [installation] -->
46
46
## SDK Installation
47
47
48
-
> [!TIP]
49
-
> 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).
50
-
51
-
52
48
> [!NOTE]
53
49
> **Python version upgrade policy**
54
50
>
@@ -61,23 +57,23 @@ The SDK can be installed with either *pip* or *poetry* package managers.
61
57
*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
62
58
63
59
```bash
64
-
pip install git+<UNSET>.git
60
+
pip install outpost_sdk
65
61
```
66
62
67
63
### Poetry
68
64
69
65
*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.
70
66
71
67
```bash
72
-
poetry add git+<UNSET>.git
68
+
poetry add outpost_sdk
73
69
```
74
70
75
71
### Shell and script usage with `uv`
76
72
77
73
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:
78
74
79
75
```shell
80
-
uvx --from openapi python
76
+
uvx --from outpost_sdk python
81
77
```
82
78
83
79
It's also possible to write a standalone Python script without needing to set up a whole project like so:
@@ -87,13 +83,13 @@ It's also possible to write a standalone Python script without needing to set up
87
83
# /// script
88
84
# requires-python = ">=3.9"
89
85
# dependencies = [
90
-
# "openapi",
86
+
# "outpost_sdk",
91
87
# ]
92
88
# ///
93
89
94
-
fromopenapiimportSDK
90
+
fromoutpost_sdkimportOutpost
95
91
96
-
sdk =SDK(
92
+
sdk =Outpost(
97
93
# SDK arguments
98
94
)
99
95
@@ -121,14 +117,12 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
121
117
122
118
```python
123
119
# Synchronous Example
124
-
fromopenapiimportSDK
120
+
fromoutpost_sdkimportOutpost
125
121
126
122
127
-
with SDK(
128
-
admin_api_key="<YOUR_BEARER_TOKEN_HERE>",
129
-
) as sdk:
123
+
with Outpost() as outpost:
130
124
131
-
res =sdk.health.check()
125
+
res =outpost.health.check()
132
126
133
127
# Handle response
134
128
print(res)
@@ -140,15 +134,13 @@ The same SDK client can also be used to make asychronous requests by importing a
140
134
```python
141
135
# Asynchronous Example
142
136
import asyncio
143
-
fromopenapiimportSDK
137
+
fromoutpost_sdkimportOutpost
144
138
145
139
asyncdefmain():
146
140
147
-
asyncwith SDK(
148
-
admin_api_key="<YOUR_BEARER_TOKEN_HERE>",
149
-
) as sdk:
141
+
asyncwith Outpost() as outpost:
150
142
151
-
res =awaitsdk.health.check_async()
143
+
res =awaitoutpost.health.check_async()
152
144
153
145
# Handle response
154
146
print(res)
@@ -170,14 +162,14 @@ This SDK supports the following security scheme globally:
170
162
171
163
To authenticate with the API the `admin_api_key` parameter must be set when initializing the SDK client instance. For example:
172
164
```python
173
-
fromopenapiimportSDK
165
+
fromoutpost_sdkimportOutpost
174
166
175
167
176
-
withSDK(
168
+
withOutpost(
177
169
admin_api_key="<YOUR_BEARER_TOKEN_HERE>",
178
-
) assdk:
170
+
) asoutpost:
179
171
180
-
res =sdk.health.check()
172
+
res =outpost.health.check()
181
173
182
174
# Handle response
183
175
print(res)
@@ -188,12 +180,12 @@ with SDK(
188
180
189
181
Some operations in this SDK require the security scheme to be specified at the request level. For example:
190
182
```python
191
-
fromopenapiimportSDK, models
183
+
fromoutpost_sdkimportOutpost, models
192
184
193
185
194
-
withSDK() assdk:
186
+
withOutpost() asoutpost:
195
187
196
-
res =sdk.tenants.get(security=models.GetTenantSecurity(
188
+
res =outpost.tenants.get(security=models.GetTenantSecurity(
197
189
198
190
), tenant_id="<id>")
199
191
@@ -232,6 +224,7 @@ with SDK() as sdk:
232
224
233
225
*[check](docs/sdks/health/README.md#check) - Health Check
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:
@@ -371,16 +360,14 @@ When custom error responses are specified for an operation, the SDK may also rai
371
360
### Example
372
361
373
362
```python
374
-
fromopenapiimportSDK, errors
363
+
fromoutpost_sdkimportOutpost, errors
375
364
376
365
377
-
with SDK(
378
-
admin_api_key="<YOUR_BEARER_TOKEN_HERE>",
379
-
) as sdk:
366
+
with Outpost() as outpost:
380
367
res =None
381
368
try:
382
369
383
-
res =sdk.health.check()
370
+
res =outpost.health.check()
384
371
385
372
# Handle response
386
373
print(res)
@@ -428,15 +415,14 @@ with SDK(
428
415
429
416
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:
430
417
```python
431
-
fromopenapiimportSDK
418
+
fromoutpost_sdkimportOutpost
432
419
433
420
434
-
withSDK(
421
+
withOutpost(
435
422
server_url="http://localhost:3333/api/v1",
436
-
admin_api_key="<YOUR_BEARER_TOKEN_HERE>",
437
-
) as sdk:
423
+
) as outpost:
438
424
439
-
res =sdk.health.check()
425
+
res =outpost.health.check()
440
426
441
427
# Handle response
442
428
print(res)
@@ -453,17 +439,17 @@ This allows you to wrap the client with your own custom logic, such as adding cu
453
439
454
440
For example, you could specify a header for every request that this sdk makes as follows:
The `SDK` 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.
517
+
The `Outpost` 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