Skip to content

Commit df6dad6

Browse files
chore(internal): codegen related update
1 parent 902c691 commit df6dad6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+352
-136
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Create releases
2+
on:
3+
schedule:
4+
- cron: '0 5 * * *' # every day at 5am UTC
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
name: release
12+
if: github.ref == 'refs/heads/main' && github.repository == 'openintegrations/python-sdk'
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: stainless-api/trigger-release-please@v1
19+
id: release
20+
with:
21+
repo: ${{ github.event.repository.full_name }}
22+
stainless-api-key: ${{ secrets.STAINLESS_API_KEY }}
23+
24+
- name: Install Rye
25+
if: ${{ steps.release.outputs.releases_created }}
26+
run: |
27+
curl -sSf https://rye.astral.sh/get | bash
28+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
29+
env:
30+
RYE_VERSION: '0.35.0'
31+
RYE_INSTALL_OPTION: '--yes'
32+
33+
- name: Publish to PyPI
34+
if: ${{ steps.release.outputs.releases_created }}
35+
run: |
36+
bash ./bin/publish-pypi
37+
env:
38+
PYPI_TOKEN: ${{ secrets.OPENINT_PYPI_TOKEN || secrets.PYPI_TOKEN }}

.github/workflows/publish-pypi.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# workflow for re-running publishing to PyPI in case it fails for some reason
2+
# you can run this workflow by navigating to https://www.github.com/openintegrations/python-sdk/actions/workflows/publish-pypi.yml
3+
name: Publish PyPI
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
publish:
9+
name: publish
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install Rye
16+
run: |
17+
curl -sSf https://rye.astral.sh/get | bash
18+
echo "$HOME/.rye/shims" >> $GITHUB_PATH
19+
env:
20+
RYE_VERSION: '0.35.0'
21+
RYE_INSTALL_OPTION: '--yes'
22+
23+
- name: Publish to PyPI
24+
run: |
25+
bash ./bin/publish-pypi
26+
env:
27+
PYPI_TOKEN: ${{ secrets.OPENINT_PYPI_TOKEN || secrets.PYPI_TOKEN }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release Doctor
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
jobs:
9+
release_doctor:
10+
name: release doctor
11+
runs-on: ubuntu-latest
12+
if: github.repository == 'openintegrations/python-sdk' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Check release environment
18+
run: |
19+
bash ./bin/check-release-environment
20+
env:
21+
STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }}
22+
PYPI_TOKEN: ${{ secrets.OPENINT_PYPI_TOKEN || secrets.PYPI_TOKEN }}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.0.1-alpha.0"
3+
}

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ pip install -r requirements-dev.lock
3737

3838
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
3939
result in merge conflicts between manual patches and changes from the generator. The generator will never
40-
modify the contents of the `src/openint/lib/` and `examples/` directories.
40+
modify the contents of the `src/openint_sdk/lib/` and `examples/` directories.
4141

4242
## Adding and running examples
4343

@@ -63,7 +63,7 @@ If you’d like to use the repository from source, you can either install from g
6363
To install via git:
6464

6565
```sh
66-
$ pip install git+ssh://git@github.com/stainless-sdks/openint-python.git
66+
$ pip install git+ssh://git@github.com/openintegrations/python-sdk.git
6767
```
6868

6969
Alternatively, you can build from source and install the wheel file:
@@ -121,7 +121,7 @@ the changes aren't made through the automated pipeline, you may want to make rel
121121

122122
### Publish with a GitHub workflow
123123

124-
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/openint-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
124+
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/openintegrations/python-sdk/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
125125

126126
### Publish manually
127127

README.md

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Openint Python API library
22

