Skip to content
1,309 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

API and MCP server in Rust; a public index at the API root1//! REST: each route maps an HTTP request onto one operation.
2
3use serde_json::{Map, Value};
4
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb975use crate::about::AboutOp;
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R26use crate::artifacts::ArtifactsOp;
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb977use crate::deployments::DeploymentsOp;
Merge branch 'worktree-agent-a3abfcce648e87dca'8use crate::protection::ProtectionOp;
API and MCP for a workspace's personal access token rules, members' tokens and approvals9use crate::token_policy::TokenOp;
API and MCP server in Rust; a public index at the API root10use crate::operations::Op;
Merge checks: statuses and check runs on every commit11use crate::checks::ChecksOp;
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge12use crate::rules::RulesOp;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar13use crate::security::SecurityOp;
API and MCP server in Rust; a public index at the API root14
15pub struct Route {
16 pub method: &'static str,
17 /// Segments starting with `:` are parameters.
18 pub path: &'static str,
19 pub op: Op,
20 /// Query parameters the route reads, as `(name in the URL, input name)`.
21 pub query: &'static [(&'static str, &'static str)],
22}
23
24const fn route(
25 method: &'static str,
26 path: &'static str,
27 op: Op,
28 query: &'static [(&'static str, &'static str)],
29) -> Route {
30 Route {
31 method,
32 path,
33 op,
34 query,
35 }
36}
37
38pub const ROUTES: &[Route] = &[
Agents as a team: lifecycle, merge queue, billing and a new shell39 route("GET", "/user", Op::Whoami, &[]),
40 route("POST", "/workspaces", Op::CreateWorkspace, &[]),
Merge branch 'worktree-agent-ad7c6d88d93adc817'41 route("GET", "/workspaces/:workspace", Op::GetWorkspace, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look42 route("DELETE", "/workspaces/:workspace", Op::DeleteWorkspace, &[]),
43 route("GET", "/user/emails", Op::ListEmails, &[]),
44 route("POST", "/user/emails", Op::AddEmail, &[]),
45 route("DELETE", "/user/emails/:email", Op::RemoveEmail, &[]),
46 route("PATCH", "/user/email-settings", Op::UpdateEmailSettings, &[]),
47 route("GET", "/user/invites", Op::ListInvites, &[]),
48 route("POST", "/user/invites", Op::CreateInvite, &[]),
49 route("DELETE", "/user/invites/:id", Op::RevokeInvite, &[]),
50 route("GET", "/workspaces/:workspace/invitations", Op::ListWorkspaceInvites, &[]),
API and MCP for a workspace's personal access token rules, members' tokens and approvals51 // A workspace's rules for personal access tokens, and its members' tokens.
52 route("GET", "/workspaces/:workspace/personal-access-token-policy", Op::Tokens(TokenOp::GetTokenPolicy), &[]),
53 route("PATCH", "/workspaces/:workspace/personal-access-token-policy", Op::Tokens(TokenOp::SetTokenPolicy), &[]),
54 route("GET", "/workspaces/:workspace/personal-access-tokens", Op::Tokens(TokenOp::ListMemberTokens), &[("kind", "kind")]),
55 route("POST", "/workspaces/:workspace/personal-access-tokens/:id", Op::Tokens(TokenOp::RevokeMemberToken), &[]),
56 route("GET", "/workspaces/:workspace/personal-access-token-requests", Op::Tokens(TokenOp::ListTokenRequests), &[]),
57 route("POST", "/workspaces/:workspace/personal-access-token-requests/:id", Op::Tokens(TokenOp::ReviewTokenRequest), &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look58 route("POST", "/workspaces/:workspace/invitations", Op::InviteMember, &[]),
59 route("DELETE", "/workspaces/:workspace/invitations/:id", Op::RevokeWorkspaceInvite, &[]),
60 // Who has access. GitHub's addresses, but for adding someone, which
61 // takes an email address as well as a username.
62 route("GET", "/repos/:owner/:name/collaborators", Op::ListCollaborators, &[]),
63 route("POST", "/repos/:owner/:name/collaborators", Op::AddCollaborator, &[]),
64 route("PATCH", "/repos/:owner/:name/collaborators/:username", Op::UpdateCollaborator, &[]),
65 route("DELETE", "/repos/:owner/:name/collaborators/:username", Op::RemoveCollaborator, &[]),
66 route(
67 "GET",
68 "/repos/:owner/:name/collaborators/:username/permission",
69 Op::GetCollaboratorPermission,
70 &[],
71 ),
72 route("GET", "/repos/:owner/:name/invitations", Op::ListRepoInvitations, &[]),
73 route("DELETE", "/repos/:owner/:name/invitations/:id", Op::RevokeRepoInvitation, &[]),
74 route("GET", "/user/repository_invitations", Op::ListMyRepoInvitations, &[]),
API: notifications over REST and MCP, with notifications scopes75 // Your notifications: threads, marking them, and what you subscribe
76 // to and watch. GitHub's addresses, with g1t's saved and snoozed.
77 route("GET", "/notifications", Op::ListNotifications, &[("all", "all"), ("participating", "participating"), ("view", "view"), ("reason", "reason"), ("severity", "severity"), ("since", "since"), ("before", "before"), ("cursor", "cursor"), ("per_page", "per_page")]),
78 route("PUT", "/notifications", Op::MarkNotificationsRead, &[]),
79 route("GET", "/notifications/threads/:id", Op::GetNotificationThread, &[]),
80 route("PATCH", "/notifications/threads/:id", Op::MarkThreadRead, &[]),
81 route("DELETE", "/notifications/threads/:id", Op::MarkThreadDone, &[]),
82 route("PUT", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
83 route("DELETE", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
84 route("PUT", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
85 route("DELETE", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
86 route("GET", "/notifications/threads/:id/subscription", Op::GetThreadSubscription, &[]),
87 route("PUT", "/notifications/threads/:id/subscription", Op::SetThreadSubscription, &[]),
88 route("DELETE", "/notifications/threads/:id/subscription", Op::DeleteThreadSubscription, &[]),
89 route("GET", "/repos/:owner/:name/notifications", Op::ListNotifications, &[("all", "all"), ("participating", "participating"), ("view", "view"), ("reason", "reason"), ("severity", "severity"), ("since", "since"), ("before", "before"), ("cursor", "cursor"), ("per_page", "per_page")]),
90 route("PUT", "/repos/:owner/:name/notifications", Op::MarkNotificationsRead, &[]),
91 route("GET", "/repos/:owner/:name/subscription", Op::GetRepoSubscription, &[]),
92 route("PUT", "/repos/:owner/:name/subscription", Op::SetRepoSubscription, &[]),
93 route("DELETE", "/repos/:owner/:name/subscription", Op::DeleteRepoSubscription, &[]),
94 route("GET", "/repos/:owner/:name/issues/:number/subscription", Op::GetThreadSubscription, &[]),
95 route("PUT", "/repos/:owner/:name/issues/:number/subscription", Op::SetThreadSubscription, &[]),
96 route("DELETE", "/repos/:owner/:name/issues/:number/subscription", Op::DeleteThreadSubscription, &[]),
97 route("GET", "/user/subscriptions", Op::ListWatchedRepos, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9798 // Stars: yours, and who starred a repository.
99 route("GET", "/user/starred", Op::About(AboutOp::ListStarred), &[]),
100 route("GET", "/user/starred/:owner/:name", Op::About(AboutOp::CheckStarred), &[]),
101 route("PUT", "/user/starred/:owner/:name", Op::About(AboutOp::Star), &[]),
102 route("DELETE", "/user/starred/:owner/:name", Op::About(AboutOp::Unstar), &[]),
103 route("GET", "/repos/:owner/:name/stargazers", Op::About(AboutOp::ListStargazers), &[("page", "page")]),
104 // What the default branch says about a repository, kept by commit.
105 route("GET", "/repos/:owner/:name/languages", Op::About(AboutOp::GetLanguages), &[]),
106 route("GET", "/repos/:owner/:name/contributors", Op::About(AboutOp::ListContributors), &[]),
107 route("GET", "/repos/:owner/:name/license", Op::About(AboutOp::GetLicense), &[]),
108 // Releases: `latest` and `tags/…` before an id.
109 route("GET", "/repos/:owner/:name/releases", Op::About(AboutOp::ListReleases), &[]),
110 route("POST", "/repos/:owner/:name/releases", Op::About(AboutOp::CreateRelease), &[]),
111 route("GET", "/repos/:owner/:name/releases/latest", Op::About(AboutOp::GetLatestRelease), &[]),
112 route("GET", "/repos/:owner/:name/releases/tags/:tag", Op::About(AboutOp::GetReleaseByTag), &[]),
113 route("GET", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::GetRelease), &[]),
114 route("PATCH", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::UpdateRelease), &[]),
115 route("DELETE", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::DeleteRelease), &[]),
API: pinned projects over REST and MCP116 // Your pinned projects in a workspace, in your order.
117 route("GET", "/user/pinned_projects/:workspace", Op::ListPinnedProjects, &[]),
118 route("PUT", "/user/pinned_projects/:workspace", Op::ReorderPinnedProjects, &[]),
119 route("PUT", "/user/pinned_projects/:workspace/:project", Op::PinProject, &[]),
120 route("DELETE", "/user/pinned_projects/:workspace/:project", Op::UnpinProject, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look121 route("PATCH", "/user/repository_invitations/:id", Op::AcceptRepoInvitation, &[]),
122 route("DELETE", "/user/repository_invitations/:id", Op::DeclineRepoInvitation, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily123 route("PATCH", "/workspaces/:workspace", Op::UpdateWorkspace, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97124 // A workspace's projects: what each is, where it runs, its links.
125 route("GET", "/workspaces/:workspace/projects", Op::ListProjects, &[]),
126 route("GET", "/workspaces/:workspace/projects/:project", Op::GetProject, &[]),
127 route("PATCH", "/workspaces/:workspace/projects/:project", Op::UpdateProject, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily128 route("PUT", "/workspaces/:workspace/base_permission", Op::SetBasePermission, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look129 route(
130 "GET",
131 "/workspaces/:workspace/outside_collaborators",
132 Op::ListOutsideCollaborators,
133 &[],
134 ),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar135 // Teams: a workspace's groups of members, with roles on repositories.
136 route("GET", "/workspaces/:workspace/teams", Op::ListTeams, &[("q", "query")]),
137 route("POST", "/workspaces/:workspace/teams", Op::CreateTeam, &[]),
138 route("GET", "/workspaces/:workspace/teams/:team", Op::GetTeam, &[]),
139 route("PATCH", "/workspaces/:workspace/teams/:team", Op::UpdateTeam, &[]),
140 route("DELETE", "/workspaces/:workspace/teams/:team", Op::DeleteTeam, &[]),
141 route(
142 "GET",
143 "/workspaces/:workspace/teams/:team/members",
144 Op::ListTeamMembers,
145 &[("include_child_teams", "include_child_teams")],
146 ),
147 route("PUT", "/workspaces/:workspace/teams/:team/members/:username", Op::SetTeamMember, &[]),
148 route("DELETE", "/workspaces/:workspace/teams/:team/members/:username", Op::RemoveTeamMember, &[]),
149 route("GET", "/workspaces/:workspace/teams/:team/teams", Op::ListChildTeams, &[]),
150 route("GET", "/workspaces/:workspace/teams/:team/repos", Op::ListTeamRepos, &[]),
151 route("PUT", "/workspaces/:workspace/teams/:team/repos/:repo", Op::SetTeamRepo, &[]),
152 route("DELETE", "/workspaces/:workspace/teams/:team/repos/:repo", Op::RemoveTeamRepo, &[]),
153 route(
154 "PUT",
155 "/workspaces/:workspace/teams/:team/review_assignment",
156 Op::SetTeamReviewAssignment,
157 &[],
158 ),
159 route("GET", "/workspaces/:workspace/members/:username/teams", Op::ListUserTeams, &[]),
Usage, Billing settings and prepaid AI credit; fixes from the UX audit160 // A workspace's billing: usage, budget, AI credit and invoices.
161 route(
162 "GET",
163 "/workspaces/:workspace/usage",
164 Op::GetUsage,
165 &[("from", "from"), ("until", "until"), ("products", "products"), ("projects", "projects"), ("group_by", "group_by")],
166 ),
167 route("GET", "/workspaces/:workspace/budget", Op::GetBudget, &[]),
168 route("PUT", "/workspaces/:workspace/budget", Op::SetBudget, &[]),
169 route("GET", "/workspaces/:workspace/ai_credit", Op::GetAiCredit, &[]),
170 route("POST", "/workspaces/:workspace/ai_credit/checkout", Op::BuyAiCredit, &[]),
171 route("GET", "/workspaces/:workspace/invoices", Op::ListInvoices, &[]),
172 route("GET", "/workspaces/:workspace/billing_details", Op::GetBillingDetails, &[]),
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens173 // The AI Gateway's log of a workspace's requests.
174 route("GET", "/workspaces/:workspace/gateway/requests", Op::ListGatewayRequests, &[("limit", "limit"), ("before", "before")]),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar175 // Code owners: the CODEOWNERS file, checked.
176 route("GET", "/repos/:owner/:name/codeowners/errors", Op::GetCodeownersErrors, &[("ref", "ref")]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily177 // Security alerts: secrets and vulnerable dependencies.
178 route(
179 "GET",
180 "/repos/:owner/:name/security/alerts",
181 Op::ListSecurityAlerts,
182 &[("state", "state"), ("kind", "kind")],
183 ),
184 route("POST", "/repos/:owner/:name/security/alerts/:id/dismiss", Op::DismissSecurityAlert, &[]),
185 route("POST", "/repos/:owner/:name/security/alerts/:id/reopen", Op::ReopenSecurityAlert, &[]),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar186 // The security suite: secret scanning, code scanning, vulnerability
187 // alerts and the supply chain, at the common addresses.
188 route("GET", "/repos/:owner/:name/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
189 route("GET", "/workspaces/:workspace/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
190 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::GetSecretAlert), &[]),
191 route("PATCH", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::UpdateSecretAlert), &[]),
192 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id/locations", Op::Security(SecurityOp::ListSecretLocations), &[]),
193 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/bypass", Op::Security(SecurityOp::BypassPushProtection), &[]),
194 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/validity", Op::Security(SecurityOp::CheckSecretValidity), &[]),
195 route("GET", "/workspaces/:workspace/secret-scanning/bypass-requests", Op::Security(SecurityOp::ListBypassRequests), &[("state", "state"), ("repo", "repo")]),
196 route("PATCH", "/workspaces/:workspace/secret-scanning/bypass-requests/:id", Op::Security(SecurityOp::ReviewBypassRequest), &[]),
197 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
198 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
199 route("GET", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
200 route("GET", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
201 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
202 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
203 route("PATCH", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
204 route("PATCH", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
205 route("DELETE", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
206 route("DELETE", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
207 route("GET", "/repos/:owner/:name/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
208 route("GET", "/workspaces/:workspace/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
209 route("GET", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::GetCodeAlert), &[]),
210 route("PATCH", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::UpdateCodeAlert), &[]),
211 route("GET", "/repos/:owner/:name/code-scanning/analyses", Op::Security(SecurityOp::ListAnalyses), &[]),
212 route("POST", "/repos/:owner/:name/code-scanning/sarifs", Op::Security(SecurityOp::UploadSarif), &[]),
213 route("GET", "/repos/:owner/:name/code-scanning/sarifs/:id", Op::Security(SecurityOp::GetSarifUpload), &[]),
214 route("GET", "/repos/:owner/:name/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
215 route("GET", "/workspaces/:workspace/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
216 route("GET", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::GetVulnerabilityAlert), &[]),
217 route("PATCH", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::UpdateVulnerabilityAlert), &[]),
218 route("POST", "/repos/:owner/:name/security/alerts/:id/fix", Op::Security(SecurityOp::FixAlert), &[]),
219 route("GET", "/repos/:owner/:name/dependency-graph", Op::Security(SecurityOp::GetDependencyGraph), &[]),
220 route("GET", "/repos/:owner/:name/dependency-graph/sbom", Op::Security(SecurityOp::GetSbom), &[]),
221 route("GET", "/repos/:owner/:name/dependency-graph/compare/:basehead", Op::Security(SecurityOp::CompareDependencies), &[]),
222 route("GET", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::GetSettings), &[]),
223 route("PATCH", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::UpdateSettings), &[]),
224 route("GET", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::GetWorkspaceSettings), &[]),
225 route("PATCH", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::UpdateWorkspaceSettings), &[]),
226 route("GET", "/workspaces/:workspace/security/overview", Op::Security(SecurityOp::GetOverview), &[("days", "days")]),
Agents as a team: lifecycle, merge queue, billing and a new shell227 route("GET", "/repos", Op::ListRepos, &[("q", "query")]),
Search across all of g1t, Explore, and a command palette228 route(
229 "GET",
230 "/search",
231 Op::Search,
232 &[("q", "query"), ("type", "type"), ("page", "page"), ("per_page", "per_page")],
233 ),
Agents as a team: lifecycle, merge queue, billing and a new shell234 route("POST", "/repos", Op::CreateRepo, &[]),
235 route("GET", "/repos/:owner/:name", Op::GetRepo, &[]),
236 route("PATCH", "/repos/:owner/:name", Op::UpdateRepo, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look237 route("POST", "/repos/:owner/:name/transfer", Op::TransferRepo, &[]),
238 route("DELETE", "/repos/:owner/:name", Op::DeleteRepo, &[]),
239 route(
240 "GET",
241 "/workspaces/:workspace/repos/deleted",
242 Op::ListDeletedRepos,
243 &[],
244 ),
245 route("POST", "/repos/:owner/:name/restore", Op::RestoreRepo, &[]),
246 route("POST", "/repos/:owner/:name/purge", Op::PurgeRepo, &[]),
247 route("POST", "/repos/:owner/:name/rename", Op::RenameRepo, &[]),
248 route("POST", "/repos/:owner/:name/archive", Op::ArchiveRepo, &[]),
249 route("POST", "/repos/:owner/:name/unarchive", Op::UnarchiveRepo, &[]),
250 route(
251 "POST",
252 "/repos/:owner/:name/visibility",
253 Op::SetRepoVisibility,
254 &[],
255 ),
256 route(
257 "POST",
258 "/repos/:owner/:name/branches/:branch/rename",
259 Op::RenameBranch,
260 &[],
261 ),
Agents as a team: lifecycle, merge queue, billing and a new shell262 route(
263 "GET",
264 "/repos/:owner/:name/settings",
265 Op::GetRepoSettings,
266 &[],
267 ),
268 route(
269 "PATCH",
270 "/repos/:owner/:name/settings",
271 Op::UpdateRepoSettings,
272 &[],
273 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents274 route("GET", "/repos/:owner/:name/check-names", Op::ListCheckNames, &[]),
Merge checks: statuses and check runs on every commit275 // Checks: GitHub's addresses for statuses, check runs and check suites.
276 route("POST", "/repos/:owner/:name/statuses/:sha", Op::Checks(ChecksOp::CreateCommitStatus), &[]),
277 route("GET", "/repos/:owner/:name/commits/:ref/statuses", Op::Checks(ChecksOp::ListCommitStatuses), &[]),
278 route("GET", "/repos/:owner/:name/commits/:ref/status", Op::Checks(ChecksOp::GetCombinedStatus), &[]),
279 route(
280 "GET",
281 "/repos/:owner/:name/commits/:ref/check-runs",
282 Op::Checks(ChecksOp::ListCheckRunsForRef),
283 &[("check_name", "check_name"), ("status", "status"), ("app", "app"), ("filter", "filter")],
284 ),
285 route(
286 "GET",
287 "/repos/:owner/:name/commits/:ref/check-suites",
288 Op::Checks(ChecksOp::ListCheckSuitesForRef),
289 &[("app", "app"), ("check_name", "check_name")],
290 ),
291 route("POST", "/repos/:owner/:name/check-runs", Op::Checks(ChecksOp::CreateCheckRun), &[]),
292 route("GET", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::GetCheckRun), &[]),
293 route("PATCH", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::UpdateCheckRun), &[]),
294 route("GET", "/repos/:owner/:name/check-runs/:id/annotations", Op::Checks(ChecksOp::ListCheckRunAnnotations), &[]),
295 route("POST", "/repos/:owner/:name/check-runs/:id/rerequest", Op::Checks(ChecksOp::RerequestCheckRun), &[]),
296 route("GET", "/repos/:owner/:name/check-suites/:id", Op::Checks(ChecksOp::GetCheckSuite), &[]),
297 route("POST", "/repos/:owner/:name/check-suites/:id/rerequest", Op::Checks(ChecksOp::RerequestCheckSuite), &[]),
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge298 // Rulesets: a repository's, a workspace's, the rules of one branch,
299 // and how they judged pushes and merges.
300 route("GET", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::ListRepoRulesets), &[("include_parents", "include_parents")]),
301 route("POST", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::CreateRepoRuleset), &[]),
302 route("GET", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::GetRepoRuleset), &[]),
303 route("PUT", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::UpdateRepoRuleset), &[]),
304 route("DELETE", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::DeleteRepoRuleset), &[]),
305 route("GET", "/repos/:owner/:name/rules/branches/:branch", Op::Rules(RulesOp::GetBranchRules), &[("target", "target")]),
306 route(
307 "GET",
308 "/repos/:owner/:name/rules/evaluations",
309 Op::Rules(RulesOp::ListRuleEvaluations),
310 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
311 ),
312 route("GET", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::ListWorkspaceRulesets), &[]),
313 route("POST", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::CreateWorkspaceRuleset), &[]),
314 route("GET", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::GetWorkspaceRuleset), &[]),
315 route("PUT", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::UpdateWorkspaceRuleset), &[]),
316 route("DELETE", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::DeleteWorkspaceRuleset), &[]),
317 route(
318 "GET",
319 "/workspaces/:workspace/rules/evaluations",
320 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
321 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
322 ),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97323 // Deployments wherever they run, their statuses, and environments.
324 route(
325 "GET",
326 "/repos/:owner/:name/deployments",
327 Op::Deployments(DeploymentsOp::ListDeployments),
328 &[("environment", "environment"), ("ref", "ref"), ("sha", "sha"), ("task", "task"), ("state", "state"), ("source", "source"), ("creator", "creator"), ("page", "page"), ("per_page", "per_page")],
329 ),
330 route("POST", "/repos/:owner/:name/deployments", Op::Deployments(DeploymentsOp::CreateDeployment), &[]),
331 route("GET", "/repos/:owner/:name/deployments/:id", Op::Deployments(DeploymentsOp::GetDeployment), &[]),
332 route("GET", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::ListDeploymentStatuses), &[]),
333 route("POST", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::CreateDeploymentStatus), &[]),
334 route("GET", "/repos/:owner/:name/environments", Op::Deployments(DeploymentsOp::ListEnvironments), &[]),
335 route("GET", "/repos/:owner/:name/environments/:environment", Op::Deployments(DeploymentsOp::GetEnvironment), &[]),
Merge branch 'worktree-agent-a3abfcce648e87dca'336 // Environments' protection rules, and the runs they hold.
337 route("PUT", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::UpdateEnvironment), &[]),
338 route("DELETE", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::DeleteEnvironment), &[]),
339 route(
340 "GET",
341 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
342 Op::Protection(ProtectionOp::GetPendingDeployments),
343 &[],
344 ),
345 route(
346 "POST",
347 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
348 Op::Protection(ProtectionOp::ReviewPendingDeployments),
349 &[],
350 ),
351 route("POST", "/repos/:owner/:name/actions/runs/:id/approve", Op::Protection(ProtectionOp::ApproveWorkflowRun), &[]),
352 route("GET", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::GetWorkflowPermissions), &[]),
353 route("PUT", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::SetWorkflowPermissions), &[]),
354 route(
355 "GET",
356 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
357 Op::Protection(ProtectionOp::GetForkPrApproval),
358 &[],
359 ),
360 route(
361 "PUT",
362 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
363 Op::Protection(ProtectionOp::SetForkPrApproval),
364 &[],
365 ),
366 route("POST", "/repos/:owner/:name/dispatches", Op::Protection(ProtectionOp::CreateRepositoryDispatch), &[]),
367 route(
368 "GET",
369 "/workspaces/:workspace/actions/permissions/workflow",
370 Op::Protection(ProtectionOp::GetWorkspaceWorkflowPermissions),
371 &[],
372 ),
373 route(
374 "PUT",
375 "/workspaces/:workspace/actions/permissions/workflow",
376 Op::Protection(ProtectionOp::SetWorkspaceWorkflowPermissions),
377 &[],
378 ),
Agents as a team: lifecycle, merge queue, billing and a new shell379 route("GET", "/repos/:owner/:name/queue", Op::GetMergeQueue, &[]),
API and MCP server in Rust; a public index at the API root380 route(
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request381 "POST",
382 "/repos/:owner/:name/pulls/:number/messages",
383 Op::MessageAgent,
384 &[],
385 ),
386 route(
387 "POST",
388 "/repos/:owner/:name/pulls/:number/messages/take",
389 Op::TakeMessages,
390 &[],
391 ),
392 route(
Docs worth reading, and kept that way393 "POST",
394 "/repos/:owner/:name/messages/:id/answer",
395 Op::AnswerMessage,
396 &[],
397 ),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains398 route("POST", "/repos/:owner/:name/memory", Op::Remember, &[]),
399 route(
400 "GET",
401 "/repos/:owner/:name/memory",
402 Op::Recall,
403 &[("q", "query"), ("limit", "limit")],
404 ),
Docs worth reading, and kept that way405 route(
API and MCP server in Rust; a public index at the API root406 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell407 "/repos/:owner/:name/events",
API and MCP server in Rust; a public index at the API root408 Op::ListEvents,
409 &[("before", "before")],
410 ),
Agents as a team: lifecycle, merge queue, billing and a new shell411 route("GET", "/repos/:owner/:name/labels", Op::ListLabels, &[]),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar412 route("POST", "/repos/:owner/:name/labels", Op::CreateLabel, &[]),
413 route("POST", "/repos/:owner/:name/labels/defaults", Op::AddDefaultLabels, &[]),
414 route("PATCH", "/repos/:owner/:name/labels/:label", Op::UpdateLabel, &[]),
415 route("DELETE", "/repos/:owner/:name/labels/:label", Op::DeleteLabel, &[]),
416 route("GET", "/repos/:owner/:name/issues/:number/labels", Op::ListIssueLabels, &[]),
417 route("POST", "/repos/:owner/:name/issues/:number/labels", Op::AddIssueLabels, &[]),
418 route("PUT", "/repos/:owner/:name/issues/:number/labels", Op::SetIssueLabels, &[]),
419 route("DELETE", "/repos/:owner/:name/issues/:number/labels", Op::RemoveIssueLabels, &[]),
420 route("DELETE", "/repos/:owner/:name/issues/:number/labels/:label", Op::RemoveIssueLabels, &[]),
421 route("GET", "/repos/:owner/:name/milestones", Op::ListMilestones, &[("state", "state")]),
422 route("POST", "/repos/:owner/:name/milestones", Op::CreateMilestone, &[]),
423 route("GET", "/repos/:owner/:name/milestones/:milestone", Op::GetMilestone, &[]),
424 route("PATCH", "/repos/:owner/:name/milestones/:milestone", Op::UpdateMilestone, &[]),
425 route("DELETE", "/repos/:owner/:name/milestones/:milestone", Op::DeleteMilestone, &[]),
API and MCP server in Rust; a public index at the API root426 route(
427 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell428 "/repos/:owner/:name/issues",
API and MCP server in Rust; a public index at the API root429 Op::ListIssues,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar430 &[("state", "state"), ("label", "label"), ("milestone", "milestone")],
API and MCP server in Rust; a public index at the API root431 ),
Agents as a team: lifecycle, merge queue, billing and a new shell432 route("POST", "/repos/:owner/:name/issues", Op::CreateIssue, &[]),
API and MCP server in Rust; a public index at the API root433 route(
434 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell435 "/repos/:owner/:name/issues/:number",
API and MCP server in Rust; a public index at the API root436 Op::GetIssue,
437 &[],
438 ),
439 route(
440 "PATCH",
Agents as a team: lifecycle, merge queue, billing and a new shell441 "/repos/:owner/:name/issues/:number",
API and MCP server in Rust; a public index at the API root442 Op::UpdateIssue,
443 &[],
444 ),
445 route(
446 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell447 "/repos/:owner/:name/issues/:number/close",
API and MCP server in Rust; a public index at the API root448 Op::CloseIssue,
449 &[],
450 ),
451 route(
452 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell453 "/repos/:owner/:name/issues/:number/reopen",
API and MCP server in Rust; a public index at the API root454 Op::ReopenIssue,
455 &[],
456 ),
457 route(
458 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell459 "/repos/:owner/:name/issues/:number/assign",
460 Op::AssignIssue,
461 &[],
462 ),
Integrations: your own model provider, alerts that open issues, tickets agents read463 route(
464 "POST",
465 "/repos/:owner/:name/issues/import",
466 Op::ImportIssue,
467 &[],
468 ),
469 route(
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step470 "POST",
471 "/repos/:owner/:name/issues/delegate",
472 Op::Delegate,
473 &[],
474 ),
475 route(
Integrations: your own model provider, alerts that open issues, tickets agents read476 "GET",
477 "/repos/:owner/:name/context",
478 Op::GetContext,
479 &[("reference", "reference")],
480 ),
481 route(
482 "GET",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API483 "/workspaces/:workspace/context/search",
484 Op::SearchContext,
485 &[("q", "query"), ("project", "project"), ("kinds", "kinds"), ("limit", "limit")],
486 ),
487 route(
488 "GET",
489 "/workspaces/:workspace/context/:kind/:id",
490 Op::GetEntity,
491 &[],
492 ),
493 route(
494 "GET",
Integrations: your own model provider, alerts that open issues, tickets agents read495 "/workspaces/:workspace/integrations",
496 Op::ListIntegrations,
497 &[],
498 ),
499 route(
500 "POST",
501 "/workspaces/:workspace/integrations",
502 Op::ConnectIntegration,
503 &[],
504 ),
505 route(
Models per workspace: several providers, routed by kind of work506 "GET",
Webhooks: every event, to your own addresses, signed and retried507 "/repos/:owner/:name/hooks",
508 Op::ListWebhooks,
509 &[],
510 ),
511 route(
512 "POST",
513 "/repos/:owner/:name/hooks",
514 Op::CreateWebhook,
515 &[],
516 ),
517 route(
518 "PATCH",
519 "/repos/:owner/:name/hooks/:id",
520 Op::UpdateWebhook,
521 &[],
522 ),
523 route(
524 "DELETE",
525 "/repos/:owner/:name/hooks/:id",
526 Op::DeleteWebhook,
527 &[],
528 ),
529 route(
530 "POST",
531 "/repos/:owner/:name/hooks/:id/pings",
532 Op::PingWebhook,
533 &[],
534 ),
535 route(
536 "GET",
537 "/repos/:owner/:name/hooks/:id/deliveries",
538 Op::ListWebhookDeliveries,
539 &[],
540 ),
541 route(
542 "POST",
543 "/repos/:owner/:name/hooks/:id/deliveries/:delivery/redeliver",
544 Op::RedeliverWebhook,
545 &[],
546 ),
547 route(
548 "GET",
549 "/workspaces/:workspace/hooks",
550 Op::ListWebhooks,
551 &[],
552 ),
553 route(
554 "POST",
555 "/workspaces/:workspace/hooks",
556 Op::CreateWebhook,
557 &[],
558 ),
559 route(
560 "PATCH",
561 "/workspaces/:workspace/hooks/:id",
562 Op::UpdateWebhook,
563 &[],
564 ),
565 route(
566 "DELETE",
567 "/workspaces/:workspace/hooks/:id",
568 Op::DeleteWebhook,
569 &[],
570 ),
571 route(
572 "POST",
573 "/workspaces/:workspace/hooks/:id/pings",
574 Op::PingWebhook,
575 &[],
576 ),
577 route(
578 "GET",
579 "/workspaces/:workspace/hooks/:id/deliveries",
580 Op::ListWebhookDeliveries,
581 &[],
582 ),
583 route(
584 "POST",
585 "/workspaces/:workspace/hooks/:id/deliveries/:delivery/redeliver",
586 Op::RedeliverWebhook,
587 &[],
588 ),
589 route(
590 "GET",
Models per workspace: several providers, routed by kind of work591 "/workspaces/:workspace/model-routes",
592 Op::GetModelRoutes,
593 &[],
594 ),
595 route(
596 "PUT",
597 "/workspaces/:workspace/model-routes",
598 Op::SetModelRoutes,
599 &[],
600 ),
601 route(
AI Gateway: OpenAI's format, open models, and your own providers602 "PATCH",
603 "/workspaces/:workspace/integrations/:id",
604 Op::UpdateIntegration,
605 &[],
606 ),
607 route(
Integrations: your own model provider, alerts that open issues, tickets agents read608 "DELETE",
609 "/workspaces/:workspace/integrations/:id",
610 Op::DisconnectIntegration,
611 &[],
612 ),
613 route(
614 "POST",
615 "/workspaces/:workspace/integrations/:id/test",
616 Op::TestIntegration,
617 &[],
618 ),
Automations: rules in .g1t/automations that act when something happens619 route(
620 "GET",
GitHub Actions on g1t, part two: running workflows621 "/repos/:owner/:name/actions/workflows",
622 Op::ListWorkflows,
623 &[],
624 ),
625 route(
626 "GET",
627 "/repos/:owner/:name/actions/workflows/:workflow/runs",
628 Op::ListWorkflowRuns,
629 &[("branch", "branch"), ("event", "event"), ("per_page", "limit")],
630 ),
631 route(
632 "POST",
633 "/repos/:owner/:name/actions/workflows/:workflow/dispatches",
634 Op::DispatchWorkflow,
635 &[],
636 ),
637 route(
638 "PATCH",
639 "/repos/:owner/:name/actions/workflows/:workflow",
640 Op::UpdateWorkflow,
641 &[],
642 ),
643 route(
644 "PUT",
645 "/repos/:owner/:name/actions/workflows/:workflow/enable",
646 Op::UpdateWorkflow,
647 &[],
648 ),
649 route(
650 "PUT",
651 "/repos/:owner/:name/actions/workflows/:workflow/disable",
652 Op::UpdateWorkflow,
653 &[],
654 ),
655 route(
656 "GET",
657 "/repos/:owner/:name/actions/runs",
658 Op::ListWorkflowRuns,
659 &[("workflow", "workflow"), ("branch", "branch"), ("event", "event"), ("pull", "pull"), ("head_sha", "sha"), ("per_page", "limit")],
660 ),
661 route(
662 "GET",
663 "/repos/:owner/:name/actions/runs/:id",
664 Op::GetWorkflowRun,
665 &[],
666 ),
667 route(
668 "POST",
669 "/repos/:owner/:name/actions/runs/:id/cancel",
670 Op::CancelWorkflowRun,
671 &[],
672 ),
673 route(
674 "POST",
675 "/repos/:owner/:name/actions/runs/:id/rerun",
676 Op::RerunWorkflowRun,
677 &[],
678 ),
679 route(
680 "POST",
681 "/repos/:owner/:name/actions/runs/:id/rerun-failed-jobs",
682 Op::RerunWorkflowRun,
683 &[],
684 ),
685 route(
686 "GET",
687 "/repos/:owner/:name/actions/jobs/:job/logs",
688 Op::GetJobLogs,
689 &[("after", "after")],
690 ),
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2691 // Artifacts, at GitHub's addresses. `…/zip` answers with a redirect to
692 // a signed link (lib.rs).
693 route("GET", "/repos/:owner/:name/actions/artifacts", Op::Artifacts(ArtifactsOp::ListArtifacts), &[("name", "name"), ("page", "page"), ("per_page", "per_page")]),
694 route("GET", "/repos/:owner/:name/actions/runs/:id/artifacts", Op::Artifacts(ArtifactsOp::ListRunArtifacts), &[("name", "name")]),
695 route("GET", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::GetArtifact), &[]),
696 route("GET", "/repos/:owner/:name/actions/artifacts/:id/zip", Op::Artifacts(ArtifactsOp::DownloadArtifact), &[]),
697 route("DELETE", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::DeleteArtifact), &[]),
698 route("GET", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::GetArtifactRetention), &[]),
699 route("PUT", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::SetArtifactRetention), &[]),
GitHub Actions on g1t, part two: running workflows700 route(
701 "GET",
702 "/repos/:owner/:name/actions/secrets",
703 Op::ListActionsSecrets,
704 &[],
705 ),
706 route(
707 "PUT",
708 "/repos/:owner/:name/actions/secrets/:setting",
709 Op::SetActionsSecret,
710 &[],
711 ),
712 route(
713 "DELETE",
714 "/repos/:owner/:name/actions/secrets/:setting",
715 Op::DeleteActionsSecret,
716 &[],
717 ),
718 route(
719 "GET",
720 "/repos/:owner/:name/actions/variables",
721 Op::ListActionsVariables,
722 &[],
723 ),
724 route(
725 "POST",
726 "/repos/:owner/:name/actions/variables",
727 Op::SetActionsVariable,
728 &[],
729 ),
730 route(
731 "PATCH",
732 "/repos/:owner/:name/actions/variables/:setting",
733 Op::SetActionsVariable,
734 &[],
735 ),
736 route(
737 "DELETE",
738 "/repos/:owner/:name/actions/variables/:setting",
739 Op::DeleteActionsVariable,
740 &[],
741 ),
742 route(
743 "GET",
744 "/workspaces/:workspace/actions/secrets",
745 Op::ListActionsSecrets,
746 &[],
747 ),
748 route(
749 "PUT",
750 "/workspaces/:workspace/actions/secrets/:setting",
751 Op::SetActionsSecret,
752 &[],
753 ),
754 route(
755 "DELETE",
756 "/workspaces/:workspace/actions/secrets/:setting",
757 Op::DeleteActionsSecret,
758 &[],
759 ),
760 route(
761 "GET",
762 "/workspaces/:workspace/actions/variables",
763 Op::ListActionsVariables,
764 &[],
765 ),
766 route(
767 "POST",
768 "/workspaces/:workspace/actions/variables",
769 Op::SetActionsVariable,
770 &[],
771 ),
772 route(
773 "PATCH",
774 "/workspaces/:workspace/actions/variables/:setting",
775 Op::SetActionsVariable,
776 &[],
777 ),
778 route(
779 "DELETE",
780 "/workspaces/:workspace/actions/variables/:setting",
781 Op::DeleteActionsVariable,
782 &[],
783 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents784 // Self-hosted runners: a repository's own, or a workspace's.
785 route("GET", "/repos/:owner/:name/actions/runners", Op::ListRunners, &[]),
786 route("POST", "/repos/:owner/:name/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
787 route("DELETE", "/repos/:owner/:name/actions/runners/:id", Op::RemoveRunner, &[]),
788 route("GET", "/repos/:owner/:name/actions/runner-settings", Op::GetRunnerSettings, &[]),
789 route("PATCH", "/repos/:owner/:name/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
790 route("GET", "/workspaces/:workspace/actions/runners", Op::ListRunners, &[]),
791 route("POST", "/workspaces/:workspace/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
792 route("DELETE", "/workspaces/:workspace/actions/runners/:id", Op::RemoveRunner, &[]),
793 route("GET", "/workspaces/:workspace/actions/runner-settings", Op::GetRunnerSettings, &[]),
794 route("PATCH", "/workspaces/:workspace/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
795 route("GET", "/workspaces/:workspace/actions/runner-groups", Op::ListRunnerGroups, &[]),
796 route("POST", "/workspaces/:workspace/actions/runner-groups", Op::CreateRunnerGroup, &[]),
797 route("PATCH", "/workspaces/:workspace/actions/runner-groups/:id", Op::UpdateRunnerGroup, &[]),
798 route("DELETE", "/workspaces/:workspace/actions/runner-groups/:id", Op::DeleteRunnerGroup, &[]),
Agents as a team: lifecycle, merge queue, billing and a new shell799 route("POST", "/repos/:owner/:name/plans", Op::PlanWork, &[]),
800 route("GET", "/repos/:owner/:name/plans/:plan", Op::GetPlan, &[]),
801 route(
802 "POST",
803 "/repos/:owner/:name/plans/:plan/apply",
804 Op::ApplyPlan,
805 &[],
806 ),
807 route(
808 "POST",
809 "/repos/:owner/:name/issues/:number/comments",
API and MCP server in Rust; a public index at the API root810 Op::AddComment,
811 &[],
812 ),
813 route(
814 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell815 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root816 Op::ListPullRequests,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar817 &[("state", "state"), ("label", "label"), ("milestone", "milestone"), ("base", "base")],
API and MCP server in Rust; a public index at the API root818 ),
819 route(
820 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell821 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root822 Op::CreatePullRequest,
823 &[],
824 ),
825 route(
826 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell827 "/repos/:owner/:name/pulls/:number",
API and MCP server in Rust; a public index at the API root828 Op::GetPullRequest,
829 &[],
830 ),
831 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar832 "PATCH",
833 "/repos/:owner/:name/pulls/:number",
834 Op::UpdatePullRequest,
835 &[],
836 ),
837 route(
API and MCP server in Rust; a public index at the API root838 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell839 "/repos/:owner/:name/pulls/:number/changes",
API and MCP server in Rust; a public index at the API root840 Op::GetPullRequestChanges,
841 &[],
842 ),
843 route(
Acceptance checks in sandboxes, line comments and review verdicts844 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell845 "/repos/:owner/:name/pulls/:number/reviews",
Acceptance checks in sandboxes, line comments and review verdicts846 Op::ReviewPullRequest,
847 &[],
848 ),
849 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar850 "POST",
851 "/repos/:owner/:name/pulls/:number/requested_reviewers",
852 Op::RequestReviewers,
853 &[],
854 ),
855 route(
856 "DELETE",
857 "/repos/:owner/:name/pulls/:number/requested_reviewers",
858 Op::RemoveRequestedReviewers,
859 &[],
860 ),
861 route(
API and MCP server in Rust; a public index at the API root862 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell863 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root864 Op::ReadSession,
865 &[("after", "after")],
866 ),
867 route(
868 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell869 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root870 Op::RecordSession,
871 &[],
872 ),
873 route(
874 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell875 "/repos/:owner/:name/pulls/:number/ready",
API and MCP server in Rust; a public index at the API root876 Op::MarkPullRequestReady,
877 &[],
878 ),
879 route(
880 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell881 "/repos/:owner/:name/pulls/:number/close",
API and MCP server in Rust; a public index at the API root882 Op::ClosePullRequest,
883 &[],
884 ),
885 route(
886 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell887 "/repos/:owner/:name/pulls/:number/merge",
API and MCP server in Rust; a public index at the API root888 Op::MergePullRequest,
889 &[],
890 ),
891];
892
893impl Route {
894 /// The names of the route's path parameters, in order.
895 pub fn params(&self) -> impl Iterator<Item = &'static str> {
896 self.path
897 .split('/')
898 .filter_map(|segment| segment.strip_prefix(':'))
899 }
900
901 /// The values of the path parameters, if `path` is this route's.
902 fn matches<'a>(&self, path: &'a str) -> Option<Vec<(&'static str, &'a str)>> {
903 let mut values = Vec::new();
904 let mut actual = path.trim_end_matches('/').split('/');
905 for expected in self.path.split('/') {
906 let segment = actual.next()?;
907 match expected.strip_prefix(':') {
908 Some(name) if !segment.is_empty() => values.push((name, segment)),
909 Some(_) => return None,
910 None if expected == segment => {}
911 None => return None,
912 }
913 }
914 actual.next().is_none().then_some(values)
915 }
916}
917
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look918/// A path segment with its `%XX` escapes decoded; as given when that is not
919/// UTF-8.
920fn percent_decoded(segment: &str) -> String {
921 let bytes = segment.as_bytes();
922 let mut out = Vec::with_capacity(bytes.len());
923 let mut i = 0;
924 while i < bytes.len() {
925 let escaped = (bytes[i] == b'%')
926 .then(|| segment.get(i + 1..i + 3))
927 .flatten()
928 .filter(|hex| hex.bytes().all(|byte| byte.is_ascii_hexdigit()))
929 .and_then(|hex| u8::from_str_radix(hex, 16).ok());
930 match escaped {
931 Some(byte) => {
932 out.push(byte);
933 i += 3;
934 }
935 None => {
936 out.push(bytes[i]);
937 i += 1;
938 }
939 }
940 }
941 String::from_utf8(out).unwrap_or_else(|_| segment.to_owned())
942}
943
API and MCP server in Rust; a public index at the API root944/// The route for a request, and the operation input it describes.
945///
946/// The input is the JSON body, overlaid with the query parameters the route
947/// reads and then with what the path names: `owner` and `name` become
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar948/// `repo`, as does a team's `repo` with its `workspace`, and `number`
949/// becomes an integer.
API and MCP server in Rust; a public index at the API root950pub fn resolve(
951 method: &str,
952 path: &str,
953 query: &[(String, String)],
954 body: Value,
955) -> Option<(&'static Route, Value)> {
956 let (route, params) = ROUTES
957 .iter()
958 .filter(|route| route.method == method)
959 .find_map(|route| Some((route, route.matches(path)?)))?;
960
961 let mut input = match body {
962 Value::Object(fields) => fields,
963 _ => Map::new(),
964 };
965 for (name, key) in route.query {
966 if let Some((_, value)) = query.iter().find(|(query_name, _)| query_name == name) {
967 input.insert((*key).to_owned(), Value::String(value.clone()));
968 }
969 }
970 let param = |wanted: &str| {
971 params
972 .iter()
973 .find(|(name, _)| *name == wanted)
974 .map(|(_, value)| *value)
975 };
976 if let (Some(owner), Some(name)) = (param("owner"), param("name")) {
977 input.insert("repo".to_owned(), Value::String(format!("{owner}/{name}")));
978 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97979 // Every other name the path gives, under that name; the ones below that
980 // need more (a repository, a number, an encoded name) are set after.
981 for (key, value) in &params {
982 if !matches!(*key, "owner" | "name") {
983 input.insert((*key).to_owned(), Value::String(percent_decoded(value)));
Docs worth reading, and kept that way984 }
Agents as a team: lifecycle, merge queue, billing and a new shell985 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar986 // A repository of a team's workspace, named by itself.
987 if let (Some(workspace), Some(name)) = (param("workspace"), param("repo")) {
988 input.insert("repo".to_owned(), Value::String(format!("{workspace}/{name}")));
989 }
990 // A branch name may hold slashes, sent URL-encoded as one segment, and
991 // a label's name spaces.
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look992 if let Some(branch) = param("branch") {
993 input.insert("branch".to_owned(), Value::String(percent_decoded(branch)));
994 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97995 // An environment's name may hold slashes and spaces, URL-encoded.
996 if let Some(environment) = param("environment") {
997 input.insert("environment".to_owned(), Value::String(percent_decoded(environment)));
998 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar999 if let Some(label) = param("label") {
1000 input.insert("label".to_owned(), Value::String(percent_decoded(label)));
1001 }
1002 if let Some(milestone) = param("milestone") {
1003 // Not a number: zero, which no milestone has.
1004 input.insert("milestone".to_owned(), milestone.parse::<u32>().unwrap_or(0).into());
1005 }
GitHub Actions on g1t, part two: running workflows1006 // GitHub says some things with the path alone.
1007 if route.path.ends_with("/enable") || route.path.ends_with("/disable") {
1008 input.insert("enabled".to_owned(), Value::Bool(route.path.ends_with("/enable")));
1009 }
1010 if route.path.ends_with("/rerun-failed-jobs") {
1011 input.insert("failed_only".to_owned(), Value::Bool(true));
1012 }
API: notifications over REST and MCP, with notifications scopes1013 // Unsaving and waking a thread are a DELETE of what PUT made.
1014 if route.method == "DELETE" && route.path.ends_with("/saved") {
1015 input.insert("saved".to_owned(), Value::Bool(false));
1016 }
1017 if route.method == "DELETE" && route.path.ends_with("/snooze") {
1018 input.remove("until");
1019 }
API and MCP server in Rust; a public index at the API root1020 if let Some(number) = param("number") {
1021 // Not a number: zero, which no issue or pull request has.
1022 input.insert(
1023 "number".to_owned(),
1024 number.parse::<u32>().unwrap_or(0).into(),
1025 );
1026 }
1027 Some((route, Value::Object(input)))
1028}
1029
1030#[cfg(test)]
1031mod tests {
1032 use serde_json::json;
1033
1034 use super::*;
1035
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971036 /// Every name a route's path gives reaches the operation: a name left
1037 /// off the lists above is dropped, and the operation answers that it
1038 /// was not given (the project routes were, until this test).
1039 #[test]
1040 fn every_path_parameter_reaches_the_input() {
1041 for route in ROUTES.iter() {
1042 let names: Vec<&str> = route.path.split('/').filter_map(|part| part.strip_prefix(':')).collect();
1043 if names.is_empty() {
1044 continue;
1045 }
1046 let path: String = route
1047 .path
1048 .split('/')
1049 .map(|part| match part.strip_prefix(':') {
1050 Some("number" | "milestone") => "7".to_owned(),
1051 Some(name) => format!("{name}-x"),
1052 None => part.to_owned(),
1053 })
1054 .collect::<Vec<_>>()
1055 .join("/");
1056 let (found, input) = resolve(route.method, &path, &[], json!({})).unwrap();
1057 // A path two routes could take is checked under the first.
1058 if found.path != route.path {
1059 continue;
1060 }
1061 for name in names {
1062 let key = match name {
1063 "owner" | "name" => "repo",
1064 "repo" if names_has_workspace(route.path) => "repo",
1065 other => other,
1066 };
1067 assert!(
1068 input.get(key).is_some_and(|value| !value.is_null()),
1069 "{} {}: :{name} does not reach the input",
1070 route.method,
1071 route.path
1072 );
1073 }
1074 }
1075 }
1076
1077 fn names_has_workspace(path: &str) -> bool {
1078 path.split('/').any(|part| part == ":workspace")
1079 }
1080
API and MCP server in Rust; a public index at the API root1081 #[test]
1082 fn a_path_resolves_to_its_operation_and_input() {
1083 let (route, input) = resolve(
1084 "POST",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1085 "/repos/flagon-io/hello/pulls/14/merge",
API and MCP server in Rust; a public index at the API root1086 &[],
1087 json!({ "keep_issue_open": true, "number": 99, "repo": "someone/else" }),
1088 )
1089 .unwrap();
1090 assert_eq!(route.op, Op::MergePullRequest);
1091 // What the path names wins over the body.
1092 assert_eq!(
1093 input,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1094 json!({ "keep_issue_open": true, "number": 14, "repo": "flagon-io/hello" })
API and MCP server in Rust; a public index at the API root1095 );
1096 }
1097
1098 #[test]
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1099 fn a_branch_with_slashes_is_one_encoded_segment() {
1100 let (route, input) = resolve(
1101 "POST",
1102 "/repos/flagon-io/hello/branches/feature%2Flogin/rename",
1103 &[],
1104 json!({ "new_name": "feature/sign-in" }),
1105 )
1106 .unwrap();
1107 assert_eq!(route.op, Op::RenameBranch);
1108 assert_eq!(
1109 input,
1110 json!({ "new_name": "feature/sign-in", "branch": "feature/login", "repo": "flagon-io/hello" })
1111 );
1112 assert_eq!(percent_decoded("100%"), "100%");
1113 assert_eq!(percent_decoded("a%2bb%zz"), "a+b%zz");
1114 }
1115
1116 #[test]
1117 fn a_collaborator_is_named_by_username() {
1118 let (route, input) = resolve(
1119 "PATCH",
1120 "/repos/flagon-io/hello/collaborators/ada",
1121 &[],
1122 json!({ "role": "maintain" }),
1123 )
1124 .unwrap();
1125 assert_eq!(route.op, Op::UpdateCollaborator);
1126 assert_eq!(input, json!({ "role": "maintain", "username": "ada", "repo": "flagon-io/hello" }));
1127 let (route, input) = resolve("DELETE", "/user/repository_invitations/rin_1", &[], Value::Null).unwrap();
1128 assert_eq!(route.op, Op::DeclineRepoInvitation);
1129 assert_eq!(input, json!({ "id": "rin_1" }));
1130 }
1131
1132 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1133 fn teams_are_addressed_by_workspace_and_slug() {
1134 let query = [("q".to_owned(), "back".to_owned())];
1135 let (route, input) = resolve("GET", "/workspaces/acme/teams", &query, Value::Null).unwrap();
1136 assert_eq!(route.op, Op::ListTeams);
1137 assert_eq!(input, json!({ "query": "back", "workspace": "acme" }));
1138 let (route, input) = resolve("PATCH", "/workspaces/acme/teams/backend", &[], json!({ "name": "Back end" })).unwrap();
1139 assert_eq!(route.op, Op::UpdateTeam);
1140 assert_eq!(input, json!({ "name": "Back end", "workspace": "acme", "team": "backend" }));
1141 let (route, input) =
1142 resolve("PUT", "/workspaces/acme/teams/backend/members/ana", &[], json!({ "role": "maintainer" })).unwrap();
1143 assert_eq!(route.op, Op::SetTeamMember);
1144 assert_eq!(input, json!({ "role": "maintainer", "workspace": "acme", "team": "backend", "username": "ana" }));
1145 let query = [("include_child_teams".to_owned(), "true".to_owned())];
1146 let (route, input) = resolve("GET", "/workspaces/acme/teams/backend/members", &query, Value::Null).unwrap();
1147 assert_eq!(route.op, Op::ListTeamMembers);
1148 assert_eq!(input, json!({ "include_child_teams": "true", "workspace": "acme", "team": "backend" }));
1149 // A repository is named by itself, in the team's workspace.
1150 let (route, input) =
1151 resolve("PUT", "/workspaces/acme/teams/backend/repos/rocket", &[], json!({ "role": "write" })).unwrap();
1152 assert_eq!(route.op, Op::SetTeamRepo);
1153 assert_eq!(input, json!({ "role": "write", "workspace": "acme", "team": "backend", "repo": "acme/rocket" }));
1154 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1155 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/repos/rocket"), Op::RemoveTeamRepo);
1156 assert_eq!(op("GET", "/workspaces/acme/teams/backend/teams"), Op::ListChildTeams);
1157 assert_eq!(op("GET", "/workspaces/acme/teams/backend/repos"), Op::ListTeamRepos);
1158 assert_eq!(op("PUT", "/workspaces/acme/teams/backend/review_assignment"), Op::SetTeamReviewAssignment);
1159 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend"), Op::DeleteTeam);
1160 assert_eq!(op("POST", "/workspaces/acme/teams"), Op::CreateTeam);
1161 assert_eq!(op("GET", "/workspaces/acme/teams/backend"), Op::GetTeam);
1162 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/members/ana"), Op::RemoveTeamMember);
1163 let (route, input) = resolve("GET", "/workspaces/acme/members/ana/teams", &[], Value::Null).unwrap();
1164 assert_eq!(route.op, Op::ListUserTeams);
1165 assert_eq!(input, json!({ "workspace": "acme", "username": "ana" }));
1166 }
1167
1168 #[test]
1169 fn reviewers_are_requested_and_code_owners_checked_on_a_repository() {
1170 let body = json!({ "reviewers": ["ana"], "team_reviewers": ["backend"] });
1171 let (route, input) = resolve("POST", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body.clone()).unwrap();
1172 assert_eq!(route.op, Op::RequestReviewers);
1173 assert_eq!(
1174 input,
1175 json!({ "reviewers": ["ana"], "team_reviewers": ["backend"], "repo": "acme/rocket", "number": 7 })
1176 );
1177 let (route, _) = resolve("DELETE", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body).unwrap();
1178 assert_eq!(route.op, Op::RemoveRequestedReviewers);
1179 let query = [("ref".to_owned(), "main".to_owned())];
1180 let (route, input) = resolve("GET", "/repos/acme/rocket/codeowners/errors", &query, Value::Null).unwrap();
1181 assert_eq!(route.op, Op::GetCodeownersErrors);
1182 assert_eq!(input, json!({ "ref": "main", "repo": "acme/rocket" }));
1183 }
1184
1185 #[test]
API: notifications over REST and MCP, with notifications scopes1186 fn notifications_are_addressed_as_threads_and_by_issue() {
1187 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1", &[], Value::Null).unwrap();
1188 assert_eq!(route.op, Op::MarkThreadDone);
1189 assert_eq!(input, json!({ "id": "ntf_1" }));
1190 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/saved", &[], Value::Null).unwrap();
1191 assert_eq!(route.op, Op::SaveThread);
1192 assert_eq!(input, json!({ "id": "ntf_1", "saved": false }));
1193 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/snooze", &[], json!({ "until": "x" })).unwrap();
1194 assert_eq!(route.op, Op::SnoozeThread);
1195 assert_eq!(input, json!({ "id": "ntf_1" }));
1196 let query = [("all".to_owned(), "true".to_owned()), ("per_page".to_owned(), "50".to_owned())];
1197 let (route, input) = resolve("GET", "/repos/acme/rocket/notifications", &query, Value::Null).unwrap();
1198 assert_eq!(route.op, Op::ListNotifications);
1199 assert_eq!(input, json!({ "all": "true", "per_page": "50", "repo": "acme/rocket" }));
1200 let (route, input) = resolve("PUT", "/repos/acme/rocket/issues/7/subscription", &[], json!({ "ignored": true })).unwrap();
1201 assert_eq!(route.op, Op::SetThreadSubscription);
1202 assert_eq!(input, json!({ "ignored": true, "number": 7, "repo": "acme/rocket" }));
1203 assert_eq!(resolve("GET", "/user/subscriptions", &[], Value::Null).unwrap().0.op, Op::ListWatchedRepos);
1204 }
1205
1206 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1207 fn labels_and_milestones_are_named_in_the_path() {
1208 let (route, input) = resolve("PATCH", "/repos/acme/web/labels/good%20first%20issue", &[], json!({ "color": "7057ff" })).unwrap();
1209 assert_eq!(route.op, Op::UpdateLabel);
1210 assert_eq!(input, json!({ "color": "7057ff", "label": "good first issue", "repo": "acme/web" }));
1211 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels/bug", &[], Value::Null).unwrap();
1212 assert_eq!(route.op, Op::RemoveIssueLabels);
1213 assert_eq!(input, json!({ "label": "bug", "number": 7, "repo": "acme/web" }));
1214 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels", &[], Value::Null).unwrap();
1215 assert_eq!(route.op, Op::RemoveIssueLabels);
1216 assert_eq!(input, json!({ "number": 7, "repo": "acme/web" }));
1217 let (route, _) = resolve("POST", "/repos/acme/web/labels/defaults", &[], Value::Null).unwrap();
1218 assert_eq!(route.op, Op::AddDefaultLabels);
1219 let (route, input) = resolve("PATCH", "/repos/acme/web/milestones/3", &[], json!({ "state": "closed" })).unwrap();
1220 assert_eq!(route.op, Op::UpdateMilestone);
1221 assert_eq!(input, json!({ "state": "closed", "milestone": 3, "repo": "acme/web" }));
1222 let (route, input) = resolve("PATCH", "/repos/acme/web/pulls/9", &[], json!({ "base": "release" })).unwrap();
1223 assert_eq!(route.op, Op::UpdatePullRequest);
1224 assert_eq!(input, json!({ "base": "release", "number": 9, "repo": "acme/web" }));
1225 }
1226
1227 #[test]
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1228 fn billing_is_addressed_by_workspace() {
1229 let query = [("from".to_owned(), "2026-10-01".to_owned()), ("products".to_owned(), "agent,sandboxes".to_owned())];
1230 let (route, input) = resolve("GET", "/workspaces/acme/usage", &query, Value::Null).unwrap();
1231 assert_eq!(route.op, Op::GetUsage);
1232 assert_eq!(input, json!({ "from": "2026-10-01", "products": "agent,sandboxes", "workspace": "acme" }));
1233 let (route, input) = resolve("PUT", "/workspaces/acme/budget", &[], json!({ "alerts": [50] })).unwrap();
1234 assert_eq!(route.op, Op::SetBudget);
1235 assert_eq!(input, json!({ "alerts": [50], "workspace": "acme" }));
1236 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1237 assert_eq!(op("GET", "/workspaces/acme/budget"), Op::GetBudget);
1238 assert_eq!(op("GET", "/workspaces/acme/ai_credit"), Op::GetAiCredit);
1239 assert_eq!(op("POST", "/workspaces/acme/ai_credit/checkout"), Op::BuyAiCredit);
1240 assert_eq!(op("GET", "/workspaces/acme/invoices"), Op::ListInvoices);
1241 assert_eq!(op("GET", "/workspaces/acme/billing_details"), Op::GetBillingDetails);
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens1242 assert_eq!(op("GET", "/workspaces/acme/gateway/requests"), Op::ListGatewayRequests);
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1243 }
1244
1245 #[test]
Merge checks: statuses and check runs on every commit1246 fn checks_are_at_githubs_addresses() {
1247 let sha = "a".repeat(40);
1248 let body = json!({ "state": "success", "context": "ci/build" });
1249 let (route, input) = resolve("POST", &format!("/repos/acme/web/statuses/{sha}"), &[], body).unwrap();
1250 assert_eq!(route.op, Op::Checks(ChecksOp::CreateCommitStatus));
1251 assert_eq!(input, json!({ "state": "success", "context": "ci/build", "sha": sha, "repo": "acme/web" }));
1252 let (route, input) = resolve("GET", "/repos/acme/web/commits/release%2F1.x/status", &[], Value::Null).unwrap();
1253 assert_eq!(route.op, Op::Checks(ChecksOp::GetCombinedStatus));
1254 assert_eq!(input, json!({ "ref": "release/1.x", "repo": "acme/web" }));
1255 let query = [("check_name".to_owned(), "lint".to_owned())];
1256 let (route, input) = resolve("GET", "/repos/acme/web/commits/main/check-runs", &query, Value::Null).unwrap();
1257 assert_eq!(route.op, Op::Checks(ChecksOp::ListCheckRunsForRef));
1258 assert_eq!(input, json!({ "check_name": "lint", "ref": "main", "repo": "acme/web" }));
1259 let (route, input) = resolve("PATCH", "/repos/acme/web/check-runs/cr_1", &[], json!({ "conclusion": "success" })).unwrap();
1260 assert_eq!(route.op, Op::Checks(ChecksOp::UpdateCheckRun));
1261 assert_eq!(input, json!({ "conclusion": "success", "id": "cr_1", "repo": "acme/web" }));
1262 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1263 assert_eq!(op("POST", "/repos/acme/web/check-runs"), Op::Checks(ChecksOp::CreateCheckRun));
1264 assert_eq!(op("GET", "/repos/acme/web/check-runs/cr_1/annotations"), Op::Checks(ChecksOp::ListCheckRunAnnotations));
1265 assert_eq!(op("POST", "/repos/acme/web/check-suites/cs_1/rerequest"), Op::Checks(ChecksOp::RerequestCheckSuite));
1266 assert_eq!(op("GET", "/repos/acme/web/commits/main/check-suites"), Op::Checks(ChecksOp::ListCheckSuitesForRef));
1267 }
1268
1269 #[test]
API and MCP server in Rust; a public index at the API root1270 fn query_parameters_are_renamed() {
1271 let query = [
1272 ("q".to_owned(), "parser".to_owned()),
1273 ("x".to_owned(), "y".to_owned()),
1274 ];
Agents as a team: lifecycle, merge queue, billing and a new shell1275 let (route, input) = resolve("GET", "/repos", &query, Value::Null).unwrap();
API and MCP server in Rust; a public index at the API root1276 assert_eq!(route.op, Op::ListRepos);
1277 assert_eq!(input, json!({ "query": "parser" }));
1278 }
1279
1280 #[test]
1281 fn method_and_shape_must_match() {
Agents as a team: lifecycle, merge queue, billing and a new shell1282 assert!(resolve("GET", "/repos/a/b/issues/1/close", &[], Value::Null).is_none());
1283 assert!(resolve("GET", "/repos/a", &[], Value::Null).is_none());
1284 assert!(resolve("GET", "/repos/a/b/issues/1/extra", &[], Value::Null).is_none());
1285 assert!(resolve("GET", "/repos/a/b/", &[], Value::Null).is_some());
API and MCP server in Rust; a public index at the API root1286 }
1287
1288 #[test]
1289 fn every_parameter_and_query_name_is_an_input() {
1290 for route in ROUTES {
1291 let properties = route.op.properties();
1292 for (_, key) in route.query {
1293 assert!(properties.contains_key(*key), "{}: {key}", route.path);
1294 }
1295 for name in route.params() {
1296 let covered = matches!(name, "owner" | "name") && properties.contains_key("repo")
1297 || properties.contains_key(name);
1298 assert!(covered, "{}: {name}", route.path);
1299 }
1300 }
1301 }
1302
1303 #[test]
1304 fn every_operation_has_a_route() {
1305 for op in Op::ALL {
1306 assert!(ROUTES.iter().any(|route| route.op == op), "{}", op.name());
1307 }
1308 }
1309}

This file's history is long; its oldest lines are credited to the oldest commit read.