-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from clear-street/release-please--branches--mai…
…n--changes--next release: 0.1.0-alpha.3
- Loading branch information
Showing
125 changed files
with
444 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "0.1.0-alpha.2" | ||
".": "0.1.0-alpha.3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,24 +15,21 @@ The REST API documentation can be found [on docs.clearstreet.io](https://docs.cl | |
## Installation | ||
|
||
```sh | ||
# install from the production repo | ||
pip install git+ssh://[email protected]/clear-street/studio-sdk-python.git | ||
# install from PyPI | ||
pip install --pre studio-sdk | ||
``` | ||
|
||
> [!NOTE] | ||
> Once this package is [published to PyPI](https://app.stainlessapi.com/docs/guides/publish), this will become: `pip install --pre studio-sdk` | ||
## Usage | ||
|
||
The full API of this library can be found in [api.md](api.md). | ||
|
||
```python | ||
from studio_minus_sdk import StudioSDK | ||
from studio_sdk import StudioSDK | ||
|
||
client = StudioSDK() | ||
|
||
entity = client.entities.retrieve( | ||
"REPLACE_ME", | ||
"<your entity_id>", | ||
) | ||
print(entity.entity_id) | ||
``` | ||
|
@@ -48,14 +45,14 @@ Simply import `AsyncStudioSDK` instead of `StudioSDK` and use `await` with each | |
|
||
```python | ||
import asyncio | ||
from studio_minus_sdk import AsyncStudioSDK | ||
from studio_sdk import AsyncStudioSDK | ||
|
||
client = AsyncStudioSDK() | ||
|
||
|
||
async def main() -> None: | ||
entity = await client.entities.retrieve( | ||
"REPLACE_ME", | ||
"<your entity_id>", | ||
) | ||
print(entity.entity_id) | ||
|
||
|
@@ -76,29 +73,29 @@ Typed requests and responses provide autocomplete and documentation within your | |
|
||
## Handling errors | ||
|
||
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `studio_minus_sdk.APIConnectionError` is raised. | ||
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `studio_sdk.APIConnectionError` is raised. | ||
|
||
When the API returns a non-success status code (that is, 4xx or 5xx | ||
response), a subclass of `studio_minus_sdk.APIStatusError` is raised, containing `status_code` and `response` properties. | ||
response), a subclass of `studio_sdk.APIStatusError` is raised, containing `status_code` and `response` properties. | ||
|
||
All errors inherit from `studio_minus_sdk.APIError`. | ||
All errors inherit from `studio_sdk.APIError`. | ||
|
||
```python | ||
import studio_minus_sdk | ||
from studio_minus_sdk import StudioSDK | ||
import studio_sdk | ||
from studio_sdk import StudioSDK | ||
|
||
client = StudioSDK() | ||
|
||
try: | ||
client.entities.retrieve( | ||
"REPLACE_ME", | ||
"<your entity_id>", | ||
) | ||
except studio_minus_sdk.APIConnectionError as e: | ||
except studio_sdk.APIConnectionError as e: | ||
print("The server could not be reached") | ||
print(e.__cause__) # an underlying Exception, likely raised within httpx. | ||
except studio_minus_sdk.RateLimitError as e: | ||
except studio_sdk.RateLimitError as e: | ||
print("A 429 status code was received; we should back off a bit.") | ||
except studio_minus_sdk.APIStatusError as e: | ||
except studio_sdk.APIStatusError as e: | ||
print("Another non-200-range status code was received") | ||
print(e.status_code) | ||
print(e.response) | ||
|
@@ -126,7 +123,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ | |
You can use the `max_retries` option to configure or disable retry settings: | ||
|
||
```python | ||
from studio_minus_sdk import StudioSDK | ||
from studio_sdk import StudioSDK | ||
|
||
# Configure the default for all requests: | ||
client = StudioSDK( | ||
|
@@ -136,7 +133,7 @@ client = StudioSDK( | |
|
||
# Or, configure per-request: | ||
client.with_options(max_retries=5).entities.retrieve( | ||
"REPLACE_ME", | ||
"<your entity_id>", | ||
) | ||
``` | ||
|
||
|
@@ -146,7 +143,7 @@ By default requests time out after 1 minute. You can configure this with a `time | |
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object: | ||
|
||
```python | ||
from studio_minus_sdk import StudioSDK | ||
from studio_sdk import StudioSDK | ||
|
||
# Configure the default for all requests: | ||
client = StudioSDK( | ||
|
@@ -161,7 +158,7 @@ client = StudioSDK( | |
|
||
# Override per-request: | ||
client.with_options(timeout=5.0).entities.retrieve( | ||
"REPLACE_ME", | ||
"<your entity_id>", | ||
) | ||
``` | ||
|
||
|
@@ -198,21 +195,21 @@ if response.my_field is None: | |
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g., | ||
|
||
```py | ||
from studio_minus_sdk import StudioSDK | ||
from studio_sdk import StudioSDK | ||
|
||
client = StudioSDK() | ||
response = client.entities.with_raw_response.retrieve( | ||
"REPLACE_ME", | ||
"<your entity_id>", | ||
) | ||
print(response.headers.get('X-My-Header')) | ||
|
||
entity = response.parse() # get the object that `entities.retrieve()` would have returned | ||
print(entity.entity_id) | ||
``` | ||
|
||
These methods return an [`APIResponse`](https://github.com/clear-street/studio-sdk-python/tree/main/src/studio_minus_sdk/_response.py) object. | ||
These methods return an [`APIResponse`](https://github.com/clear-street/studio-sdk-python/tree/main/src/studio_sdk/_response.py) object. | ||
|
||
The async client returns an [`AsyncAPIResponse`](https://github.com/clear-street/studio-sdk-python/tree/main/src/studio_minus_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content. | ||
The async client returns an [`AsyncAPIResponse`](https://github.com/clear-street/studio-sdk-python/tree/main/src/studio_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content. | ||
|
||
#### `.with_streaming_response` | ||
|
||
|
@@ -222,7 +219,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi | |
|
||
```python | ||
with client.entities.with_streaming_response.retrieve( | ||
"REPLACE_ME", | ||
"<your entity_id>", | ||
) as response: | ||
print(response.headers.get("X-My-Header")) | ||
|
||
|
@@ -276,7 +273,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c | |
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality | ||
|
||
```python | ||
from studio_minus_sdk import StudioSDK, DefaultHttpxClient | ||
from studio_sdk import StudioSDK, DefaultHttpxClient | ||
|
||
client = StudioSDK( | ||
# Or use the `STUDIO_SDK_BASE_URL` env var | ||
|
Oops, something went wrong.