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
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.
47
-
48
-
```python
49
-
client = AuthenticatedClient(
50
-
base_url="https://internal_api.example.com",
51
-
token="SuperSecretToken",
52
-
verify_ssl="/path/to/certificate_bundle.pem",
53
-
)
54
-
```
55
-
56
-
You can also disable certificate validation altogether, but beware that **this is a security risk**.
raise Exception(f"Got unexpected status code {response.status_code} for project ")
41
+
42
+
```
43
+
44
+
Things to know:
45
+
1. Every path/method combo becomes a Python module with four functions:
46
+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
47
+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
48
+
1. `asyncio`: Like `sync` but async instead of blocking
49
+
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
50
+
51
+
1. All path/query params, and bodies become method arguments.
52
+
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)
53
+
1. Any endpoint which did not have a tag will be in `{{ package_name }}.api.default`
54
+
55
+
## Advanced customizations
56
+
57
+
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):
58
+
59
+
```python
60
+
from {{ package_name }} import Client
61
+
62
+
def log_request(request):
63
+
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
64
+
65
+
def log_response(response):
66
+
request = response.request
67
+
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
0 commit comments