adaptsapi 0.1.3__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.
@@ -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
+ [![PyPI version](https://badge.fury.io/py/adaptsapi.svg)](https://badge.fury.io/py/adaptsapi)
28
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
29
+ [![License: Proprietary](https://img.shields.io/badge/License-Proprietary-red.svg)](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
+ [![PyPI version](https://badge.fury.io/py/adaptsapi.svg)](https://badge.fury.io/py/adaptsapi)
6
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
7
+ [![License: Proprietary](https://img.shields.io/badge/License-Proprietary-red.svg)](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.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "adaptsapi"
7
- version = "0.1.3"
7
+ version = "0.1.4"
8
8
  description = "CLI to enqueue triggers via internal API Gateway → SNS"
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
 
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = adaptsapi
3
- version = 0.1.2
3
+ version = 0.1.4
4
4
  author = adapts
5
5
  author_email = dev@adapts.ai
6
6
  description = CLI to enqueue triggers via internal API Gateway → SNS
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="adaptsapi",
5
- version="0.1.3",
5
+ version="0.1.4",
6
6
  author="adapts",
7
7
  author_email="dev@adapts.ai",
8
8
  description="CLI to enqueue triggers via internal API Gateway → SNS",
@@ -1,7 +1,7 @@
1
1
  import re
2
2
  import requests
3
- from typing import Dict, Any, Optional
4
- from datetime import datetime, date
3
+ from typing import Dict, Any
4
+ from datetime import date
5
5
  import uuid
6
6
 
7
7
  # regex for a very basic email validation
@@ -9,13 +9,13 @@ _EMAIL_RE = re.compile(r"^[^@]+@[^@]+\.[^@]+$")
9
9
 
10
10
 
11
11
  class PayloadValidationError(ValueError):
12
- """Raised when the payload is missing required fields or has invalid values."""
12
+ """Raised when the payload is missing required fields or
13
+ has invalid values."""
13
14
 
14
15
 
15
16
  def _validate_payload(payload: Dict[str, Any]) -> None:
16
17
  # Top‐level required fields
17
- required = {
18
- "user_id": str,
18
+ required = {
19
19
  "email_address": str,
20
20
  "user_name": str,
21
21
  "repo_object": dict,
@@ -24,7 +24,9 @@ def _validate_payload(payload: Dict[str, Any]) -> None:
24
24
  if field not in payload:
25
25
  raise PayloadValidationError(f"Missing required field: '{field}'")
26
26
  if not isinstance(payload[field], typ):
27
- raise PayloadValidationError(f"Field '{field}' must be of type {typ.__name__}")
27
+ raise PayloadValidationError(
28
+ f"Field '{field}' must be of type {typ.__name__}"
29
+ )
28
30
 
29
31
  # email format
30
32
  if not _EMAIL_RE.match(payload["email_address"]):
@@ -33,7 +35,7 @@ def _validate_payload(payload: Dict[str, Any]) -> None:
33
35
  # repo_object sub‐fields
34
36
  repo = payload["repo_object"]
35
37
 
36
- # *Required* sub-fields – must be present and right type
38
+ # *Required* sub-fields – must be present and right type
37
39
  required_repo_fields = {
38
40
  "repository_name": str,
39
41
  "repository_url": str,
@@ -77,7 +79,7 @@ def _validate_payload(payload: Dict[str, Any]) -> None:
77
79
 
78
80
  def _populate_metadata(payload: Dict[str, Any]) -> None:
79
81
  """Autofill metadata.created_by/on and updated_by/on."""
80
- user = payload["user_id"]
82
+ user = payload["email_address"]
81
83
  today = date.today().isoformat()
82
84
  payload["metadata"] = {
83
85
  "created_by": user,
@@ -99,7 +101,6 @@ def _populate_metadata(payload: Dict[str, Any]) -> None:
99
101
  payload["status"] = "pending"
100
102
 
101
103
 
102
-
103
104
  def post(
104
105
  endpoint: str,
105
106
  token: str,
@@ -107,7 +108,7 @@ def post(
107
108
  timeout: int = 30
108
109
  ) -> requests.Response:
109
110
  """
110
- Send a POST with validated payload and auto‐populated metadata.
111
+ Send a POST with validated payload and autopopulated metadata.
111
112
 
112
113
  Raises:
113
114
  PayloadValidationError: if payload is missing required data.
@@ -118,10 +119,11 @@ def post(
118
119
 
119
120
  # 2) Add metadata
120
121
  _populate_metadata(payload)
121
-
122
+
122
123
  headers = {
123
124
  "x-api-key": token,
124
125
  "Content-Type": "application/json",
125
126
  }
126
127
  print(payload)
127
- return requests.post(endpoint, json=payload, headers=headers, timeout=timeout)
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
+ [![PyPI version](https://badge.fury.io/py/adaptsapi.svg)](https://badge.fury.io/py/adaptsapi)
28
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
29
+ [![License: Proprietary](https://img.shields.io/badge/License-Proprietary-red.svg)](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,7 +3,6 @@ import os
3
3
  from adaptsapi.generate_docs import post, PayloadValidationError
4
4
 
5
5
  payload = {
6
- "user_id": "d36a113a-25d3-402b-8f5d-9e443f5570cd",
7
6
  "email_address": "sheel@adapts.ai",
8
7
  "user_name": "sheel",
9
8
  "repo_object": {
adaptsapi-0.1.3/PKG-INFO DELETED
@@ -1,21 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: adaptsapi
3
- Version: 0.1.3
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.3/README.md DELETED
File without changes
@@ -1,21 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: adaptsapi
3
- Version: 0.1.3
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