@@ -93,7 +93,38 @@ Fetches commits from the `refs/gittuf/policy` branch of a remote repository.
9393
9494#### POST ` /metadata `
9595
96- Retrieves and decodes a metadata blob from a specific commit in a remote repository.
96+ Retrieves and decodes both ` root.json ` and ` targets.json ` from a specific commit in a remote repository.
97+
98+ - ** Request Body** (JSON):
99+ ``` json
100+ {
101+ "url" : " https://github.com/user/repo.git" ,
102+ "commit" : " abc123..."
103+ }
104+ ```
105+ - ** Response** (200 OK):
106+ ``` json
107+ {
108+ "root" : {
109+ // Decoded root metadata object
110+ },
111+ "targets" : {
112+ // Decoded targets metadata object
113+ }
114+ }
115+ ```
116+ - ** Error Response** (400/500):
117+ ``` json
118+ {
119+ "error" : " Error message" ,
120+ "code" : 400 ,
121+ "details" : " Detailed error information"
122+ }
123+ ```
124+
125+ #### POST ` /metadata-single `
126+
127+ Retrieves and decodes a single metadata blob from a specific commit in a remote repository.
97128
98129- ** Request Body** (JSON):
99130 ``` json
@@ -118,13 +149,44 @@ Retrieves and decodes a metadata blob from a specific commit in a remote reposit
118149 }
119150 ```
120151
152+ #### POST ` /policy-query `
153+
154+ Evaluates a branch/path query against policy metadata at a specific remote policy commit.
155+
156+ - ** Request Body** (JSON):
157+ ``` json
158+ {
159+ "url" : " https://github.com/user/repo.git" ,
160+ "commit" : " abc123..." ,
161+ "branch" : " main" ,
162+ "changedPath" : " src/app.ts"
163+ }
164+ ```
165+ - ** Response** (200 OK):
166+ ``` json
167+ {
168+ "matchedBranch" : " main" ,
169+ "matchedRule" : " src/**" ,
170+ "requiredApprovals" : 2 ,
171+ "authorizedUsers" : [" alice" , " bob" ]
172+ }
173+ ```
174+ - ** Error Response** (400/500):
175+ ``` json
176+ {
177+ "error" : " Error message" ,
178+ "code" : 400 ,
179+ "details" : " Detailed error information"
180+ }
181+ ```
182+
121183---
122184
123185### Local Repository Endpoints
124186
125187#### POST ` /commits-local `
126188
127- Lists commits from the HEAD of a local Git repository.
189+ Lists commits from the ` refs/gittuf/policy ` ref of a local Git repository.
128190
129191- ** Request Body** (JSON):
130192 ``` json
@@ -154,7 +216,38 @@ Lists commits from the HEAD of a local Git repository.
154216
155217#### POST ` /metadata-local `
156218
157- Retrieves and decodes a metadata blob from a specific commit in a local repository.
219+ Retrieves and decodes both ` root.json ` and ` targets.json ` from a specific commit in a local repository.
220+
221+ - ** Request Body** (JSON):
222+ ``` json
223+ {
224+ "path" : " /path/to/local/repo" ,
225+ "commit" : " abc123..."
226+ }
227+ ```
228+ - ** Response** (200 OK):
229+ ``` json
230+ {
231+ "root" : {
232+ // Decoded root metadata object
233+ },
234+ "targets" : {
235+ // Decoded targets metadata object
236+ }
237+ }
238+ ```
239+ - ** Error Response** (400/500):
240+ ``` json
241+ {
242+ "error" : " Error message" ,
243+ "code" : 400 ,
244+ "details" : " Detailed error information"
245+ }
246+ ```
247+
248+ #### POST ` /metadata-local-single `
249+
250+ Retrieves and decodes a single metadata blob from a specific commit in a local repository.
158251
159252- ** Request Body** (JSON):
160253 ``` json
@@ -179,6 +272,37 @@ Retrieves and decodes a metadata blob from a specific commit in a local reposito
179272 }
180273 ```
181274
275+ #### POST ` /policy-query-local `
276+
277+ Evaluates a branch/path query against policy metadata at a specific local policy commit.
278+
279+ - ** Request Body** (JSON):
280+ ``` json
281+ {
282+ "path" : " /path/to/local/repo" ,
283+ "commit" : " abc123..." ,
284+ "branch" : " main" ,
285+ "changedPath" : " src/app.ts"
286+ }
287+ ```
288+ - ** Response** (200 OK):
289+ ``` json
290+ {
291+ "matchedBranch" : " main" ,
292+ "matchedRule" : " src/**" ,
293+ "requiredApprovals" : 2 ,
294+ "authorizedUsers" : [" alice" , " bob" ]
295+ }
296+ ```
297+ - ** Error Response** (400/500):
298+ ``` json
299+ {
300+ "error" : " Error message" ,
301+ "code" : 400 ,
302+ "details" : " Detailed error information"
303+ }
304+ ```
305+
182306## Project Structure
183307
184308```
@@ -194,4 +318,4 @@ go-backend/
194318├── go.mod # Go module definition and dependencies
195319├── go.sum # Dependencies checksums
196320└── .env # Environment configuration
197- ```
321+ ```
0 commit comments