adaptsapi 0.1.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.
adaptsapi/__init__.py ADDED
File without changes
adaptsapi/cli.py ADDED
@@ -0,0 +1,40 @@
1
+ import argparse
2
+ import sys
3
+ import json
4
+
5
+ from adaptsapi.http import post
6
+ from adaptsapi.config import load_token, load_default_endpoint
7
+
8
+ def main():
9
+ default_ep = load_default_endpoint()
10
+ parser = argparse.ArgumentParser(prog="adaptsapi")
11
+ parser.add_argument(
12
+ "--endpoint",
13
+ default=default_ep,
14
+ required=(default_ep is None),
15
+ help="Full URL of the API endpoint (default from ./config.json)"
16
+ )
17
+ parser.add_argument("--payload-file", type=argparse.FileType('r'),
18
+ help="Path to JSON payload file (overrides inline --data)")
19
+ parser.add_argument("--data", help="Inline JSON payload string")
20
+ parser.add_argument("--timeout", type=int, default=30)
21
+ args = parser.parse_args()
22
+
23
+ token = load_token()
24
+ # load payload
25
+ if args.payload_file:
26
+ payload = json.load(args.payload_file)
27
+ elif args.data:
28
+ payload = json.loads(args.data)
29
+ else:
30
+ print("Error: must specify --data or --payload-file", file=sys.stderr)
31
+ sys.exit(1)
32
+
33
+ resp = post(args.endpoint, token, payload, timeout=args.timeout)
34
+ if resp.status_code >= 400:
35
+ print(f"Error {resp.status_code}: {resp.text}", file=sys.stderr)
36
+ sys.exit(resp.status_code)
37
+ print(resp.text)
38
+
39
+ if __name__ == "__main__":
40
+ main()
adaptsapi/config.py ADDED
@@ -0,0 +1,58 @@
1
+ import os
2
+ import json
3
+ import getpass
4
+ from pathlib import Path
5
+
6
+ # Point at config.json in whatever directory you run the CLI from
7
+ CONFIG_PATH = Path.cwd() / "config.json"
8
+
9
+ class ConfigError(Exception):
10
+ """Raised when no token can be found or loaded."""
11
+ pass
12
+
13
+ def load_token() -> str:
14
+ # 1) ENV override
15
+ token = os.getenv("ADAPTS_API_TOKEN")
16
+ if token:
17
+ return token
18
+
19
+ # 2) config.json in current directory
20
+ if CONFIG_PATH.exists():
21
+ try:
22
+ data = json.loads(CONFIG_PATH.read_text())
23
+ token = data.get("token")
24
+ if token:
25
+ return token
26
+ except json.JSONDecodeError:
27
+ # invalid JSON in config.json; fall through to prompt
28
+ pass
29
+
30
+ # 3) interactive first-run and save
31
+ token = getpass.getpass("API token not found; please paste it here: ")
32
+ if not token:
33
+ raise ConfigError("No token provided")
34
+ CONFIG_PATH.write_text(json.dumps({"token": token}, indent=2))
35
+ print(f"Saved token to {CONFIG_PATH}")
36
+ return token
37
+
38
+ def load_default_endpoint() -> str | None:
39
+ """Return `endpoint` from ./config.json if present, else None."""
40
+ if CONFIG_PATH.exists():
41
+ try:
42
+ data = json.loads(CONFIG_PATH.read_text())
43
+ return data.get("endpoint")
44
+ except json.JSONDecodeError:
45
+ return None
46
+ return None
47
+
48
+ def _ensure_config_dir_and_write(obj: dict) -> None:
49
+ """Helper to merge+write config.json in cwd."""
50
+ # read existing if any
51
+ existing = {}
52
+ if CONFIG_PATH.exists():
53
+ try:
54
+ existing = json.loads(CONFIG_PATH.read_text())
55
+ except json.JSONDecodeError:
56
+ existing = {}
57
+ merged = {**existing, **obj}
58
+ CONFIG_PATH.write_text(json.dumps(merged, indent=2))
adaptsapi/http.py ADDED
@@ -0,0 +1,6 @@
1
+ import requests
2
+ from typing import Optional, Dict, Any
3
+
4
+ def post(endpoint: str, token: str, payload: Dict[str, Any], timeout: int = 30) -> requests.Response:
5
+ headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
6
+ return requests.post(endpoint, json=payload, headers=headers, timeout=timeout)
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: adaptsapi
3
+ Version: 0.1.0
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
@@ -0,0 +1,10 @@
1
+ adaptsapi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ adaptsapi/cli.py,sha256=ImJ1rjMpApeRIFwgThPhMysf74mr3D5wzPLvirtM9oY,1307
3
+ adaptsapi/config.py,sha256=oKe9HOsHIFgOf3RjVHFLyYluoWsVpZR8kaepTK9HlLg,1779
4
+ adaptsapi/http.py,sha256=LTrszKQnK-myysuRzyf3CaHv-hwqCt-b7ft79Xx4nfg,327
5
+ adaptsapi-0.1.0.dist-info/licenses/LICENSE,sha256=Dvte6V8UuiWxm6IYN8La5mwf8ddFQkhPhoSl6Wk1xJk,1221
6
+ adaptsapi-0.1.0.dist-info/METADATA,sha256=TsRlXNHtiITnMIXH6-0vmA5EpGNUOdEnuBzSxyu54NM,708
7
+ adaptsapi-0.1.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
8
+ adaptsapi-0.1.0.dist-info/entry_points.txt,sha256=NV-kArdRW9sjcBjP4dd11ACODrMfEeVl8rPwUWFxCrc,49
9
+ adaptsapi-0.1.0.dist-info/top_level.txt,sha256=LLgR2ljWT4ERCSV2eSCBYFkW1gLGyWBsL58IHYV9US4,10
10
+ adaptsapi-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ adaptsapi = adaptsapi.cli:main
@@ -0,0 +1,25 @@
1
+ Adapts API Use-Only License v1.0
2
+ © 2025 VerifyAI Inc. All rights reserved.
3
+
4
+ Permission is hereby granted to any person or entity (the “Licensee”) obtaining a copy
5
+ of this software and accompanying documentation files (the “Software”) to install and run
6
+ the Software for any lawful purpose, provided that:
7
+
8
+ 1. USE-ONLY. The Licensee may use the Software in its original, unmodified form.
9
+
10
+ 2. NO MODIFICATION. The Licensee MAY NOT modify, adapt, translate, or create derivative
11
+ works of the Software.
12
+
13
+ 3. NO REDISTRIBUTION. The Licensee MAY NOT distribute, sublicense, sell, or otherwise
14
+ transfer copies of the Software—original or modified—without express prior written
15
+ permission from VerifyAI Inc.
16
+
17
+ 4. TERMINATION. This license is effective until terminated. VerifyAI Inc. may terminate
18
+ it immediately if the Licensee breaches any term. Upon termination, the Licensee
19
+ must cease all use and destroy all copies of the Software.
20
+
21
+ 5. WARRANTY DISCLAIMER. THE SOFTWARE IS PROVIDED “AS IS,” WITHOUT WARRANTY OF ANY KIND,
22
+ EXPRESS OR IMPLIED.
23
+
24
+ 6. LIMITATION OF LIABILITY. IN NO EVENT WILL VERIFYAI INC. BE LIABLE FOR ANY DAMAGES
25
+ ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE.
@@ -0,0 +1 @@
1
+ adaptsapi