3-
[![PyPI version](https://img.shields.io/pypi/v/openint.svg)](https://pypi.org/project/openint/)
3+
[![PyPI version](https://img.shields.io/pypi/v/openint_sdk.svg)](https://pypi.org/project/openint_sdk/)
44

55
The Openint Python library provides convenient access to the Openint REST API from any Python 3.8+
66
application. The library includes type definitions for all request params and response fields,
@@ -15,38 +15,45 @@ The REST API documentation can be found on [docs.openint.dev](https://docs.openi
1515
## Installation
1616

1717
```sh
18-
# install from this staging repo
19-
pip install git+ssh://git@github.com/stainless-sdks/openint-python.git
18+
# install from the production repo
19+
pip install git+ssh://git@github.com/openintegrations/python-sdk.git
2020
```
2121

2222
> [!NOTE]
23-
> Once this package is [published to PyPI](https://app.stainless.com/docs/guides/publish), this will become: `pip install --pre openint`
23+
> Once this package is [published to PyPI](https://app.stainless.com/docs/guides/publish), this will become: `pip install --pre openint_sdk`
2424
2525
## Usage
2626

2727
The full API of this library can be found in [api.md](api.md).
2828

2929
```python
30-
from openint import Openint
30+
import os
31+
from openint_sdk import Openint
3132

3233
client = Openint(
33-
api_key="My API Key",
34+
api_key=os.environ.get("OPENINT_API_KEY"), # This is the default and can be omitted
3435
)
3536

3637
response = client.get_connection()
3738
print(response.items)
3839
```
3940

41+
While you can provide an `api_key` keyword argument,
42+
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
43+
to add `OPENINT_API_KEY="My API Key"` to your `.env` file
44+
so that your API Key is not stored in source control.
45+
4046
## Async usage
4147

4248
Simply import `AsyncOpenint` instead of `Openint` and use `await` with each API call:
4349

4450
```python
51+
import os
4552
import asyncio
46-
from openint import AsyncOpenint
53+
from openint_sdk import AsyncOpenint
4754

4855
client = AsyncOpenint(
49-
api_key="My API Key",
56+
api_key=os.environ.get("OPENINT_API_KEY"), # This is the default and can be omitted
5057
)
5158

5259

@@ -71,29 +78,27 @@ Typed requests and responses provide autocomplete and documentation within your
7178

7279
## Handling errors
7380

74-
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openint.APIConnectionError` is raised.
81+
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `openint_sdk.APIConnectionError` is raised.
7582

7683
When the API returns a non-success status code (that is, 4xx or 5xx
77-
response), a subclass of `openint.APIStatusError` is raised, containing `status_code` and `response` properties.
84+
response), a subclass of `openint_sdk.APIStatusError` is raised, containing `status_code` and `response` properties.
7885

79-
All errors inherit from `openint.APIError`.
86+
All errors inherit from `openint_sdk.APIError`.
8087

8188
```python
82-
import openint
83-
from openint import Openint
89+
import openint_sdk
90+
from openint_sdk import Openint
8491

85-
client = Openint(
86-
api_key="My API Key",
87-
)
92+
client = Openint()
8893

8994
try:
9095
client.get_connection()
91-
except openint.APIConnectionError as e:
96+
except openint_sdk.APIConnectionError as e:
9297
print("The server could not be reached")
9398
print(e.__cause__) # an underlying Exception, likely raised within httpx.
94-
except openint.RateLimitError as e:
99+
except openint_sdk.RateLimitError as e:
95100
print("A 429 status code was received; we should back off a bit.")
96-
except openint.APIStatusError as e:
101+
except openint_sdk.APIStatusError as e:
97102
print("Another non-200-range status code was received")
98103
print(e.status_code)
99104
print(e.response)
@@ -121,13 +126,12 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
121126
You can use the `max_retries` option to configure or disable retry settings:
122127

123128
```python
124-
from openint import Openint
129+
from openint_sdk import Openint
125130

126131
# Configure the default for all requests:
127132
client = Openint(
128133
# default is 2
129134
max_retries=0,
130-
api_key="My API Key",
131135
)
132136

133137
# Or, configure per-request:
@@ -140,19 +144,17 @@ By default requests time out after 1 minute. You can configure this with a `time
140144
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
141145

142146
```python
143-
from openint import Openint
147+
from openint_sdk import Openint
144148

145149
# Configure the default for all requests:
146150
client = Openint(
147151
# 20 seconds (default is 1 minute)
148152
timeout=20.0,
149-
api_key="My API Key",
150153
)
151154

152155
# More granular control:
153156
client = Openint(
154157
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
155-
api_key="My API Key",
156158
)
157159

158160
# Override per-request:
@@ -194,21 +196,19 @@ if response.my_field is None:
194196
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,
195197

196198
```py
197-
from openint import Openint
199+
from openint_sdk import Openint
198200

199-
client = Openint(
200-
api_key="My API Key",
201-
)
201+
client = Openint()
202202
response = client.with_raw_response.get_connection()
203203
print(response.headers.get('X-My-Header'))
204204

205205
client = response.parse() # get the object that `get_connection()` would have returned
206206
print(client.items)
207207
```
208208

209-
These methods return an [`APIResponse`](https://github.com/stainless-sdks/openint-python/tree/main/src/openint/_response.py) object.
209+
These methods return an [`APIResponse`](https://github.com/openintegrations/python-sdk/tree/main/src/openint_sdk/_response.py) object.
210210

211-
The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/openint-python/tree/main/src/openint/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
211+
The async client returns an [`AsyncAPIResponse`](https://github.com/openintegrations/python-sdk/tree/main/src/openint_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
212212

213213
#### `.with_streaming_response`
214214

@@ -270,7 +270,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
270270

271271
```python
272272
import httpx
273-
from openint import Openint, DefaultHttpxClient
273+
from openint_sdk import Openint, DefaultHttpxClient
274274

275275
client = Openint(
276276
# Or use the `OPENINT_BASE_URL` env var
@@ -279,7 +279,6 @@ client = Openint(
279279
proxy="http://my.test.proxy.example.com",
280280
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
281281
),
282-
api_key="My API Key",
283282
)
284283
```
285284

@@ -294,11 +293,9 @@ client.with_options(http_client=DefaultHttpxClient(...))
294293
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
295294

296295
```py
297-
from openint import Openint
296+
from openint_sdk import Openint
298297

299-
with Openint(
300-
api_key="My API Key",
301-
) as client:
298+
with Openint() as client:
302299
# make requests here
303300
...
304301

@@ -315,7 +312,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con
315312

316313
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
317314

318-
We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/openint-python/issues) with questions, bugs, or suggestions.
315+
We are keen for your feedback; please open an [issue](https://www.github.com/openintegrations/python-sdk/issues) with questions, bugs, or suggestions.
319316

320317
### Determining the installed version
321318

@@ -324,8 +321,8 @@ If you've upgraded to the latest version but aren't seeing any new features you
324321
You can determine the version that is being used at runtime with:
325322

326323
```py
327-
import openint
328-
print(openint.__version__)
324+
import openint_sdk
325+
print(openint_sdk.__version__)
329326
```
330327

331328
## Requirements

api.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
Types:
44

55
```python
6-
from openint.types import CheckHealthResponse, GetConnectionResponse, GetConnectionConfigResponse
6+
from openint_sdk.types import (
7+
CheckHealthResponse,
8+
GetConnectionResponse,
9+
GetConnectionConfigResponse,
10+
)
711
```
812

913
Methods:
1014

11-
- <code title="get /health">client.<a href="./src/openint/_client.py">check_health</a>() -> str</code>
12-
- <code title="get /connection">client.<a href="./src/openint/_client.py">get_connection</a>() -> <a href="./src/openint/types/get_connection_response.py">GetConnectionResponse</a></code>
13-
- <code title="get /connector-config">client.<a href="./src/openint/_client.py">get_connection_config</a>() -> <a href="./src/openint/types/get_connection_config_response.py">GetConnectionConfigResponse</a></code>
15+
- <code title="get /health">client.<a href="./src/openint_sdk/_client.py">check_health</a>() -> str</code>
16+
- <code title="get /connection">client.<a href="./src/openint_sdk/_client.py">get_connection</a>() -> <a href="./src/openint_sdk/types/get_connection_response.py">GetConnectionResponse</a></code>
17+
- <code title="get /connector-config">client.<a href="./src/openint_sdk/_client.py">get_connection_config</a>() -> <a href="./src/openint_sdk/types/get_connection_config_response.py">GetConnectionConfigResponse</a></code>

bin/check-release-environment

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
errors=()
4+
5+
if [ -z "${STAINLESS_API_KEY}" ]; then
6+
errors+=("The STAINLESS_API_KEY secret has not been set. Please contact Stainless for an API key & set it in your organization secrets on GitHub.")
7+
fi
8+
9+
if [ -z "${PYPI_TOKEN}" ]; then
10+
errors+=("The OPENINT_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
11+
fi
12+
13+
lenErrors=${#errors[@]}
14+
15+
if [[ lenErrors -gt 0 ]]; then
16+
echo -e "Found the following errors in the release environment:\n"
17+
18+
for error in "${errors[@]}"; do
19+
echo -e "- $error\n"
20+
done
21+
22+
exit 1
23+
fi
24+
25+
echo "The environment is ready to push releases!"

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ show_error_codes = True
88
#
99
# We also exclude our `tests` as mypy doesn't always infer
1010
# types correctly and Pyright will still catch any type errors.
11-
exclude = ^(src/openint/_files\.py|_dev/.*\.py|tests/.*)$
11+
exclude = ^(src/openint_sdk/_files\.py|_dev/.*\.py|tests/.*)$
1212

1313
strict_equality = True
1414
implicit_reexport = True

0 commit comments

Comments
 (0)