Skip to content

Commit ceb6ea6

Browse files
kwentclaude
andcommitted
Improve README documentation
Enhanced the README with better structure, installation instructions, PyPI/Python version badges, proper Rootly API URLs, clearer sections for quick start, development, and publishing workflows, and added license and support information. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent eae4d80 commit ceb6ea6

1 file changed

Lines changed: 157 additions & 53 deletions

File tree

README.md

Lines changed: 157 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,57 @@
1-
# rootly
2-
A client library for accessing Rootly API v1
1+
# Rootly Python SDK
2+
3+
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.
4+
5+
[![PyPI version](https://badge.fury.io/py/rootly.svg)](https://badge.fury.io/py/rootly)
6+
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
7+
8+
## Installation
9+
10+
```bash
11+
pip install rootly
12+
```
13+
14+
## Quick Start
15+
16+
### Basic Usage
317

4-
## Usage
518
First, create a client:
619

720
```python
821
from rootly_sdk import Client
922

10-
client = Client(base_url="https://api.example.com")
23+
client = Client(base_url="https://api.rootly.com")
1124
```
1225

13-
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
26+
### Authentication
27+
28+
For endpoints that require authentication, use `AuthenticatedClient`:
1429

1530
```python
1631
from rootly_sdk import AuthenticatedClient
1732

18-
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
33+
client = AuthenticatedClient(
34+
base_url="https://api.rootly.com",
35+
token="your-api-token"
36+
)
1937
```
2038

21-
Now call your endpoint and use your models:
39+
### Making API Calls
2240

2341
```python
2442
from rootly_sdk.models import MyDataModel
2543
from rootly_sdk.api.my_tag import get_my_data_model
2644
from rootly_sdk.types import Response
2745

46+
# Simple synchronous call
2847
with client as client:
2948
my_data: MyDataModel = get_my_data_model.sync(client=client)
30-
# or if you need more info (e.g. status_code)
49+
50+
# Or get detailed response (includes status_code, headers, etc.)
3151
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
3252
```
3353

34-
Or do the same thing with an async version:
54+
### Async Usage
3555

3656
```python
3757
from rootly_sdk.models import MyDataModel
@@ -43,82 +63,162 @@ async with client as client:
4363
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
4464
```
4565

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.
66+
## Advanced Configuration
67+
68+
### SSL Certificate Verification
69+
70+
By default, the client verifies SSL certificates. For internal APIs with custom certificates:
4771

4872
```python
4973
client = AuthenticatedClient(
50-
base_url="https://internal_api.example.com",
51-
token="SuperSecretToken",
74+
base_url="https://internal-api.example.com",
75+
token="your-api-token",
5276
verify_ssl="/path/to/certificate_bundle.pem",
5377
)
5478
```
5579

56-
You can also disable certificate validation altogether, but beware that **this is a security risk**.
80+
**Warning:** Disabling SSL verification is a security risk and should only be used in development:
5781

5882
```python
5983
client = AuthenticatedClient(
60-
base_url="https://internal_api.example.com",
61-
token="SuperSecretToken",
84+
base_url="https://internal-api.example.com",
85+
token="your-api-token",
6286
verify_ssl=False
6387
)
6488
```
6589

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`
90+
### Custom HTTP Client Configuration
7691

77-
## Advanced customizations
78-
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):
92+
You can customize the underlying `httpx.Client` with event hooks and other options:
8093

8194
```python
8295
from rootly_sdk import Client
8396

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

87100
def log_response(response):
88-
request = response.request
89-
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
101+
print(f"Response: {response.request.method} {response.request.url} - Status {response.status_code}")
90102

91103
client = Client(
92-
base_url="https://api.example.com",
93-
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
104+
base_url="https://api.rootly.com",
105+
httpx_args={
106+
"event_hooks": {
107+
"request": [log_request],
108+
"response": [log_response]
109+
}
110+
},
94111
)
112+
```
113+
114+
Access the underlying httpx client directly:
115+
116+
```python
117+
# Synchronous client
118+
httpx_client = client.get_httpx_client()
95119

96-
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
120+
# Asynchronous client
121+
async_httpx_client = client.get_async_httpx_client()
97122
```
98123

99-
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
124+
Set a custom httpx client (note: this overrides base_url and other settings):
100125

101126
```python
102127
import httpx
103128
from rootly_sdk import Client
104129

105-
client = Client(
106-
base_url="https://api.example.com",
130+
client = Client(base_url="https://api.rootly.com")
131+
client.set_httpx_client(
132+
httpx.Client(
133+
base_url="https://api.rootly.com",
134+
proxies="http://localhost:8030"
135+
)
107136
)
108-
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
109-
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
110137
```
111138

112-
## Building / publishing this package
113-
This project uses [uv](https://github.com/astral-sh/uv) and Python's build system for packaging. Publishing is automated via GitHub Actions.
139+
## API Structure
140+
141+
The SDK is structured as follows:
142+
143+
1. **Four function variants per endpoint:**
144+
- `sync`: Blocking request returning parsed data or `None`
145+
- `sync_detailed`: Blocking request returning full `Response` object
146+
- `asyncio`: Async version of `sync`
147+
- `asyncio_detailed`: Async version of `sync_detailed`
114148

115-
### Automated Publishing (Recommended)
116-
1. Update metadata in pyproject.toml (e.g. authors, version)
117-
2. Create and push a git tag: `git tag v1.0.0 && git push origin v1.0.0`
118-
3. The GitHub Action will automatically build and publish to PyPI
149+
2. **Module organization:**
150+
- Path/query parameters and request bodies become function arguments
151+
- Endpoints are grouped by their first OpenAPI tag (e.g., `rootly_sdk.api.incidents`)
152+
- Untagged endpoints are in `rootly_sdk.api.default`
153+
154+
## Development
155+
156+
### Requirements
157+
158+
- Python 3.9 or higher
159+
- [uv](https://github.com/astral-sh/uv) (recommended) or pip
160+
161+
### Installation for Development
162+
163+
```bash
164+
# Clone the repository
165+
git clone https://github.com/rootlyhq/rootly-python.git
166+
cd rootly-python
167+
168+
# Install in editable mode
169+
pip install -e .
170+
```
171+
172+
### Regenerating the Client
173+
174+
To regenerate the client from the latest OpenAPI specification:
175+
176+
```bash
177+
openapi-python-client generate \
178+
--url https://rootly-heroku.s3.amazonaws.com/swagger/v1/swagger.json \
179+
--no-fail-on-warning \
180+
--output-path . \
181+
--overwrite \
182+
--config tools/config.yaml
183+
```
184+
185+
### Building the Package
186+
187+
```bash
188+
# Install build tools
189+
pip install uv
190+
uv pip install build
191+
192+
# Build distribution files
193+
python -m build
194+
```
195+
196+
### Running Tests
197+
198+
```bash
199+
# Verify SDK imports successfully
200+
python -c "import rootly_sdk; print('SDK imports successfully')"
201+
```
202+
203+
## Publishing
204+
205+
### Automated Publishing via GitHub Actions (Recommended)
206+
207+
1. Update the version in `pyproject.toml`
208+
2. Update `CHANGELOG.md` with release notes
209+
3. Create and push a git tag:
210+
```bash
211+
git tag v1.0.0
212+
git push origin v1.0.0
213+
```
214+
4. GitHub Actions will automatically build and publish to PyPI
215+
216+
See [.github/PUBLISHING.md](.github/PUBLISHING.md) for detailed publishing instructions.
119217

120218
### Manual Publishing
219+
121220
If you need to publish manually:
221+
122222
```bash
123223
# Install dependencies
124224
pip install uv
@@ -131,12 +231,16 @@ python -m build
131231
twine upload dist/*
132232
```
133233

134-
### Development Installation
135-
To install this client into another project for development:
136-
```bash
137-
# Install directly from source
138-
pip install /path/to/rootly-python
234+
## Dependencies
139235

140-
# Or install in editable mode
141-
pip install -e /path/to/rootly-python
142-
```
236+
- [httpx](https://www.python-httpx.org/) >= 0.20.0, < 0.29.0 - HTTP client
237+
- [attrs](https://www.attrs.org/) >= 22.2.0 - Data classes
238+
- [python-dateutil](https://dateutil.readthedocs.io/) >= 2.8.0 - Date parsing
239+
240+
## License
241+
242+
Apache 2.0
243+
244+
## Support
245+
246+
For issues, questions, or contributions, please visit the [GitHub repository](https://github.com/rootlyhq/rootly-python).

0 commit comments

Comments
 (0)