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
A Python client library for accessing the [Rootly API v1](https://rootly.com/). This SDK provides both synchronous and asynchronous interfaces for interacting with Rootly's incident management platform.
By default, the client verifies SSL certificates. For internal APIs with custom certificates:
46
+
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.
71
47
72
48
```python
73
49
client = AuthenticatedClient(
74
-
base_url="https://internal-api.example.com",
75
-
token="your-api-token",
50
+
base_url="https://internal_api.example.com",
51
+
token="SuperSecretToken",
76
52
verify_ssl="/path/to/certificate_bundle.pem",
77
53
)
78
54
```
79
55
80
-
**Warning:** Disabling SSL verification is a security risk and should only be used in development:
56
+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
81
57
82
58
```python
83
59
client = AuthenticatedClient(
84
-
base_url="https://internal-api.example.com",
85
-
token="your-api-token",
60
+
base_url="https://internal_api.example.com",
61
+
token="SuperSecretToken",
86
62
verify_ssl=False
87
63
)
88
64
```
89
65
90
-
### Custom HTTP Client Configuration
66
+
Things to know:
67
+
1. Every path/method combo becomes a Python module with four functions:
68
+
1.`sync`: Blocking request that returns parsed data (if successful) or `None`
69
+
1.`sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
70
+
1.`asyncio`: Like `sync` but async instead of blocking
71
+
1.`asyncio_detailed`: Like `sync_detailed` but async instead of blocking
72
+
73
+
1. All path/query params, and bodies become method arguments.
74
+
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)
75
+
1. Any endpoint which did not have a tag will be in `rootly_sdk.api.default`
76
+
77
+
## Advanced customizations
91
78
92
-
You can customize the underlying `httpx.Client`with event hooks and other options:
79
+
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):
93
80
94
81
```python
95
82
from rootly_sdk import Client
96
83
97
84
deflog_request(request):
98
-
print(f"Request: {request.method}{request.url}")
85
+
print(f"Request event hook: {request.method}{request.url} - Waiting for response")
99
86
100
87
deflog_response(response):
101
-
print(f"Response: {response.request.method}{response.request.url} - Status {response.status_code}")
88
+
request = response.request
89
+
print(f"Response event hook: {request.method}{request.url} - Status {response.status_code}")
0 commit comments