Skip to content
1,376 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 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca7use crate::deploy_keys::DeployKeysOp;
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb978use crate::deployments::DeploymentsOp;
Merge packages: roles, Actions access, source label, soft delete, API9use crate::packages::PackagesOp;
Merge branch 'worktree-agent-a3abfcce648e87dca'10use crate::protection::ProtectionOp;
API and MCP for a workspace's personal access token rules, members' tokens and approvals11use crate::token_policy::TokenOp;
API and MCP server in Rust; a public index at the API root12use crate::operations::Op;
Merge checks: statuses and check runs on every commit13use crate::checks::ChecksOp;
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge14use crate::rules::RulesOp;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar15use crate::security::SecurityOp;
API and MCP server in Rust; a public index at the API root16
17pub struct Route {
18 pub method: &'static str,
19 /// Segments starting with `:` are parameters.
20 pub path: &'static str,
21 pub op: Op,
22 /// Query parameters the route reads, as `(name in the URL, input name)`.
23 pub query: &'static [(&'static str, &'static str)],
24}
25
26const fn route(
27 method: &'static str,
28 path: &'static str,
29 op: Op,
30 query: &'static [(&'static str, &'static str)],
31) -> Route {
32 Route {
33 method,
34 path,
35 op,
36 query,
37 }
38}
39
40pub const ROUTES: &[Route] = &[
Agents as a team: lifecycle, merge queue, billing and a new shell41 route("GET", "/user", Op::Whoami, &[]),
42 route("POST", "/workspaces", Op::CreateWorkspace, &[]),
Merge branch 'worktree-agent-ad7c6d88d93adc817'43 route("GET", "/workspaces/:workspace", Op::GetWorkspace, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look44 route("DELETE", "/workspaces/:workspace", Op::DeleteWorkspace, &[]),
45 route("GET", "/user/emails", Op::ListEmails, &[]),
46 route("POST", "/user/emails", Op::AddEmail, &[]),
47 route("DELETE", "/user/emails/:email", Op::RemoveEmail, &[]),
48 route("PATCH", "/user/email-settings", Op::UpdateEmailSettings, &[]),
49 route("GET", "/user/invites", Op::ListInvites, &[]),
50 route("POST", "/user/invites", Op::CreateInvite, &[]),
51 route("DELETE", "/user/invites/:id", Op::RevokeInvite, &[]),
52 route("GET", "/workspaces/:workspace/invitations", Op::ListWorkspaceInvites, &[]),
API and MCP for a workspace's personal access token rules, members' tokens and approvals53 // A workspace's rules for personal access tokens, and its members' tokens.
54 route("GET", "/workspaces/:workspace/personal-access-token-policy", Op::Tokens(TokenOp::GetTokenPolicy), &[]),
55 route("PATCH", "/workspaces/:workspace/personal-access-token-policy", Op::Tokens(TokenOp::SetTokenPolicy), &[]),
56 route("GET", "/workspaces/:workspace/personal-access-tokens", Op::Tokens(TokenOp::ListMemberTokens), &[("kind", "kind")]),
57 route("POST", "/workspaces/:workspace/personal-access-tokens/:id", Op::Tokens(TokenOp::RevokeMemberToken), &[]),
58 route("GET", "/workspaces/:workspace/personal-access-token-requests", Op::Tokens(TokenOp::ListTokenRequests), &[]),
59 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 look60 route("POST", "/workspaces/:workspace/invitations", Op::InviteMember, &[]),
61 route("DELETE", "/workspaces/:workspace/invitations/:id", Op::RevokeWorkspaceInvite, &[]),
62 // Who has access. GitHub's addresses, but for adding someone, which
63 // takes an email address as well as a username.
64 route("GET", "/repos/:owner/:name/collaborators", Op::ListCollaborators, &[]),
65 route("POST", "/repos/:owner/:name/collaborators", Op::AddCollaborator, &[]),
66 route("PATCH", "/repos/:owner/:name/collaborators/:username", Op::UpdateCollaborator, &[]),
67 route("DELETE", "/repos/:owner/:name/collaborators/:username", Op::RemoveCollaborator, &[]),
68 route(
69 "GET",
70 "/repos/:owner/:name/collaborators/:username/permission",
71 Op::GetCollaboratorPermission,
72 &[],
73 ),
74 route("GET", "/repos/:owner/:name/invitations", Op::ListRepoInvitations, &[]),
75 route("DELETE", "/repos/:owner/:name/invitations/:id", Op::RevokeRepoInvitation, &[]),
76 route("GET", "/user/repository_invitations", Op::ListMyRepoInvitations, &[]),
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca77 // Deploy keys, at GitHub's addresses.
78 route("GET", "/repos/:owner/:name/keys", Op::DeployKeys(DeployKeysOp::ListDeployKeys), &[]),
79 route("POST", "/repos/:owner/:name/keys", Op::DeployKeys(DeployKeysOp::CreateDeployKey), &[]),
80 route("GET", "/repos/:owner/:name/keys/:id", Op::DeployKeys(DeployKeysOp::GetDeployKey), &[]),
81 route("DELETE", "/repos/:owner/:name/keys/:id", Op::DeployKeys(DeployKeysOp::DeleteDeployKey), &[]),
API: notifications over REST and MCP, with notifications scopes82 // Your notifications: threads, marking them, and what you subscribe
83 // to and watch. GitHub's addresses, with g1t's saved and snoozed.
84 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")]),
85 route("PUT", "/notifications", Op::MarkNotificationsRead, &[]),
86 route("GET", "/notifications/threads/:id", Op::GetNotificationThread, &[]),
87 route("PATCH", "/notifications/threads/:id", Op::MarkThreadRead, &[]),
88 route("DELETE", "/notifications/threads/:id", Op::MarkThreadDone, &[]),
89 route("PUT", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
90 route("DELETE", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
91 route("PUT", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
92 route("DELETE", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
93 route("GET", "/notifications/threads/:id/subscription", Op::GetThreadSubscription, &[]),
94 route("PUT", "/notifications/threads/:id/subscription", Op::SetThreadSubscription, &[]),
95 route("DELETE", "/notifications/threads/:id/subscription", Op::DeleteThreadSubscription, &[]),
96 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")]),
97 route("PUT", "/repos/:owner/:name/notifications", Op::MarkNotificationsRead, &[]),
98 route("GET", "/repos/:owner/:name/subscription", Op::GetRepoSubscription, &[]),
99 route("PUT", "/repos/:owner/:name/subscription", Op::SetRepoSubscription, &[]),
100 route("DELETE", "/repos/:owner/:name/subscription", Op::DeleteRepoSubscription, &[]),
101 route("GET", "/repos/:owner/:name/issues/:number/subscription", Op::GetThreadSubscription, &[]),
102 route("PUT", "/repos/:owner/:name/issues/:number/subscription", Op::SetThreadSubscription, &[]),
103 route("DELETE", "/repos/:owner/:name/issues/:number/subscription", Op::DeleteThreadSubscription, &[]),
104 route("GET", "/user/subscriptions", Op::ListWatchedRepos, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97105 // Stars: yours, and who starred a repository.
106 route("GET", "/user/starred", Op::About(AboutOp::ListStarred), &[]),
107 route("GET", "/user/starred/:owner/:name", Op::About(AboutOp::CheckStarred), &[]),
108 route("PUT", "/user/starred/:owner/:name", Op::About(AboutOp::Star), &[]),
109 route("DELETE", "/user/starred/:owner/:name", Op::About(AboutOp::Unstar), &[]),
110 route("GET", "/repos/:owner/:name/stargazers", Op::About(AboutOp::ListStargazers), &[("page", "page")]),
111 // What the default branch says about a repository, kept by commit.
112 route("GET", "/repos/:owner/:name/languages", Op::About(AboutOp::GetLanguages), &[]),
113 route("GET", "/repos/:owner/:name/contributors", Op::About(AboutOp::ListContributors), &[]),
114 route("GET", "/repos/:owner/:name/license", Op::About(AboutOp::GetLicense), &[]),
115 // Releases: `latest` and `tags/…` before an id.
116 route("GET", "/repos/:owner/:name/releases", Op::About(AboutOp::ListReleases), &[]),
117 route("POST", "/repos/:owner/:name/releases", Op::About(AboutOp::CreateRelease), &[]),
118 route("GET", "/repos/:owner/:name/releases/latest", Op::About(AboutOp::GetLatestRelease), &[]),
119 route("GET", "/repos/:owner/:name/releases/tags/:tag", Op::About(AboutOp::GetReleaseByTag), &[]),
120 route("GET", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::GetRelease), &[]),
121 route("PATCH", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::UpdateRelease), &[]),
122 route("DELETE", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::DeleteRelease), &[]),
API: pinned projects over REST and MCP123 // Your pinned projects in a workspace, in your order.
124 route("GET", "/user/pinned_projects/:workspace", Op::ListPinnedProjects, &[]),
125 route("PUT", "/user/pinned_projects/:workspace", Op::ReorderPinnedProjects, &[]),
126 route("PUT", "/user/pinned_projects/:workspace/:project", Op::PinProject, &[]),
127 route("DELETE", "/user/pinned_projects/:workspace/:project", Op::UnpinProject, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look128 route("PATCH", "/user/repository_invitations/:id", Op::AcceptRepoInvitation, &[]),
129 route("DELETE", "/user/repository_invitations/:id", Op::DeclineRepoInvitation, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily130 route("PATCH", "/workspaces/:workspace", Op::UpdateWorkspace, &[]),
Merge main (membership, two-factor, GitHub repo roles) into tokens131 // Members and owners: GitHub's organization members, by username.
132 route("GET", "/workspaces/:workspace/members", Op::ListMembers, &[]),
133 route("PATCH", "/workspaces/:workspace/members/:username", Op::UpdateMember, &[]),
134 route("DELETE", "/workspaces/:workspace/members/:username", Op::RemoveMember, &[]),
135 route("POST", "/workspaces/:workspace/transfer_ownership", Op::TransferOwnership, &[]),
136 route("DELETE", "/user/memberships/:workspace", Op::LeaveWorkspace, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97137 // A workspace's projects: what each is, where it runs, its links.
138 route("GET", "/workspaces/:workspace/projects", Op::ListProjects, &[]),
139 route("GET", "/workspaces/:workspace/projects/:project", Op::GetProject, &[]),
140 route("PATCH", "/workspaces/:workspace/projects/:project", Op::UpdateProject, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily141 route("PUT", "/workspaces/:workspace/base_permission", Op::SetBasePermission, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look142 route(
143 "GET",
144 "/workspaces/:workspace/outside_collaborators",
145 Op::ListOutsideCollaborators,
146 &[],
147 ),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar148 // Teams: a workspace's groups of members, with roles on repositories.
149 route("GET", "/workspaces/:workspace/teams", Op::ListTeams, &[("q", "query")]),
150 route("POST", "/workspaces/:workspace/teams", Op::CreateTeam, &[]),
151 route("GET", "/workspaces/:workspace/teams/:team", Op::GetTeam, &[]),
152 route("PATCH", "/workspaces/:workspace/teams/:team", Op::UpdateTeam, &[]),
153 route("DELETE", "/workspaces/:workspace/teams/:team", Op::DeleteTeam, &[]),
154 route(
155 "GET",
156 "/workspaces/:workspace/teams/:team/members",
157 Op::ListTeamMembers,
158 &[("include_child_teams", "include_child_teams")],
159 ),
160 route("PUT", "/workspaces/:workspace/teams/:team/members/:username", Op::SetTeamMember, &[]),
161 route("DELETE", "/workspaces/:workspace/teams/:team/members/:username", Op::RemoveTeamMember, &[]),
162 route("GET", "/workspaces/:workspace/teams/:team/teams", Op::ListChildTeams, &[]),
163 route("GET", "/workspaces/:workspace/teams/:team/repos", Op::ListTeamRepos, &[]),
164 route("PUT", "/workspaces/:workspace/teams/:team/repos/:repo", Op::SetTeamRepo, &[]),
165 route("DELETE", "/workspaces/:workspace/teams/:team/repos/:repo", Op::RemoveTeamRepo, &[]),
166 route(
167 "PUT",
168 "/workspaces/:workspace/teams/:team/review_assignment",
169 Op::SetTeamReviewAssignment,
170 &[],
171 ),
172 route("GET", "/workspaces/:workspace/members/:username/teams", Op::ListUserTeams, &[]),
Usage, Billing settings and prepaid AI credit; fixes from the UX audit173 // A workspace's billing: usage, budget, AI credit and invoices.
174 route(
175 "GET",
176 "/workspaces/:workspace/usage",
177 Op::GetUsage,
178 &[("from", "from"), ("until", "until"), ("products", "products"), ("projects", "projects"), ("group_by", "group_by")],
179 ),
180 route("GET", "/workspaces/:workspace/budget", Op::GetBudget, &[]),
181 route("PUT", "/workspaces/:workspace/budget", Op::SetBudget, &[]),
182 route("GET", "/workspaces/:workspace/ai_credit", Op::GetAiCredit, &[]),
183 route("POST", "/workspaces/:workspace/ai_credit/checkout", Op::BuyAiCredit, &[]),
184 route("GET", "/workspaces/:workspace/invoices", Op::ListInvoices, &[]),
185 route("GET", "/workspaces/:workspace/billing_details", Op::GetBillingDetails, &[]),
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens186 // The AI Gateway's log of a workspace's requests.
187 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 bar188 // Code owners: the CODEOWNERS file, checked.
189 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 daily190 // Security alerts: secrets and vulnerable dependencies.
191 route(
192 "GET",
193 "/repos/:owner/:name/security/alerts",
194 Op::ListSecurityAlerts,
195 &[("state", "state"), ("kind", "kind")],
196 ),
197 route("POST", "/repos/:owner/:name/security/alerts/:id/dismiss", Op::DismissSecurityAlert, &[]),
198 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 bar199 // The security suite: secret scanning, code scanning, vulnerability
200 // alerts and the supply chain, at the common addresses.
201 route("GET", "/repos/:owner/:name/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
202 route("GET", "/workspaces/:workspace/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
203 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::GetSecretAlert), &[]),
204 route("PATCH", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::UpdateSecretAlert), &[]),
205 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id/locations", Op::Security(SecurityOp::ListSecretLocations), &[]),
206 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/bypass", Op::Security(SecurityOp::BypassPushProtection), &[]),
207 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/validity", Op::Security(SecurityOp::CheckSecretValidity), &[]),
208 route("GET", "/workspaces/:workspace/secret-scanning/bypass-requests", Op::Security(SecurityOp::ListBypassRequests), &[("state", "state"), ("repo", "repo")]),
209 route("PATCH", "/workspaces/:workspace/secret-scanning/bypass-requests/:id", Op::Security(SecurityOp::ReviewBypassRequest), &[]),
210 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
211 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
212 route("GET", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
213 route("GET", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
214 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
215 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
216 route("PATCH", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
217 route("PATCH", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
218 route("DELETE", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
219 route("DELETE", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
220 route("GET", "/repos/:owner/:name/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
221 route("GET", "/workspaces/:workspace/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
222 route("GET", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::GetCodeAlert), &[]),
223 route("PATCH", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::UpdateCodeAlert), &[]),
224 route("GET", "/repos/:owner/:name/code-scanning/analyses", Op::Security(SecurityOp::ListAnalyses), &[]),
225 route("POST", "/repos/:owner/:name/code-scanning/sarifs", Op::Security(SecurityOp::UploadSarif), &[]),
226 route("GET", "/repos/:owner/:name/code-scanning/sarifs/:id", Op::Security(SecurityOp::GetSarifUpload), &[]),
227 route("GET", "/repos/:owner/:name/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
228 route("GET", "/workspaces/:workspace/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
229 route("GET", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::GetVulnerabilityAlert), &[]),
230 route("PATCH", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::UpdateVulnerabilityAlert), &[]),
231 route("POST", "/repos/:owner/:name/security/alerts/:id/fix", Op::Security(SecurityOp::FixAlert), &[]),
232 route("GET", "/repos/:owner/:name/dependency-graph", Op::Security(SecurityOp::GetDependencyGraph), &[]),
233 route("GET", "/repos/:owner/:name/dependency-graph/sbom", Op::Security(SecurityOp::GetSbom), &[]),
234 route("GET", "/repos/:owner/:name/dependency-graph/compare/:basehead", Op::Security(SecurityOp::CompareDependencies), &[]),
235 route("GET", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::GetSettings), &[]),
236 route("PATCH", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::UpdateSettings), &[]),
237 route("GET", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::GetWorkspaceSettings), &[]),
238 route("PATCH", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::UpdateWorkspaceSettings), &[]),
239 route("GET", "/workspaces/:workspace/security/overview", Op::Security(SecurityOp::GetOverview), &[("days", "days")]),
Agents as a team: lifecycle, merge queue, billing and a new shell240 route("GET", "/repos", Op::ListRepos, &[("q", "query")]),
Search across all of g1t, Explore, and a command palette241 route(
242 "GET",
243 "/search",
244 Op::Search,
245 &[("q", "query"), ("type", "type"), ("page", "page"), ("per_page", "per_page")],
246 ),
Agents as a team: lifecycle, merge queue, billing and a new shell247 route("POST", "/repos", Op::CreateRepo, &[]),
248 route("GET", "/repos/:owner/:name", Op::GetRepo, &[]),
249 route("PATCH", "/repos/:owner/:name", Op::UpdateRepo, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look250 route("POST", "/repos/:owner/:name/transfer", Op::TransferRepo, &[]),
251 route("DELETE", "/repos/:owner/:name", Op::DeleteRepo, &[]),
252 route(
253 "GET",
254 "/workspaces/:workspace/repos/deleted",
255 Op::ListDeletedRepos,
256 &[],
257 ),
258 route("POST", "/repos/:owner/:name/restore", Op::RestoreRepo, &[]),
259 route("POST", "/repos/:owner/:name/purge", Op::PurgeRepo, &[]),
260 route("POST", "/repos/:owner/:name/rename", Op::RenameRepo, &[]),
261 route("POST", "/repos/:owner/:name/archive", Op::ArchiveRepo, &[]),
262 route("POST", "/repos/:owner/:name/unarchive", Op::UnarchiveRepo, &[]),
263 route(
264 "POST",
265 "/repos/:owner/:name/visibility",
266 Op::SetRepoVisibility,
267 &[],
268 ),
269 route(
270 "POST",
271 "/repos/:owner/:name/branches/:branch/rename",
272 Op::RenameBranch,
273 &[],
274 ),
Agents as a team: lifecycle, merge queue, billing and a new shell275 route(
276 "GET",
277 "/repos/:owner/:name/settings",
278 Op::GetRepoSettings,
279 &[],
280 ),
281 route(
282 "PATCH",
283 "/repos/:owner/:name/settings",
284 Op::UpdateRepoSettings,
285 &[],
286 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents287 route("GET", "/repos/:owner/:name/check-names", Op::ListCheckNames, &[]),
Merge checks: statuses and check runs on every commit288 // Checks: GitHub's addresses for statuses, check runs and check suites.
289 route("POST", "/repos/:owner/:name/statuses/:sha", Op::Checks(ChecksOp::CreateCommitStatus), &[]),
290 route("GET", "/repos/:owner/:name/commits/:ref/statuses", Op::Checks(ChecksOp::ListCommitStatuses), &[]),
291 route("GET", "/repos/:owner/:name/commits/:ref/status", Op::Checks(ChecksOp::GetCombinedStatus), &[]),
292 route(
293 "GET",
294 "/repos/:owner/:name/commits/:ref/check-runs",
295 Op::Checks(ChecksOp::ListCheckRunsForRef),
296 &[("check_name", "check_name"), ("status", "status"), ("app", "app"), ("filter", "filter")],
297 ),
298 route(
299 "GET",
300 "/repos/:owner/:name/commits/:ref/check-suites",
301 Op::Checks(ChecksOp::ListCheckSuitesForRef),
302 &[("app", "app"), ("check_name", "check_name")],
303 ),
304 route("POST", "/repos/:owner/:name/check-runs", Op::Checks(ChecksOp::CreateCheckRun), &[]),
305 route("GET", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::GetCheckRun), &[]),
306 route("PATCH", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::UpdateCheckRun), &[]),
307 route("GET", "/repos/:owner/:name/check-runs/:id/annotations", Op::Checks(ChecksOp::ListCheckRunAnnotations), &[]),
308 route("POST", "/repos/:owner/:name/check-runs/:id/rerequest", Op::Checks(ChecksOp::RerequestCheckRun), &[]),
309 route("GET", "/repos/:owner/:name/check-suites/:id", Op::Checks(ChecksOp::GetCheckSuite), &[]),
310 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 merge311 // Rulesets: a repository's, a workspace's, the rules of one branch,
312 // and how they judged pushes and merges.
313 route("GET", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::ListRepoRulesets), &[("include_parents", "include_parents")]),
314 route("POST", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::CreateRepoRuleset), &[]),
315 route("GET", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::GetRepoRuleset), &[]),
316 route("PUT", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::UpdateRepoRuleset), &[]),
317 route("DELETE", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::DeleteRepoRuleset), &[]),
318 route("GET", "/repos/:owner/:name/rules/branches/:branch", Op::Rules(RulesOp::GetBranchRules), &[("target", "target")]),
319 route(
320 "GET",
321 "/repos/:owner/:name/rules/evaluations",
322 Op::Rules(RulesOp::ListRuleEvaluations),
323 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
324 ),
325 route("GET", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::ListWorkspaceRulesets), &[]),
326 route("POST", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::CreateWorkspaceRuleset), &[]),
327 route("GET", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::GetWorkspaceRuleset), &[]),
328 route("PUT", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::UpdateWorkspaceRuleset), &[]),
329 route("DELETE", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::DeleteWorkspaceRuleset), &[]),
330 route(
331 "GET",
332 "/workspaces/:workspace/rules/evaluations",
333 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
334 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
335 ),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97336 // Deployments wherever they run, their statuses, and environments.
337 route(
338 "GET",
339 "/repos/:owner/:name/deployments",
340 Op::Deployments(DeploymentsOp::ListDeployments),
341 &[("environment", "environment"), ("ref", "ref"), ("sha", "sha"), ("task", "task"), ("state", "state"), ("source", "source"), ("creator", "creator"), ("page", "page"), ("per_page", "per_page")],
342 ),
343 route("POST", "/repos/:owner/:name/deployments", Op::Deployments(DeploymentsOp::CreateDeployment), &[]),
344 route("GET", "/repos/:owner/:name/deployments/:id", Op::Deployments(DeploymentsOp::GetDeployment), &[]),
345 route("GET", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::ListDeploymentStatuses), &[]),
346 route("POST", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::CreateDeploymentStatus), &[]),
347 route("GET", "/repos/:owner/:name/environments", Op::Deployments(DeploymentsOp::ListEnvironments), &[]),
348 route("GET", "/repos/:owner/:name/environments/:environment", Op::Deployments(DeploymentsOp::GetEnvironment), &[]),
Merge branch 'worktree-agent-a3abfcce648e87dca'349 // Environments' protection rules, and the runs they hold.
350 route("PUT", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::UpdateEnvironment), &[]),
351 route("DELETE", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::DeleteEnvironment), &[]),
352 route(
353 "GET",
354 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
355 Op::Protection(ProtectionOp::GetPendingDeployments),
356 &[],
357 ),
358 route(
359 "POST",
360 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
361 Op::Protection(ProtectionOp::ReviewPendingDeployments),
362 &[],
363 ),
364 route("POST", "/repos/:owner/:name/actions/runs/:id/approve", Op::Protection(ProtectionOp::ApproveWorkflowRun), &[]),
365 route("GET", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::GetWorkflowPermissions), &[]),
366 route("PUT", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::SetWorkflowPermissions), &[]),
367 route(
368 "GET",
369 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
370 Op::Protection(ProtectionOp::GetForkPrApproval),
371 &[],
372 ),
373 route(
374 "PUT",
375 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
376 Op::Protection(ProtectionOp::SetForkPrApproval),
377 &[],
378 ),
Pull requests reopen and convert to draft; comments edit and delete379 route("GET", "/repos/:owner/:name/actions/permissions/access", Op::Protection(ProtectionOp::GetActionsAccess), &[]),
380 route("PUT", "/repos/:owner/:name/actions/permissions/access", Op::Protection(ProtectionOp::SetActionsAccess), &[]),
Merge branch 'worktree-agent-a3abfcce648e87dca'381 route("POST", "/repos/:owner/:name/dispatches", Op::Protection(ProtectionOp::CreateRepositoryDispatch), &[]),
382 route(
383 "GET",
384 "/workspaces/:workspace/actions/permissions/workflow",
385 Op::Protection(ProtectionOp::GetWorkspaceWorkflowPermissions),
386 &[],
387 ),
388 route(
389 "PUT",
390 "/workspaces/:workspace/actions/permissions/workflow",
391 Op::Protection(ProtectionOp::SetWorkspaceWorkflowPermissions),
392 &[],
393 ),
Agents as a team: lifecycle, merge queue, billing and a new shell394 route("GET", "/repos/:owner/:name/queue", Op::GetMergeQueue, &[]),
API and MCP server in Rust; a public index at the API root395 route(
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request396 "POST",
397 "/repos/:owner/:name/pulls/:number/messages",
398 Op::MessageAgent,
399 &[],
400 ),
401 route(
402 "POST",
403 "/repos/:owner/:name/pulls/:number/messages/take",
404 Op::TakeMessages,
405 &[],
406 ),
407 route(
Docs worth reading, and kept that way408 "POST",
409 "/repos/:owner/:name/messages/:id/answer",
410 Op::AnswerMessage,
411 &[],
412 ),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains413 route("POST", "/repos/:owner/:name/memory", Op::Remember, &[]),
414 route(
415 "GET",
416 "/repos/:owner/:name/memory",
417 Op::Recall,
418 &[("q", "query"), ("limit", "limit")],
419 ),
Docs worth reading, and kept that way420 route(
API and MCP server in Rust; a public index at the API root421 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell422 "/repos/:owner/:name/events",
API and MCP server in Rust; a public index at the API root423 Op::ListEvents,
424 &[("before", "before")],
425 ),
Agents as a team: lifecycle, merge queue, billing and a new shell426 route("GET", "/repos/:owner/:name/labels", Op::ListLabels, &[]),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar427 route("POST", "/repos/:owner/:name/labels", Op::CreateLabel, &[]),
428 route("POST", "/repos/:owner/:name/labels/defaults", Op::AddDefaultLabels, &[]),
429 route("PATCH", "/repos/:owner/:name/labels/:label", Op::UpdateLabel, &[]),
430 route("DELETE", "/repos/:owner/:name/labels/:label", Op::DeleteLabel, &[]),
431 route("GET", "/repos/:owner/:name/issues/:number/labels", Op::ListIssueLabels, &[]),
432 route("POST", "/repos/:owner/:name/issues/:number/labels", Op::AddIssueLabels, &[]),
433 route("PUT", "/repos/:owner/:name/issues/:number/labels", Op::SetIssueLabels, &[]),
434 route("DELETE", "/repos/:owner/:name/issues/:number/labels", Op::RemoveIssueLabels, &[]),
435 route("DELETE", "/repos/:owner/:name/issues/:number/labels/:label", Op::RemoveIssueLabels, &[]),
436 route("GET", "/repos/:owner/:name/milestones", Op::ListMilestones, &[("state", "state")]),
437 route("POST", "/repos/:owner/:name/milestones", Op::CreateMilestone, &[]),
438 route("GET", "/repos/:owner/:name/milestones/:milestone", Op::GetMilestone, &[]),
439 route("PATCH", "/repos/:owner/:name/milestones/:milestone", Op::UpdateMilestone, &[]),
440 route("DELETE", "/repos/:owner/:name/milestones/:milestone", Op::DeleteMilestone, &[]),
API and MCP server in Rust; a public index at the API root441 route(
442 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell443 "/repos/:owner/:name/issues",
API and MCP server in Rust; a public index at the API root444 Op::ListIssues,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar445 &[("state", "state"), ("label", "label"), ("milestone", "milestone")],
API and MCP server in Rust; a public index at the API root446 ),
Agents as a team: lifecycle, merge queue, billing and a new shell447 route("POST", "/repos/:owner/:name/issues", Op::CreateIssue, &[]),
API and MCP server in Rust; a public index at the API root448 route(
449 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell450 "/repos/:owner/:name/issues/:number",
API and MCP server in Rust; a public index at the API root451 Op::GetIssue,
452 &[],
453 ),
454 route(
455 "PATCH",
Agents as a team: lifecycle, merge queue, billing and a new shell456 "/repos/:owner/:name/issues/:number",
API and MCP server in Rust; a public index at the API root457 Op::UpdateIssue,
458 &[],
459 ),
460 route(
461 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell462 "/repos/:owner/:name/issues/:number/close",
API and MCP server in Rust; a public index at the API root463 Op::CloseIssue,
464 &[],
465 ),
466 route(
467 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell468 "/repos/:owner/:name/issues/:number/reopen",
API and MCP server in Rust; a public index at the API root469 Op::ReopenIssue,
470 &[],
471 ),
472 route(
473 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell474 "/repos/:owner/:name/issues/:number/assign",
475 Op::AssignIssue,
476 &[],
477 ),
Integrations: your own model provider, alerts that open issues, tickets agents read478 route(
479 "POST",
480 "/repos/:owner/:name/issues/import",
481 Op::ImportIssue,
482 &[],
483 ),
484 route(
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step485 "POST",
486 "/repos/:owner/:name/issues/delegate",
487 Op::Delegate,
488 &[],
489 ),
490 route(
Integrations: your own model provider, alerts that open issues, tickets agents read491 "GET",
492 "/repos/:owner/:name/context",
493 Op::GetContext,
494 &[("reference", "reference")],
495 ),
496 route(
497 "GET",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API498 "/workspaces/:workspace/context/search",
499 Op::SearchContext,
500 &[("q", "query"), ("project", "project"), ("kinds", "kinds"), ("limit", "limit")],
501 ),
502 route(
503 "GET",
504 "/workspaces/:workspace/context/:kind/:id",
505 Op::GetEntity,
506 &[],
507 ),
508 route(
509 "GET",
Integrations: your own model provider, alerts that open issues, tickets agents read510 "/workspaces/:workspace/integrations",
511 Op::ListIntegrations,
512 &[],
513 ),
514 route(
515 "POST",
516 "/workspaces/:workspace/integrations",
517 Op::ConnectIntegration,
518 &[],
519 ),
520 route(
Models per workspace: several providers, routed by kind of work521 "GET",
Webhooks: every event, to your own addresses, signed and retried522 "/repos/:owner/:name/hooks",
523 Op::ListWebhooks,
524 &[],
525 ),
526 route(
527 "POST",
528 "/repos/:owner/:name/hooks",
529 Op::CreateWebhook,
530 &[],
531 ),
532 route(
533 "PATCH",
534 "/repos/:owner/:name/hooks/:id",
535 Op::UpdateWebhook,
536 &[],
537 ),
538 route(
539 "DELETE",
540 "/repos/:owner/:name/hooks/:id",
541 Op::DeleteWebhook,
542 &[],
543 ),
544 route(
545 "POST",
546 "/repos/:owner/:name/hooks/:id/pings",
547 Op::PingWebhook,
548 &[],
549 ),
550 route(
551 "GET",
552 "/repos/:owner/:name/hooks/:id/deliveries",
553 Op::ListWebhookDeliveries,
554 &[],
555 ),
556 route(
557 "POST",
558 "/repos/:owner/:name/hooks/:id/deliveries/:delivery/redeliver",
559 Op::RedeliverWebhook,
560 &[],
561 ),
562 route(
563 "GET",
564 "/workspaces/:workspace/hooks",
565 Op::ListWebhooks,
566 &[],
567 ),
568 route(
569 "POST",
570 "/workspaces/:workspace/hooks",
571 Op::CreateWebhook,
572 &[],
573 ),
574 route(
575 "PATCH",
576 "/workspaces/:workspace/hooks/:id",
577 Op::UpdateWebhook,
578 &[],
579 ),
580 route(
581 "DELETE",
582 "/workspaces/:workspace/hooks/:id",
583 Op::DeleteWebhook,
584 &[],
585 ),
586 route(
587 "POST",
588 "/workspaces/:workspace/hooks/:id/pings",
589 Op::PingWebhook,
590 &[],
591 ),
592 route(
593 "GET",
594 "/workspaces/:workspace/hooks/:id/deliveries",
595 Op::ListWebhookDeliveries,
596 &[],
597 ),
598 route(
599 "POST",
600 "/workspaces/:workspace/hooks/:id/deliveries/:delivery/redeliver",
601 Op::RedeliverWebhook,
602 &[],
603 ),
604 route(
605 "GET",
Models per workspace: several providers, routed by kind of work606 "/workspaces/:workspace/model-routes",
607 Op::GetModelRoutes,
608 &[],
609 ),
610 route(
611 "PUT",
612 "/workspaces/:workspace/model-routes",
613 Op::SetModelRoutes,
614 &[],
615 ),
616 route(
AI Gateway: OpenAI's format, open models, and your own providers617 "PATCH",
618 "/workspaces/:workspace/integrations/:id",
619 Op::UpdateIntegration,
620 &[],
621 ),
622 route(
Integrations: your own model provider, alerts that open issues, tickets agents read623 "DELETE",
624 "/workspaces/:workspace/integrations/:id",
625 Op::DisconnectIntegration,
626 &[],
627 ),
628 route(
629 "POST",
630 "/workspaces/:workspace/integrations/:id/test",
631 Op::TestIntegration,
632 &[],
633 ),
Automations: rules in .g1t/automations that act when something happens634 route(
635 "GET",
GitHub Actions on g1t, part two: running workflows636 "/repos/:owner/:name/actions/workflows",
637 Op::ListWorkflows,
638 &[],
639 ),
640 route(
641 "GET",
642 "/repos/:owner/:name/actions/workflows/:workflow/runs",
643 Op::ListWorkflowRuns,
644 &[("branch", "branch"), ("event", "event"), ("per_page", "limit")],
645 ),
646 route(
647 "POST",
648 "/repos/:owner/:name/actions/workflows/:workflow/dispatches",
649 Op::DispatchWorkflow,
650 &[],
651 ),
652 route(
653 "PATCH",
654 "/repos/:owner/:name/actions/workflows/:workflow",
655 Op::UpdateWorkflow,
656 &[],
657 ),
658 route(
659 "PUT",
660 "/repos/:owner/:name/actions/workflows/:workflow/enable",
661 Op::UpdateWorkflow,
662 &[],
663 ),
664 route(
665 "PUT",
666 "/repos/:owner/:name/actions/workflows/:workflow/disable",
667 Op::UpdateWorkflow,
668 &[],
669 ),
670 route(
671 "GET",
672 "/repos/:owner/:name/actions/runs",
673 Op::ListWorkflowRuns,
674 &[("workflow", "workflow"), ("branch", "branch"), ("event", "event"), ("pull", "pull"), ("head_sha", "sha"), ("per_page", "limit")],
675 ),
676 route(
677 "GET",
678 "/repos/:owner/:name/actions/runs/:id",
679 Op::GetWorkflowRun,
680 &[],
681 ),
682 route(
683 "POST",
684 "/repos/:owner/:name/actions/runs/:id/cancel",
685 Op::CancelWorkflowRun,
686 &[],
687 ),
688 route(
689 "POST",
690 "/repos/:owner/:name/actions/runs/:id/rerun",
691 Op::RerunWorkflowRun,
692 &[],
693 ),
694 route(
695 "POST",
696 "/repos/:owner/:name/actions/runs/:id/rerun-failed-jobs",
697 Op::RerunWorkflowRun,
698 &[],
699 ),
700 route(
701 "GET",
702 "/repos/:owner/:name/actions/jobs/:job/logs",
703 Op::GetJobLogs,
704 &[("after", "after")],
705 ),
Merge packages: roles, Actions access, source label, soft delete, API706 // Packages, at GitHub's addresses with the workspace in place of the
707 // organization. A name with a slash is one URL-encoded segment.
708 route("GET", "/workspaces/:workspace/packages", Op::Packages(PackagesOp::ListPackages), &[("package_type", "package_type"), ("q", "q"), ("state", "state")]),
709 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::GetPackage), &[]),
710 route("PATCH", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::UpdatePackage), &[]),
711 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::DeletePackage), &[]),
712 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/restore", Op::Packages(PackagesOp::RestorePackage), &[]),
713 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions", Op::Packages(PackagesOp::ListVersions), &[("state", "state")]),
714 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::GetVersion), &[]),
715 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::DeleteVersion), &[]),
716 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id/restore", Op::Packages(PackagesOp::RestoreVersion), &[]),
717 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::LinkPackage), &[]),
718 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::UnlinkPackage), &[]),
719 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::ListAccess), &[]),
720 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::SetAccess), &[]),
721 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::RemoveAccess), &[("username", "username"), ("team", "team")]),
722 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::ListActionsAccess), &[]),
723 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::SetActionsAccess), &[]),
724 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 R2725 // Artifacts, at GitHub's addresses. `…/zip` answers with a redirect to
726 // a signed link (lib.rs).
727 route("GET", "/repos/:owner/:name/actions/artifacts", Op::Artifacts(ArtifactsOp::ListArtifacts), &[("name", "name"), ("page", "page"), ("per_page", "per_page")]),
728 route("GET", "/repos/:owner/:name/actions/runs/:id/artifacts", Op::Artifacts(ArtifactsOp::ListRunArtifacts), &[("name", "name")]),
729 route("GET", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::GetArtifact), &[]),
730 route("GET", "/repos/:owner/:name/actions/artifacts/:id/zip", Op::Artifacts(ArtifactsOp::DownloadArtifact), &[]),
731 route("DELETE", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::DeleteArtifact), &[]),
732 route("GET", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::GetArtifactRetention), &[]),
733 route("PUT", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::SetArtifactRetention), &[]),
GitHub Actions on g1t, part two: running workflows734 route(
735 "GET",
736 "/repos/:owner/:name/actions/secrets",
737 Op::ListActionsSecrets,
738 &[],
739 ),
740 route(
741 "PUT",
742 "/repos/:owner/:name/actions/secrets/:setting",
743 Op::SetActionsSecret,
744 &[],
745 ),
746 route(
747 "DELETE",
748 "/repos/:owner/:name/actions/secrets/:setting",
749 Op::DeleteActionsSecret,
750 &[],
751 ),
752 route(
753 "GET",
754 "/repos/:owner/:name/actions/variables",
755 Op::ListActionsVariables,
756 &[],
757 ),
758 route(
759 "POST",
760 "/repos/:owner/:name/actions/variables",
761 Op::SetActionsVariable,
762 &[],
763 ),
764 route(
765 "PATCH",
766 "/repos/:owner/:name/actions/variables/:setting",
767 Op::SetActionsVariable,
768 &[],
769 ),
770 route(
771 "DELETE",
772 "/repos/:owner/:name/actions/variables/:setting",
773 Op::DeleteActionsVariable,
774 &[],
775 ),
776 route(
777 "GET",
778 "/workspaces/:workspace/actions/secrets",
779 Op::ListActionsSecrets,
780 &[],
781 ),
782 route(
783 "PUT",
784 "/workspaces/:workspace/actions/secrets/:setting",
785 Op::SetActionsSecret,
786 &[],
787 ),
788 route(
789 "DELETE",
790 "/workspaces/:workspace/actions/secrets/:setting",
791 Op::DeleteActionsSecret,
792 &[],
793 ),
794 route(
795 "GET",
796 "/workspaces/:workspace/actions/variables",
797 Op::ListActionsVariables,
798 &[],
799 ),
800 route(
801 "POST",
802 "/workspaces/:workspace/actions/variables",
803 Op::SetActionsVariable,
804 &[],
805 ),
806 route(
807 "PATCH",
808 "/workspaces/:workspace/actions/variables/:setting",
809 Op::SetActionsVariable,
810 &[],
811 ),
812 route(
813 "DELETE",
814 "/workspaces/:workspace/actions/variables/:setting",
815 Op::DeleteActionsVariable,
816 &[],
817 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents818 // Self-hosted runners: a repository's own, or a workspace's.
819 route("GET", "/repos/:owner/:name/actions/runners", Op::ListRunners, &[]),
820 route("POST", "/repos/:owner/:name/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
821 route("DELETE", "/repos/:owner/:name/actions/runners/:id", Op::RemoveRunner, &[]),
822 route("GET", "/repos/:owner/:name/actions/runner-settings", Op::GetRunnerSettings, &[]),
823 route("PATCH", "/repos/:owner/:name/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
824 route("GET", "/workspaces/:workspace/actions/runners", Op::ListRunners, &[]),
825 route("POST", "/workspaces/:workspace/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
826 route("DELETE", "/workspaces/:workspace/actions/runners/:id", Op::RemoveRunner, &[]),
827 route("GET", "/workspaces/:workspace/actions/runner-settings", Op::GetRunnerSettings, &[]),
828 route("PATCH", "/workspaces/:workspace/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
829 route("GET", "/workspaces/:workspace/actions/runner-groups", Op::ListRunnerGroups, &[]),
830 route("POST", "/workspaces/:workspace/actions/runner-groups", Op::CreateRunnerGroup, &[]),
831 route("PATCH", "/workspaces/:workspace/actions/runner-groups/:id", Op::UpdateRunnerGroup, &[]),
832 route("DELETE", "/workspaces/:workspace/actions/runner-groups/:id", Op::DeleteRunnerGroup, &[]),
Agents as a team: lifecycle, merge queue, billing and a new shell833 route("POST", "/repos/:owner/:name/plans", Op::PlanWork, &[]),
834 route("GET", "/repos/:owner/:name/plans/:plan", Op::GetPlan, &[]),
835 route(
836 "POST",
837 "/repos/:owner/:name/plans/:plan/apply",
838 Op::ApplyPlan,
839 &[],
840 ),
841 route(
842 "POST",
843 "/repos/:owner/:name/issues/:number/comments",
API and MCP server in Rust; a public index at the API root844 Op::AddComment,
845 &[],
846 ),
Pull requests reopen and convert to draft; comments edit and delete847 route("PATCH", "/repos/:owner/:name/issues/comments/:comment_id", Op::EditComment, &[]),
848 route("DELETE", "/repos/:owner/:name/issues/comments/:comment_id", Op::DeleteComment, &[]),
API and MCP server in Rust; a public index at the API root849 route(
850 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell851 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root852 Op::ListPullRequests,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar853 &[("state", "state"), ("label", "label"), ("milestone", "milestone"), ("base", "base")],
API and MCP server in Rust; a public index at the API root854 ),
855 route(
856 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell857 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root858 Op::CreatePullRequest,
859 &[],
860 ),
861 route(
862 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell863 "/repos/:owner/:name/pulls/:number",
API and MCP server in Rust; a public index at the API root864 Op::GetPullRequest,
865 &[],
866 ),
867 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar868 "PATCH",
869 "/repos/:owner/:name/pulls/:number",
870 Op::UpdatePullRequest,
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/changes",
API and MCP server in Rust; a public index at the API root876 Op::GetPullRequestChanges,
877 &[],
878 ),
879 route(
Acceptance checks in sandboxes, line comments and review verdicts880 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell881 "/repos/:owner/:name/pulls/:number/reviews",
Acceptance checks in sandboxes, line comments and review verdicts882 Op::ReviewPullRequest,
883 &[],
884 ),
885 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar886 "POST",
887 "/repos/:owner/:name/pulls/:number/requested_reviewers",
888 Op::RequestReviewers,
889 &[],
890 ),
891 route(
892 "DELETE",
893 "/repos/:owner/:name/pulls/:number/requested_reviewers",
894 Op::RemoveRequestedReviewers,
895 &[],
896 ),
897 route(
API and MCP server in Rust; a public index at the API root898 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell899 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root900 Op::ReadSession,
901 &[("after", "after")],
902 ),
903 route(
904 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell905 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root906 Op::RecordSession,
907 &[],
908 ),
909 route(
910 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell911 "/repos/:owner/:name/pulls/:number/ready",
API and MCP server in Rust; a public index at the API root912 Op::MarkPullRequestReady,
913 &[],
914 ),
Pull requests reopen and convert to draft; comments edit and delete915 route("POST", "/repos/:owner/:name/pulls/:number/draft", Op::ConvertPullRequestToDraft, &[]),
API and MCP server in Rust; a public index at the API root916 route(
917 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell918 "/repos/:owner/:name/pulls/:number/close",
API and MCP server in Rust; a public index at the API root919 Op::ClosePullRequest,
920 &[],
921 ),
Pull requests reopen and convert to draft; comments edit and delete922 route("POST", "/repos/:owner/:name/pulls/:number/reopen", Op::ReopenPullRequest, &[]),
API and MCP server in Rust; a public index at the API root923 route(
924 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell925 "/repos/:owner/:name/pulls/:number/merge",
API and MCP server in Rust; a public index at the API root926 Op::MergePullRequest,
927 &[],
928 ),
929];
930
931impl Route {
Pull requests reopen and convert to draft; comments edit and delete932 /// Whether the route answers success with `204` and no body, as
933 /// GitHub's address for the same does. MCP still answers `true`.
934 pub fn no_content(&self) -> bool {
935 self.op == Op::DeleteComment
936 }
937
API and MCP server in Rust; a public index at the API root938 /// The names of the route's path parameters, in order.
939 pub fn params(&self) -> impl Iterator<Item = &'static str> {
940 self.path
941 .split('/')
942 .filter_map(|segment| segment.strip_prefix(':'))
943 }
944
945 /// The values of the path parameters, if `path` is this route's.
946 fn matches<'a>(&self, path: &'a str) -> Option<Vec<(&'static str, &'a str)>> {
947 let mut values = Vec::new();
948 let mut actual = path.trim_end_matches('/').split('/');
949 for expected in self.path.split('/') {
950 let segment = actual.next()?;
951 match expected.strip_prefix(':') {
952 Some(name) if !segment.is_empty() => values.push((name, segment)),
953 Some(_) => return None,
954 None if expected == segment => {}
955 None => return None,
956 }
957 }
958 actual.next().is_none().then_some(values)
959 }
960}
961
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look962/// A path segment with its `%XX` escapes decoded; as given when that is not
963/// UTF-8.
964fn percent_decoded(segment: &str) -> String {
965 let bytes = segment.as_bytes();
966 let mut out = Vec::with_capacity(bytes.len());
967 let mut i = 0;
968 while i < bytes.len() {
969 let escaped = (bytes[i] == b'%')
970 .then(|| segment.get(i + 1..i + 3))
971 .flatten()
972 .filter(|hex| hex.bytes().all(|byte| byte.is_ascii_hexdigit()))
973 .and_then(|hex| u8::from_str_radix(hex, 16).ok());
974 match escaped {
975 Some(byte) => {
976 out.push(byte);
977 i += 3;
978 }
979 None => {
980 out.push(bytes[i]);
981 i += 1;
982 }
983 }
984 }
985 String::from_utf8(out).unwrap_or_else(|_| segment.to_owned())
986}
987
API and MCP server in Rust; a public index at the API root988/// The route for a request, and the operation input it describes.
989///
990/// The input is the JSON body, overlaid with the query parameters the route
991/// 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 bar992/// `repo`, as does a team's `repo` with its `workspace`, and `number`
993/// becomes an integer.
API and MCP server in Rust; a public index at the API root994pub fn resolve(
995 method: &str,
996 path: &str,
997 query: &[(String, String)],
998 body: Value,
999) -> Option<(&'static Route, Value)> {
1000 let (route, params) = ROUTES
1001 .iter()
1002 .filter(|route| route.method == method)
1003 .find_map(|route| Some((route, route.matches(path)?)))?;
1004
1005 let mut input = match body {
1006 Value::Object(fields) => fields,
1007 _ => Map::new(),
1008 };
1009 for (name, key) in route.query {
1010 if let Some((_, value)) = query.iter().find(|(query_name, _)| query_name == name) {
1011 input.insert((*key).to_owned(), Value::String(value.clone()));
1012 }
1013 }
1014 let param = |wanted: &str| {
1015 params
1016 .iter()
1017 .find(|(name, _)| *name == wanted)
1018 .map(|(_, value)| *value)
1019 };
1020 if let (Some(owner), Some(name)) = (param("owner"), param("name")) {
1021 input.insert("repo".to_owned(), Value::String(format!("{owner}/{name}")));
1022 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971023 // Every other name the path gives, under that name; the ones below that
1024 // need more (a repository, a number, an encoded name) are set after.
1025 for (key, value) in &params {
1026 if !matches!(*key, "owner" | "name") {
1027 input.insert((*key).to_owned(), Value::String(percent_decoded(value)));
Docs worth reading, and kept that way1028 }
Agents as a team: lifecycle, merge queue, billing and a new shell1029 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1030 // A repository of a team's workspace, named by itself.
1031 if let (Some(workspace), Some(name)) = (param("workspace"), param("repo")) {
1032 input.insert("repo".to_owned(), Value::String(format!("{workspace}/{name}")));
1033 }
1034 // A branch name may hold slashes, sent URL-encoded as one segment, and
1035 // a label's name spaces.
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1036 if let Some(branch) = param("branch") {
1037 input.insert("branch".to_owned(), Value::String(percent_decoded(branch)));
1038 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971039 // An environment's name may hold slashes and spaces, URL-encoded.
1040 if let Some(environment) = param("environment") {
1041 input.insert("environment".to_owned(), Value::String(percent_decoded(environment)));
1042 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1043 if let Some(label) = param("label") {
1044 input.insert("label".to_owned(), Value::String(percent_decoded(label)));
1045 }
1046 if let Some(milestone) = param("milestone") {
1047 // Not a number: zero, which no milestone has.
1048 input.insert("milestone".to_owned(), milestone.parse::<u32>().unwrap_or(0).into());
1049 }
GitHub Actions on g1t, part two: running workflows1050 // GitHub says some things with the path alone.
1051 if route.path.ends_with("/enable") || route.path.ends_with("/disable") {
1052 input.insert("enabled".to_owned(), Value::Bool(route.path.ends_with("/enable")));
1053 }
1054 if route.path.ends_with("/rerun-failed-jobs") {
1055 input.insert("failed_only".to_owned(), Value::Bool(true));
1056 }
API: notifications over REST and MCP, with notifications scopes1057 // Unsaving and waking a thread are a DELETE of what PUT made.
1058 if route.method == "DELETE" && route.path.ends_with("/saved") {
1059 input.insert("saved".to_owned(), Value::Bool(false));
1060 }
1061 if route.method == "DELETE" && route.path.ends_with("/snooze") {
1062 input.remove("until");
1063 }
API and MCP server in Rust; a public index at the API root1064 if let Some(number) = param("number") {
1065 // Not a number: zero, which no issue or pull request has.
1066 input.insert(
1067 "number".to_owned(),
1068 number.parse::<u32>().unwrap_or(0).into(),
1069 );
1070 }
1071 Some((route, Value::Object(input)))
1072}
1073
1074#[cfg(test)]
1075mod tests {
1076 use serde_json::json;
1077
1078 use super::*;
1079
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971080 /// Every name a route's path gives reaches the operation: a name left
1081 /// off the lists above is dropped, and the operation answers that it
1082 /// was not given (the project routes were, until this test).
1083 #[test]
1084 fn every_path_parameter_reaches_the_input() {
1085 for route in ROUTES.iter() {
1086 let names: Vec<&str> = route.path.split('/').filter_map(|part| part.strip_prefix(':')).collect();
1087 if names.is_empty() {
1088 continue;
1089 }
1090 let path: String = route
1091 .path
1092 .split('/')
1093 .map(|part| match part.strip_prefix(':') {
1094 Some("number" | "milestone") => "7".to_owned(),
1095 Some(name) => format!("{name}-x"),
1096 None => part.to_owned(),
1097 })
1098 .collect::<Vec<_>>()
1099 .join("/");
1100 let (found, input) = resolve(route.method, &path, &[], json!({})).unwrap();
1101 // A path two routes could take is checked under the first.
1102 if found.path != route.path {
1103 continue;
1104 }
1105 for name in names {
1106 let key = match name {
1107 "owner" | "name" => "repo",
1108 "repo" if names_has_workspace(route.path) => "repo",
1109 other => other,
1110 };
1111 assert!(
1112 input.get(key).is_some_and(|value| !value.is_null()),
1113 "{} {}: :{name} does not reach the input",
1114 route.method,
1115 route.path
1116 );
1117 }
1118 }
1119 }
1120
1121 fn names_has_workspace(path: &str) -> bool {
1122 path.split('/').any(|part| part == ":workspace")
1123 }
1124
API and MCP server in Rust; a public index at the API root1125 #[test]
1126 fn a_path_resolves_to_its_operation_and_input() {
1127 let (route, input) = resolve(
1128 "POST",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1129 "/repos/flagon-io/hello/pulls/14/merge",
API and MCP server in Rust; a public index at the API root1130 &[],
1131 json!({ "keep_issue_open": true, "number": 99, "repo": "someone/else" }),
1132 )
1133 .unwrap();
1134 assert_eq!(route.op, Op::MergePullRequest);
1135 // What the path names wins over the body.
1136 assert_eq!(
1137 input,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1138 json!({ "keep_issue_open": true, "number": 14, "repo": "flagon-io/hello" })
API and MCP server in Rust; a public index at the API root1139 );
1140 }
1141
1142 #[test]
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1143 fn a_branch_with_slashes_is_one_encoded_segment() {
1144 let (route, input) = resolve(
1145 "POST",
1146 "/repos/flagon-io/hello/branches/feature%2Flogin/rename",
1147 &[],
1148 json!({ "new_name": "feature/sign-in" }),
1149 )
1150 .unwrap();
1151 assert_eq!(route.op, Op::RenameBranch);
1152 assert_eq!(
1153 input,
1154 json!({ "new_name": "feature/sign-in", "branch": "feature/login", "repo": "flagon-io/hello" })
1155 );
1156 assert_eq!(percent_decoded("100%"), "100%");
1157 assert_eq!(percent_decoded("a%2bb%zz"), "a+b%zz");
1158 }
1159
1160 #[test]
1161 fn a_collaborator_is_named_by_username() {
1162 let (route, input) = resolve(
1163 "PATCH",
1164 "/repos/flagon-io/hello/collaborators/ada",
1165 &[],
1166 json!({ "role": "maintain" }),
1167 )
1168 .unwrap();
1169 assert_eq!(route.op, Op::UpdateCollaborator);
1170 assert_eq!(input, json!({ "role": "maintain", "username": "ada", "repo": "flagon-io/hello" }));
1171 let (route, input) = resolve("DELETE", "/user/repository_invitations/rin_1", &[], Value::Null).unwrap();
1172 assert_eq!(route.op, Op::DeclineRepoInvitation);
1173 assert_eq!(input, json!({ "id": "rin_1" }));
1174 }
1175
1176 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1177 fn teams_are_addressed_by_workspace_and_slug() {
1178 let query = [("q".to_owned(), "back".to_owned())];
1179 let (route, input) = resolve("GET", "/workspaces/acme/teams", &query, Value::Null).unwrap();
1180 assert_eq!(route.op, Op::ListTeams);
1181 assert_eq!(input, json!({ "query": "back", "workspace": "acme" }));
1182 let (route, input) = resolve("PATCH", "/workspaces/acme/teams/backend", &[], json!({ "name": "Back end" })).unwrap();
1183 assert_eq!(route.op, Op::UpdateTeam);
1184 assert_eq!(input, json!({ "name": "Back end", "workspace": "acme", "team": "backend" }));
1185 let (route, input) =
1186 resolve("PUT", "/workspaces/acme/teams/backend/members/ana", &[], json!({ "role": "maintainer" })).unwrap();
1187 assert_eq!(route.op, Op::SetTeamMember);
1188 assert_eq!(input, json!({ "role": "maintainer", "workspace": "acme", "team": "backend", "username": "ana" }));
1189 let query = [("include_child_teams".to_owned(), "true".to_owned())];
1190 let (route, input) = resolve("GET", "/workspaces/acme/teams/backend/members", &query, Value::Null).unwrap();
1191 assert_eq!(route.op, Op::ListTeamMembers);
1192 assert_eq!(input, json!({ "include_child_teams": "true", "workspace": "acme", "team": "backend" }));
1193 // A repository is named by itself, in the team's workspace.
1194 let (route, input) =
1195 resolve("PUT", "/workspaces/acme/teams/backend/repos/rocket", &[], json!({ "role": "write" })).unwrap();
1196 assert_eq!(route.op, Op::SetTeamRepo);
1197 assert_eq!(input, json!({ "role": "write", "workspace": "acme", "team": "backend", "repo": "acme/rocket" }));
1198 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1199 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/repos/rocket"), Op::RemoveTeamRepo);
1200 assert_eq!(op("GET", "/workspaces/acme/teams/backend/teams"), Op::ListChildTeams);
1201 assert_eq!(op("GET", "/workspaces/acme/teams/backend/repos"), Op::ListTeamRepos);
1202 assert_eq!(op("PUT", "/workspaces/acme/teams/backend/review_assignment"), Op::SetTeamReviewAssignment);
1203 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend"), Op::DeleteTeam);
1204 assert_eq!(op("POST", "/workspaces/acme/teams"), Op::CreateTeam);
1205 assert_eq!(op("GET", "/workspaces/acme/teams/backend"), Op::GetTeam);
1206 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/members/ana"), Op::RemoveTeamMember);
1207 let (route, input) = resolve("GET", "/workspaces/acme/members/ana/teams", &[], Value::Null).unwrap();
1208 assert_eq!(route.op, Op::ListUserTeams);
1209 assert_eq!(input, json!({ "workspace": "acme", "username": "ana" }));
1210 }
1211
1212 #[test]
1213 fn reviewers_are_requested_and_code_owners_checked_on_a_repository() {
1214 let body = json!({ "reviewers": ["ana"], "team_reviewers": ["backend"] });
1215 let (route, input) = resolve("POST", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body.clone()).unwrap();
1216 assert_eq!(route.op, Op::RequestReviewers);
1217 assert_eq!(
1218 input,
1219 json!({ "reviewers": ["ana"], "team_reviewers": ["backend"], "repo": "acme/rocket", "number": 7 })
1220 );
1221 let (route, _) = resolve("DELETE", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body).unwrap();
1222 assert_eq!(route.op, Op::RemoveRequestedReviewers);
1223 let query = [("ref".to_owned(), "main".to_owned())];
1224 let (route, input) = resolve("GET", "/repos/acme/rocket/codeowners/errors", &query, Value::Null).unwrap();
1225 assert_eq!(route.op, Op::GetCodeownersErrors);
1226 assert_eq!(input, json!({ "ref": "main", "repo": "acme/rocket" }));
1227 }
1228
1229 #[test]
API: notifications over REST and MCP, with notifications scopes1230 fn notifications_are_addressed_as_threads_and_by_issue() {
1231 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1", &[], Value::Null).unwrap();
1232 assert_eq!(route.op, Op::MarkThreadDone);
1233 assert_eq!(input, json!({ "id": "ntf_1" }));
1234 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/saved", &[], Value::Null).unwrap();
1235 assert_eq!(route.op, Op::SaveThread);
1236 assert_eq!(input, json!({ "id": "ntf_1", "saved": false }));
1237 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/snooze", &[], json!({ "until": "x" })).unwrap();
1238 assert_eq!(route.op, Op::SnoozeThread);
1239 assert_eq!(input, json!({ "id": "ntf_1" }));
1240 let query = [("all".to_owned(), "true".to_owned()), ("per_page".to_owned(), "50".to_owned())];
1241 let (route, input) = resolve("GET", "/repos/acme/rocket/notifications", &query, Value::Null).unwrap();
1242 assert_eq!(route.op, Op::ListNotifications);
1243 assert_eq!(input, json!({ "all": "true", "per_page": "50", "repo": "acme/rocket" }));
1244 let (route, input) = resolve("PUT", "/repos/acme/rocket/issues/7/subscription", &[], json!({ "ignored": true })).unwrap();
1245 assert_eq!(route.op, Op::SetThreadSubscription);
1246 assert_eq!(input, json!({ "ignored": true, "number": 7, "repo": "acme/rocket" }));
1247 assert_eq!(resolve("GET", "/user/subscriptions", &[], Value::Null).unwrap().0.op, Op::ListWatchedRepos);
1248 }
1249
1250 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1251 fn labels_and_milestones_are_named_in_the_path() {
1252 let (route, input) = resolve("PATCH", "/repos/acme/web/labels/good%20first%20issue", &[], json!({ "color": "7057ff" })).unwrap();
1253 assert_eq!(route.op, Op::UpdateLabel);
1254 assert_eq!(input, json!({ "color": "7057ff", "label": "good first issue", "repo": "acme/web" }));
1255 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels/bug", &[], Value::Null).unwrap();
1256 assert_eq!(route.op, Op::RemoveIssueLabels);
1257 assert_eq!(input, json!({ "label": "bug", "number": 7, "repo": "acme/web" }));
1258 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels", &[], Value::Null).unwrap();
1259 assert_eq!(route.op, Op::RemoveIssueLabels);
1260 assert_eq!(input, json!({ "number": 7, "repo": "acme/web" }));
1261 let (route, _) = resolve("POST", "/repos/acme/web/labels/defaults", &[], Value::Null).unwrap();
1262 assert_eq!(route.op, Op::AddDefaultLabels);
1263 let (route, input) = resolve("PATCH", "/repos/acme/web/milestones/3", &[], json!({ "state": "closed" })).unwrap();
1264 assert_eq!(route.op, Op::UpdateMilestone);
1265 assert_eq!(input, json!({ "state": "closed", "milestone": 3, "repo": "acme/web" }));
1266 let (route, input) = resolve("PATCH", "/repos/acme/web/pulls/9", &[], json!({ "base": "release" })).unwrap();
1267 assert_eq!(route.op, Op::UpdatePullRequest);
1268 assert_eq!(input, json!({ "base": "release", "number": 9, "repo": "acme/web" }));
1269 }
1270
1271 #[test]
Pull requests reopen and convert to draft; comments edit and delete1272 fn pull_requests_reopen_and_turn_draft_and_comments_are_named_by_id() {
1273 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1274 assert_eq!(op("POST", "/repos/acme/web/pulls/9/reopen"), Op::ReopenPullRequest);
1275 assert_eq!(op("POST", "/repos/acme/web/pulls/9/draft"), Op::ConvertPullRequestToDraft);
1276 assert_eq!(op("POST", "/repos/acme/web/pulls/9/close"), Op::ClosePullRequest);
1277 // Reopening and closing with a PATCH, as `state`.
1278 let (route, input) = resolve("PATCH", "/repos/acme/web/pulls/9", &[], json!({ "state": "open" })).unwrap();
1279 assert_eq!(route.op, Op::UpdatePullRequest);
1280 assert_eq!(input, json!({ "state": "open", "number": 9, "repo": "acme/web" }));
1281 let (route, input) =
1282 resolve("PATCH", "/repos/acme/web/issues/comments/cmt_1", &[], json!({ "body": "Better" })).unwrap();
1283 assert_eq!(route.op, Op::EditComment);
1284 assert_eq!(input, json!({ "body": "Better", "comment_id": "cmt_1", "repo": "acme/web" }));
1285 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/comments/cmt_1", &[], Value::Null).unwrap();
1286 assert_eq!(route.op, Op::DeleteComment);
1287 assert_eq!(input, json!({ "comment_id": "cmt_1", "repo": "acme/web" }));
1288 // Still an issue's comments, labels and subscription.
1289 assert_eq!(op("POST", "/repos/acme/web/issues/7/comments"), Op::AddComment);
1290 assert_eq!(op("DELETE", "/repos/acme/web/issues/7/labels"), Op::RemoveIssueLabels);
1291 assert_eq!(op("DELETE", "/repos/acme/web/issues/7/subscription"), Op::DeleteThreadSubscription);
1292 }
1293
1294 #[test]
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1295 fn billing_is_addressed_by_workspace() {
1296 let query = [("from".to_owned(), "2026-10-01".to_owned()), ("products".to_owned(), "agent,sandboxes".to_owned())];
1297 let (route, input) = resolve("GET", "/workspaces/acme/usage", &query, Value::Null).unwrap();
1298 assert_eq!(route.op, Op::GetUsage);
1299 assert_eq!(input, json!({ "from": "2026-10-01", "products": "agent,sandboxes", "workspace": "acme" }));
1300 let (route, input) = resolve("PUT", "/workspaces/acme/budget", &[], json!({ "alerts": [50] })).unwrap();
1301 assert_eq!(route.op, Op::SetBudget);
1302 assert_eq!(input, json!({ "alerts": [50], "workspace": "acme" }));
1303 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1304 assert_eq!(op("GET", "/workspaces/acme/budget"), Op::GetBudget);
1305 assert_eq!(op("GET", "/workspaces/acme/ai_credit"), Op::GetAiCredit);
1306 assert_eq!(op("POST", "/workspaces/acme/ai_credit/checkout"), Op::BuyAiCredit);
1307 assert_eq!(op("GET", "/workspaces/acme/invoices"), Op::ListInvoices);
1308 assert_eq!(op("GET", "/workspaces/acme/billing_details"), Op::GetBillingDetails);
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens1309 assert_eq!(op("GET", "/workspaces/acme/gateway/requests"), Op::ListGatewayRequests);
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1310 }
1311
1312 #[test]
Merge checks: statuses and check runs on every commit1313 fn checks_are_at_githubs_addresses() {
1314 let sha = "a".repeat(40);
1315 let body = json!({ "state": "success", "context": "ci/build" });
1316 let (route, input) = resolve("POST", &format!("/repos/acme/web/statuses/{sha}"), &[], body).unwrap();
1317 assert_eq!(route.op, Op::Checks(ChecksOp::CreateCommitStatus));
1318 assert_eq!(input, json!({ "state": "success", "context": "ci/build", "sha": sha, "repo": "acme/web" }));
1319 let (route, input) = resolve("GET", "/repos/acme/web/commits/release%2F1.x/status", &[], Value::Null).unwrap();
1320 assert_eq!(route.op, Op::Checks(ChecksOp::GetCombinedStatus));
1321 assert_eq!(input, json!({ "ref": "release/1.x", "repo": "acme/web" }));
1322 let query = [("check_name".to_owned(), "lint".to_owned())];
1323 let (route, input) = resolve("GET", "/repos/acme/web/commits/main/check-runs", &query, Value::Null).unwrap();
1324 assert_eq!(route.op, Op::Checks(ChecksOp::ListCheckRunsForRef));
1325 assert_eq!(input, json!({ "check_name": "lint", "ref": "main", "repo": "acme/web" }));
1326 let (route, input) = resolve("PATCH", "/repos/acme/web/check-runs/cr_1", &[], json!({ "conclusion": "success" })).unwrap();
1327 assert_eq!(route.op, Op::Checks(ChecksOp::UpdateCheckRun));
1328 assert_eq!(input, json!({ "conclusion": "success", "id": "cr_1", "repo": "acme/web" }));
1329 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1330 assert_eq!(op("POST", "/repos/acme/web/check-runs"), Op::Checks(ChecksOp::CreateCheckRun));
1331 assert_eq!(op("GET", "/repos/acme/web/check-runs/cr_1/annotations"), Op::Checks(ChecksOp::ListCheckRunAnnotations));
1332 assert_eq!(op("POST", "/repos/acme/web/check-suites/cs_1/rerequest"), Op::Checks(ChecksOp::RerequestCheckSuite));
1333 assert_eq!(op("GET", "/repos/acme/web/commits/main/check-suites"), Op::Checks(ChecksOp::ListCheckSuitesForRef));
1334 }
1335
1336 #[test]
API and MCP server in Rust; a public index at the API root1337 fn query_parameters_are_renamed() {
1338 let query = [
1339 ("q".to_owned(), "parser".to_owned()),
1340 ("x".to_owned(), "y".to_owned()),
1341 ];
Agents as a team: lifecycle, merge queue, billing and a new shell1342 let (route, input) = resolve("GET", "/repos", &query, Value::Null).unwrap();
API and MCP server in Rust; a public index at the API root1343 assert_eq!(route.op, Op::ListRepos);
1344 assert_eq!(input, json!({ "query": "parser" }));
1345 }
1346
1347 #[test]
1348 fn method_and_shape_must_match() {
Agents as a team: lifecycle, merge queue, billing and a new shell1349 assert!(resolve("GET", "/repos/a/b/issues/1/close", &[], Value::Null).is_none());
1350 assert!(resolve("GET", "/repos/a", &[], Value::Null).is_none());
1351 assert!(resolve("GET", "/repos/a/b/issues/1/extra", &[], Value::Null).is_none());
1352 assert!(resolve("GET", "/repos/a/b/", &[], Value::Null).is_some());
API and MCP server in Rust; a public index at the API root1353 }
1354
1355 #[test]
1356 fn every_parameter_and_query_name_is_an_input() {
1357 for route in ROUTES {
1358 let properties = route.op.properties();
1359 for (_, key) in route.query {
1360 assert!(properties.contains_key(*key), "{}: {key}", route.path);
1361 }
1362 for name in route.params() {
1363 let covered = matches!(name, "owner" | "name") && properties.contains_key("repo")
1364 || properties.contains_key(name);
1365 assert!(covered, "{}: {name}", route.path);
1366 }
1367 }
1368 }
1369
1370 #[test]
1371 fn every_operation_has_a_route() {
1372 for op in Op::ALL {
1373 assert!(ROUTES.iter().any(|route| route.op == op), "{}", op.name());
1374 }
1375 }
1376}

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