adaptsapi 0.1.2__tar.gz → 0.1.4__tar.gz
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.
- adaptsapi-0.1.4/PKG-INFO +320 -0
- adaptsapi-0.1.4/README.md +298 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/pyproject.toml +1 -1
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/setup.cfg +1 -1
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/setup.py +1 -1
- adaptsapi-0.1.4/src/adaptsapi/generate_docs.py +129 -0
- adaptsapi-0.1.4/src/adaptsapi.egg-info/PKG-INFO +320 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/tests/test_generate_docs.py +11 -7
- adaptsapi-0.1.2/PKG-INFO +0 -21
- adaptsapi-0.1.2/README.md +0 -0
- adaptsapi-0.1.2/src/adaptsapi/generate_docs.py +0 -84
- adaptsapi-0.1.2/src/adaptsapi.egg-info/PKG-INFO +0 -21
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/LICENSE +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi/__init__.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi/cli.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi/config.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi.egg-info/SOURCES.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi.egg-info/dependency_links.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi.egg-info/entry_points.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi.egg-info/requires.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/src/adaptsapi.egg-info/top_level.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/tests/test_cli.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.4}/tests/test_config.py +0 -0
adaptsapi-0.1.4/PKG-INFO
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adaptsapi
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: CLI to enqueue triggers via internal API Gateway → SNS
|
|
5
|
+
Home-page: https://github.com/adaptsai/adaptsapi
|
|
6
|
+
Author: adapts
|
|
7
|
+
Author-email: "VerifyAI Inc." <dev@adapts.ai>
|
|
8
|
+
License-Expression: LicenseRef-Proprietary
|
|
9
|
+
Project-URL: Homepage, https://github.com/adaptsai/adaptsapi
|
|
10
|
+
Project-URL: Source, https://github.com/adaptsai/adaptsapi
|
|
11
|
+
Keywords: adapts,api,cli,sns
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
|
|
23
|
+
# AdaptsAPI CLI
|
|
24
|
+
|
|
25
|
+
A command-line interface for triggering documentation generation via the Adapts API Gateway → SNS.
|
|
26
|
+
|
|
27
|
+
[](https://badge.fury.io/py/adaptsapi)
|
|
28
|
+
[](https://www.python.org/downloads/)
|
|
29
|
+
[](LICENSE)
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- 🚀 **Simple CLI** for triggering Adapts API endpoints
|
|
34
|
+
- 🔑 **Secure token management** with environment variables or local config
|
|
35
|
+
- 📄 **Flexible payload support** via JSON files or inline data
|
|
36
|
+
- 🔧 **Configurable endpoints** with default endpoint support
|
|
37
|
+
- ✅ **Built-in payload validation** for documentation generation requests
|
|
38
|
+
- 🤖 **GitHub Actions integration** for automated wiki documentation
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
### From PyPI
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install adaptsapi
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### From Source
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/adaptsai/adaptsapi.git
|
|
52
|
+
cd adaptsapi
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
### 1. Set up your API token
|
|
59
|
+
|
|
60
|
+
You can provide your API token in three ways (in order of precedence):
|
|
61
|
+
|
|
62
|
+
1. **Environment variable** (recommended for CI/CD):
|
|
63
|
+
```bash
|
|
64
|
+
export ADAPTS_API_TOKEN="your-api-token-here"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. **Local config file** (`config.json` in current directory):
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"token": "your-api-token-here",
|
|
71
|
+
"endpoint": "https://your-api-endpoint.com/prod/generate_wiki_docs"
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. **Interactive prompt** (first-time setup):
|
|
76
|
+
```bash
|
|
77
|
+
adaptsapi --data '{"test": "payload"}'
|
|
78
|
+
# CLI will prompt for token and save to config.json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2. Make your first API call
|
|
82
|
+
|
|
83
|
+
**Using inline JSON data:**
|
|
84
|
+
```bash
|
|
85
|
+
adaptsapi \
|
|
86
|
+
--endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
|
|
87
|
+
--data '{"email_address": "user@example.com", "user_name": "john_doe", "repo_object": {...}}'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Using a JSON payload file:**
|
|
91
|
+
```bash
|
|
92
|
+
adaptsapi \
|
|
93
|
+
--endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
|
|
94
|
+
--payload-file payload.json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
98
|
+
|
|
99
|
+
### Command Line Options
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
adaptsapi [OPTIONS]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| Option | Description | Required |
|
|
106
|
+
|--------|-------------|----------|
|
|
107
|
+
| `--endpoint URL` | Full URL of the API endpoint | Yes (unless set in config.json) |
|
|
108
|
+
| `--data JSON` | Inline JSON payload string | Yes (or --payload-file) |
|
|
109
|
+
| `--payload-file FILE` | Path to JSON payload file | Yes (or --data) |
|
|
110
|
+
| `--timeout SECONDS` | Request timeout in seconds (default: 30) | No |
|
|
111
|
+
|
|
112
|
+
### Payload Structure
|
|
113
|
+
|
|
114
|
+
For documentation generation, your payload should follow this structure:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"email_address": "user@example.com",
|
|
119
|
+
"user_name": "github_username",
|
|
120
|
+
"repo_object": {
|
|
121
|
+
"repository_name": "my-repo",
|
|
122
|
+
"source": "github",
|
|
123
|
+
"repository_url": "https://github.com/user/my-repo",
|
|
124
|
+
"branch": "main",
|
|
125
|
+
"size": "12345",
|
|
126
|
+
"language": "python",
|
|
127
|
+
"is_private": false,
|
|
128
|
+
"git_provider_type": "github",
|
|
129
|
+
"refresh_token": "github_token_here"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Required Fields
|
|
135
|
+
|
|
136
|
+
- `email_address`: Valid email address
|
|
137
|
+
- `user_name`: Username string
|
|
138
|
+
- `repo_object.repository_name`: Repository name
|
|
139
|
+
- `repo_object.repository_url`: Full repository URL
|
|
140
|
+
- `repo_object.branch`: Branch name
|
|
141
|
+
- `repo_object.size`: Repository size as string
|
|
142
|
+
- `repo_object.language`: Primary programming language
|
|
143
|
+
- `repo_object.source`: Source platform (e.g., "github")
|
|
144
|
+
|
|
145
|
+
#### Optional Fields
|
|
146
|
+
|
|
147
|
+
- `repo_object.is_private`: Boolean indicating if repo is private
|
|
148
|
+
- `repo_object.git_provider_type`: Git provider type
|
|
149
|
+
- `repo_object.installation_id`: Installation ID (for GitHub Apps)
|
|
150
|
+
- `repo_object.refresh_token`: Refresh token for authentication
|
|
151
|
+
|
|
152
|
+
## GitHub Actions Integration
|
|
153
|
+
|
|
154
|
+
This package is designed to work seamlessly with GitHub Actions for automated documentation generation. Here's an example workflow:
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
name: Generate Wiki Docs
|
|
158
|
+
|
|
159
|
+
on:
|
|
160
|
+
pull_request:
|
|
161
|
+
branches: [ main ]
|
|
162
|
+
types: [ closed ]
|
|
163
|
+
|
|
164
|
+
jobs:
|
|
165
|
+
call-adapts-api:
|
|
166
|
+
if: github.event.pull_request.merged == true
|
|
167
|
+
runs-on: ubuntu-latest
|
|
168
|
+
|
|
169
|
+
steps:
|
|
170
|
+
- uses: actions/checkout@v4
|
|
171
|
+
|
|
172
|
+
- name: Set up Python
|
|
173
|
+
uses: actions/setup-python@v5
|
|
174
|
+
with:
|
|
175
|
+
python-version: "3.11"
|
|
176
|
+
|
|
177
|
+
- name: Install adaptsapi
|
|
178
|
+
run: pip install adaptsapi
|
|
179
|
+
|
|
180
|
+
- name: Generate documentation
|
|
181
|
+
env:
|
|
182
|
+
ADAPTS_API_KEY: ${{ secrets.ADAPTS_API_KEY }}
|
|
183
|
+
run: |
|
|
184
|
+
python -c "
|
|
185
|
+
import os
|
|
186
|
+
from adaptsapi.generate_docs import post
|
|
187
|
+
|
|
188
|
+
payload = {
|
|
189
|
+
'email_address': '${{ github.actor }}@users.noreply.github.com',
|
|
190
|
+
'user_name': '${{ github.actor }}',
|
|
191
|
+
'repo_object': {
|
|
192
|
+
'repository_name': '${{ github.event.repository.name }}',
|
|
193
|
+
'source': 'github',
|
|
194
|
+
'repository_url': '${{ github.event.repository.html_url }}',
|
|
195
|
+
'branch': 'main',
|
|
196
|
+
'size': '0',
|
|
197
|
+
'language': 'python',
|
|
198
|
+
'is_private': False,
|
|
199
|
+
'git_provider_type': 'github',
|
|
200
|
+
'refresh_token': '${{ secrets.GITHUB_TOKEN }}'
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
resp = post(
|
|
205
|
+
'https://your-api-endpoint.com/prod/generate_wiki_docs',
|
|
206
|
+
os.environ['ADAPTS_API_KEY'],
|
|
207
|
+
payload
|
|
208
|
+
)
|
|
209
|
+
resp.raise_for_status()
|
|
210
|
+
print('✅ Documentation generated successfully')
|
|
211
|
+
"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Setting up GitHub Secrets
|
|
215
|
+
|
|
216
|
+
1. Go to your repository on GitHub
|
|
217
|
+
2. Click **Settings** → **Secrets and variables** → **Actions**
|
|
218
|
+
3. Click **New repository secret**
|
|
219
|
+
4. Add `ADAPTS_API_KEY` with your API token value
|
|
220
|
+
|
|
221
|
+
## Configuration
|
|
222
|
+
|
|
223
|
+
### Config File Format
|
|
224
|
+
|
|
225
|
+
The `config.json` file in your current working directory can contain:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"token": "your-api-token-here",
|
|
230
|
+
"endpoint": "https://your-default-endpoint.com/prod/generate_wiki_docs"
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Environment Variables
|
|
235
|
+
|
|
236
|
+
- `ADAPTS_API_TOKEN`: Your API authentication token
|
|
237
|
+
|
|
238
|
+
## Error Handling
|
|
239
|
+
|
|
240
|
+
The CLI provides clear error messages for common issues:
|
|
241
|
+
|
|
242
|
+
- **Missing token**: Prompts for interactive token input
|
|
243
|
+
- **Invalid JSON**: Shows JSON parsing errors
|
|
244
|
+
- **API errors**: Displays HTTP status codes and error messages
|
|
245
|
+
- **Payload validation**: Shows specific validation failures
|
|
246
|
+
|
|
247
|
+
## Development
|
|
248
|
+
|
|
249
|
+
### Prerequisites
|
|
250
|
+
|
|
251
|
+
- Python 3.10+
|
|
252
|
+
- pip
|
|
253
|
+
|
|
254
|
+
### Setup Development Environment
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
git clone https://github.com/adaptsai/adaptsapi.git
|
|
258
|
+
cd adaptsapi
|
|
259
|
+
python -m venv venv
|
|
260
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
261
|
+
pip install -e .
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Running Tests
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
python -m pytest tests/
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## API Reference
|
|
271
|
+
|
|
272
|
+
### Functions
|
|
273
|
+
|
|
274
|
+
#### `post(endpoint, auth_token, payload, timeout=30)`
|
|
275
|
+
|
|
276
|
+
Make a POST request to the Adapts API.
|
|
277
|
+
|
|
278
|
+
**Parameters:**
|
|
279
|
+
- `endpoint` (str): The API endpoint URL
|
|
280
|
+
- `auth_token` (str): Authentication token
|
|
281
|
+
- `payload` (dict): JSON payload to send
|
|
282
|
+
- `timeout` (int): Request timeout in seconds
|
|
283
|
+
|
|
284
|
+
**Returns:**
|
|
285
|
+
- `requests.Response`: The HTTP response object
|
|
286
|
+
|
|
287
|
+
**Raises:**
|
|
288
|
+
- `PayloadValidationError`: If payload validation fails
|
|
289
|
+
- `requests.RequestException`: If the HTTP request fails
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
|
|
293
|
+
This software is licensed under the Adapts API Use-Only License v1.0. See [LICENSE](LICENSE) for details.
|
|
294
|
+
|
|
295
|
+
**Key restrictions:**
|
|
296
|
+
- ✅ Use the software as-is
|
|
297
|
+
- ❌ No modifications allowed
|
|
298
|
+
- ❌ No redistribution allowed
|
|
299
|
+
- ❌ Commercial use restrictions apply
|
|
300
|
+
|
|
301
|
+
## Support
|
|
302
|
+
|
|
303
|
+
- 📧 Email: dev@adapts.ai
|
|
304
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/adaptsai/adaptsapi/issues)
|
|
305
|
+
- 📖 Documentation: This README
|
|
306
|
+
|
|
307
|
+
## Changelog
|
|
308
|
+
|
|
309
|
+
### v0.1.4 (Latest)
|
|
310
|
+
- Current release
|
|
311
|
+
|
|
312
|
+
### v0.1.3
|
|
313
|
+
- Patch updates
|
|
314
|
+
|
|
315
|
+
### v0.1.2
|
|
316
|
+
- Initial stable release
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
© 2025 AdaptsAI All rights reserved.
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# AdaptsAPI CLI
|
|
2
|
+
|
|
3
|
+
A command-line interface for triggering documentation generation via the Adapts API Gateway → SNS.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/py/adaptsapi)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 🚀 **Simple CLI** for triggering Adapts API endpoints
|
|
12
|
+
- 🔑 **Secure token management** with environment variables or local config
|
|
13
|
+
- 📄 **Flexible payload support** via JSON files or inline data
|
|
14
|
+
- 🔧 **Configurable endpoints** with default endpoint support
|
|
15
|
+
- ✅ **Built-in payload validation** for documentation generation requests
|
|
16
|
+
- 🤖 **GitHub Actions integration** for automated wiki documentation
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### From PyPI
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install adaptsapi
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### From Source
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone https://github.com/adaptsai/adaptsapi.git
|
|
30
|
+
cd adaptsapi
|
|
31
|
+
pip install -e .
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### 1. Set up your API token
|
|
37
|
+
|
|
38
|
+
You can provide your API token in three ways (in order of precedence):
|
|
39
|
+
|
|
40
|
+
1. **Environment variable** (recommended for CI/CD):
|
|
41
|
+
```bash
|
|
42
|
+
export ADAPTS_API_TOKEN="your-api-token-here"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. **Local config file** (`config.json` in current directory):
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"token": "your-api-token-here",
|
|
49
|
+
"endpoint": "https://your-api-endpoint.com/prod/generate_wiki_docs"
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. **Interactive prompt** (first-time setup):
|
|
54
|
+
```bash
|
|
55
|
+
adaptsapi --data '{"test": "payload"}'
|
|
56
|
+
# CLI will prompt for token and save to config.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 2. Make your first API call
|
|
60
|
+
|
|
61
|
+
**Using inline JSON data:**
|
|
62
|
+
```bash
|
|
63
|
+
adaptsapi \
|
|
64
|
+
--endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
|
|
65
|
+
--data '{"email_address": "user@example.com", "user_name": "john_doe", "repo_object": {...}}'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Using a JSON payload file:**
|
|
69
|
+
```bash
|
|
70
|
+
adaptsapi \
|
|
71
|
+
--endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
|
|
72
|
+
--payload-file payload.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
### Command Line Options
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
adaptsapi [OPTIONS]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
| Option | Description | Required |
|
|
84
|
+
|--------|-------------|----------|
|
|
85
|
+
| `--endpoint URL` | Full URL of the API endpoint | Yes (unless set in config.json) |
|
|
86
|
+
| `--data JSON` | Inline JSON payload string | Yes (or --payload-file) |
|
|
87
|
+
| `--payload-file FILE` | Path to JSON payload file | Yes (or --data) |
|
|
88
|
+
| `--timeout SECONDS` | Request timeout in seconds (default: 30) | No |
|
|
89
|
+
|
|
90
|
+
### Payload Structure
|
|
91
|
+
|
|
92
|
+
For documentation generation, your payload should follow this structure:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"email_address": "user@example.com",
|
|
97
|
+
"user_name": "github_username",
|
|
98
|
+
"repo_object": {
|
|
99
|
+
"repository_name": "my-repo",
|
|
100
|
+
"source": "github",
|
|
101
|
+
"repository_url": "https://github.com/user/my-repo",
|
|
102
|
+
"branch": "main",
|
|
103
|
+
"size": "12345",
|
|
104
|
+
"language": "python",
|
|
105
|
+
"is_private": false,
|
|
106
|
+
"git_provider_type": "github",
|
|
107
|
+
"refresh_token": "github_token_here"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Required Fields
|
|
113
|
+
|
|
114
|
+
- `email_address`: Valid email address
|
|
115
|
+
- `user_name`: Username string
|
|
116
|
+
- `repo_object.repository_name`: Repository name
|
|
117
|
+
- `repo_object.repository_url`: Full repository URL
|
|
118
|
+
- `repo_object.branch`: Branch name
|
|
119
|
+
- `repo_object.size`: Repository size as string
|
|
120
|
+
- `repo_object.language`: Primary programming language
|
|
121
|
+
- `repo_object.source`: Source platform (e.g., "github")
|
|
122
|
+
|
|
123
|
+
#### Optional Fields
|
|
124
|
+
|
|
125
|
+
- `repo_object.is_private`: Boolean indicating if repo is private
|
|
126
|
+
- `repo_object.git_provider_type`: Git provider type
|
|
127
|
+
- `repo_object.installation_id`: Installation ID (for GitHub Apps)
|
|
128
|
+
- `repo_object.refresh_token`: Refresh token for authentication
|
|
129
|
+
|
|
130
|
+
## GitHub Actions Integration
|
|
131
|
+
|
|
132
|
+
This package is designed to work seamlessly with GitHub Actions for automated documentation generation. Here's an example workflow:
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
name: Generate Wiki Docs
|
|
136
|
+
|
|
137
|
+
on:
|
|
138
|
+
pull_request:
|
|
139
|
+
branches: [ main ]
|
|
140
|
+
types: [ closed ]
|
|
141
|
+
|
|
142
|
+
jobs:
|
|
143
|
+
call-adapts-api:
|
|
144
|
+
if: github.event.pull_request.merged == true
|
|
145
|
+
runs-on: ubuntu-latest
|
|
146
|
+
|
|
147
|
+
steps:
|
|
148
|
+
- uses: actions/checkout@v4
|
|
149
|
+
|
|
150
|
+
- name: Set up Python
|
|
151
|
+
uses: actions/setup-python@v5
|
|
152
|
+
with:
|
|
153
|
+
python-version: "3.11"
|
|
154
|
+
|
|
155
|
+
- name: Install adaptsapi
|
|
156
|
+
run: pip install adaptsapi
|
|
157
|
+
|
|
158
|
+
- name: Generate documentation
|
|
159
|
+
env:
|
|
160
|
+
ADAPTS_API_KEY: ${{ secrets.ADAPTS_API_KEY }}
|
|
161
|
+
run: |
|
|
162
|
+
python -c "
|
|
163
|
+
import os
|
|
164
|
+
from adaptsapi.generate_docs import post
|
|
165
|
+
|
|
166
|
+
payload = {
|
|
167
|
+
'email_address': '${{ github.actor }}@users.noreply.github.com',
|
|
168
|
+
'user_name': '${{ github.actor }}',
|
|
169
|
+
'repo_object': {
|
|
170
|
+
'repository_name': '${{ github.event.repository.name }}',
|
|
171
|
+
'source': 'github',
|
|
172
|
+
'repository_url': '${{ github.event.repository.html_url }}',
|
|
173
|
+
'branch': 'main',
|
|
174
|
+
'size': '0',
|
|
175
|
+
'language': 'python',
|
|
176
|
+
'is_private': False,
|
|
177
|
+
'git_provider_type': 'github',
|
|
178
|
+
'refresh_token': '${{ secrets.GITHUB_TOKEN }}'
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
resp = post(
|
|
183
|
+
'https://your-api-endpoint.com/prod/generate_wiki_docs',
|
|
184
|
+
os.environ['ADAPTS_API_KEY'],
|
|
185
|
+
payload
|
|
186
|
+
)
|
|
187
|
+
resp.raise_for_status()
|
|
188
|
+
print('✅ Documentation generated successfully')
|
|
189
|
+
"
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Setting up GitHub Secrets
|
|
193
|
+
|
|
194
|
+
1. Go to your repository on GitHub
|
|
195
|
+
2. Click **Settings** → **Secrets and variables** → **Actions**
|
|
196
|
+
3. Click **New repository secret**
|
|
197
|
+
4. Add `ADAPTS_API_KEY` with your API token value
|
|
198
|
+
|
|
199
|
+
## Configuration
|
|
200
|
+
|
|
201
|
+
### Config File Format
|
|
202
|
+
|
|
203
|
+
The `config.json` file in your current working directory can contain:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"token": "your-api-token-here",
|
|
208
|
+
"endpoint": "https://your-default-endpoint.com/prod/generate_wiki_docs"
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Environment Variables
|
|
213
|
+
|
|
214
|
+
- `ADAPTS_API_TOKEN`: Your API authentication token
|
|
215
|
+
|
|
216
|
+
## Error Handling
|
|
217
|
+
|
|
218
|
+
The CLI provides clear error messages for common issues:
|
|
219
|
+
|
|
220
|
+
- **Missing token**: Prompts for interactive token input
|
|
221
|
+
- **Invalid JSON**: Shows JSON parsing errors
|
|
222
|
+
- **API errors**: Displays HTTP status codes and error messages
|
|
223
|
+
- **Payload validation**: Shows specific validation failures
|
|
224
|
+
|
|
225
|
+
## Development
|
|
226
|
+
|
|
227
|
+
### Prerequisites
|
|
228
|
+
|
|
229
|
+
- Python 3.10+
|
|
230
|
+
- pip
|
|
231
|
+
|
|
232
|
+
### Setup Development Environment
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
git clone https://github.com/adaptsai/adaptsapi.git
|
|
236
|
+
cd adaptsapi
|
|
237
|
+
python -m venv venv
|
|
238
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
239
|
+
pip install -e .
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Running Tests
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
python -m pytest tests/
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## API Reference
|
|
249
|
+
|
|
250
|
+
### Functions
|
|
251
|
+
|
|
252
|
+
#### `post(endpoint, auth_token, payload, timeout=30)`
|
|
253
|
+
|
|
254
|
+
Make a POST request to the Adapts API.
|
|
255
|
+
|
|
256
|
+
**Parameters:**
|
|
257
|
+
- `endpoint` (str): The API endpoint URL
|
|
258
|
+
- `auth_token` (str): Authentication token
|
|
259
|
+
- `payload` (dict): JSON payload to send
|
|
260
|
+
- `timeout` (int): Request timeout in seconds
|
|
261
|
+
|
|
262
|
+
**Returns:**
|
|
263
|
+
- `requests.Response`: The HTTP response object
|
|
264
|
+
|
|
265
|
+
**Raises:**
|
|
266
|
+
- `PayloadValidationError`: If payload validation fails
|
|
267
|
+
- `requests.RequestException`: If the HTTP request fails
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
This software is licensed under the Adapts API Use-Only License v1.0. See [LICENSE](LICENSE) for details.
|
|
272
|
+
|
|
273
|
+
**Key restrictions:**
|
|
274
|
+
- ✅ Use the software as-is
|
|
275
|
+
- ❌ No modifications allowed
|
|
276
|
+
- ❌ No redistribution allowed
|
|
277
|
+
- ❌ Commercial use restrictions apply
|
|
278
|
+
|
|
279
|
+
## Support
|
|
280
|
+
|
|
281
|
+
- 📧 Email: dev@adapts.ai
|
|
282
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/adaptsai/adaptsapi/issues)
|
|
283
|
+
- 📖 Documentation: This README
|
|
284
|
+
|
|
285
|
+
## Changelog
|
|
286
|
+
|
|
287
|
+
### v0.1.4 (Latest)
|
|
288
|
+
- Current release
|
|
289
|
+
|
|
290
|
+
### v0.1.3
|
|
291
|
+
- Patch updates
|
|
292
|
+
|
|
293
|
+
### v0.1.2
|
|
294
|
+
- Initial stable release
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
© 2025 AdaptsAI All rights reserved.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import requests
|
|
3
|
+
from typing import Dict, Any
|
|
4
|
+
from datetime import date
|
|
5
|
+
import uuid
|
|
6
|
+
|
|
7
|
+
# regex for a very basic email validation
|
|
8
|
+
_EMAIL_RE = re.compile(r"^[^@]+@[^@]+\.[^@]+$")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PayloadValidationError(ValueError):
|
|
12
|
+
"""Raised when the payload is missing required fields or
|
|
13
|
+
has invalid values."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _validate_payload(payload: Dict[str, Any]) -> None:
|
|
17
|
+
# Top‐level required fields
|
|
18
|
+
required = {
|
|
19
|
+
"email_address": str,
|
|
20
|
+
"user_name": str,
|
|
21
|
+
"repo_object": dict,
|
|
22
|
+
}
|
|
23
|
+
for field, typ in required.items():
|
|
24
|
+
if field not in payload:
|
|
25
|
+
raise PayloadValidationError(f"Missing required field: '{field}'")
|
|
26
|
+
if not isinstance(payload[field], typ):
|
|
27
|
+
raise PayloadValidationError(
|
|
28
|
+
f"Field '{field}' must be of type {typ.__name__}"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
# email format
|
|
32
|
+
if not _EMAIL_RE.match(payload["email_address"]):
|
|
33
|
+
raise PayloadValidationError("Invalid email address format")
|
|
34
|
+
|
|
35
|
+
# repo_object sub‐fields
|
|
36
|
+
repo = payload["repo_object"]
|
|
37
|
+
|
|
38
|
+
# *Required* sub-fields – must be present and right type
|
|
39
|
+
required_repo_fields = {
|
|
40
|
+
"repository_name": str,
|
|
41
|
+
"repository_url": str,
|
|
42
|
+
"branch": str,
|
|
43
|
+
"size": str,
|
|
44
|
+
"language": str,
|
|
45
|
+
"source": str,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# *Optional* sub-fields – validate only if provided (can be None)
|
|
49
|
+
optional_repo_fields = {
|
|
50
|
+
"is_private": bool,
|
|
51
|
+
"git_provider_type": str,
|
|
52
|
+
"installation_id": str, # ← now **optional**
|
|
53
|
+
"refresh_token": str,
|
|
54
|
+
"commit_hash": str,
|
|
55
|
+
"commit_message": str,
|
|
56
|
+
"commit_author": str,
|
|
57
|
+
"directory_name": str,
|
|
58
|
+
}
|
|
59
|
+
# required loop
|
|
60
|
+
for field, typ in required_repo_fields.items():
|
|
61
|
+
if field not in repo:
|
|
62
|
+
raise PayloadValidationError(f"Missing repo_object.{field}")
|
|
63
|
+
if not isinstance(repo[field], typ):
|
|
64
|
+
raise PayloadValidationError(
|
|
65
|
+
f"repo_object.{field} must be {typ.__name__}"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# optional loop
|
|
69
|
+
for field, typ in optional_repo_fields.items():
|
|
70
|
+
if field in repo and repo[field] is not None and not isinstance(
|
|
71
|
+
repo[field], typ
|
|
72
|
+
):
|
|
73
|
+
raise PayloadValidationError(
|
|
74
|
+
f"repo_object.{field} must be {typ.__name__}"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# you can add more checks here (URL validation, branch name patterns, etc.)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _populate_metadata(payload: Dict[str, Any]) -> None:
|
|
81
|
+
"""Autofill metadata.created_by/on and updated_by/on."""
|
|
82
|
+
user = payload["email_address"]
|
|
83
|
+
today = date.today().isoformat()
|
|
84
|
+
payload["metadata"] = {
|
|
85
|
+
"created_by": user,
|
|
86
|
+
"created_on": today,
|
|
87
|
+
"updated_by": user,
|
|
88
|
+
"updated_on": today,
|
|
89
|
+
}
|
|
90
|
+
payload["action"] = "code_to_wiki"
|
|
91
|
+
|
|
92
|
+
# populate wiki if missing or incomplete
|
|
93
|
+
wiki = payload.get("wiki", {})
|
|
94
|
+
wiki.setdefault("wiki_name", payload["repo_object"]["repository_name"])
|
|
95
|
+
wiki.setdefault("wiki_source", payload["repo_object"]["source"]) # new!
|
|
96
|
+
wiki.setdefault("wiki_url", None)
|
|
97
|
+
|
|
98
|
+
payload["wiki_object"] = wiki
|
|
99
|
+
payload["request_id"] = str(uuid.uuid4())
|
|
100
|
+
payload["request_type"] = "code_to_wiki"
|
|
101
|
+
payload["status"] = "pending"
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def post(
|
|
105
|
+
endpoint: str,
|
|
106
|
+
token: str,
|
|
107
|
+
payload: Dict[str, Any],
|
|
108
|
+
timeout: int = 30
|
|
109
|
+
) -> requests.Response:
|
|
110
|
+
"""
|
|
111
|
+
Send a POST with validated payload and autopopulated metadata.
|
|
112
|
+
|
|
113
|
+
Raises:
|
|
114
|
+
PayloadValidationError: if payload is missing required data.
|
|
115
|
+
requests.RequestException: on network failures.
|
|
116
|
+
"""
|
|
117
|
+
# 1) Validate schema
|
|
118
|
+
_validate_payload(payload)
|
|
119
|
+
|
|
120
|
+
# 2) Add metadata
|
|
121
|
+
_populate_metadata(payload)
|
|
122
|
+
|
|
123
|
+
headers = {
|
|
124
|
+
"x-api-key": token,
|
|
125
|
+
"Content-Type": "application/json",
|
|
126
|
+
}
|
|
127
|
+
print(payload)
|
|
128
|
+
return requests.post(endpoint, json=payload, headers=headers,
|
|
129
|
+
timeout=timeout)
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: adaptsapi
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: CLI to enqueue triggers via internal API Gateway → SNS
|
|
5
|
+
Home-page: https://github.com/adaptsai/adaptsapi
|
|
6
|
+
Author: adapts
|
|
7
|
+
Author-email: "VerifyAI Inc." <dev@adapts.ai>
|
|
8
|
+
License-Expression: LicenseRef-Proprietary
|
|
9
|
+
Project-URL: Homepage, https://github.com/adaptsai/adaptsapi
|
|
10
|
+
Project-URL: Source, https://github.com/adaptsai/adaptsapi
|
|
11
|
+
Keywords: adapts,api,cli,sns
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
|
|
23
|
+
# AdaptsAPI CLI
|
|
24
|
+
|
|
25
|
+
A command-line interface for triggering documentation generation via the Adapts API Gateway → SNS.
|
|
26
|
+
|
|
27
|
+
[](https://badge.fury.io/py/adaptsapi)
|
|
28
|
+
[](https://www.python.org/downloads/)
|
|
29
|
+
[](LICENSE)
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- 🚀 **Simple CLI** for triggering Adapts API endpoints
|
|
34
|
+
- 🔑 **Secure token management** with environment variables or local config
|
|
35
|
+
- 📄 **Flexible payload support** via JSON files or inline data
|
|
36
|
+
- 🔧 **Configurable endpoints** with default endpoint support
|
|
37
|
+
- ✅ **Built-in payload validation** for documentation generation requests
|
|
38
|
+
- 🤖 **GitHub Actions integration** for automated wiki documentation
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
### From PyPI
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install adaptsapi
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### From Source
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/adaptsai/adaptsapi.git
|
|
52
|
+
cd adaptsapi
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
### 1. Set up your API token
|
|
59
|
+
|
|
60
|
+
You can provide your API token in three ways (in order of precedence):
|
|
61
|
+
|
|
62
|
+
1. **Environment variable** (recommended for CI/CD):
|
|
63
|
+
```bash
|
|
64
|
+
export ADAPTS_API_TOKEN="your-api-token-here"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. **Local config file** (`config.json` in current directory):
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"token": "your-api-token-here",
|
|
71
|
+
"endpoint": "https://your-api-endpoint.com/prod/generate_wiki_docs"
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. **Interactive prompt** (first-time setup):
|
|
76
|
+
```bash
|
|
77
|
+
adaptsapi --data '{"test": "payload"}'
|
|
78
|
+
# CLI will prompt for token and save to config.json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2. Make your first API call
|
|
82
|
+
|
|
83
|
+
**Using inline JSON data:**
|
|
84
|
+
```bash
|
|
85
|
+
adaptsapi \
|
|
86
|
+
--endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
|
|
87
|
+
--data '{"email_address": "user@example.com", "user_name": "john_doe", "repo_object": {...}}'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Using a JSON payload file:**
|
|
91
|
+
```bash
|
|
92
|
+
adaptsapi \
|
|
93
|
+
--endpoint "https://api.adapts.ai/prod/generate_wiki_docs" \
|
|
94
|
+
--payload-file payload.json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
98
|
+
|
|
99
|
+
### Command Line Options
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
adaptsapi [OPTIONS]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| Option | Description | Required |
|
|
106
|
+
|--------|-------------|----------|
|
|
107
|
+
| `--endpoint URL` | Full URL of the API endpoint | Yes (unless set in config.json) |
|
|
108
|
+
| `--data JSON` | Inline JSON payload string | Yes (or --payload-file) |
|
|
109
|
+
| `--payload-file FILE` | Path to JSON payload file | Yes (or --data) |
|
|
110
|
+
| `--timeout SECONDS` | Request timeout in seconds (default: 30) | No |
|
|
111
|
+
|
|
112
|
+
### Payload Structure
|
|
113
|
+
|
|
114
|
+
For documentation generation, your payload should follow this structure:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"email_address": "user@example.com",
|
|
119
|
+
"user_name": "github_username",
|
|
120
|
+
"repo_object": {
|
|
121
|
+
"repository_name": "my-repo",
|
|
122
|
+
"source": "github",
|
|
123
|
+
"repository_url": "https://github.com/user/my-repo",
|
|
124
|
+
"branch": "main",
|
|
125
|
+
"size": "12345",
|
|
126
|
+
"language": "python",
|
|
127
|
+
"is_private": false,
|
|
128
|
+
"git_provider_type": "github",
|
|
129
|
+
"refresh_token": "github_token_here"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Required Fields
|
|
135
|
+
|
|
136
|
+
- `email_address`: Valid email address
|
|
137
|
+
- `user_name`: Username string
|
|
138
|
+
- `repo_object.repository_name`: Repository name
|
|
139
|
+
- `repo_object.repository_url`: Full repository URL
|
|
140
|
+
- `repo_object.branch`: Branch name
|
|
141
|
+
- `repo_object.size`: Repository size as string
|
|
142
|
+
- `repo_object.language`: Primary programming language
|
|
143
|
+
- `repo_object.source`: Source platform (e.g., "github")
|
|
144
|
+
|
|
145
|
+
#### Optional Fields
|
|
146
|
+
|
|
147
|
+
- `repo_object.is_private`: Boolean indicating if repo is private
|
|
148
|
+
- `repo_object.git_provider_type`: Git provider type
|
|
149
|
+
- `repo_object.installation_id`: Installation ID (for GitHub Apps)
|
|
150
|
+
- `repo_object.refresh_token`: Refresh token for authentication
|
|
151
|
+
|
|
152
|
+
## GitHub Actions Integration
|
|
153
|
+
|
|
154
|
+
This package is designed to work seamlessly with GitHub Actions for automated documentation generation. Here's an example workflow:
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
name: Generate Wiki Docs
|
|
158
|
+
|
|
159
|
+
on:
|
|
160
|
+
pull_request:
|
|
161
|
+
branches: [ main ]
|
|
162
|
+
types: [ closed ]
|
|
163
|
+
|
|
164
|
+
jobs:
|
|
165
|
+
call-adapts-api:
|
|
166
|
+
if: github.event.pull_request.merged == true
|
|
167
|
+
runs-on: ubuntu-latest
|
|
168
|
+
|
|
169
|
+
steps:
|
|
170
|
+
- uses: actions/checkout@v4
|
|
171
|
+
|
|
172
|
+
- name: Set up Python
|
|
173
|
+
uses: actions/setup-python@v5
|
|
174
|
+
with:
|
|
175
|
+
python-version: "3.11"
|
|
176
|
+
|
|
177
|
+
- name: Install adaptsapi
|
|
178
|
+
run: pip install adaptsapi
|
|
179
|
+
|
|
180
|
+
- name: Generate documentation
|
|
181
|
+
env:
|
|
182
|
+
ADAPTS_API_KEY: ${{ secrets.ADAPTS_API_KEY }}
|
|
183
|
+
run: |
|
|
184
|
+
python -c "
|
|
185
|
+
import os
|
|
186
|
+
from adaptsapi.generate_docs import post
|
|
187
|
+
|
|
188
|
+
payload = {
|
|
189
|
+
'email_address': '${{ github.actor }}@users.noreply.github.com',
|
|
190
|
+
'user_name': '${{ github.actor }}',
|
|
191
|
+
'repo_object': {
|
|
192
|
+
'repository_name': '${{ github.event.repository.name }}',
|
|
193
|
+
'source': 'github',
|
|
194
|
+
'repository_url': '${{ github.event.repository.html_url }}',
|
|
195
|
+
'branch': 'main',
|
|
196
|
+
'size': '0',
|
|
197
|
+
'language': 'python',
|
|
198
|
+
'is_private': False,
|
|
199
|
+
'git_provider_type': 'github',
|
|
200
|
+
'refresh_token': '${{ secrets.GITHUB_TOKEN }}'
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
resp = post(
|
|
205
|
+
'https://your-api-endpoint.com/prod/generate_wiki_docs',
|
|
206
|
+
os.environ['ADAPTS_API_KEY'],
|
|
207
|
+
payload
|
|
208
|
+
)
|
|
209
|
+
resp.raise_for_status()
|
|
210
|
+
print('✅ Documentation generated successfully')
|
|
211
|
+
"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Setting up GitHub Secrets
|
|
215
|
+
|
|
216
|
+
1. Go to your repository on GitHub
|
|
217
|
+
2. Click **Settings** → **Secrets and variables** → **Actions**
|
|
218
|
+
3. Click **New repository secret**
|
|
219
|
+
4. Add `ADAPTS_API_KEY` with your API token value
|
|
220
|
+
|
|
221
|
+
## Configuration
|
|
222
|
+
|
|
223
|
+
### Config File Format
|
|
224
|
+
|
|
225
|
+
The `config.json` file in your current working directory can contain:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"token": "your-api-token-here",
|
|
230
|
+
"endpoint": "https://your-default-endpoint.com/prod/generate_wiki_docs"
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Environment Variables
|
|
235
|
+
|
|
236
|
+
- `ADAPTS_API_TOKEN`: Your API authentication token
|
|
237
|
+
|
|
238
|
+
## Error Handling
|
|
239
|
+
|
|
240
|
+
The CLI provides clear error messages for common issues:
|
|
241
|
+
|
|
242
|
+
- **Missing token**: Prompts for interactive token input
|
|
243
|
+
- **Invalid JSON**: Shows JSON parsing errors
|
|
244
|
+
- **API errors**: Displays HTTP status codes and error messages
|
|
245
|
+
- **Payload validation**: Shows specific validation failures
|
|
246
|
+
|
|
247
|
+
## Development
|
|
248
|
+
|
|
249
|
+
### Prerequisites
|
|
250
|
+
|
|
251
|
+
- Python 3.10+
|
|
252
|
+
- pip
|
|
253
|
+
|
|
254
|
+
### Setup Development Environment
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
git clone https://github.com/adaptsai/adaptsapi.git
|
|
258
|
+
cd adaptsapi
|
|
259
|
+
python -m venv venv
|
|
260
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
261
|
+
pip install -e .
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Running Tests
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
python -m pytest tests/
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## API Reference
|
|
271
|
+
|
|
272
|
+
### Functions
|
|
273
|
+
|
|
274
|
+
#### `post(endpoint, auth_token, payload, timeout=30)`
|
|
275
|
+
|
|
276
|
+
Make a POST request to the Adapts API.
|
|
277
|
+
|
|
278
|
+
**Parameters:**
|
|
279
|
+
- `endpoint` (str): The API endpoint URL
|
|
280
|
+
- `auth_token` (str): Authentication token
|
|
281
|
+
- `payload` (dict): JSON payload to send
|
|
282
|
+
- `timeout` (int): Request timeout in seconds
|
|
283
|
+
|
|
284
|
+
**Returns:**
|
|
285
|
+
- `requests.Response`: The HTTP response object
|
|
286
|
+
|
|
287
|
+
**Raises:**
|
|
288
|
+
- `PayloadValidationError`: If payload validation fails
|
|
289
|
+
- `requests.RequestException`: If the HTTP request fails
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
|
|
293
|
+
This software is licensed under the Adapts API Use-Only License v1.0. See [LICENSE](LICENSE) for details.
|
|
294
|
+
|
|
295
|
+
**Key restrictions:**
|
|
296
|
+
- ✅ Use the software as-is
|
|
297
|
+
- ❌ No modifications allowed
|
|
298
|
+
- ❌ No redistribution allowed
|
|
299
|
+
- ❌ Commercial use restrictions apply
|
|
300
|
+
|
|
301
|
+
## Support
|
|
302
|
+
|
|
303
|
+
- 📧 Email: dev@adapts.ai
|
|
304
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/adaptsai/adaptsapi/issues)
|
|
305
|
+
- 📖 Documentation: This README
|
|
306
|
+
|
|
307
|
+
## Changelog
|
|
308
|
+
|
|
309
|
+
### v0.1.4 (Latest)
|
|
310
|
+
- Current release
|
|
311
|
+
|
|
312
|
+
### v0.1.3
|
|
313
|
+
- Patch updates
|
|
314
|
+
|
|
315
|
+
### v0.1.2
|
|
316
|
+
- Initial stable release
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
© 2025 AdaptsAI All rights reserved.
|
|
@@ -3,14 +3,18 @@ import os
|
|
|
3
3
|
from adaptsapi.generate_docs import post, PayloadValidationError
|
|
4
4
|
|
|
5
5
|
payload = {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"user_name": "johndoe",
|
|
6
|
+
"email_address": "sheel@adapts.ai",
|
|
7
|
+
"user_name": "sheel",
|
|
9
8
|
"repo_object": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
9
|
+
"repository_name": "kotlin-tree-sitter",
|
|
10
|
+
"source": "github",
|
|
11
|
+
"repository_url": "https://github.com/tree-sitter/kotlin-tree-sitter",
|
|
12
|
+
"branch": "master",
|
|
13
|
+
"size": "100",
|
|
14
|
+
"language": "Kotlin",
|
|
15
|
+
"is_private": False,
|
|
16
|
+
"git_provider_type": "github",
|
|
17
|
+
"refresh_token": "1234567890"
|
|
14
18
|
},
|
|
15
19
|
}
|
|
16
20
|
|
adaptsapi-0.1.2/PKG-INFO
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: adaptsapi
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: CLI to enqueue triggers via internal API Gateway → SNS
|
|
5
|
-
Home-page: https://github.com/adaptsai/adaptsapi
|
|
6
|
-
Author: adapts
|
|
7
|
-
Author-email: "VerifyAI Inc." <dev@adapts.ai>
|
|
8
|
-
License-Expression: LicenseRef-Proprietary
|
|
9
|
-
Project-URL: Homepage, https://github.com/adaptsai/adaptsapi
|
|
10
|
-
Project-URL: Source, https://github.com/adaptsai/adaptsapi
|
|
11
|
-
Keywords: adapts,api,cli,sns
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Requires-Python: >=3.10
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENSE
|
|
17
|
-
Requires-Dist: requests
|
|
18
|
-
Dynamic: author
|
|
19
|
-
Dynamic: home-page
|
|
20
|
-
Dynamic: license-file
|
|
21
|
-
Dynamic: requires-python
|
adaptsapi-0.1.2/README.md
DELETED
|
File without changes
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
import requests
|
|
3
|
-
from typing import Dict, Any
|
|
4
|
-
from datetime import datetime, date
|
|
5
|
-
|
|
6
|
-
# regex for a very basic email validation
|
|
7
|
-
_EMAIL_RE = re.compile(r"^[^@]+@[^@]+\.[^@]+$")
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class PayloadValidationError(ValueError):
|
|
11
|
-
"""Raised when the payload is missing required fields or has invalid values."""
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def _validate_payload(payload: Dict[str, Any]) -> None:
|
|
15
|
-
# Top‐level required fields
|
|
16
|
-
required = {
|
|
17
|
-
"user_id": str,
|
|
18
|
-
"email_address": str,
|
|
19
|
-
"user_name": str,
|
|
20
|
-
"repo_object": dict,
|
|
21
|
-
}
|
|
22
|
-
for field, typ in required.items():
|
|
23
|
-
if field not in payload:
|
|
24
|
-
raise PayloadValidationError(f"Missing required field: '{field}'")
|
|
25
|
-
if not isinstance(payload[field], typ):
|
|
26
|
-
raise PayloadValidationError(f"Field '{field}' must be of type {typ.__name__}")
|
|
27
|
-
|
|
28
|
-
# email format
|
|
29
|
-
if not _EMAIL_RE.match(payload["email_address"]):
|
|
30
|
-
raise PayloadValidationError("Invalid email address format")
|
|
31
|
-
|
|
32
|
-
# repo_object sub‐fields
|
|
33
|
-
repo = payload["repo_object"]
|
|
34
|
-
repo_required = {
|
|
35
|
-
"repo_name": str,
|
|
36
|
-
"repo_source": str,
|
|
37
|
-
"repo_url": str,
|
|
38
|
-
"repo_branch": str,
|
|
39
|
-
}
|
|
40
|
-
for rfield, rtyp in repo_required.items():
|
|
41
|
-
if rfield not in repo:
|
|
42
|
-
raise PayloadValidationError(f"Missing repo_object.{rfield}")
|
|
43
|
-
if not isinstance(repo[rfield], rtyp):
|
|
44
|
-
raise PayloadValidationError(f"repo_object.{rfield} must be a {rtyp.__name__}")
|
|
45
|
-
|
|
46
|
-
# you can add more checks here (URL validation, branch name patterns, etc.)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def _populate_metadata(payload: Dict[str, Any]) -> None:
|
|
50
|
-
"""Autofill metadata.created_by/on and updated_by/on."""
|
|
51
|
-
user = payload["user_id"]
|
|
52
|
-
today = date.today().isoformat()
|
|
53
|
-
payload["metadata"] = {
|
|
54
|
-
"created_by": user,
|
|
55
|
-
"created_on": today,
|
|
56
|
-
"updated_by": user,
|
|
57
|
-
"updated_on": today,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def post(
|
|
62
|
-
endpoint: str,
|
|
63
|
-
token: str,
|
|
64
|
-
payload: Dict[str, Any],
|
|
65
|
-
timeout: int = 30
|
|
66
|
-
) -> requests.Response:
|
|
67
|
-
"""
|
|
68
|
-
Send a POST with validated payload and auto‐populated metadata.
|
|
69
|
-
|
|
70
|
-
Raises:
|
|
71
|
-
PayloadValidationError: if payload is missing required data.
|
|
72
|
-
requests.RequestException: on network failures.
|
|
73
|
-
"""
|
|
74
|
-
# 1) Validate schema
|
|
75
|
-
_validate_payload(payload)
|
|
76
|
-
|
|
77
|
-
# 2) Add metadata
|
|
78
|
-
_populate_metadata(payload)
|
|
79
|
-
|
|
80
|
-
headers = {
|
|
81
|
-
"x-api-key": token,
|
|
82
|
-
"Content-Type": "application/json",
|
|
83
|
-
}
|
|
84
|
-
return requests.post(endpoint, json=payload, headers=headers, timeout=timeout)
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: adaptsapi
|
|
3
|
-
Version: 0.1.2
|
|
4
|
-
Summary: CLI to enqueue triggers via internal API Gateway → SNS
|
|
5
|
-
Home-page: https://github.com/adaptsai/adaptsapi
|
|
6
|
-
Author: adapts
|
|
7
|
-
Author-email: "VerifyAI Inc." <dev@adapts.ai>
|
|
8
|
-
License-Expression: LicenseRef-Proprietary
|
|
9
|
-
Project-URL: Homepage, https://github.com/adaptsai/adaptsapi
|
|
10
|
-
Project-URL: Source, https://github.com/adaptsai/adaptsapi
|
|
11
|
-
Keywords: adapts,api,cli,sns
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Requires-Python: >=3.10
|
|
15
|
-
Description-Content-Type: text/markdown
|
|
16
|
-
License-File: LICENSE
|
|
17
|
-
Requires-Dist: requests
|
|
18
|
-
Dynamic: author
|
|
19
|
-
Dynamic: home-page
|
|
20
|
-
Dynamic: license-file
|
|
21
|
-
Dynamic: requires-python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|