Skip to content

Commit 3ac755f

Browse files
Command/API audit scaffolding
1 parent 48dd6a5 commit 3ac755f

File tree

63 files changed

+36967
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+36967
-6
lines changed

api-audit/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Terminus API Response Audit
2+
3+
This directory contains the audit data and analysis for understanding which API response fields are actually used by the Terminus CLI, enabling API gateway filtering optimization.
4+
5+
## Methodology
6+
7+
1. **Command Inventory**: Catalog all available Terminus commands
8+
2. **Response Capture**: Execute commands and capture full API request/response data
9+
3. **Code Analysis**: Analyze which response fields are actually used in the code
10+
4. **Field Mapping**: Create mapping of endpoints → fields returned vs fields used
11+
5. **Recommendations**: Generate filtering recommendations for the API gateway
12+
13+
## Directory Structure
14+
15+
- `commands/` - Command inventory and categorization
16+
- `requests/` - Captured API requests and responses
17+
- `analysis/` - Analysis results and summaries
18+
- `scripts/` - Automation scripts for data capture and analysis
19+
20+
## Usage
21+
22+
1. Run `scripts/capture-responses.php` to execute commands and capture API data
23+
2. Run `scripts/analyze-usage.php` to analyze code usage patterns
24+
3. Run `scripts/generate-report.php` to generate the final filtering recommendations
25+
26+
## Test Environment
27+
28+
- Organization: initech-bw
29+
- Site: deve12131231
30+
31+
## Status
32+
33+
This is an iterative audit focusing on one command at a time to ensure thorough analysis.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"analysis_timestamp": "2025-11-17T11:50:47+00:00",
3+
"total_api_calls_captured": 23,
4+
"unique_endpoints": 9,
5+
"unique_commands": 6,
6+
"endpoint_patterns": [
7+
"track",
8+
"users\/{id}",
9+
"sites\/{id}",
10+
"site-names\/deve12131231",
11+
"sites\/{id}\/environments",
12+
"sites\/{id}\/environments\/live\/workflows",
13+
"sites\/{id}\/environments\/test\/settings",
14+
"sites\/{id}\/environments\/asdf\/settings",
15+
"users\/{id}\/workflows\/{id}"
16+
],
17+
"most_called_endpoints": [
18+
"track",
19+
"sites\/{id}",
20+
"users\/{id}",
21+
"site-names\/deve12131231",
22+
"sites\/{id}\/environments",
23+
"sites\/{id}\/environments\/live\/workflows",
24+
"sites\/{id}\/environments\/test\/settings",
25+
"sites\/{id}\/environments\/asdf\/settings",
26+
"users\/{id}\/workflows\/{id}"
27+
],
28+
"commands_by_endpoint_count": {
29+
"env:clear-cache": 4,
30+
"env:list": 4,
31+
"site:delete": 3,
32+
"site:info": 3,
33+
"auth:whoami": 2,
34+
"backup:list": 2
35+
}
36+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"auth:whoami": [
3+
"track",
4+
"users\/{id}"
5+
],
6+
"backup:list": [
7+
"sites\/{id}",
8+
"track"
9+
],
10+
"env:clear-cache": [
11+
"site-names\/deve12131231",
12+
"sites\/{id}\/environments",
13+
"sites\/{id}\/environments\/live\/workflows",
14+
"track"
15+
],
16+
"env:list": [
17+
"sites\/{id}\/environments",
18+
"sites\/{id}\/environments\/test\/settings",
19+
"sites\/{id}\/environments\/asdf\/settings",
20+
"track"
21+
],
22+
"site:delete": [
23+
"sites\/{id}",
24+
"users\/{id}\/workflows\/{id}",
25+
"track"
26+
],
27+
"site:info": [
28+
"site-names\/deve12131231",
29+
"track",
30+
"sites\/{id}"
31+
]
32+
}
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
{
2+
"track": {
3+
"pattern": "track",
4+
"methods": [
5+
"POST"
6+
],
7+
"commands": {
8+
"0": "auth:whoami",
9+
"4": "backup:list",
10+
"5": "env:clear-cache",
11+
"6": "env:list",
12+
"7": "site:delete",
13+
"8": "site:info"
14+
},
15+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/track",
16+
"call_count": 10,
17+
"sample_responses": [
18+
{
19+
"command": "auth:whoami",
20+
"method": "POST",
21+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/track",
22+
"status_code": 200,
23+
"response_size": 0
24+
},
25+
{
26+
"command": "auth:whoami",
27+
"method": "POST",
28+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/track",
29+
"status_code": 200,
30+
"response_size": 0
31+
},
32+
{
33+
"command": "auth:whoami",
34+
"method": "POST",
35+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/track",
36+
"status_code": 200,
37+
"response_size": 0
38+
}
39+
]
40+
},
41+
"users\/{id}": {
42+
"pattern": "users\/{id}",
43+
"methods": [
44+
"GET"
45+
],
46+
"commands": [
47+
"auth:whoami"
48+
],
49+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/users\/17f91e87-3807-4c93-837a-78f388bfbb5c",
50+
"call_count": 2,
51+
"sample_responses": [
52+
{
53+
"command": "auth:whoami",
54+
"method": "GET",
55+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/users\/17f91e87-3807-4c93-837a-78f388bfbb5c",
56+
"status_code": 200,
57+
"response_size": 16
58+
},
59+
{
60+
"command": "auth:whoami",
61+
"method": "GET",
62+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/users\/17f91e87-3807-4c93-837a-78f388bfbb5c",
63+
"status_code": 200,
64+
"response_size": 16
65+
}
66+
]
67+
},
68+
"sites\/{id}": {
69+
"pattern": "sites\/{id}",
70+
"methods": [
71+
"GET"
72+
],
73+
"commands": [
74+
"backup:list",
75+
"site:delete",
76+
"site:info"
77+
],
78+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7?site_state=true",
79+
"call_count": 3,
80+
"sample_responses": [
81+
{
82+
"command": "backup:list",
83+
"method": "GET",
84+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7?site_state=true",
85+
"status_code": 200,
86+
"response_size": 28
87+
},
88+
{
89+
"command": "site:delete",
90+
"method": "GET",
91+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/e4210648-57bd-4102-90b8-164893210e15?site_state=true",
92+
"status_code": 200,
93+
"response_size": 29
94+
},
95+
{
96+
"command": "site:info",
97+
"method": "GET",
98+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7?site_state=true",
99+
"status_code": 200,
100+
"response_size": 28
101+
}
102+
]
103+
},
104+
"site-names\/deve12131231": {
105+
"pattern": "site-names\/deve12131231",
106+
"methods": [
107+
"GET"
108+
],
109+
"commands": [
110+
"env:clear-cache",
111+
"site:info"
112+
],
113+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/site-names\/deve12131231",
114+
"call_count": 2,
115+
"sample_responses": [
116+
{
117+
"command": "env:clear-cache",
118+
"method": "GET",
119+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/site-names\/deve12131231",
120+
"status_code": 200,
121+
"response_size": 2
122+
},
123+
{
124+
"command": "site:info",
125+
"method": "GET",
126+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/site-names\/deve12131231",
127+
"status_code": 200,
128+
"response_size": 2
129+
}
130+
]
131+
},
132+
"sites\/{id}\/environments": {
133+
"pattern": "sites\/{id}\/environments",
134+
"methods": [
135+
"GET"
136+
],
137+
"commands": [
138+
"env:clear-cache",
139+
"env:list"
140+
],
141+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments",
142+
"call_count": 2,
143+
"sample_responses": [
144+
{
145+
"command": "env:clear-cache",
146+
"method": "GET",
147+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments",
148+
"status_code": 200,
149+
"response_size": 4
150+
},
151+
{
152+
"command": "env:list",
153+
"method": "GET",
154+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments",
155+
"status_code": 200,
156+
"response_size": 4
157+
}
158+
]
159+
},
160+
"sites\/{id}\/environments\/live\/workflows": {
161+
"pattern": "sites\/{id}\/environments\/live\/workflows",
162+
"methods": [
163+
"POST"
164+
],
165+
"commands": [
166+
"env:clear-cache"
167+
],
168+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments\/live\/workflows",
169+
"call_count": 1,
170+
"sample_responses": [
171+
{
172+
"command": "env:clear-cache",
173+
"method": "POST",
174+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments\/live\/workflows",
175+
"status_code": 202,
176+
"response_size": 37
177+
}
178+
]
179+
},
180+
"sites\/{id}\/environments\/test\/settings": {
181+
"pattern": "sites\/{id}\/environments\/test\/settings",
182+
"methods": [
183+
"GET"
184+
],
185+
"commands": [
186+
"env:list"
187+
],
188+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments\/test\/settings",
189+
"call_count": 1,
190+
"sample_responses": [
191+
{
192+
"command": "env:list",
193+
"method": "GET",
194+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments\/test\/settings",
195+
"status_code": 200,
196+
"response_size": 104
197+
}
198+
]
199+
},
200+
"sites\/{id}\/environments\/asdf\/settings": {
201+
"pattern": "sites\/{id}\/environments\/asdf\/settings",
202+
"methods": [
203+
"GET"
204+
],
205+
"commands": [
206+
"env:list"
207+
],
208+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments\/asdf\/settings",
209+
"call_count": 1,
210+
"sample_responses": [
211+
{
212+
"command": "env:list",
213+
"method": "GET",
214+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/sites\/99f1ccb6-4827-4787-ba84-c2af3ed45cf7\/environments\/asdf\/settings",
215+
"status_code": 200,
216+
"response_size": 106
217+
}
218+
]
219+
},
220+
"users\/{id}\/workflows\/{id}": {
221+
"pattern": "users\/{id}\/workflows\/{id}",
222+
"methods": [
223+
"GET"
224+
],
225+
"commands": [
226+
"site:delete"
227+
],
228+
"example_uri": "https:\/\/terminus.pantheon.io:443\/api\/users\/17f91e87-3807-4c93-837a-78f388bfbb5c\/workflows\/3fcf50e4-c3a6-11f0-a005-8e3205cf23e6",
229+
"call_count": 1,
230+
"sample_responses": [
231+
{
232+
"command": "site:delete",
233+
"method": "GET",
234+
"uri": "https:\/\/terminus.pantheon.io:443\/api\/users\/17f91e87-3807-4c93-837a-78f388bfbb5c\/workflows\/3fcf50e4-c3a6-11f0-a005-8e3205cf23e6",
235+
"status_code": 200,
236+
"response_size": 36
237+
}
238+
]
239+
}
240+
}

0 commit comments

Comments
 (0)