diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml deleted file mode 100644 index 346eb213..00000000 --- a/.github/workflows/create-releases.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Create releases -on: - schedule: - - cron: '0 5 * * *' # every day at 5am UTC - push: - branches: - - main - -jobs: - release: - name: release - if: github.ref == 'refs/heads/main' && github.repository == 'orbcorp/orb-python' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - uses: stainless-api/trigger-release-please@v1 - id: release - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} - - - name: Install Rye - if: ${{ steps.release.outputs.releases_created }} - run: | - curl -sSf https://rye-up.com/get | bash - echo "$HOME/.rye/shims" >> $GITHUB_PATH - env: - RYE_VERSION: 0.15.2 - RYE_INSTALL_OPTION: "--yes" - - - name: Publish to PyPI - if: ${{ steps.release.outputs.releases_created }} - run: | - bash ./bin/publish-pypi - env: - PYPI_TOKEN: ${{ secrets.ORB_PYPI_TOKEN || secrets.PYPI_TOKEN }} diff --git a/.github/workflows/handle-release-pr-title-edit.yml b/.github/workflows/handle-release-pr-title-edit.yml deleted file mode 100644 index 30a9bcd2..00000000 --- a/.github/workflows/handle-release-pr-title-edit.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Handle release PR title edits -on: - pull_request: - types: - - edited - - unlabeled - -jobs: - update_pr_content: - name: Update pull request content - if: | - ((github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) || - (github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version')) && - startsWith(github.event.pull_request.head.ref, 'release-please--') && - github.event.pull_request.state == 'open' && - github.event.sender.login != 'stainless-bot' && - github.event.sender.login != 'stainless-app' && - github.repository == 'orbcorp/orb-python' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: stainless-api/trigger-release-please@v1 - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index db65bec7..00847985 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -1,9 +1,13 @@ -# workflow for re-running publishing to PyPI in case it fails for some reason -# you can run this workflow by navigating to https://www.github.com/orbcorp/orb-python/actions/workflows/publish-pypi.yml +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to PyPI in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/orbcorp/orb-python/actions/workflows/publish-pypi.yml name: Publish PyPI on: workflow_dispatch: + release: + types: [published] + jobs: publish: name: publish diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index fa9a5309..a55199c6 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -16,5 +16,4 @@ jobs: run: | bash ./bin/check-release-environment env: - STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} PYPI_TOKEN: ${{ secrets.ORB_PYPI_TOKEN || secrets.PYPI_TOKEN }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b3636e9a..1332969b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.42.3" + ".": "0.0.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a8763a6c..36ba5925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,66 @@ # Changelog +## 0.0.1 (2024-02-15) + +Full Changelog: [...abc-v0.0.1](https://github.com/orbcorp/orb-python/compare/...abc-v0.0.1) + +### Features + +* add `None` default value to nullable response properties ([#123](https://github.com/orbcorp/orb-python/issues/123)) ([bb30383](https://github.com/orbcorp/orb-python/commit/bb30383a4d6c22a214e8a8b0b8be918abf6dc1f8)) +* **api:** add `external_customer_id` ([#155](https://github.com/orbcorp/orb-python/issues/155)) ([bbb2b27](https://github.com/orbcorp/orb-python/commit/bbb2b273b1a1040d1f28e988bd4ba127e9544846)) +* **api:** add `version` to plan ([#160](https://github.com/orbcorp/orb-python/issues/160)) ([789fd3c](https://github.com/orbcorp/orb-python/commit/789fd3cc16ae7a70d34806c2ac6049233240a795)) +* **api:** add beta evaluate price endpoint ([#129](https://github.com/orbcorp/orb-python/issues/129)) ([81a1ad3](https://github.com/orbcorp/orb-python/commit/81a1ad3615e42067cdcc33d4ea4c8f98edc0fc3b)) +* **api:** add currency fields ([#119](https://github.com/orbcorp/orb-python/issues/119)) ([cca829b](https://github.com/orbcorp/orb-python/commit/cca829bd03ff099ef8cdbdbdbaa6f776ce2e1971)) +* **api:** price schema updates ([#156](https://github.com/orbcorp/orb-python/issues/156)) ([e765ff5](https://github.com/orbcorp/orb-python/commit/e765ff5188468e7ee2f2ae709b1799a16f83dc70)) +* **api:** remove unsupported field ([#95](https://github.com/orbcorp/orb-python/issues/95)) ([3a7182d](https://github.com/orbcorp/orb-python/commit/3a7182da4c9a1cf0ab2467d5a4f438601de5f695)) +* **api:** remove unsupported params ([#33](https://github.com/orbcorp/orb-python/issues/33)) ([b543a4a](https://github.com/orbcorp/orb-python/commit/b543a4a9d4dae7bb4de77ea834a7876dbb5e34ea)) +* **api:** updates ([#13](https://github.com/orbcorp/orb-python/issues/13)) ([028b445](https://github.com/orbcorp/orb-python/commit/028b4454865af03b1487fbb06b7fddf244817d8b)) +* **api:** updates ([#133](https://github.com/orbcorp/orb-python/issues/133)) ([233c371](https://github.com/orbcorp/orb-python/commit/233c371d6ba7ff0979b666059ae8cae8a3301dbb)) +* **api:** updates ([#139](https://github.com/orbcorp/orb-python/issues/139)) ([8f11913](https://github.com/orbcorp/orb-python/commit/8f1191364a5f965390d543a87e0dea4e4c218467)) +* **api:** updates ([#41](https://github.com/orbcorp/orb-python/issues/41)) ([6fa62f5](https://github.com/orbcorp/orb-python/commit/6fa62f5ce0889168cfb3cbe8dc3fe6b481afc3ab)) +* **api:** updates ([#55](https://github.com/orbcorp/orb-python/issues/55)) ([c4aead0](https://github.com/orbcorp/orb-python/commit/c4aead096d71fd98894ec3927d4e9ce9b8d672f2)) +* **api:** updates ([#66](https://github.com/orbcorp/orb-python/issues/66)) ([65cd6ee](https://github.com/orbcorp/orb-python/commit/65cd6eef7a8b7199f3298c52f897f0b067cca225)) +* **api:** updates ([#73](https://github.com/orbcorp/orb-python/issues/73)) ([8111a20](https://github.com/orbcorp/orb-python/commit/8111a20b678bae2c5fc3b383d94b73e9dfb0d24e)) +* **api:** updates ([#8](https://github.com/orbcorp/orb-python/issues/8)) ([6277147](https://github.com/orbcorp/orb-python/commit/6277147e7d03e74867339684adabe7e6e98d039a)) +* **api:** updates ([#99](https://github.com/orbcorp/orb-python/issues/99)) ([b6e752a](https://github.com/orbcorp/orb-python/commit/b6e752af7f8319ad87f48984d6dffc37ff6a6dc7)) +* **client:** add support for streaming raw responses ([#132](https://github.com/orbcorp/orb-python/issues/132)) ([c952056](https://github.com/orbcorp/orb-python/commit/c95205609c87d02a8a332118133c4084cddfe93f)) +* **client:** adjust retry behavior to be exponential backoff ([#4](https://github.com/orbcorp/orb-python/issues/4)) ([c2d507d](https://github.com/orbcorp/orb-python/commit/c2d507d2c02cd9b2abde5cb09cfb0cdb542fe8b0)) +* **client:** allow binary returns ([#26](https://github.com/orbcorp/orb-python/issues/26)) ([2a00845](https://github.com/orbcorp/orb-python/commit/2a008459ec8b7777234f8e16eb4afdd222098e6d)) +* **client:** enable follow redirects by default ([#150](https://github.com/orbcorp/orb-python/issues/150)) ([fdeba93](https://github.com/orbcorp/orb-python/commit/fdeba9317a933189891f70e8f763685e0e7f29b8)) +* **client:** improve file upload types ([#3](https://github.com/orbcorp/orb-python/issues/3)) ([c069dbd](https://github.com/orbcorp/orb-python/commit/c069dbdd4881b08d2c1d54c2a3edd2d892930ee9)) +* **client:** improve retry behaviour ([#6](https://github.com/orbcorp/orb-python/issues/6)) ([f945929](https://github.com/orbcorp/orb-python/commit/f945929adc1cfeda8e7475b4551a613ae9215892)) +* **client:** support parsing custom response types ([#153](https://github.com/orbcorp/orb-python/issues/153)) ([58ec02b](https://github.com/orbcorp/orb-python/commit/58ec02b7402a4fef8796c14b23c7674ae7a82e49)) +* **client:** support passing BaseModels to request params at runtime ([#27](https://github.com/orbcorp/orb-python/issues/27)) ([8adf54e](https://github.com/orbcorp/orb-python/commit/8adf54eca23e7af99504485403250884a1c50c18)) +* **client:** support passing chunk size for binary responses ([#40](https://github.com/orbcorp/orb-python/issues/40)) ([4385c41](https://github.com/orbcorp/orb-python/commit/4385c412ff00e02d63e1769d37481d37656ce3b4)) +* **client:** support passing httpx.Timeout to method timeout argument ([#35](https://github.com/orbcorp/orb-python/issues/35)) ([7392c32](https://github.com/orbcorp/orb-python/commit/7392c3237e2c51c915b875d0ad8794fc90d20c21)) +* **client:** support reading the base url from an env variable ([#54](https://github.com/orbcorp/orb-python/issues/54)) ([f3ce13e](https://github.com/orbcorp/orb-python/commit/f3ce13e5a3a411c7c1ad344ee3294635e7897e7a)) +* **github:** include a devcontainer setup ([#25](https://github.com/orbcorp/orb-python/issues/25)) ([b1a5a6c](https://github.com/orbcorp/orb-python/commit/b1a5a6c5f286e9cdd0799106fe323367d741cc42)) +* **init:** initial commit ([33d4af6](https://github.com/orbcorp/orb-python/commit/33d4af66059edfeffd6b39f058867d1babfd8fa9)) +* **package:** add classifiers ([#16](https://github.com/orbcorp/orb-python/issues/16)) ([b020093](https://github.com/orbcorp/orb-python/commit/b02009382ca130051eec94710a53ae525c188fdf)) + + +### Bug Fixes + +* avoid leaking memory when Client.with_options is used ([#97](https://github.com/orbcorp/orb-python/issues/97)) ([3c44a61](https://github.com/orbcorp/orb-python/commit/3c44a61dd9019e583d2a3cead6053c1d7903182a)) +* **binaries:** don't synchronously block in astream_to_file ([#28](https://github.com/orbcorp/orb-python/issues/28)) ([a63dc23](https://github.com/orbcorp/orb-python/commit/a63dc23d67712f84b4652447d988bd7449226035)) +* change status serialization behavior ([#168](https://github.com/orbcorp/orb-python/issues/168)) ([8c4c57a](https://github.com/orbcorp/orb-python/commit/8c4c57afbf20a9e9eff5076db24dd0b0e66ab606)) +* **ci:** ignore stainless-app edits to release PR title ([#146](https://github.com/orbcorp/orb-python/issues/146)) ([c55f8fd](https://github.com/orbcorp/orb-python/commit/c55f8fd5469edde52d050fa373ae7af139bcd25c)) +* **client:** attempt to parse unknown json content types ([#61](https://github.com/orbcorp/orb-python/issues/61)) ([ef4fc99](https://github.com/orbcorp/orb-python/commit/ef4fc999a961d2b6919ab6d8d96bcf997103037e)) +* **client:** correct base_url setter implementation ([#83](https://github.com/orbcorp/orb-python/issues/83)) ([44767ac](https://github.com/orbcorp/orb-python/commit/44767acf59fc879a0cb605658138ffe82ef57837)) +* **client:** correctly use custom http client auth ([#117](https://github.com/orbcorp/orb-python/issues/117)) ([7f382a9](https://github.com/orbcorp/orb-python/commit/7f382a91603f97a2a37e8158894787ece549f324)) +* **client:** ensure path params are non-empty ([#134](https://github.com/orbcorp/orb-python/issues/134)) ([f86298f](https://github.com/orbcorp/orb-python/commit/f86298fc796ad6dd6587e7f55e7d02f2cd8e2f4f)) +* **client:** ensure retried requests are closed ([#78](https://github.com/orbcorp/orb-python/issues/78)) ([fd84eba](https://github.com/orbcorp/orb-python/commit/fd84ebacdc7fbba940f6dc76b567a2d7009ea562)) +* **client:** include more detail in error messages ([#12](https://github.com/orbcorp/orb-python/issues/12)) ([cbecaf8](https://github.com/orbcorp/orb-python/commit/cbecaf8bb89cb2b308773e1b664ce2d588d320a6)) +* **client:** retry if SSLWantReadError occurs in the async client ([#48](https://github.com/orbcorp/orb-python/issues/48)) ([2f6c2af](https://github.com/orbcorp/orb-python/commit/2f6c2af227233f8c25db85c7cb4a52800bc290ab)) +* **client:** serialise pydantic v1 default fields correctly in params ([#46](https://github.com/orbcorp/orb-python/issues/46)) ([da14007](https://github.com/orbcorp/orb-python/commit/da140077ad01c50145894671616ab801c031c3bb)) +* **errors:** properly assign APIError.body ([#94](https://github.com/orbcorp/orb-python/issues/94)) ([659eba3](https://github.com/orbcorp/orb-python/commit/659eba359fe39b48d93e8fc4ae2306a0c4763408)) +* **models:** mark unknown fields as set in pydantic v1 ([#45](https://github.com/orbcorp/orb-python/issues/45)) ([dc668ef](https://github.com/orbcorp/orb-python/commit/dc668efb85a83e775c6ef729828d0c9bd681a12e)) +* prevent crash when platform.architecture() is not allowed ([#163](https://github.com/orbcorp/orb-python/issues/163)) ([38c953a](https://github.com/orbcorp/orb-python/commit/38c953ad498cb2aa832e8ed31efa05312e749c3a)) +* prevent TypeError in Python 3.8 (ABC is not subscriptable) ([#32](https://github.com/orbcorp/orb-python/issues/32)) ([3a6a751](https://github.com/orbcorp/orb-python/commit/3a6a751b9715841ae8343dbf2a2d40ff07909894)) +* rename customer.credits.ledger.create_entry_by_exteral_id and RequestValidationErrors ([#9](https://github.com/orbcorp/orb-python/issues/9)) ([a0a1968](https://github.com/orbcorp/orb-python/commit/a0a196819f08a11d50eee0e1778b1ff98c779bb6)) +* **types:** loosen most List params types to Iterable ([#167](https://github.com/orbcorp/orb-python/issues/167)) ([1a6d303](https://github.com/orbcorp/orb-python/commit/1a6d3036ef8c78b5bcb7b084189b4825b98bbff8)) +* use brackets instead of commas for array query params ([#116](https://github.com/orbcorp/orb-python/issues/116)) ([bfd1bf4](https://github.com/orbcorp/orb-python/commit/bfd1bf4f7cb71784a5a8034c784695a53b6ff63a)) + ## 1.42.3 (2024-02-07) Full Changelog: [v1.42.2...v1.42.3](https://github.com/orbcorp/orb-python/compare/v1.42.2...v1.42.3) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..cc2aa4a2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,125 @@ +## Setting up the environment + +### With Rye + +We use [Rye](https://rye-up.com/) to manage dependencies so we highly recommend [installing it](https://rye-up.com/guide/installation/) as it will automatically provision a Python environment with the expected Python version. + +After installing Rye, you'll just have to run this command: + +```sh +$ rye sync --all-features +``` + +You can then run scripts using `rye run python script.py` or by activating the virtual environment: + +```sh +$ rye shell +# or manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work +$ source .venv/bin/activate + +# now you can omit the `rye run` prefix +$ python script.py +``` + +### Without Rye + +Alternatively if you don't want to install `Rye`, you can stick with the standard `pip` setup by ensuring you have the Python version specified in `.python-version`, create a virtual environment however you desire and then install dependencies using this command: + +```sh +$ pip install -r requirements-dev.lock +``` + +## Modifying/Adding code + +Most of the SDK is generated code, and any modified code will be overridden on the next generation. The +`src/orb/lib/` and `examples/` directories are exceptions and will never be overridden. + +## Adding and running examples + +All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or +added to. + +```bash +# add an example to examples/.py + +#!/usr/bin/env -S rye run python +… +``` + +``` +chmod +x examples/.py +# run the example against your api +./examples/.py +``` + +## Using the repository from source + +If you’d like to use the repository from source, you can either install from git or link to a cloned repository: + +To install via git: + +```bash +pip install git+ssh://git@github.com:orbcorp/orb-python.git +``` + +Alternatively, you can build from source and install the wheel file: + +Building this package will create two files in the `dist/` directory, a `.tar.gz` containing the source files and a `.whl` that can be used to install the package efficiently. + +To create a distributable version of the library, all you have to do is run this command: + +```bash +rye build +# or +python -m build +``` + +Then to install: + +```sh +pip install ./path-to-wheel-file.whl +``` + +## Running tests + +Most tests will require you to [setup a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. + +```bash +# you will need npm installed +npx prism path/to/your/openapi.yml +``` + +```bash +rye run pytest +``` + +## Linting and formatting + +This repository uses [ruff](https://github.com/astral-sh/ruff) and +[black](https://github.com/psf/black) to format the code in the repository. + +To lint: + +```bash +rye run lint +``` + +To format and fix all ruff issues automatically: + +```bash +rye run format +``` + +## Publishing and releases + +Changes made to this repository via the automated release PR pipeline should publish to PyPI automatically. If +the changes aren't made through the automated pipeline, you may want to make releases manually. + +### Publish with a GitHub workflow + +You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/orbcorp/orb-python/actions/workflows/publish-pypi.yml). This will require a setup organization or repository secret to be set up. + +### Publish manually + +If you need to manually release a package, you can run the `bin/publish-pypi` script with an `PYPI_TOKEN` set on +the environment. diff --git a/bin/check-release-environment b/bin/check-release-environment index 7e344b6f..b0828071 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -2,17 +2,13 @@ errors=() -if [ -z "${STAINLESS_API_KEY}" ]; then - 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.") -fi - if [ -z "${PYPI_TOKEN}" ]; then errors+=("The ORB_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.") fi -len=${#errors[@]} +lenErrors=${#errors[@]} -if [[ len -gt 0 ]]; then +if [[ lenErrors -gt 0 ]]; then echo -e "Found the following errors in the release environment:\n" for error in "${errors[@]}"; do