devrev-Python-SDK 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- devrev/__init__.py +47 -0
- devrev/client.py +343 -0
- devrev/config.py +180 -0
- devrev/exceptions.py +205 -0
- devrev/models/__init__.py +499 -0
- devrev/models/accounts.py +187 -0
- devrev/models/articles.py +109 -0
- devrev/models/base.py +147 -0
- devrev/models/code_changes.py +103 -0
- devrev/models/conversations.py +115 -0
- devrev/models/dev_users.py +258 -0
- devrev/models/groups.py +140 -0
- devrev/models/links.py +107 -0
- devrev/models/parts.py +110 -0
- devrev/models/rev_users.py +177 -0
- devrev/models/slas.py +112 -0
- devrev/models/tags.py +90 -0
- devrev/models/timeline_entries.py +100 -0
- devrev/models/webhooks.py +109 -0
- devrev/models/works.py +280 -0
- devrev/py.typed +1 -0
- devrev/services/__init__.py +74 -0
- devrev/services/accounts.py +325 -0
- devrev/services/articles.py +80 -0
- devrev/services/base.py +234 -0
- devrev/services/code_changes.py +80 -0
- devrev/services/conversations.py +98 -0
- devrev/services/dev_users.py +401 -0
- devrev/services/groups.py +103 -0
- devrev/services/links.py +68 -0
- devrev/services/parts.py +100 -0
- devrev/services/rev_users.py +235 -0
- devrev/services/slas.py +82 -0
- devrev/services/tags.py +80 -0
- devrev/services/timeline_entries.py +80 -0
- devrev/services/webhooks.py +80 -0
- devrev/services/works.py +363 -0
- devrev/utils/__init__.py +14 -0
- devrev/utils/deprecation.py +49 -0
- devrev/utils/http.py +521 -0
- devrev/utils/logging.py +139 -0
- devrev/utils/pagination.py +155 -0
- devrev_python_sdk-1.0.0.dist-info/METADATA +774 -0
- devrev_python_sdk-1.0.0.dist-info/RECORD +45 -0
- devrev_python_sdk-1.0.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: devrev-Python-SDK
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A modern, type-safe Python SDK for the DevRev API
|
|
5
|
+
Project-URL: Homepage, https://github.com/mgmonteleone/py-dev-rev
|
|
6
|
+
Project-URL: Documentation, https://github.com/mgmonteleone/py-dev-rev
|
|
7
|
+
Project-URL: Repository, https://github.com/mgmonteleone/py-dev-rev.git
|
|
8
|
+
Project-URL: Issues, https://github.com/mgmonteleone/py-dev-rev/issues
|
|
9
|
+
Author-email: "Matthew G. Monteleone" <matthewm@augmentcode.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
Keywords: api,client,devrev,sdk
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: httpx>=0.25.0
|
|
22
|
+
Requires-Dist: pydantic-settings>=2.1.0
|
|
23
|
+
Requires-Dist: pydantic>=2.5.0
|
|
24
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
25
|
+
Provides-Extra: all
|
|
26
|
+
Requires-Dist: bandit>=1.7.0; extra == 'all'
|
|
27
|
+
Requires-Dist: mkdocs-material>=9.5.0; extra == 'all'
|
|
28
|
+
Requires-Dist: mkdocs>=1.5.0; extra == 'all'
|
|
29
|
+
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == 'all'
|
|
30
|
+
Requires-Dist: mypy>=1.7.0; extra == 'all'
|
|
31
|
+
Requires-Dist: pip-audit>=2.7.0; extra == 'all'
|
|
32
|
+
Requires-Dist: pre-commit>=3.6.0; extra == 'all'
|
|
33
|
+
Requires-Dist: pymdown-extensions>=10.7.0; extra == 'all'
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'all'
|
|
35
|
+
Requires-Dist: pytest-benchmark>=4.0.0; extra == 'all'
|
|
36
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'all'
|
|
37
|
+
Requires-Dist: pytest-mock>=3.12.0; extra == 'all'
|
|
38
|
+
Requires-Dist: pytest>=7.4.0; extra == 'all'
|
|
39
|
+
Requires-Dist: respx>=0.20.0; extra == 'all'
|
|
40
|
+
Requires-Dist: ruff>=0.1.0; extra == 'all'
|
|
41
|
+
Requires-Dist: safety>=2.3.0; extra == 'all'
|
|
42
|
+
Provides-Extra: benchmark
|
|
43
|
+
Requires-Dist: pytest-benchmark>=4.0.0; extra == 'benchmark'
|
|
44
|
+
Requires-Dist: pytest>=7.4.0; extra == 'benchmark'
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: mypy>=1.7.0; extra == 'dev'
|
|
47
|
+
Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
|
|
48
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
49
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest-mock>=3.12.0; extra == 'dev'
|
|
51
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
52
|
+
Requires-Dist: respx>=0.20.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
54
|
+
Provides-Extra: docs
|
|
55
|
+
Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
|
|
56
|
+
Requires-Dist: mkdocs>=1.5.0; extra == 'docs'
|
|
57
|
+
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == 'docs'
|
|
58
|
+
Requires-Dist: pymdown-extensions>=10.7.0; extra == 'docs'
|
|
59
|
+
Provides-Extra: security
|
|
60
|
+
Requires-Dist: bandit>=1.7.0; extra == 'security'
|
|
61
|
+
Requires-Dist: pip-audit>=2.7.0; extra == 'security'
|
|
62
|
+
Requires-Dist: safety>=2.3.0; extra == 'security'
|
|
63
|
+
Description-Content-Type: text/markdown
|
|
64
|
+
|
|
65
|
+
# py-devrev
|
|
66
|
+
|
|
67
|
+
A modern, type-safe Python SDK for the DevRev API.
|
|
68
|
+
|
|
69
|
+
[](https://pypi.org/project/py-devrev/)
|
|
70
|
+
[](https://www.python.org/downloads/)
|
|
71
|
+
[](https://mypy-lang.org/)
|
|
72
|
+
[](https://github.com/astral-sh/ruff)
|
|
73
|
+
[](https://opensource.org/licenses/MIT)
|
|
74
|
+
[](https://github.com/mgmonteleone/py-dev-rev)
|
|
75
|
+
<!-- Note: Coverage badge should be updated manually or replaced with dynamic badge from codecov/coveralls -->
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Table of Contents
|
|
80
|
+
|
|
81
|
+
- [Overview](#overview)
|
|
82
|
+
- [Features](#features)
|
|
83
|
+
- [Installation](#installation)
|
|
84
|
+
- [Quick Start](#quick-start)
|
|
85
|
+
- [Authentication](#authentication)
|
|
86
|
+
- [API Coverage](#api-coverage)
|
|
87
|
+
- [Usage Examples](#usage-examples)
|
|
88
|
+
- [Configuration](#configuration)
|
|
89
|
+
- [Error Handling](#error-handling)
|
|
90
|
+
- [Logging](#logging)
|
|
91
|
+
- [Development](#development)
|
|
92
|
+
- [Testing Strategy](#testing-strategy)
|
|
93
|
+
- [CI/CD Pipeline](#cicd-pipeline)
|
|
94
|
+
- [Roadmap](#roadmap)
|
|
95
|
+
- [Contributing](#contributing)
|
|
96
|
+
- [License](#license)
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Overview
|
|
101
|
+
|
|
102
|
+
`py-devrev` is a modern Python library for interacting with the [DevRev API](https://devrev.ai). Built with developer experience in mind, it provides:
|
|
103
|
+
|
|
104
|
+
- **100% API Coverage**: Full support for all 209 public DevRev API endpoints
|
|
105
|
+
- **Type Safety**: Complete type annotations with Pydantic v2 models
|
|
106
|
+
- **Modern Python**: Supports Python 3.11+ (N-2 policy)
|
|
107
|
+
- **Developer Friendly**: Intuitive API design with comprehensive documentation
|
|
108
|
+
|
|
109
|
+
This SDK is generated and maintained from the official DevRev OpenAPI specification (`openapi-public.yaml`), ensuring it stays current with the latest API changes.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Features
|
|
114
|
+
|
|
115
|
+
### Core Capabilities
|
|
116
|
+
|
|
117
|
+
- ✅ **Full API Coverage** - All DevRev public API endpoints supported
|
|
118
|
+
- ✅ **Type-Safe Models** - Pydantic v2 models for all request/response objects
|
|
119
|
+
- ✅ **Async Support** - Native async/await support for high-performance applications
|
|
120
|
+
- ✅ **Automatic Retries** - Configurable retry logic with exponential backoff
|
|
121
|
+
- ✅ **Rate Limiting** - Built-in rate limit handling with Retry-After support
|
|
122
|
+
- ✅ **Pagination** - Easy iteration over paginated endpoints
|
|
123
|
+
|
|
124
|
+
### Developer Experience
|
|
125
|
+
|
|
126
|
+
- ✅ **Rich Exceptions** - Detailed, actionable error messages
|
|
127
|
+
- ✅ **Colored Logging** - Beautiful console output with configurable levels
|
|
128
|
+
- ✅ **IDE Support** - Full autocomplete and type hints in modern IDEs
|
|
129
|
+
- ✅ **Comprehensive Docs** - Detailed documentation with examples
|
|
130
|
+
|
|
131
|
+
### Enterprise Ready
|
|
132
|
+
|
|
133
|
+
- ✅ **Security First** - No secrets in code, environment-based configuration
|
|
134
|
+
- ✅ **Production Logging** - Structured logging suitable for production
|
|
135
|
+
- ✅ **High Test Coverage** - 80%+ code coverage with unit and integration tests
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Installation
|
|
140
|
+
|
|
141
|
+
### From Google Artifact Registry (Recommended)
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install py-devrev
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### From Source
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
git clone https://github.com/mgmonteleone/py-dev-rev.git
|
|
151
|
+
cd py-dev-rev
|
|
152
|
+
pip install -e ".[dev]"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Requirements
|
|
156
|
+
|
|
157
|
+
- Python 3.11 or higher
|
|
158
|
+
- Dependencies are automatically installed
|
|
159
|
+
|
|
160
|
+
### Python support policy
|
|
161
|
+
|
|
162
|
+
py-devrev follows an **N-2** support policy (current stable Python + two previous minor versions).
|
|
163
|
+
|
|
164
|
+
- See: [Python version support policy](docs/guides/version-support.md)
|
|
165
|
+
- See: [Compatibility matrix](docs/guides/compatibility.md)
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Quick Start
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from devrev import DevRevClient
|
|
173
|
+
|
|
174
|
+
# Initialize the client (reads DEVREV_API_TOKEN from environment)
|
|
175
|
+
client = DevRevClient()
|
|
176
|
+
|
|
177
|
+
# List accounts
|
|
178
|
+
accounts = client.accounts.list(limit=10)
|
|
179
|
+
for account in accounts:
|
|
180
|
+
print(f"{account.id}: {account.display_name}")
|
|
181
|
+
|
|
182
|
+
# Get a specific work item
|
|
183
|
+
work = client.works.get(id="don:core:...")
|
|
184
|
+
print(f"Work: {work.title} - Status: {work.stage.name}")
|
|
185
|
+
|
|
186
|
+
# Create a new ticket
|
|
187
|
+
ticket = client.works.create(
|
|
188
|
+
title="Bug: Login page not loading",
|
|
189
|
+
type="ticket",
|
|
190
|
+
applies_to_part="don:core:...",
|
|
191
|
+
body="Users are reporting issues with the login page..."
|
|
192
|
+
)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Async Usage
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
import asyncio
|
|
199
|
+
from devrev import AsyncDevRevClient
|
|
200
|
+
|
|
201
|
+
async def main():
|
|
202
|
+
async with AsyncDevRevClient() as client:
|
|
203
|
+
accounts = await client.accounts.list(limit=10)
|
|
204
|
+
for account in accounts:
|
|
205
|
+
print(f"{account.id}: {account.display_name}")
|
|
206
|
+
|
|
207
|
+
asyncio.run(main())
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Authentication
|
|
213
|
+
|
|
214
|
+
The SDK supports multiple authentication methods:
|
|
215
|
+
|
|
216
|
+
### API Token (Recommended)
|
|
217
|
+
|
|
218
|
+
Set the `DEVREV_API_TOKEN` environment variable:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
export DEVREV_API_TOKEN="your-api-token-here"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Or pass it directly (not recommended for production):
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
client = DevRevClient(api_token="your-api-token-here")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Personal Access Token (PAT)
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
export DEVREV_PAT="your-personal-access-token"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Service Account
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
client = DevRevClient(
|
|
240
|
+
service_account_id="your-service-account-id",
|
|
241
|
+
service_account_secret="your-service-account-secret" # Load from env!
|
|
242
|
+
)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## API Coverage
|
|
248
|
+
|
|
249
|
+
The SDK provides complete coverage of all 209 DevRev public API endpoints, organized into logical service groups:
|
|
250
|
+
|
|
251
|
+
### Core Objects
|
|
252
|
+
|
|
253
|
+
| Service | Endpoints | Description |
|
|
254
|
+
|---------|-----------|-------------|
|
|
255
|
+
| **Accounts** | 7 | Customer account management (create, list, get, update, delete, merge, export) |
|
|
256
|
+
| **Rev Orgs** | 5 | Revenue organization management |
|
|
257
|
+
| **Rev Users** | 7 | External user management (customers) |
|
|
258
|
+
| **Dev Users** | 10 | Internal user management (team members) |
|
|
259
|
+
| **Works** | 6 | Work items - tickets, issues, tasks (create, list, get, update, delete, export, count) |
|
|
260
|
+
| **Parts** | 5 | Product parts and components |
|
|
261
|
+
|
|
262
|
+
### Content & Knowledge
|
|
263
|
+
|
|
264
|
+
| Service | Endpoints | Description |
|
|
265
|
+
|---------|-----------|-------------|
|
|
266
|
+
| **Articles** | 5 | Knowledge base articles |
|
|
267
|
+
| **Conversations** | 5 | Customer conversations |
|
|
268
|
+
| **Timeline Entries** | 5 | Activity timeline management |
|
|
269
|
+
| **Tags** | 5 | Tagging and categorization |
|
|
270
|
+
|
|
271
|
+
### Collaboration
|
|
272
|
+
|
|
273
|
+
| Service | Endpoints | Description |
|
|
274
|
+
|---------|-----------|-------------|
|
|
275
|
+
| **Groups** | 6 | User group management |
|
|
276
|
+
| **Meetings** | 6 | Meeting scheduling and management |
|
|
277
|
+
| **Chats** | 3 | Chat functionality |
|
|
278
|
+
| **Comments** | - | Via timeline entries |
|
|
279
|
+
|
|
280
|
+
### Development & Engineering
|
|
281
|
+
|
|
282
|
+
| Service | Endpoints | Description |
|
|
283
|
+
|---------|-----------|-------------|
|
|
284
|
+
| **Code Changes** | 5 | Code change tracking |
|
|
285
|
+
| **Artifacts** | 6 | File and artifact management |
|
|
286
|
+
| **Webhooks** | 6 | Webhook configuration |
|
|
287
|
+
| **Links** | 5 | Object linking and relationships |
|
|
288
|
+
|
|
289
|
+
### Configuration & Admin
|
|
290
|
+
|
|
291
|
+
| Service | Endpoints | Description |
|
|
292
|
+
|---------|-----------|-------------|
|
|
293
|
+
| **Auth Tokens** | 8 | Authentication token management |
|
|
294
|
+
| **Service Accounts** | 2 | Service account management |
|
|
295
|
+
| **Dev Orgs** | 7 | Organization settings and auth connections |
|
|
296
|
+
| **Schemas** | 7 | Custom schema management |
|
|
297
|
+
| **Custom Objects** | 6 | Custom object CRUD operations |
|
|
298
|
+
|
|
299
|
+
### Workflows & SLAs
|
|
300
|
+
|
|
301
|
+
| Service | Endpoints | Description |
|
|
302
|
+
|---------|-----------|-------------|
|
|
303
|
+
| **SLAs** | 6 | Service level agreement management |
|
|
304
|
+
| **SLA Trackers** | 3 | SLA tracking and monitoring |
|
|
305
|
+
| **Stages** | 4 | Custom stage definitions |
|
|
306
|
+
| **States** | 4 | Custom state definitions |
|
|
307
|
+
| **Stage Diagrams** | 4 | Workflow visualization |
|
|
308
|
+
|
|
309
|
+
### Analytics & Observability
|
|
310
|
+
|
|
311
|
+
| Service | Endpoints | Description |
|
|
312
|
+
|---------|-----------|-------------|
|
|
313
|
+
| **Metrics** | 6 | Metric definitions and tracking |
|
|
314
|
+
| **Surveys** | 9 | Customer surveys and responses |
|
|
315
|
+
| **Observability** | 3 | Session observability data |
|
|
316
|
+
|
|
317
|
+
### Other Services
|
|
318
|
+
|
|
319
|
+
| Service | Endpoints | Description |
|
|
320
|
+
|---------|-----------|-------------|
|
|
321
|
+
| **Directories** | 6 | Directory management |
|
|
322
|
+
| **Vistas** | 6 | View configurations |
|
|
323
|
+
| **Org Schedules** | 7 | Business hour schedules |
|
|
324
|
+
| **Jobs** | 2 | Background job management |
|
|
325
|
+
| **Web Crawler** | 4 | Web crawler job management |
|
|
326
|
+
| **Reactions** | 2 | Emoji reactions |
|
|
327
|
+
| **Snap Widgets** | 2 | UI widget management |
|
|
328
|
+
| **Commands** | 4 | Slash command management |
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Usage Examples
|
|
333
|
+
|
|
334
|
+
### Working with Accounts
|
|
335
|
+
|
|
336
|
+
```python
|
|
337
|
+
from devrev import DevRevClient
|
|
338
|
+
|
|
339
|
+
client = DevRevClient()
|
|
340
|
+
|
|
341
|
+
# List all accounts with pagination
|
|
342
|
+
for account in client.accounts.list():
|
|
343
|
+
print(f"Account: {account.display_name}")
|
|
344
|
+
print(f" Tier: {account.tier}")
|
|
345
|
+
print(f" Domains: {', '.join(account.domains or [])}")
|
|
346
|
+
|
|
347
|
+
# Create a new account
|
|
348
|
+
new_account = client.accounts.create(
|
|
349
|
+
display_name="Acme Corporation",
|
|
350
|
+
domains=["acme.com", "acme.io"],
|
|
351
|
+
tier="enterprise",
|
|
352
|
+
description="Major enterprise customer"
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
# Update an account
|
|
356
|
+
updated = client.accounts.update(
|
|
357
|
+
id=new_account.id,
|
|
358
|
+
tier="premium"
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
# Search/filter accounts
|
|
362
|
+
enterprise_accounts = client.accounts.list(
|
|
363
|
+
tier=["enterprise"],
|
|
364
|
+
created_after="2024-01-01"
|
|
365
|
+
)
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Managing Work Items
|
|
369
|
+
|
|
370
|
+
```python
|
|
371
|
+
# Create a ticket
|
|
372
|
+
ticket = client.works.create(
|
|
373
|
+
type="ticket",
|
|
374
|
+
title="Cannot access dashboard",
|
|
375
|
+
body="Customer reports 500 error when loading dashboard",
|
|
376
|
+
applies_to_part="don:core:dvrv-us-1:devo/1:part/1",
|
|
377
|
+
severity="high",
|
|
378
|
+
owned_by=["don:identity:dvrv-us-1:devo/1:devu/123"]
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
# List open tickets
|
|
382
|
+
open_tickets = client.works.list(
|
|
383
|
+
type=["ticket"],
|
|
384
|
+
stage_name=["open", "in_progress"]
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
# Update work item status
|
|
388
|
+
client.works.update(
|
|
389
|
+
id=ticket.id,
|
|
390
|
+
stage_name="resolved"
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
# Export works for reporting
|
|
394
|
+
export_result = client.works.export(
|
|
395
|
+
type=["ticket"],
|
|
396
|
+
created_after="2024-01-01"
|
|
397
|
+
)
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Articles and Knowledge Base
|
|
401
|
+
|
|
402
|
+
```python
|
|
403
|
+
# Create an article
|
|
404
|
+
article = client.articles.create(
|
|
405
|
+
title="Getting Started Guide",
|
|
406
|
+
applies_to_parts=["don:core:..."],
|
|
407
|
+
authored_by="don:identity:...",
|
|
408
|
+
body="# Welcome\n\nThis guide will help you get started..."
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
# List published articles
|
|
412
|
+
published = client.articles.list(
|
|
413
|
+
status=["published"]
|
|
414
|
+
)
|
|
415
|
+
|
|
416
|
+
# Update article content
|
|
417
|
+
client.articles.update(
|
|
418
|
+
id=article.id,
|
|
419
|
+
body="# Updated Content\n\n..."
|
|
420
|
+
)
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Webhooks
|
|
424
|
+
|
|
425
|
+
```python
|
|
426
|
+
# Register a webhook
|
|
427
|
+
webhook = client.webhooks.create(
|
|
428
|
+
url="https://your-server.com/webhooks/devrev",
|
|
429
|
+
event_types=["work_created", "work_updated"],
|
|
430
|
+
secret="your-webhook-secret" # Load from environment!
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
# List webhooks
|
|
434
|
+
webhooks = client.webhooks.list()
|
|
435
|
+
|
|
436
|
+
# Update webhook
|
|
437
|
+
client.webhooks.update(
|
|
438
|
+
id=webhook.id,
|
|
439
|
+
event_types=["work_created", "work_updated", "work_deleted"]
|
|
440
|
+
)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Configuration
|
|
446
|
+
|
|
447
|
+
### Environment Variables
|
|
448
|
+
|
|
449
|
+
| Variable | Required | Default | Description |
|
|
450
|
+
|----------|----------|---------|-------------|
|
|
451
|
+
| `DEVREV_API_TOKEN` | Yes* | - | API authentication token |
|
|
452
|
+
| `DEVREV_BASE_URL` | No | `https://api.devrev.ai` | API base URL |
|
|
453
|
+
| `DEVREV_TIMEOUT` | No | `30` | Request timeout in seconds |
|
|
454
|
+
| `DEVREV_MAX_RETRIES` | No | `3` | Maximum retry attempts |
|
|
455
|
+
| `DEVREV_LOG_LEVEL` | No | `WARN` | Logging level (DEBUG, INFO, WARN, ERROR) |
|
|
456
|
+
|
|
457
|
+
### Configuration File
|
|
458
|
+
|
|
459
|
+
Create a `.env` file for local development:
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
# .env (never commit this file!)
|
|
463
|
+
DEVREV_API_TOKEN=your-api-token-here
|
|
464
|
+
DEVREV_LOG_LEVEL=DEBUG
|
|
465
|
+
DEVREV_TIMEOUT=60
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
A `.env.sample` file is provided as a template.
|
|
469
|
+
|
|
470
|
+
### Programmatic Configuration
|
|
471
|
+
|
|
472
|
+
```python
|
|
473
|
+
from devrev import DevRevClient, DevRevConfig
|
|
474
|
+
|
|
475
|
+
config = DevRevConfig(
|
|
476
|
+
base_url="https://api.devrev.ai",
|
|
477
|
+
timeout=60,
|
|
478
|
+
max_retries=5,
|
|
479
|
+
log_level="DEBUG"
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
client = DevRevClient(config=config)
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## Error Handling
|
|
488
|
+
|
|
489
|
+
The SDK provides rich, informative exceptions:
|
|
490
|
+
|
|
491
|
+
```python
|
|
492
|
+
from devrev import DevRevClient
|
|
493
|
+
from devrev.exceptions import (
|
|
494
|
+
DevRevError,
|
|
495
|
+
AuthenticationError,
|
|
496
|
+
NotFoundError,
|
|
497
|
+
ValidationError,
|
|
498
|
+
RateLimitError,
|
|
499
|
+
ServerError
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
client = DevRevClient()
|
|
503
|
+
|
|
504
|
+
try:
|
|
505
|
+
account = client.accounts.get(id="invalid-id")
|
|
506
|
+
except NotFoundError as e:
|
|
507
|
+
print(f"Account not found: {e.message}")
|
|
508
|
+
print(f"Request ID: {e.request_id}") # For support tickets
|
|
509
|
+
except ValidationError as e:
|
|
510
|
+
print(f"Invalid request: {e.message}")
|
|
511
|
+
print(f"Field errors: {e.field_errors}")
|
|
512
|
+
except RateLimitError as e:
|
|
513
|
+
print(f"Rate limited. Retry after: {e.retry_after} seconds")
|
|
514
|
+
except AuthenticationError as e:
|
|
515
|
+
print(f"Auth failed: {e.message}")
|
|
516
|
+
except ServerError as e:
|
|
517
|
+
print(f"Server error: {e.message}")
|
|
518
|
+
except DevRevError as e:
|
|
519
|
+
print(f"Unexpected error: {e}")
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Exception Hierarchy
|
|
523
|
+
|
|
524
|
+
```
|
|
525
|
+
DevRevError (base)
|
|
526
|
+
├── AuthenticationError (401)
|
|
527
|
+
├── ForbiddenError (403)
|
|
528
|
+
├── NotFoundError (404)
|
|
529
|
+
├── ValidationError (400)
|
|
530
|
+
├── ConflictError (409)
|
|
531
|
+
├── RateLimitError (429)
|
|
532
|
+
├── ServerError (500)
|
|
533
|
+
└── ServiceUnavailableError (503)
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
## Logging
|
|
539
|
+
|
|
540
|
+
The SDK uses structured logging with optional color support:
|
|
541
|
+
|
|
542
|
+
### Log Levels
|
|
543
|
+
|
|
544
|
+
Set via `DEVREV_LOG_LEVEL` environment variable:
|
|
545
|
+
|
|
546
|
+
- `DEBUG` - Detailed debugging information
|
|
547
|
+
- `INFO` - General operational information
|
|
548
|
+
- `WARN` - Warning messages (default)
|
|
549
|
+
- `ERROR` - Error messages only
|
|
550
|
+
|
|
551
|
+
### Example Output
|
|
552
|
+
|
|
553
|
+
```
|
|
554
|
+
2024-01-15 10:30:45 [INFO] devrev.client: Initialized DevRevClient
|
|
555
|
+
2024-01-15 10:30:45 [DEBUG] devrev.http: POST /accounts.list
|
|
556
|
+
2024-01-15 10:30:46 [DEBUG] devrev.http: Response 200 (245ms)
|
|
557
|
+
2024-01-15 10:30:47 [WARN] devrev.http: Rate limit approaching (80% used)
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### Custom Logger Integration
|
|
561
|
+
|
|
562
|
+
```python
|
|
563
|
+
import logging
|
|
564
|
+
|
|
565
|
+
# Use your own logger
|
|
566
|
+
my_logger = logging.getLogger("myapp.devrev")
|
|
567
|
+
client = DevRevClient(logger=my_logger)
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## Development
|
|
573
|
+
|
|
574
|
+
### Project Structure
|
|
575
|
+
|
|
576
|
+
```
|
|
577
|
+
py-devrev/
|
|
578
|
+
├── src/
|
|
579
|
+
│ └── devrev/
|
|
580
|
+
│ ├── __init__.py
|
|
581
|
+
│ ├── client.py # Main client classes
|
|
582
|
+
│ ├── config.py # Configuration management
|
|
583
|
+
│ ├── exceptions.py # Exception definitions
|
|
584
|
+
│ ├── models/ # Pydantic models
|
|
585
|
+
│ │ ├── __init__.py
|
|
586
|
+
│ │ ├── accounts.py
|
|
587
|
+
│ │ ├── works.py
|
|
588
|
+
│ │ └── ...
|
|
589
|
+
│ ├── services/ # API service classes
|
|
590
|
+
│ │ ├── __init__.py
|
|
591
|
+
│ │ ├── accounts.py
|
|
592
|
+
│ │ ├── works.py
|
|
593
|
+
│ │ └── ...
|
|
594
|
+
│ └── utils/ # Utilities
|
|
595
|
+
│ ├── __init__.py
|
|
596
|
+
│ ├── http.py
|
|
597
|
+
│ ├── logging.py
|
|
598
|
+
│ └── pagination.py
|
|
599
|
+
├── tests/
|
|
600
|
+
│ ├── unit/
|
|
601
|
+
│ ├── integration/
|
|
602
|
+
│ └── fixtures/
|
|
603
|
+
├── openapi-public.yaml # DevRev OpenAPI specification
|
|
604
|
+
├── pyproject.toml
|
|
605
|
+
└── README.md
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### Setting Up Development Environment
|
|
609
|
+
|
|
610
|
+
```bash
|
|
611
|
+
# Clone the repository
|
|
612
|
+
git clone https://github.com/mgmonteleone/py-dev-rev.git
|
|
613
|
+
cd py-dev-rev
|
|
614
|
+
|
|
615
|
+
# Create virtual environment
|
|
616
|
+
python -m venv .venv
|
|
617
|
+
source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
|
|
618
|
+
|
|
619
|
+
# Install dev dependencies
|
|
620
|
+
pip install -e ".[dev]"
|
|
621
|
+
|
|
622
|
+
# Set up pre-commit hooks
|
|
623
|
+
pre-commit install
|
|
624
|
+
|
|
625
|
+
# Copy environment template
|
|
626
|
+
cp .env.sample .env
|
|
627
|
+
# Edit .env with your credentials
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
### Code Quality Tools
|
|
631
|
+
|
|
632
|
+
```bash
|
|
633
|
+
# Format code
|
|
634
|
+
ruff format .
|
|
635
|
+
|
|
636
|
+
# Lint code
|
|
637
|
+
ruff check .
|
|
638
|
+
|
|
639
|
+
# Type checking
|
|
640
|
+
mypy src/
|
|
641
|
+
|
|
642
|
+
# Run all checks
|
|
643
|
+
pre-commit run --all-files
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
---
|
|
647
|
+
|
|
648
|
+
## Testing Strategy
|
|
649
|
+
|
|
650
|
+
### Test Categories
|
|
651
|
+
|
|
652
|
+
1. **Unit Tests** - Test individual functions and classes in isolation
|
|
653
|
+
- All models and their validation
|
|
654
|
+
- Utility functions
|
|
655
|
+
- Error handling logic
|
|
656
|
+
|
|
657
|
+
2. **Integration Tests** - Test against the real API
|
|
658
|
+
- **Read-only endpoints**: Tested against actual DevRev API
|
|
659
|
+
- **Mutating endpoints**: Tested with comprehensive mocks
|
|
660
|
+
|
|
661
|
+
### Running Tests
|
|
662
|
+
|
|
663
|
+
```bash
|
|
664
|
+
# Run all tests
|
|
665
|
+
pytest
|
|
666
|
+
|
|
667
|
+
# Run with coverage
|
|
668
|
+
pytest --cov=src --cov-report=html
|
|
669
|
+
|
|
670
|
+
# Run only unit tests
|
|
671
|
+
pytest tests/unit/
|
|
672
|
+
|
|
673
|
+
# Run only integration tests (requires API credentials)
|
|
674
|
+
pytest tests/integration/ -m integration
|
|
675
|
+
|
|
676
|
+
# Run specific test file
|
|
677
|
+
pytest tests/unit/test_accounts.py
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
### Coverage Requirements
|
|
681
|
+
|
|
682
|
+
- **Minimum**: 80% line coverage
|
|
683
|
+
- **Critical paths**: 95% coverage (auth, error handling)
|
|
684
|
+
|
|
685
|
+
---
|
|
686
|
+
|
|
687
|
+
## CI/CD Pipeline
|
|
688
|
+
|
|
689
|
+
The SDK uses Google Cloud Build for automated testing, security scanning, and publishing:
|
|
690
|
+
|
|
691
|
+
### Pipeline Stages
|
|
692
|
+
|
|
693
|
+
1. **Lint & Format** - Code quality checks with Ruff
|
|
694
|
+
2. **Type Check** - Static type analysis with mypy
|
|
695
|
+
3. **Unit Tests** - Fast isolated tests
|
|
696
|
+
4. **Integration Tests** - API integration verification
|
|
697
|
+
5. **Security Scan** - Dependency vulnerability scanning
|
|
698
|
+
6. **Build** - Package building
|
|
699
|
+
7. **Publish** - Automated publishing to Google Artifact Registry
|
|
700
|
+
|
|
701
|
+
### Automated Publishing
|
|
702
|
+
|
|
703
|
+
On tagged releases (`v*`), the package is automatically published to Google Artifact Registry.
|
|
704
|
+
|
|
705
|
+
---
|
|
706
|
+
|
|
707
|
+
## Roadmap
|
|
708
|
+
|
|
709
|
+
### Phase 1: Foundation ✅
|
|
710
|
+
- [x] Project structure and configuration
|
|
711
|
+
- [x] OpenAPI specification integration
|
|
712
|
+
- [x] Development standards documentation
|
|
713
|
+
|
|
714
|
+
### Phase 2: Core Implementation ✅
|
|
715
|
+
- [x] Base client with authentication
|
|
716
|
+
- [x] HTTP layer with retry logic
|
|
717
|
+
- [x] Pydantic models generation
|
|
718
|
+
- [x] Core services (Accounts, Works, Users)
|
|
719
|
+
|
|
720
|
+
### Phase 3: Full API Coverage ✅
|
|
721
|
+
- [x] All 209 endpoints implemented
|
|
722
|
+
- [x] Pagination helpers
|
|
723
|
+
- [x] Async client support
|
|
724
|
+
|
|
725
|
+
### Phase 4: Polish & Production ✅
|
|
726
|
+
- [x] Comprehensive test suite (80%+ coverage)
|
|
727
|
+
- [x] Performance benchmarking
|
|
728
|
+
- [x] Documentation site
|
|
729
|
+
- [x] Example applications
|
|
730
|
+
- [x] Security audit passed
|
|
731
|
+
|
|
732
|
+
### Phase 5: Maintenance 🔄
|
|
733
|
+
- [x] Automated release workflow
|
|
734
|
+
- [x] Dependency updates (Dependabot)
|
|
735
|
+
- [ ] Community contributions
|
|
736
|
+
- [ ] Automated OpenAPI sync
|
|
737
|
+
|
|
738
|
+
---
|
|
739
|
+
|
|
740
|
+
## Contributing
|
|
741
|
+
|
|
742
|
+
We welcome contributions! Please see our contributing guidelines:
|
|
743
|
+
|
|
744
|
+
1. Fork the repository
|
|
745
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
746
|
+
3. Make your changes with tests
|
|
747
|
+
4. Ensure all tests pass (`pytest`)
|
|
748
|
+
5. Submit a pull request
|
|
749
|
+
|
|
750
|
+
### Development Guidelines
|
|
751
|
+
|
|
752
|
+
- Follow PEP 8 and project style guidelines
|
|
753
|
+
- Add type hints to all functions
|
|
754
|
+
- Write tests for new functionality
|
|
755
|
+
- Update documentation as needed
|
|
756
|
+
|
|
757
|
+
---
|
|
758
|
+
|
|
759
|
+
## License
|
|
760
|
+
|
|
761
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
762
|
+
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
## Support
|
|
766
|
+
|
|
767
|
+
- 📖 [Documentation](https://github.com/mgmonteleone/py-dev-rev)
|
|
768
|
+
- 🐛 [Issue Tracker](https://github.com/mgmonteleone/py-dev-rev/issues)
|
|
769
|
+
- 💬 [Discussions](https://github.com/mgmonteleone/py-dev-rev/discussions)
|
|
770
|
+
|
|
771
|
+
---
|
|
772
|
+
|
|
773
|
+
*Built with ❤️ using [Augment Code](https://augmentcode.com)*
|
|
774
|
+
|