Skip to content
1,321 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;
Packages: roles, Manage Actions access, source-label linking, soft delete and restore, package API8use crate::packages::PackagesOp;
Merge branch 'worktree-agent-a3abfcce648e87dca'9use crate::protection::ProtectionOp;
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, &[]),
51 route("POST", "/workspaces/:workspace/invitations", Op::InviteMember, &[]),
52 route("DELETE", "/workspaces/:workspace/invitations/:id", Op::RevokeWorkspaceInvite, &[]),
53 // Who has access. GitHub's addresses, but for adding someone, which
54 // takes an email address as well as a username.
55 route("GET", "/repos/:owner/:name/collaborators", Op::ListCollaborators, &[]),
56 route("POST", "/repos/:owner/:name/collaborators", Op::AddCollaborator, &[]),
57 route("PATCH", "/repos/:owner/:name/collaborators/:username", Op::UpdateCollaborator, &[]),
58 route("DELETE", "/repos/:owner/:name/collaborators/:username", Op::RemoveCollaborator, &[]),
59 route(
60 "GET",
61 "/repos/:owner/:name/collaborators/:username/permission",
62 Op::GetCollaboratorPermission,
63 &[],
64 ),
65 route("GET", "/repos/:owner/:name/invitations", Op::ListRepoInvitations, &[]),
66 route("DELETE", "/repos/:owner/:name/invitations/:id", Op::RevokeRepoInvitation, &[]),
67 route("GET", "/user/repository_invitations", Op::ListMyRepoInvitations, &[]),
API: notifications over REST and MCP, with notifications scopes68 // Your notifications: threads, marking them, and what you subscribe
69 // to and watch. GitHub's addresses, with g1t's saved and snoozed.
70 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")]),
71 route("PUT", "/notifications", Op::MarkNotificationsRead, &[]),
72 route("GET", "/notifications/threads/:id", Op::GetNotificationThread, &[]),
73 route("PATCH", "/notifications/threads/:id", Op::MarkThreadRead, &[]),
74 route("DELETE", "/notifications/threads/:id", Op::MarkThreadDone, &[]),
75 route("PUT", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
76 route("DELETE", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
77 route("PUT", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
78 route("DELETE", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
79 route("GET", "/notifications/threads/:id/subscription", Op::GetThreadSubscription, &[]),
80 route("PUT", "/notifications/threads/:id/subscription", Op::SetThreadSubscription, &[]),
81 route("DELETE", "/notifications/threads/:id/subscription", Op::DeleteThreadSubscription, &[]),
82 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")]),
83 route("PUT", "/repos/:owner/:name/notifications", Op::MarkNotificationsRead, &[]),
84 route("GET", "/repos/:owner/:name/subscription", Op::GetRepoSubscription, &[]),
85 route("PUT", "/repos/:owner/:name/subscription", Op::SetRepoSubscription, &[]),
86 route("DELETE", "/repos/:owner/:name/subscription", Op::DeleteRepoSubscription, &[]),
87 route("GET", "/repos/:owner/:name/issues/:number/subscription", Op::GetThreadSubscription, &[]),
88 route("PUT", "/repos/:owner/:name/issues/:number/subscription", Op::SetThreadSubscription, &[]),
89 route("DELETE", "/repos/:owner/:name/issues/:number/subscription", Op::DeleteThreadSubscription, &[]),
90 route("GET", "/user/subscriptions", Op::ListWatchedRepos, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9791 // Stars: yours, and who starred a repository.
92 route("GET", "/user/starred", Op::About(AboutOp::ListStarred), &[]),
93 route("GET", "/user/starred/:owner/:name", Op::About(AboutOp::CheckStarred), &[]),
94 route("PUT", "/user/starred/:owner/:name", Op::About(AboutOp::Star), &[]),
95 route("DELETE", "/user/starred/:owner/:name", Op::About(AboutOp::Unstar), &[]),
96 route("GET", "/repos/:owner/:name/stargazers", Op::About(AboutOp::ListStargazers), &[("page", "page")]),
97 // What the default branch says about a repository, kept by commit.
98 route("GET", "/repos/:owner/:name/languages", Op::About(AboutOp::GetLanguages), &[]),
99 route("GET", "/repos/:owner/:name/contributors", Op::About(AboutOp::ListContributors), &[]),
100 route("GET", "/repos/:owner/:name/license", Op::About(AboutOp::GetLicense), &[]),
101 // Releases: `latest` and `tags/…` before an id.
102 route("GET", "/repos/:owner/:name/releases", Op::About(AboutOp::ListReleases), &[]),
103 route("POST", "/repos/:owner/:name/releases", Op::About(AboutOp::CreateRelease), &[]),
104 route("GET", "/repos/:owner/:name/releases/latest", Op::About(AboutOp::GetLatestRelease), &[]),
105 route("GET", "/repos/:owner/:name/releases/tags/:tag", Op::About(AboutOp::GetReleaseByTag), &[]),
106 route("GET", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::GetRelease), &[]),
107 route("PATCH", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::UpdateRelease), &[]),
108 route("DELETE", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::DeleteRelease), &[]),
API: pinned projects over REST and MCP109 // Your pinned projects in a workspace, in your order.
110 route("GET", "/user/pinned_projects/:workspace", Op::ListPinnedProjects, &[]),
111 route("PUT", "/user/pinned_projects/:workspace", Op::ReorderPinnedProjects, &[]),
112 route("PUT", "/user/pinned_projects/:workspace/:project", Op::PinProject, &[]),
113 route("DELETE", "/user/pinned_projects/:workspace/:project", Op::UnpinProject, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look114 route("PATCH", "/user/repository_invitations/:id", Op::AcceptRepoInvitation, &[]),
115 route("DELETE", "/user/repository_invitations/:id", Op::DeclineRepoInvitation, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily116 route("PATCH", "/workspaces/:workspace", Op::UpdateWorkspace, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97117 // A workspace's projects: what each is, where it runs, its links.
118 route("GET", "/workspaces/:workspace/projects", Op::ListProjects, &[]),
119 route("GET", "/workspaces/:workspace/projects/:project", Op::GetProject, &[]),
120 route("PATCH", "/workspaces/:workspace/projects/:project", Op::UpdateProject, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily121 route("PUT", "/workspaces/:workspace/base_permission", Op::SetBasePermission, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look122 route(
123 "GET",
124 "/workspaces/:workspace/outside_collaborators",
125 Op::ListOutsideCollaborators,
126 &[],
127 ),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar128 // Teams: a workspace's groups of members, with roles on repositories.
129 route("GET", "/workspaces/:workspace/teams", Op::ListTeams, &[("q", "query")]),
130 route("POST", "/workspaces/:workspace/teams", Op::CreateTeam, &[]),
131 route("GET", "/workspaces/:workspace/teams/:team", Op::GetTeam, &[]),
132 route("PATCH", "/workspaces/:workspace/teams/:team", Op::UpdateTeam, &[]),
133 route("DELETE", "/workspaces/:workspace/teams/:team", Op::DeleteTeam, &[]),
134 route(
135 "GET",
136 "/workspaces/:workspace/teams/:team/members",
137 Op::ListTeamMembers,
138 &[("include_child_teams", "include_child_teams")],
139 ),
140 route("PUT", "/workspaces/:workspace/teams/:team/members/:username", Op::SetTeamMember, &[]),
141 route("DELETE", "/workspaces/:workspace/teams/:team/members/:username", Op::RemoveTeamMember, &[]),
142 route("GET", "/workspaces/:workspace/teams/:team/teams", Op::ListChildTeams, &[]),
143 route("GET", "/workspaces/:workspace/teams/:team/repos", Op::ListTeamRepos, &[]),
144 route("PUT", "/workspaces/:workspace/teams/:team/repos/:repo", Op::SetTeamRepo, &[]),
145 route("DELETE", "/workspaces/:workspace/teams/:team/repos/:repo", Op::RemoveTeamRepo, &[]),
146 route(
147 "PUT",
148 "/workspaces/:workspace/teams/:team/review_assignment",
149 Op::SetTeamReviewAssignment,
150 &[],
151 ),
152 route("GET", "/workspaces/:workspace/members/:username/teams", Op::ListUserTeams, &[]),
Usage, Billing settings and prepaid AI credit; fixes from the UX audit153 // A workspace's billing: usage, budget, AI credit and invoices.
154 route(
155 "GET",
156 "/workspaces/:workspace/usage",
157 Op::GetUsage,
158 &[("from", "from"), ("until", "until"), ("products", "products"), ("projects", "projects"), ("group_by", "group_by")],
159 ),
160 route("GET", "/workspaces/:workspace/budget", Op::GetBudget, &[]),
161 route("PUT", "/workspaces/:workspace/budget", Op::SetBudget, &[]),
162 route("GET", "/workspaces/:workspace/ai_credit", Op::GetAiCredit, &[]),
163 route("POST", "/workspaces/:workspace/ai_credit/checkout", Op::BuyAiCredit, &[]),
164 route("GET", "/workspaces/:workspace/invoices", Op::ListInvoices, &[]),
165 route("GET", "/workspaces/:workspace/billing_details", Op::GetBillingDetails, &[]),
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens166 // The AI Gateway's log of a workspace's requests.
167 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 bar168 // Code owners: the CODEOWNERS file, checked.
169 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 daily170 // Security alerts: secrets and vulnerable dependencies.
171 route(
172 "GET",
173 "/repos/:owner/:name/security/alerts",
174 Op::ListSecurityAlerts,
175 &[("state", "state"), ("kind", "kind")],
176 ),
177 route("POST", "/repos/:owner/:name/security/alerts/:id/dismiss", Op::DismissSecurityAlert, &[]),
178 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 bar179 // The security suite: secret scanning, code scanning, vulnerability
180 // alerts and the supply chain, at the common addresses.
181 route("GET", "/repos/:owner/:name/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
182 route("GET", "/workspaces/:workspace/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
183 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::GetSecretAlert), &[]),
184 route("PATCH", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::UpdateSecretAlert), &[]),
185 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id/locations", Op::Security(SecurityOp::ListSecretLocations), &[]),
186 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/bypass", Op::Security(SecurityOp::BypassPushProtection), &[]),
187 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/validity", Op::Security(SecurityOp::CheckSecretValidity), &[]),
188 route("GET", "/workspaces/:workspace/secret-scanning/bypass-requests", Op::Security(SecurityOp::ListBypassRequests), &[("state", "state"), ("repo", "repo")]),
189 route("PATCH", "/workspaces/:workspace/secret-scanning/bypass-requests/:id", Op::Security(SecurityOp::ReviewBypassRequest), &[]),
190 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
191 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
192 route("GET", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
193 route("GET", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
194 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
195 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
196 route("PATCH", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
197 route("PATCH", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
198 route("DELETE", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
199 route("DELETE", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
200 route("GET", "/repos/:owner/:name/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
201 route("GET", "/workspaces/:workspace/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
202 route("GET", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::GetCodeAlert), &[]),
203 route("PATCH", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::UpdateCodeAlert), &[]),
204 route("GET", "/repos/:owner/:name/code-scanning/analyses", Op::Security(SecurityOp::ListAnalyses), &[]),
205 route("POST", "/repos/:owner/:name/code-scanning/sarifs", Op::Security(SecurityOp::UploadSarif), &[]),
206 route("GET", "/repos/:owner/:name/code-scanning/sarifs/:id", Op::Security(SecurityOp::GetSarifUpload), &[]),
207 route("GET", "/repos/:owner/:name/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
208 route("GET", "/workspaces/:workspace/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
209 route("GET", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::GetVulnerabilityAlert), &[]),
210 route("PATCH", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::UpdateVulnerabilityAlert), &[]),
211 route("POST", "/repos/:owner/:name/security/alerts/:id/fix", Op::Security(SecurityOp::FixAlert), &[]),
212 route("GET", "/repos/:owner/:name/dependency-graph", Op::Security(SecurityOp::GetDependencyGraph), &[]),
213 route("GET", "/repos/:owner/:name/dependency-graph/sbom", Op::Security(SecurityOp::GetSbom), &[]),
214 route("GET", "/repos/:owner/:name/dependency-graph/compare/:basehead", Op::Security(SecurityOp::CompareDependencies), &[]),
215 route("GET", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::GetSettings), &[]),
216 route("PATCH", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::UpdateSettings), &[]),
217 route("GET", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::GetWorkspaceSettings), &[]),
218 route("PATCH", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::UpdateWorkspaceSettings), &[]),
219 route("GET", "/workspaces/:workspace/security/overview", Op::Security(SecurityOp::GetOverview), &[("days", "days")]),
Agents as a team: lifecycle, merge queue, billing and a new shell220 route("GET", "/repos", Op::ListRepos, &[("q", "query")]),
Search across all of g1t, Explore, and a command palette221 route(
222 "GET",
223 "/search",
224 Op::Search,
225 &[("q", "query"), ("type", "type"), ("page", "page"), ("per_page", "per_page")],
226 ),
Agents as a team: lifecycle, merge queue, billing and a new shell227 route("POST", "/repos", Op::CreateRepo, &[]),
228 route("GET", "/repos/:owner/:name", Op::GetRepo, &[]),
229 route("PATCH", "/repos/:owner/:name", Op::UpdateRepo, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look230 route("POST", "/repos/:owner/:name/transfer", Op::TransferRepo, &[]),
231 route("DELETE", "/repos/:owner/:name", Op::DeleteRepo, &[]),
232 route(
233 "GET",
234 "/workspaces/:workspace/repos/deleted",
235 Op::ListDeletedRepos,
236 &[],
237 ),
238 route("POST", "/repos/:owner/:name/restore", Op::RestoreRepo, &[]),
239 route("POST", "/repos/:owner/:name/purge", Op::PurgeRepo, &[]),
240 route("POST", "/repos/:owner/:name/rename", Op::RenameRepo, &[]),
241 route("POST", "/repos/:owner/:name/archive", Op::ArchiveRepo, &[]),
242 route("POST", "/repos/:owner/:name/unarchive", Op::UnarchiveRepo, &[]),
243 route(
244 "POST",
245 "/repos/:owner/:name/visibility",
246 Op::SetRepoVisibility,
247 &[],
248 ),
249 route(
250 "POST",
251 "/repos/:owner/:name/branches/:branch/rename",
252 Op::RenameBranch,
253 &[],
254 ),
Agents as a team: lifecycle, merge queue, billing and a new shell255 route(
256 "GET",
257 "/repos/:owner/:name/settings",
258 Op::GetRepoSettings,
259 &[],
260 ),
261 route(
262 "PATCH",
263 "/repos/:owner/:name/settings",
264 Op::UpdateRepoSettings,
265 &[],
266 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents267 route("GET", "/repos/:owner/:name/check-names", Op::ListCheckNames, &[]),
Merge checks: statuses and check runs on every commit268 // Checks: GitHub's addresses for statuses, check runs and check suites.
269 route("POST", "/repos/:owner/:name/statuses/:sha", Op::Checks(ChecksOp::CreateCommitStatus), &[]),
270 route("GET", "/repos/:owner/:name/commits/:ref/statuses", Op::Checks(ChecksOp::ListCommitStatuses), &[]),
271 route("GET", "/repos/:owner/:name/commits/:ref/status", Op::Checks(ChecksOp::GetCombinedStatus), &[]),
272 route(
273 "GET",
274 "/repos/:owner/:name/commits/:ref/check-runs",
275 Op::Checks(ChecksOp::ListCheckRunsForRef),
276 &[("check_name", "check_name"), ("status", "status"), ("app", "app"), ("filter", "filter")],
277 ),
278 route(
279 "GET",
280 "/repos/:owner/:name/commits/:ref/check-suites",
281 Op::Checks(ChecksOp::ListCheckSuitesForRef),
282 &[("app", "app"), ("check_name", "check_name")],
283 ),
284 route("POST", "/repos/:owner/:name/check-runs", Op::Checks(ChecksOp::CreateCheckRun), &[]),
285 route("GET", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::GetCheckRun), &[]),
286 route("PATCH", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::UpdateCheckRun), &[]),
287 route("GET", "/repos/:owner/:name/check-runs/:id/annotations", Op::Checks(ChecksOp::ListCheckRunAnnotations), &[]),
288 route("POST", "/repos/:owner/:name/check-runs/:id/rerequest", Op::Checks(ChecksOp::RerequestCheckRun), &[]),
289 route("GET", "/repos/:owner/:name/check-suites/:id", Op::Checks(ChecksOp::GetCheckSuite), &[]),
290 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 merge291 // Rulesets: a repository's, a workspace's, the rules of one branch,
292 // and how they judged pushes and merges.
293 route("GET", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::ListRepoRulesets), &[("include_parents", "include_parents")]),
294 route("POST", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::CreateRepoRuleset), &[]),
295 route("GET", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::GetRepoRuleset), &[]),
296 route("PUT", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::UpdateRepoRuleset), &[]),
297 route("DELETE", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::DeleteRepoRuleset), &[]),
298 route("GET", "/repos/:owner/:name/rules/branches/:branch", Op::Rules(RulesOp::GetBranchRules), &[("target", "target")]),
299 route(
300 "GET",
301 "/repos/:owner/:name/rules/evaluations",
302 Op::Rules(RulesOp::ListRuleEvaluations),
303 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
304 ),
305 route("GET", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::ListWorkspaceRulesets), &[]),
306 route("POST", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::CreateWorkspaceRuleset), &[]),
307 route("GET", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::GetWorkspaceRuleset), &[]),
308 route("PUT", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::UpdateWorkspaceRuleset), &[]),
309 route("DELETE", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::DeleteWorkspaceRuleset), &[]),
310 route(
311 "GET",
312 "/workspaces/:workspace/rules/evaluations",
313 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
314 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
315 ),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97316 // Deployments wherever they run, their statuses, and environments.
317 route(
318 "GET",
319 "/repos/:owner/:name/deployments",
320 Op::Deployments(DeploymentsOp::ListDeployments),
321 &[("environment", "environment"), ("ref", "ref"), ("sha", "sha"), ("task", "task"), ("state", "state"), ("source", "source"), ("creator", "creator"), ("page", "page"), ("per_page", "per_page")],
322 ),
323 route("POST", "/repos/:owner/:name/deployments", Op::Deployments(DeploymentsOp::CreateDeployment), &[]),
324 route("GET", "/repos/:owner/:name/deployments/:id", Op::Deployments(DeploymentsOp::GetDeployment), &[]),
325 route("GET", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::ListDeploymentStatuses), &[]),
326 route("POST", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::CreateDeploymentStatus), &[]),
327 route("GET", "/repos/:owner/:name/environments", Op::Deployments(DeploymentsOp::ListEnvironments), &[]),
328 route("GET", "/repos/:owner/:name/environments/:environment", Op::Deployments(DeploymentsOp::GetEnvironment), &[]),
Merge branch 'worktree-agent-a3abfcce648e87dca'329 // Environments' protection rules, and the runs they hold.
330 route("PUT", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::UpdateEnvironment), &[]),
331 route("DELETE", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::DeleteEnvironment), &[]),
332 route(
333 "GET",
334 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
335 Op::Protection(ProtectionOp::GetPendingDeployments),
336 &[],
337 ),
338 route(
339 "POST",
340 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
341 Op::Protection(ProtectionOp::ReviewPendingDeployments),
342 &[],
343 ),
344 route("POST", "/repos/:owner/:name/actions/runs/:id/approve", Op::Protection(ProtectionOp::ApproveWorkflowRun), &[]),
345 route("GET", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::GetWorkflowPermissions), &[]),
346 route("PUT", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::SetWorkflowPermissions), &[]),
347 route(
348 "GET",
349 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
350 Op::Protection(ProtectionOp::GetForkPrApproval),
351 &[],
352 ),
353 route(
354 "PUT",
355 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
356 Op::Protection(ProtectionOp::SetForkPrApproval),
357 &[],
358 ),
359 route("POST", "/repos/:owner/:name/dispatches", Op::Protection(ProtectionOp::CreateRepositoryDispatch), &[]),
360 route(
361 "GET",
362 "/workspaces/:workspace/actions/permissions/workflow",
363 Op::Protection(ProtectionOp::GetWorkspaceWorkflowPermissions),
364 &[],
365 ),
366 route(
367 "PUT",
368 "/workspaces/:workspace/actions/permissions/workflow",
369 Op::Protection(ProtectionOp::SetWorkspaceWorkflowPermissions),
370 &[],
371 ),
Agents as a team: lifecycle, merge queue, billing and a new shell372 route("GET", "/repos/:owner/:name/queue", Op::GetMergeQueue, &[]),
API and MCP server in Rust; a public index at the API root373 route(
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request374 "POST",
375 "/repos/:owner/:name/pulls/:number/messages",
376 Op::MessageAgent,
377 &[],
378 ),
379 route(
380 "POST",
381 "/repos/:owner/:name/pulls/:number/messages/take",
382 Op::TakeMessages,
383 &[],
384 ),
385 route(
Docs worth reading, and kept that way386 "POST",
387 "/repos/:owner/:name/messages/:id/answer",
388 Op::AnswerMessage,
389 &[],
390 ),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains391 route("POST", "/repos/:owner/:name/memory", Op::Remember, &[]),
392 route(
393 "GET",
394 "/repos/:owner/:name/memory",
395 Op::Recall,
396 &[("q", "query"), ("limit", "limit")],
397 ),
Docs worth reading, and kept that way398 route(
API and MCP server in Rust; a public index at the API root399 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell400 "/repos/:owner/:name/events",
API and MCP server in Rust; a public index at the API root401 Op::ListEvents,
402 &[("before", "before")],
403 ),
Agents as a team: lifecycle, merge queue, billing and a new shell404 route("GET", "/repos/:owner/:name/labels", Op::ListLabels, &[]),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar405 route("POST", "/repos/:owner/:name/labels", Op::CreateLabel, &[]),
406 route("POST", "/repos/:owner/:name/labels/defaults", Op::AddDefaultLabels, &[]),
407 route("PATCH", "/repos/:owner/:name/labels/:label", Op::UpdateLabel, &[]),
408 route("DELETE", "/repos/:owner/:name/labels/:label", Op::DeleteLabel, &[]),
409 route("GET", "/repos/:owner/:name/issues/:number/labels", Op::ListIssueLabels, &[]),
410 route("POST", "/repos/:owner/:name/issues/:number/labels", Op::AddIssueLabels, &[]),
411 route("PUT", "/repos/:owner/:name/issues/:number/labels", Op::SetIssueLabels, &[]),
412 route("DELETE", "/repos/:owner/:name/issues/:number/labels", Op::RemoveIssueLabels, &[]),
413 route("DELETE", "/repos/:owner/:name/issues/:number/labels/:label", Op::RemoveIssueLabels, &[]),
414 route("GET", "/repos/:owner/:name/milestones", Op::ListMilestones, &[("state", "state")]),
415 route("POST", "/repos/:owner/:name/milestones", Op::CreateMilestone, &[]),
416 route("GET", "/repos/:owner/:name/milestones/:milestone", Op::GetMilestone, &[]),
417 route("PATCH", "/repos/:owner/:name/milestones/:milestone", Op::UpdateMilestone, &[]),
418 route("DELETE", "/repos/:owner/:name/milestones/:milestone", Op::DeleteMilestone, &[]),
API and MCP server in Rust; a public index at the API root419 route(
420 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell421 "/repos/:owner/:name/issues",
API and MCP server in Rust; a public index at the API root422 Op::ListIssues,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar423 &[("state", "state"), ("label", "label"), ("milestone", "milestone")],
API and MCP server in Rust; a public index at the API root424 ),
Agents as a team: lifecycle, merge queue, billing and a new shell425 route("POST", "/repos/:owner/:name/issues", Op::CreateIssue, &[]),
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/:number",
API and MCP server in Rust; a public index at the API root429 Op::GetIssue,
430 &[],
431 ),
432 route(
433 "PATCH",
Agents as a team: lifecycle, merge queue, billing and a new shell434 "/repos/:owner/:name/issues/:number",
API and MCP server in Rust; a public index at the API root435 Op::UpdateIssue,
436 &[],
437 ),
438 route(
439 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell440 "/repos/:owner/:name/issues/:number/close",
API and MCP server in Rust; a public index at the API root441 Op::CloseIssue,
442 &[],
443 ),
444 route(
445 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell446 "/repos/:owner/:name/issues/:number/reopen",
API and MCP server in Rust; a public index at the API root447 Op::ReopenIssue,
448 &[],
449 ),
450 route(
451 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell452 "/repos/:owner/:name/issues/:number/assign",
453 Op::AssignIssue,
454 &[],
455 ),
Integrations: your own model provider, alerts that open issues, tickets agents read456 route(
457 "POST",
458 "/repos/:owner/:name/issues/import",
459 Op::ImportIssue,
460 &[],
461 ),
462 route(
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step463 "POST",
464 "/repos/:owner/:name/issues/delegate",
465 Op::Delegate,
466 &[],
467 ),
468 route(
Integrations: your own model provider, alerts that open issues, tickets agents read469 "GET",
470 "/repos/:owner/:name/context",
471 Op::GetContext,
472 &[("reference", "reference")],
473 ),
474 route(
475 "GET",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API476 "/workspaces/:workspace/context/search",
477 Op::SearchContext,
478 &[("q", "query"), ("project", "project"), ("kinds", "kinds"), ("limit", "limit")],
479 ),
480 route(
481 "GET",
482 "/workspaces/:workspace/context/:kind/:id",
483 Op::GetEntity,
484 &[],
485 ),
486 route(
487 "GET",
Integrations: your own model provider, alerts that open issues, tickets agents read488 "/workspaces/:workspace/integrations",
489 Op::ListIntegrations,
490 &[],
491 ),
492 route(
493 "POST",
494 "/workspaces/:workspace/integrations",
495 Op::ConnectIntegration,
496 &[],
497 ),
498 route(
Models per workspace: several providers, routed by kind of work499 "GET",
Webhooks: every event, to your own addresses, signed and retried500 "/repos/:owner/:name/hooks",
501 Op::ListWebhooks,
502 &[],
503 ),
504 route(
505 "POST",
506 "/repos/:owner/:name/hooks",
507 Op::CreateWebhook,
508 &[],
509 ),
510 route(
511 "PATCH",
512 "/repos/:owner/:name/hooks/:id",
513 Op::UpdateWebhook,
514 &[],
515 ),
516 route(
517 "DELETE",
518 "/repos/:owner/:name/hooks/:id",
519 Op::DeleteWebhook,
520 &[],
521 ),
522 route(
523 "POST",
524 "/repos/:owner/:name/hooks/:id/pings",
525 Op::PingWebhook,
526 &[],
527 ),
528 route(
529 "GET",
530 "/repos/:owner/:name/hooks/:id/deliveries",
531 Op::ListWebhookDeliveries,
532 &[],
533 ),
534 route(
535 "POST",
536 "/repos/:owner/:name/hooks/:id/deliveries/:delivery/redeliver",
537 Op::RedeliverWebhook,
538 &[],
539 ),
540 route(
541 "GET",
542 "/workspaces/:workspace/hooks",
543 Op::ListWebhooks,
544 &[],
545 ),
546 route(
547 "POST",
548 "/workspaces/:workspace/hooks",
549 Op::CreateWebhook,
550 &[],
551 ),
552 route(
553 "PATCH",
554 "/workspaces/:workspace/hooks/:id",
555 Op::UpdateWebhook,
556 &[],
557 ),
558 route(
559 "DELETE",
560 "/workspaces/:workspace/hooks/:id",
561 Op::DeleteWebhook,
562 &[],
563 ),
564 route(
565 "POST",
566 "/workspaces/:workspace/hooks/:id/pings",
567 Op::PingWebhook,
568 &[],
569 ),
570 route(
571 "GET",
572 "/workspaces/:workspace/hooks/:id/deliveries",
573 Op::ListWebhookDeliveries,
574 &[],
575 ),
576 route(
577 "POST",
578 "/workspaces/:workspace/hooks/:id/deliveries/:delivery/redeliver",
579 Op::RedeliverWebhook,
580 &[],
581 ),
582 route(
583 "GET",
Models per workspace: several providers, routed by kind of work584 "/workspaces/:workspace/model-routes",
585 Op::GetModelRoutes,
586 &[],
587 ),
588 route(
589 "PUT",
590 "/workspaces/:workspace/model-routes",
591 Op::SetModelRoutes,
592 &[],
593 ),
594 route(
AI Gateway: OpenAI's format, open models, and your own providers595 "PATCH",
596 "/workspaces/:workspace/integrations/:id",
597 Op::UpdateIntegration,
598 &[],
599 ),
600 route(
Integrations: your own model provider, alerts that open issues, tickets agents read601 "DELETE",
602 "/workspaces/:workspace/integrations/:id",
603 Op::DisconnectIntegration,
604 &[],
605 ),
606 route(
607 "POST",
608 "/workspaces/:workspace/integrations/:id/test",
609 Op::TestIntegration,
610 &[],
611 ),
Automations: rules in .g1t/automations that act when something happens612 route(
613 "GET",
GitHub Actions on g1t, part two: running workflows614 "/repos/:owner/:name/actions/workflows",
615 Op::ListWorkflows,
616 &[],
617 ),
618 route(
619 "GET",
620 "/repos/:owner/:name/actions/workflows/:workflow/runs",
621 Op::ListWorkflowRuns,
622 &[("branch", "branch"), ("event", "event"), ("per_page", "limit")],
623 ),
624 route(
625 "POST",
626 "/repos/:owner/:name/actions/workflows/:workflow/dispatches",
627 Op::DispatchWorkflow,
628 &[],
629 ),
630 route(
631 "PATCH",
632 "/repos/:owner/:name/actions/workflows/:workflow",
633 Op::UpdateWorkflow,
634 &[],
635 ),
636 route(
637 "PUT",
638 "/repos/:owner/:name/actions/workflows/:workflow/enable",
639 Op::UpdateWorkflow,
640 &[],
641 ),
642 route(
643 "PUT",
644 "/repos/:owner/:name/actions/workflows/:workflow/disable",
645 Op::UpdateWorkflow,
646 &[],
647 ),
648 route(
649 "GET",
650 "/repos/:owner/:name/actions/runs",
651 Op::ListWorkflowRuns,
652 &[("workflow", "workflow"), ("branch", "branch"), ("event", "event"), ("pull", "pull"), ("head_sha", "sha"), ("per_page", "limit")],
653 ),
654 route(
655 "GET",
656 "/repos/:owner/:name/actions/runs/:id",
657 Op::GetWorkflowRun,
658 &[],
659 ),
660 route(
661 "POST",
662 "/repos/:owner/:name/actions/runs/:id/cancel",
663 Op::CancelWorkflowRun,
664 &[],
665 ),
666 route(
667 "POST",
668 "/repos/:owner/:name/actions/runs/:id/rerun",
669 Op::RerunWorkflowRun,
670 &[],
671 ),
672 route(
673 "POST",
674 "/repos/:owner/:name/actions/runs/:id/rerun-failed-jobs",
675 Op::RerunWorkflowRun,
676 &[],
677 ),
678 route(
679 "GET",
680 "/repos/:owner/:name/actions/jobs/:job/logs",
681 Op::GetJobLogs,
682 &[("after", "after")],
683 ),
Packages: roles, Manage Actions access, source-label linking, soft delete and restore, package API684 // Packages, at GitHub's addresses with the workspace in place of the
685 // organization. A name with a slash is one URL-encoded segment.
686 route("GET", "/workspaces/:workspace/packages", Op::Packages(PackagesOp::ListPackages), &[("package_type", "package_type"), ("q", "q"), ("state", "state")]),
687 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::GetPackage), &[]),
688 route("PATCH", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::UpdatePackage), &[]),
689 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::DeletePackage), &[]),
690 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/restore", Op::Packages(PackagesOp::RestorePackage), &[]),
691 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions", Op::Packages(PackagesOp::ListVersions), &[("state", "state")]),
692 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::GetVersion), &[]),
693 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::DeleteVersion), &[]),
694 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id/restore", Op::Packages(PackagesOp::RestoreVersion), &[]),
695 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::LinkPackage), &[]),
696 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::UnlinkPackage), &[]),
697 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::ListAccess), &[]),
698 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::SetAccess), &[]),
699 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::RemoveAccess), &[("username", "username"), ("team", "team")]),
700 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::ListActionsAccess), &[]),
701 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::SetActionsAccess), &[]),
702 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access/:repository", Op::Packages(PackagesOp::RemoveActionsAccess), &[]),
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R2703 // Artifacts, at GitHub's addresses. `…/zip` answers with a redirect to
704 // a signed link (lib.rs).
705 route("GET", "/repos/:owner/:name/actions/artifacts", Op::Artifacts(ArtifactsOp::ListArtifacts), &[("name", "name"), ("page", "page"), ("per_page", "per_page")]),
706 route("GET", "/repos/:owner/:name/actions/runs/:id/artifacts", Op::Artifacts(ArtifactsOp::ListRunArtifacts), &[("name", "name")]),
707 route("GET", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::GetArtifact), &[]),
708 route("GET", "/repos/:owner/:name/actions/artifacts/:id/zip", Op::Artifacts(ArtifactsOp::DownloadArtifact), &[]),
709 route("DELETE", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::DeleteArtifact), &[]),
710 route("GET", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::GetArtifactRetention), &[]),
711 route("PUT", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::SetArtifactRetention), &[]),
GitHub Actions on g1t, part two: running workflows712 route(
713 "GET",
714 "/repos/:owner/:name/actions/secrets",
715 Op::ListActionsSecrets,
716 &[],
717 ),
718 route(
719 "PUT",
720 "/repos/:owner/:name/actions/secrets/:setting",
721 Op::SetActionsSecret,
722 &[],
723 ),
724 route(
725 "DELETE",
726 "/repos/:owner/:name/actions/secrets/:setting",
727 Op::DeleteActionsSecret,
728 &[],
729 ),
730 route(
731 "GET",
732 "/repos/:owner/:name/actions/variables",
733 Op::ListActionsVariables,
734 &[],
735 ),
736 route(
737 "POST",
738 "/repos/:owner/:name/actions/variables",
739 Op::SetActionsVariable,
740 &[],
741 ),
742 route(
743 "PATCH",
744 "/repos/:owner/:name/actions/variables/:setting",
745 Op::SetActionsVariable,
746 &[],
747 ),
748 route(
749 "DELETE",
750 "/repos/:owner/:name/actions/variables/:setting",
751 Op::DeleteActionsVariable,
752 &[],
753 ),
754 route(
755 "GET",
756 "/workspaces/:workspace/actions/secrets",
757 Op::ListActionsSecrets,
758 &[],
759 ),
760 route(
761 "PUT",
762 "/workspaces/:workspace/actions/secrets/:setting",
763 Op::SetActionsSecret,
764 &[],
765 ),
766 route(
767 "DELETE",
768 "/workspaces/:workspace/actions/secrets/:setting",
769 Op::DeleteActionsSecret,
770 &[],
771 ),
772 route(
773 "GET",
774 "/workspaces/:workspace/actions/variables",
775 Op::ListActionsVariables,
776 &[],
777 ),
778 route(
779 "POST",
780 "/workspaces/:workspace/actions/variables",
781 Op::SetActionsVariable,
782 &[],
783 ),
784 route(
785 "PATCH",
786 "/workspaces/:workspace/actions/variables/:setting",
787 Op::SetActionsVariable,
788 &[],
789 ),
790 route(
791 "DELETE",
792 "/workspaces/:workspace/actions/variables/:setting",
793 Op::DeleteActionsVariable,
794 &[],
795 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents796 // Self-hosted runners: a repository's own, or a workspace's.
797 route("GET", "/repos/:owner/:name/actions/runners", Op::ListRunners, &[]),
798 route("POST", "/repos/:owner/:name/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
799 route("DELETE", "/repos/:owner/:name/actions/runners/:id", Op::RemoveRunner, &[]),
800 route("GET", "/repos/:owner/:name/actions/runner-settings", Op::GetRunnerSettings, &[]),
801 route("PATCH", "/repos/:owner/:name/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
802 route("GET", "/workspaces/:workspace/actions/runners", Op::ListRunners, &[]),
803 route("POST", "/workspaces/:workspace/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
804 route("DELETE", "/workspaces/:workspace/actions/runners/:id", Op::RemoveRunner, &[]),
805 route("GET", "/workspaces/:workspace/actions/runner-settings", Op::GetRunnerSettings, &[]),
806 route("PATCH", "/workspaces/:workspace/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
807 route("GET", "/workspaces/:workspace/actions/runner-groups", Op::ListRunnerGroups, &[]),
808 route("POST", "/workspaces/:workspace/actions/runner-groups", Op::CreateRunnerGroup, &[]),
809 route("PATCH", "/workspaces/:workspace/actions/runner-groups/:id", Op::UpdateRunnerGroup, &[]),
810 route("DELETE", "/workspaces/:workspace/actions/runner-groups/:id", Op::DeleteRunnerGroup, &[]),
Agents as a team: lifecycle, merge queue, billing and a new shell811 route("POST", "/repos/:owner/:name/plans", Op::PlanWork, &[]),
812 route("GET", "/repos/:owner/:name/plans/:plan", Op::GetPlan, &[]),
813 route(
814 "POST",
815 "/repos/:owner/:name/plans/:plan/apply",
816 Op::ApplyPlan,
817 &[],
818 ),
819 route(
820 "POST",
821 "/repos/:owner/:name/issues/:number/comments",
API and MCP server in Rust; a public index at the API root822 Op::AddComment,
823 &[],
824 ),
825 route(
826 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell827 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root828 Op::ListPullRequests,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar829 &[("state", "state"), ("label", "label"), ("milestone", "milestone"), ("base", "base")],
API and MCP server in Rust; a public index at the API root830 ),
831 route(
832 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell833 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root834 Op::CreatePullRequest,
835 &[],
836 ),
837 route(
838 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell839 "/repos/:owner/:name/pulls/:number",
API and MCP server in Rust; a public index at the API root840 Op::GetPullRequest,
841 &[],
842 ),
843 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar844 "PATCH",
845 "/repos/:owner/:name/pulls/:number",
846 Op::UpdatePullRequest,
847 &[],
848 ),
849 route(
API and MCP server in Rust; a public index at the API root850 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell851 "/repos/:owner/:name/pulls/:number/changes",
API and MCP server in Rust; a public index at the API root852 Op::GetPullRequestChanges,
853 &[],
854 ),
855 route(
Acceptance checks in sandboxes, line comments and review verdicts856 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell857 "/repos/:owner/:name/pulls/:number/reviews",
Acceptance checks in sandboxes, line comments and review verdicts858 Op::ReviewPullRequest,
859 &[],
860 ),
861 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar862 "POST",
863 "/repos/:owner/:name/pulls/:number/requested_reviewers",
864 Op::RequestReviewers,
865 &[],
866 ),
867 route(
868 "DELETE",
869 "/repos/:owner/:name/pulls/:number/requested_reviewers",
870 Op::RemoveRequestedReviewers,
871 &[],
872 ),
873 route(
API and MCP server in Rust; a public index at the API root874 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell875 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root876 Op::ReadSession,
877 &[("after", "after")],
878 ),
879 route(
880 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell881 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root882 Op::RecordSession,
883 &[],
884 ),
885 route(
886 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell887 "/repos/:owner/:name/pulls/:number/ready",
API and MCP server in Rust; a public index at the API root888 Op::MarkPullRequestReady,
889 &[],
890 ),
891 route(
892 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell893 "/repos/:owner/:name/pulls/:number/close",
API and MCP server in Rust; a public index at the API root894 Op::ClosePullRequest,
895 &[],
896 ),
897 route(
898 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell899 "/repos/:owner/:name/pulls/:number/merge",
API and MCP server in Rust; a public index at the API root900 Op::MergePullRequest,
901 &[],
902 ),
903];
904
905impl Route {
906 /// The names of the route's path parameters, in order.
907 pub fn params(&self) -> impl Iterator<Item = &'static str> {
908 self.path
909 .split('/')
910 .filter_map(|segment| segment.strip_prefix(':'))
911 }
912
913 /// The values of the path parameters, if `path` is this route's.
914 fn matches<'a>(&self, path: &'a str) -> Option<Vec<(&'static str, &'a str)>> {
915 let mut values = Vec::new();
916 let mut actual = path.trim_end_matches('/').split('/');
917 for expected in self.path.split('/') {
918 let segment = actual.next()?;
919 match expected.strip_prefix(':') {
920 Some(name) if !segment.is_empty() => values.push((name, segment)),
921 Some(_) => return None,
922 None if expected == segment => {}
923 None => return None,
924 }
925 }
926 actual.next().is_none().then_some(values)
927 }
928}
929
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look930/// A path segment with its `%XX` escapes decoded; as given when that is not
931/// UTF-8.
932fn percent_decoded(segment: &str) -> String {
933 let bytes = segment.as_bytes();
934 let mut out = Vec::with_capacity(bytes.len());
935 let mut i = 0;
936 while i < bytes.len() {
937 let escaped = (bytes[i] == b'%')
938 .then(|| segment.get(i + 1..i + 3))
939 .flatten()
940 .filter(|hex| hex.bytes().all(|byte| byte.is_ascii_hexdigit()))
941 .and_then(|hex| u8::from_str_radix(hex, 16).ok());
942 match escaped {
943 Some(byte) => {
944 out.push(byte);
945 i += 3;
946 }
947 None => {
948 out.push(bytes[i]);
949 i += 1;
950 }
951 }
952 }
953 String::from_utf8(out).unwrap_or_else(|_| segment.to_owned())
954}
955
API and MCP server in Rust; a public index at the API root956/// The route for a request, and the operation input it describes.
957///
958/// The input is the JSON body, overlaid with the query parameters the route
959/// 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 bar960/// `repo`, as does a team's `repo` with its `workspace`, and `number`
961/// becomes an integer.
API and MCP server in Rust; a public index at the API root962pub fn resolve(
963 method: &str,
964 path: &str,
965 query: &[(String, String)],
966 body: Value,
967) -> Option<(&'static Route, Value)> {
968 let (route, params) = ROUTES
969 .iter()
970 .filter(|route| route.method == method)
971 .find_map(|route| Some((route, route.matches(path)?)))?;
972
973 let mut input = match body {
974 Value::Object(fields) => fields,
975 _ => Map::new(),
976 };
977 for (name, key) in route.query {
978 if let Some((_, value)) = query.iter().find(|(query_name, _)| query_name == name) {
979 input.insert((*key).to_owned(), Value::String(value.clone()));
980 }
981 }
982 let param = |wanted: &str| {
983 params
984 .iter()
985 .find(|(name, _)| *name == wanted)
986 .map(|(_, value)| *value)
987 };
988 if let (Some(owner), Some(name)) = (param("owner"), param("name")) {
989 input.insert("repo".to_owned(), Value::String(format!("{owner}/{name}")));
990 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97991 // Every other name the path gives, under that name; the ones below that
992 // need more (a repository, a number, an encoded name) are set after.
993 for (key, value) in &params {
994 if !matches!(*key, "owner" | "name") {
995 input.insert((*key).to_owned(), Value::String(percent_decoded(value)));
Docs worth reading, and kept that way996 }
Agents as a team: lifecycle, merge queue, billing and a new shell997 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar998 // A repository of a team's workspace, named by itself.
999 if let (Some(workspace), Some(name)) = (param("workspace"), param("repo")) {
1000 input.insert("repo".to_owned(), Value::String(format!("{workspace}/{name}")));
1001 }
1002 // A branch name may hold slashes, sent URL-encoded as one segment, and
1003 // a label's name spaces.
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1004 if let Some(branch) = param("branch") {
1005 input.insert("branch".to_owned(), Value::String(percent_decoded(branch)));
1006 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971007 // An environment's name may hold slashes and spaces, URL-encoded.
1008 if let Some(environment) = param("environment") {
1009 input.insert("environment".to_owned(), Value::String(percent_decoded(environment)));
1010 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1011 if let Some(label) = param("label") {
1012 input.insert("label".to_owned(), Value::String(percent_decoded(label)));
1013 }
1014 if let Some(milestone) = param("milestone") {
1015 // Not a number: zero, which no milestone has.
1016 input.insert("milestone".to_owned(), milestone.parse::<u32>().unwrap_or(0).into());
1017 }
GitHub Actions on g1t, part two: running workflows1018 // GitHub says some things with the path alone.
1019 if route.path.ends_with("/enable") || route.path.ends_with("/disable") {
1020 input.insert("enabled".to_owned(), Value::Bool(route.path.ends_with("/enable")));
1021 }
1022 if route.path.ends_with("/rerun-failed-jobs") {
1023 input.insert("failed_only".to_owned(), Value::Bool(true));
1024 }
API: notifications over REST and MCP, with notifications scopes1025 // Unsaving and waking a thread are a DELETE of what PUT made.
1026 if route.method == "DELETE" && route.path.ends_with("/saved") {
1027 input.insert("saved".to_owned(), Value::Bool(false));
1028 }
1029 if route.method == "DELETE" && route.path.ends_with("/snooze") {
1030 input.remove("until");
1031 }
API and MCP server in Rust; a public index at the API root1032 if let Some(number) = param("number") {
1033 // Not a number: zero, which no issue or pull request has.
1034 input.insert(
1035 "number".to_owned(),
1036 number.parse::<u32>().unwrap_or(0).into(),
1037 );
1038 }
1039 Some((route, Value::Object(input)))
1040}
1041
1042#[cfg(test)]
1043mod tests {
1044 use serde_json::json;
1045
1046 use super::*;
1047
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971048 /// Every name a route's path gives reaches the operation: a name left
1049 /// off the lists above is dropped, and the operation answers that it
1050 /// was not given (the project routes were, until this test).
1051 #[test]
1052 fn every_path_parameter_reaches_the_input() {
1053 for route in ROUTES.iter() {
1054 let names: Vec<&str> = route.path.split('/').filter_map(|part| part.strip_prefix(':')).collect();
1055 if names.is_empty() {
1056 continue;
1057 }
1058 let path: String = route
1059 .path
1060 .split('/')
1061 .map(|part| match part.strip_prefix(':') {
1062 Some("number" | "milestone") => "7".to_owned(),
1063 Some(name) => format!("{name}-x"),
1064 None => part.to_owned(),
1065 })
1066 .collect::<Vec<_>>()
1067 .join("/");
1068 let (found, input) = resolve(route.method, &path, &[], json!({})).unwrap();
1069 // A path two routes could take is checked under the first.
1070 if found.path != route.path {
1071 continue;
1072 }
1073 for name in names {
1074 let key = match name {
1075 "owner" | "name" => "repo",
1076 "repo" if names_has_workspace(route.path) => "repo",
1077 other => other,
1078 };
1079 assert!(
1080 input.get(key).is_some_and(|value| !value.is_null()),
1081 "{} {}: :{name} does not reach the input",
1082 route.method,
1083 route.path
1084 );
1085 }
1086 }
1087 }
1088
1089 fn names_has_workspace(path: &str) -> bool {
1090 path.split('/').any(|part| part == ":workspace")
1091 }
1092
API and MCP server in Rust; a public index at the API root1093 #[test]
1094 fn a_path_resolves_to_its_operation_and_input() {
1095 let (route, input) = resolve(
1096 "POST",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1097 "/repos/flagon-io/hello/pulls/14/merge",
API and MCP server in Rust; a public index at the API root1098 &[],
1099 json!({ "keep_issue_open": true, "number": 99, "repo": "someone/else" }),
1100 )
1101 .unwrap();
1102 assert_eq!(route.op, Op::MergePullRequest);
1103 // What the path names wins over the body.
1104 assert_eq!(
1105 input,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1106 json!({ "keep_issue_open": true, "number": 14, "repo": "flagon-io/hello" })
API and MCP server in Rust; a public index at the API root1107 );
1108 }
1109
1110 #[test]
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1111 fn a_branch_with_slashes_is_one_encoded_segment() {
1112 let (route, input) = resolve(
1113 "POST",
1114 "/repos/flagon-io/hello/branches/feature%2Flogin/rename",
1115 &[],
1116 json!({ "new_name": "feature/sign-in" }),
1117 )
1118 .unwrap();
1119 assert_eq!(route.op, Op::RenameBranch);
1120 assert_eq!(
1121 input,
1122 json!({ "new_name": "feature/sign-in", "branch": "feature/login", "repo": "flagon-io/hello" })
1123 );
1124 assert_eq!(percent_decoded("100%"), "100%");
1125 assert_eq!(percent_decoded("a%2bb%zz"), "a+b%zz");
1126 }
1127
1128 #[test]
1129 fn a_collaborator_is_named_by_username() {
1130 let (route, input) = resolve(
1131 "PATCH",
1132 "/repos/flagon-io/hello/collaborators/ada",
1133 &[],
1134 json!({ "role": "maintain" }),
1135 )
1136 .unwrap();
1137 assert_eq!(route.op, Op::UpdateCollaborator);
1138 assert_eq!(input, json!({ "role": "maintain", "username": "ada", "repo": "flagon-io/hello" }));
1139 let (route, input) = resolve("DELETE", "/user/repository_invitations/rin_1", &[], Value::Null).unwrap();
1140 assert_eq!(route.op, Op::DeclineRepoInvitation);
1141 assert_eq!(input, json!({ "id": "rin_1" }));
1142 }
1143
1144 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1145 fn teams_are_addressed_by_workspace_and_slug() {
1146 let query = [("q".to_owned(), "back".to_owned())];
1147 let (route, input) = resolve("GET", "/workspaces/acme/teams", &query, Value::Null).unwrap();
1148 assert_eq!(route.op, Op::ListTeams);
1149 assert_eq!(input, json!({ "query": "back", "workspace": "acme" }));
1150 let (route, input) = resolve("PATCH", "/workspaces/acme/teams/backend", &[], json!({ "name": "Back end" })).unwrap();
1151 assert_eq!(route.op, Op::UpdateTeam);
1152 assert_eq!(input, json!({ "name": "Back end", "workspace": "acme", "team": "backend" }));
1153 let (route, input) =
1154 resolve("PUT", "/workspaces/acme/teams/backend/members/ana", &[], json!({ "role": "maintainer" })).unwrap();
1155 assert_eq!(route.op, Op::SetTeamMember);
1156 assert_eq!(input, json!({ "role": "maintainer", "workspace": "acme", "team": "backend", "username": "ana" }));
1157 let query = [("include_child_teams".to_owned(), "true".to_owned())];
1158 let (route, input) = resolve("GET", "/workspaces/acme/teams/backend/members", &query, Value::Null).unwrap();
1159 assert_eq!(route.op, Op::ListTeamMembers);
1160 assert_eq!(input, json!({ "include_child_teams": "true", "workspace": "acme", "team": "backend" }));
1161 // A repository is named by itself, in the team's workspace.
1162 let (route, input) =
1163 resolve("PUT", "/workspaces/acme/teams/backend/repos/rocket", &[], json!({ "role": "write" })).unwrap();
1164 assert_eq!(route.op, Op::SetTeamRepo);
1165 assert_eq!(input, json!({ "role": "write", "workspace": "acme", "team": "backend", "repo": "acme/rocket" }));
1166 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1167 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/repos/rocket"), Op::RemoveTeamRepo);
1168 assert_eq!(op("GET", "/workspaces/acme/teams/backend/teams"), Op::ListChildTeams);
1169 assert_eq!(op("GET", "/workspaces/acme/teams/backend/repos"), Op::ListTeamRepos);
1170 assert_eq!(op("PUT", "/workspaces/acme/teams/backend/review_assignment"), Op::SetTeamReviewAssignment);
1171 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend"), Op::DeleteTeam);
1172 assert_eq!(op("POST", "/workspaces/acme/teams"), Op::CreateTeam);
1173 assert_eq!(op("GET", "/workspaces/acme/teams/backend"), Op::GetTeam);
1174 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/members/ana"), Op::RemoveTeamMember);
1175 let (route, input) = resolve("GET", "/workspaces/acme/members/ana/teams", &[], Value::Null).unwrap();
1176 assert_eq!(route.op, Op::ListUserTeams);
1177 assert_eq!(input, json!({ "workspace": "acme", "username": "ana" }));
1178 }
1179
1180 #[test]
1181 fn reviewers_are_requested_and_code_owners_checked_on_a_repository() {
1182 let body = json!({ "reviewers": ["ana"], "team_reviewers": ["backend"] });
1183 let (route, input) = resolve("POST", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body.clone()).unwrap();
1184 assert_eq!(route.op, Op::RequestReviewers);
1185 assert_eq!(
1186 input,
1187 json!({ "reviewers": ["ana"], "team_reviewers": ["backend"], "repo": "acme/rocket", "number": 7 })
1188 );
1189 let (route, _) = resolve("DELETE", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body).unwrap();
1190 assert_eq!(route.op, Op::RemoveRequestedReviewers);
1191 let query = [("ref".to_owned(), "main".to_owned())];
1192 let (route, input) = resolve("GET", "/repos/acme/rocket/codeowners/errors", &query, Value::Null).unwrap();
1193 assert_eq!(route.op, Op::GetCodeownersErrors);
1194 assert_eq!(input, json!({ "ref": "main", "repo": "acme/rocket" }));
1195 }
1196
1197 #[test]
API: notifications over REST and MCP, with notifications scopes1198 fn notifications_are_addressed_as_threads_and_by_issue() {
1199 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1", &[], Value::Null).unwrap();
1200 assert_eq!(route.op, Op::MarkThreadDone);
1201 assert_eq!(input, json!({ "id": "ntf_1" }));
1202 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/saved", &[], Value::Null).unwrap();
1203 assert_eq!(route.op, Op::SaveThread);
1204 assert_eq!(input, json!({ "id": "ntf_1", "saved": false }));
1205 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/snooze", &[], json!({ "until": "x" })).unwrap();
1206 assert_eq!(route.op, Op::SnoozeThread);
1207 assert_eq!(input, json!({ "id": "ntf_1" }));
1208 let query = [("all".to_owned(), "true".to_owned()), ("per_page".to_owned(), "50".to_owned())];
1209 let (route, input) = resolve("GET", "/repos/acme/rocket/notifications", &query, Value::Null).unwrap();
1210 assert_eq!(route.op, Op::ListNotifications);
1211 assert_eq!(input, json!({ "all": "true", "per_page": "50", "repo": "acme/rocket" }));
1212 let (route, input) = resolve("PUT", "/repos/acme/rocket/issues/7/subscription", &[], json!({ "ignored": true })).unwrap();
1213 assert_eq!(route.op, Op::SetThreadSubscription);
1214 assert_eq!(input, json!({ "ignored": true, "number": 7, "repo": "acme/rocket" }));
1215 assert_eq!(resolve("GET", "/user/subscriptions", &[], Value::Null).unwrap().0.op, Op::ListWatchedRepos);
1216 }
1217
1218 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1219 fn labels_and_milestones_are_named_in_the_path() {
1220 let (route, input) = resolve("PATCH", "/repos/acme/web/labels/good%20first%20issue", &[], json!({ "color": "7057ff" })).unwrap();
1221 assert_eq!(route.op, Op::UpdateLabel);
1222 assert_eq!(input, json!({ "color": "7057ff", "label": "good first issue", "repo": "acme/web" }));
1223 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels/bug", &[], Value::Null).unwrap();
1224 assert_eq!(route.op, Op::RemoveIssueLabels);
1225 assert_eq!(input, json!({ "label": "bug", "number": 7, "repo": "acme/web" }));
1226 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels", &[], Value::Null).unwrap();
1227 assert_eq!(route.op, Op::RemoveIssueLabels);
1228 assert_eq!(input, json!({ "number": 7, "repo": "acme/web" }));
1229 let (route, _) = resolve("POST", "/repos/acme/web/labels/defaults", &[], Value::Null).unwrap();
1230 assert_eq!(route.op, Op::AddDefaultLabels);
1231 let (route, input) = resolve("PATCH", "/repos/acme/web/milestones/3", &[], json!({ "state": "closed" })).unwrap();
1232 assert_eq!(route.op, Op::UpdateMilestone);
1233 assert_eq!(input, json!({ "state": "closed", "milestone": 3, "repo": "acme/web" }));
1234 let (route, input) = resolve("PATCH", "/repos/acme/web/pulls/9", &[], json!({ "base": "release" })).unwrap();
1235 assert_eq!(route.op, Op::UpdatePullRequest);
1236 assert_eq!(input, json!({ "base": "release", "number": 9, "repo": "acme/web" }));
1237 }
1238
1239 #[test]
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1240 fn billing_is_addressed_by_workspace() {
1241 let query = [("from".to_owned(), "2026-10-01".to_owned()), ("products".to_owned(), "agent,sandboxes".to_owned())];
1242 let (route, input) = resolve("GET", "/workspaces/acme/usage", &query, Value::Null).unwrap();
1243 assert_eq!(route.op, Op::GetUsage);
1244 assert_eq!(input, json!({ "from": "2026-10-01", "products": "agent,sandboxes", "workspace": "acme" }));
1245 let (route, input) = resolve("PUT", "/workspaces/acme/budget", &[], json!({ "alerts": [50] })).unwrap();
1246 assert_eq!(route.op, Op::SetBudget);
1247 assert_eq!(input, json!({ "alerts": [50], "workspace": "acme" }));
1248 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1249 assert_eq!(op("GET", "/workspaces/acme/budget"), Op::GetBudget);
1250 assert_eq!(op("GET", "/workspaces/acme/ai_credit"), Op::GetAiCredit);
1251 assert_eq!(op("POST", "/workspaces/acme/ai_credit/checkout"), Op::BuyAiCredit);
1252 assert_eq!(op("GET", "/workspaces/acme/invoices"), Op::ListInvoices);
1253 assert_eq!(op("GET", "/workspaces/acme/billing_details"), Op::GetBillingDetails);
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens1254 assert_eq!(op("GET", "/workspaces/acme/gateway/requests"), Op::ListGatewayRequests);
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1255 }
1256
1257 #[test]
Merge checks: statuses and check runs on every commit1258 fn checks_are_at_githubs_addresses() {
1259 let sha = "a".repeat(40);
1260 let body = json!({ "state": "success", "context": "ci/build" });
1261 let (route, input) = resolve("POST", &format!("/repos/acme/web/statuses/{sha}"), &[], body).unwrap();
1262 assert_eq!(route.op, Op::Checks(ChecksOp::CreateCommitStatus));
1263 assert_eq!(input, json!({ "state": "success", "context": "ci/build", "sha": sha, "repo": "acme/web" }));
1264 let (route, input) = resolve("GET", "/repos/acme/web/commits/release%2F1.x/status", &[], Value::Null).unwrap();
1265 assert_eq!(route.op, Op::Checks(ChecksOp::GetCombinedStatus));
1266 assert_eq!(input, json!({ "ref": "release/1.x", "repo": "acme/web" }));
1267 let query = [("check_name".to_owned(), "lint".to_owned())];
1268 let (route, input) = resolve("GET", "/repos/acme/web/commits/main/check-runs", &query, Value::Null).unwrap();
1269 assert_eq!(route.op, Op::Checks(ChecksOp::ListCheckRunsForRef));
1270 assert_eq!(input, json!({ "check_name": "lint", "ref": "main", "repo": "acme/web" }));
1271 let (route, input) = resolve("PATCH", "/repos/acme/web/check-runs/cr_1", &[], json!({ "conclusion": "success" })).unwrap();
1272 assert_eq!(route.op, Op::Checks(ChecksOp::UpdateCheckRun));
1273 assert_eq!(input, json!({ "conclusion": "success", "id": "cr_1", "repo": "acme/web" }));
1274 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1275 assert_eq!(op("POST", "/repos/acme/web/check-runs"), Op::Checks(ChecksOp::CreateCheckRun));
1276 assert_eq!(op("GET", "/repos/acme/web/check-runs/cr_1/annotations"), Op::Checks(ChecksOp::ListCheckRunAnnotations));
1277 assert_eq!(op("POST", "/repos/acme/web/check-suites/cs_1/rerequest"), Op::Checks(ChecksOp::RerequestCheckSuite));
1278 assert_eq!(op("GET", "/repos/acme/web/commits/main/check-suites"), Op::Checks(ChecksOp::ListCheckSuitesForRef));
1279 }
1280
1281 #[test]
API and MCP server in Rust; a public index at the API root1282 fn query_parameters_are_renamed() {
1283 let query = [
1284 ("q".to_owned(), "parser".to_owned()),
1285 ("x".to_owned(), "y".to_owned()),
1286 ];
Agents as a team: lifecycle, merge queue, billing and a new shell1287 let (route, input) = resolve("GET", "/repos", &query, Value::Null).unwrap();
API and MCP server in Rust; a public index at the API root1288 assert_eq!(route.op, Op::ListRepos);
1289 assert_eq!(input, json!({ "query": "parser" }));
1290 }
1291
1292 #[test]
1293 fn method_and_shape_must_match() {
Agents as a team: lifecycle, merge queue, billing and a new shell1294 assert!(resolve("GET", "/repos/a/b/issues/1/close", &[], Value::Null).is_none());
1295 assert!(resolve("GET", "/repos/a", &[], Value::Null).is_none());
1296 assert!(resolve("GET", "/repos/a/b/issues/1/extra", &[], Value::Null).is_none());
1297 assert!(resolve("GET", "/repos/a/b/", &[], Value::Null).is_some());
API and MCP server in Rust; a public index at the API root1298 }
1299
1300 #[test]
1301 fn every_parameter_and_query_name_is_an_input() {
1302 for route in ROUTES {
1303 let properties = route.op.properties();
1304 for (_, key) in route.query {
1305 assert!(properties.contains_key(*key), "{}: {key}", route.path);
1306 }
1307 for name in route.params() {
1308 let covered = matches!(name, "owner" | "name") && properties.contains_key("repo")
1309 || properties.contains_key(name);
1310 assert!(covered, "{}: {name}", route.path);
1311 }
1312 }
1313 }
1314
1315 #[test]
1316 fn every_operation_has_a_route() {
1317 for op in Op::ALL {
1318 assert!(ROUTES.iter().any(|route| route.op == op), "{}", op.name());
1319 }
1320 }
1321}

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