adaptsapi 0.1.2__tar.gz → 0.1.3__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.2/src/adaptsapi.egg-info → adaptsapi-0.1.3}/PKG-INFO +1 -1
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/pyproject.toml +1 -1
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/setup.py +1 -1
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi/generate_docs.py +55 -12
- {adaptsapi-0.1.2 → adaptsapi-0.1.3/src/adaptsapi.egg-info}/PKG-INFO +1 -1
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/tests/test_generate_docs.py +12 -7
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/LICENSE +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/README.md +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/setup.cfg +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi/__init__.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi/cli.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi/config.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi.egg-info/SOURCES.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi.egg-info/dependency_links.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi.egg-info/entry_points.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi.egg-info/requires.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/src/adaptsapi.egg-info/top_level.txt +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/tests/test_cli.py +0 -0
- {adaptsapi-0.1.2 → adaptsapi-0.1.3}/tests/test_config.py +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import requests
|
|
3
|
-
from typing import Dict, Any
|
|
3
|
+
from typing import Dict, Any, Optional
|
|
4
4
|
from datetime import datetime, date
|
|
5
|
+
import uuid
|
|
5
6
|
|
|
6
7
|
# regex for a very basic email validation
|
|
7
8
|
_EMAIL_RE = re.compile(r"^[^@]+@[^@]+\.[^@]+$")
|
|
@@ -31,17 +32,45 @@ def _validate_payload(payload: Dict[str, Any]) -> None:
|
|
|
31
32
|
|
|
32
33
|
# repo_object sub‐fields
|
|
33
34
|
repo = payload["repo_object"]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
35
|
+
|
|
36
|
+
# *Required* sub-fields – must be present and right type
|
|
37
|
+
required_repo_fields = {
|
|
38
|
+
"repository_name": str,
|
|
39
|
+
"repository_url": str,
|
|
40
|
+
"branch": str,
|
|
41
|
+
"size": str,
|
|
42
|
+
"language": str,
|
|
43
|
+
"source": str,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# *Optional* sub-fields – validate only if provided (can be None)
|
|
47
|
+
optional_repo_fields = {
|
|
48
|
+
"is_private": bool,
|
|
49
|
+
"git_provider_type": str,
|
|
50
|
+
"installation_id": str, # ← now **optional**
|
|
51
|
+
"refresh_token": str,
|
|
52
|
+
"commit_hash": str,
|
|
53
|
+
"commit_message": str,
|
|
54
|
+
"commit_author": str,
|
|
55
|
+
"directory_name": str,
|
|
39
56
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
# required loop
|
|
58
|
+
for field, typ in required_repo_fields.items():
|
|
59
|
+
if field not in repo:
|
|
60
|
+
raise PayloadValidationError(f"Missing repo_object.{field}")
|
|
61
|
+
if not isinstance(repo[field], typ):
|
|
62
|
+
raise PayloadValidationError(
|
|
63
|
+
f"repo_object.{field} must be {typ.__name__}"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# optional loop
|
|
67
|
+
for field, typ in optional_repo_fields.items():
|
|
68
|
+
if field in repo and repo[field] is not None and not isinstance(
|
|
69
|
+
repo[field], typ
|
|
70
|
+
):
|
|
71
|
+
raise PayloadValidationError(
|
|
72
|
+
f"repo_object.{field} must be {typ.__name__}"
|
|
73
|
+
)
|
|
45
74
|
|
|
46
75
|
# you can add more checks here (URL validation, branch name patterns, etc.)
|
|
47
76
|
|
|
@@ -56,6 +85,19 @@ def _populate_metadata(payload: Dict[str, Any]) -> None:
|
|
|
56
85
|
"updated_by": user,
|
|
57
86
|
"updated_on": today,
|
|
58
87
|
}
|
|
88
|
+
payload["action"] = "code_to_wiki"
|
|
89
|
+
|
|
90
|
+
# populate wiki if missing or incomplete
|
|
91
|
+
wiki = payload.get("wiki", {})
|
|
92
|
+
wiki.setdefault("wiki_name", payload["repo_object"]["repository_name"])
|
|
93
|
+
wiki.setdefault("wiki_source", payload["repo_object"]["source"]) # new!
|
|
94
|
+
wiki.setdefault("wiki_url", None)
|
|
95
|
+
|
|
96
|
+
payload["wiki_object"] = wiki
|
|
97
|
+
payload["request_id"] = str(uuid.uuid4())
|
|
98
|
+
payload["request_type"] = "code_to_wiki"
|
|
99
|
+
payload["status"] = "pending"
|
|
100
|
+
|
|
59
101
|
|
|
60
102
|
|
|
61
103
|
def post(
|
|
@@ -80,5 +122,6 @@ def post(
|
|
|
80
122
|
headers = {
|
|
81
123
|
"x-api-key": token,
|
|
82
124
|
"Content-Type": "application/json",
|
|
83
|
-
}
|
|
125
|
+
}
|
|
126
|
+
print(payload)
|
|
84
127
|
return requests.post(endpoint, json=payload, headers=headers, timeout=timeout)
|
|
@@ -3,14 +3,19 @@ import os
|
|
|
3
3
|
from adaptsapi.generate_docs import post, PayloadValidationError
|
|
4
4
|
|
|
5
5
|
payload = {
|
|
6
|
-
"user_id": "
|
|
7
|
-
"email_address": "
|
|
8
|
-
"user_name": "
|
|
6
|
+
"user_id": "d36a113a-25d3-402b-8f5d-9e443f5570cd",
|
|
7
|
+
"email_address": "sheel@adapts.ai",
|
|
8
|
+
"user_name": "sheel",
|
|
9
9
|
"repo_object": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
10
|
+
"repository_name": "kotlin-tree-sitter",
|
|
11
|
+
"source": "github",
|
|
12
|
+
"repository_url": "https://github.com/tree-sitter/kotlin-tree-sitter",
|
|
13
|
+
"branch": "master",
|
|
14
|
+
"size": "100",
|
|
15
|
+
"language": "Kotlin",
|
|
16
|
+
"is_private": False,
|
|
17
|
+
"git_provider_type": "github",
|
|
18
|
+
"refresh_token": "1234567890"
|
|
14
19
|
},
|
|
15
20
|
}
|
|
16
21
|
|
|
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
|
|
File without changes
|
|
File without changes
|