Skip to content

Commit

Permalink
Regenerate bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubFrejlach committed Dec 19, 2024
1 parent 4cc3b7c commit 7c01396
Show file tree
Hide file tree
Showing 277 changed files with 26,413 additions and 15,737 deletions.
2 changes: 1 addition & 1 deletion osidb_bindings/bindings/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ dmypy.json
.idea/

/coverage.xml
/.coverage
/.coverage
55 changes: 46 additions & 9 deletions osidb_bindings/bindings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ from python_client.models import MyDataModel
from python_client.api.my_tag import get_my_data_model
from python_client.types import Response

my_data: MyDataModel = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
with client as client:
my_data: MyDataModel = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
```

Or do the same thing with an async version:
Expand All @@ -37,8 +38,9 @@ from python_client.models import MyDataModel
from python_client.api.my_tag import get_my_data_model
from python_client.types import Response

my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
async with client as client:
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
```

By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
Expand All @@ -65,14 +67,49 @@ Things to know:
1. Every path/method combo becomes a Python module with four functions:
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
1. `asyncio`: Like `sync` but the async instead of blocking
1. `asyncio_detailed`: Like `sync_detailed` by async instead of blocking
1. `asyncio`: Like `sync` but async instead of blocking
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking

1. All path/query params, and bodies become method arguments.
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
1. Any endpoint which did not have a tag will be in `python_client.api.default`

## Building / publishing this Client
## Advanced customizations

There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):

```python
from python_client import Client

def log_request(request):
print(f"Request event hook: {request.method} {request.url} - Waiting for response")

def log_response(response):
request = response.request
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")

client = Client(
base_url="https://api.example.com",
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)

# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
```

You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):

```python
import httpx
from python_client import Client

client = Client(
base_url="https://api.example.com",
)
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
```

## Building / publishing this package
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
1. Update the metadata in pyproject.toml (e.g. authors, version)
1. If you're using a private repository, configure it with Poetry
Expand All @@ -84,4 +121,4 @@ If you want to install this client into another project without publishing it (e
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
1. If that project is not using Poetry:
1. Build a wheel with `poetry build -f wheel`
1. Install that wheel from the other project `pip install <path-to-wheel>`
1. Install that wheel from the other project `pip install <path-to-wheel>`
32 changes: 10 additions & 22 deletions osidb_bindings/bindings/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
[tool.poetry]
name = "bindings"
version = "4.6.0"
version = "4.6.1"
description = "A client library for accessing OSIDB API"

authors = []

readme = "README.md"
packages = [
{include = "python_client"},
]
include = ["CHANGELOG.md", "python_client/py.typed"]


[tool.poetry.dependencies]
python = "^3.6"
httpx = ">=0.15.4,<0.21.0"
attrs = ">=20.1.0,<22.0.0"
python = "^3.9"
httpx = ">=0.20.0,<0.28.0"
attrs = ">=21.3.0"
python-dateutil = "^2.8.0"

[build-system]
requires = ["poetry>=1.0"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
[tool.ruff]
line-length = 120
target_version = ['py36', 'py37', 'py38']
exclude = '''
(
/(
| \.git
| \.venv
| \.mypy_cache
)/
)
'''

[tool.isort]
line_length = 120
profile = "black"
[tool.ruff.lint]
select = ["F", "I", "UP"]
8 changes: 7 additions & 1 deletion osidb_bindings/bindings/python_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
""" A client library for accessing OSIDB API """
"""A client library for accessing OSIDB API"""

from .client import AuthenticatedClient, Client

__all__ = (
"AuthenticatedClient",
"Client",
)
2 changes: 1 addition & 1 deletion osidb_bindings/bindings/python_client/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
""" Contains methods for accessing the API """
"""Contains methods for accessing the API"""
Loading

0 comments on commit 7c01396

Please sign in to comment.