Skip to content
1,397 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 ),
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts379 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(
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)683 "GET",
684 "/repos/:owner/:name/actions/runs/:id/attempts/:attempt",
685 Op::GetWorkflowRun,
686 &[],
687 ),
688 route(
GitHub Actions on g1t, part two: running workflows689 "POST",
690 "/repos/:owner/:name/actions/runs/:id/cancel",
691 Op::CancelWorkflowRun,
692 &[],
693 ),
694 route(
695 "POST",
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)696 "/repos/:owner/:name/actions/runs/:id/force-cancel",
697 Op::CancelWorkflowRun,
698 &[],
699 ),
700 route(
701 "POST",
GitHub Actions on g1t, part two: running workflows702 "/repos/:owner/:name/actions/runs/:id/rerun",
703 Op::RerunWorkflowRun,
704 &[],
705 ),
706 route(
707 "POST",
708 "/repos/:owner/:name/actions/runs/:id/rerun-failed-jobs",
709 Op::RerunWorkflowRun,
710 &[],
711 ),
712 route(
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)713 "POST",
714 "/repos/:owner/:name/actions/jobs/:job/rerun",
715 Op::RerunWorkflowRun,
716 &[],
717 ),
718 route(
GitHub Actions on g1t, part two: running workflows719 "GET",
720 "/repos/:owner/:name/actions/jobs/:job/logs",
721 Op::GetJobLogs,
722 &[("after", "after")],
723 ),
Merge packages: roles, Actions access, source label, soft delete, API724 // Packages, at GitHub's addresses with the workspace in place of the
725 // organization. A name with a slash is one URL-encoded segment.
726 route("GET", "/workspaces/:workspace/packages", Op::Packages(PackagesOp::ListPackages), &[("package_type", "package_type"), ("q", "q"), ("state", "state")]),
727 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::GetPackage), &[]),
728 route("PATCH", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::UpdatePackage), &[]),
729 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::DeletePackage), &[]),
730 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/restore", Op::Packages(PackagesOp::RestorePackage), &[]),
731 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions", Op::Packages(PackagesOp::ListVersions), &[("state", "state")]),
732 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::GetVersion), &[]),
733 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::DeleteVersion), &[]),
734 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id/restore", Op::Packages(PackagesOp::RestoreVersion), &[]),
735 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::LinkPackage), &[]),
736 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::UnlinkPackage), &[]),
737 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::ListAccess), &[]),
738 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::SetAccess), &[]),
739 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::RemoveAccess), &[("username", "username"), ("team", "team")]),
740 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::ListActionsAccess), &[]),
741 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::SetActionsAccess), &[]),
742 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 R2743 // Artifacts, at GitHub's addresses. `…/zip` answers with a redirect to
744 // a signed link (lib.rs).
745 route("GET", "/repos/:owner/:name/actions/artifacts", Op::Artifacts(ArtifactsOp::ListArtifacts), &[("name", "name"), ("page", "page"), ("per_page", "per_page")]),
746 route("GET", "/repos/:owner/:name/actions/runs/:id/artifacts", Op::Artifacts(ArtifactsOp::ListRunArtifacts), &[("name", "name")]),
747 route("GET", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::GetArtifact), &[]),
748 route("GET", "/repos/:owner/:name/actions/artifacts/:id/zip", Op::Artifacts(ArtifactsOp::DownloadArtifact), &[]),
749 route("DELETE", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::DeleteArtifact), &[]),
750 route("GET", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::GetArtifactRetention), &[]),
751 route("PUT", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::SetArtifactRetention), &[]),
GitHub Actions on g1t, part two: running workflows752 route(
753 "GET",
754 "/repos/:owner/:name/actions/secrets",
755 Op::ListActionsSecrets,
756 &[],
757 ),
758 route(
759 "PUT",
760 "/repos/:owner/:name/actions/secrets/:setting",
761 Op::SetActionsSecret,
762 &[],
763 ),
764 route(
765 "DELETE",
766 "/repos/:owner/:name/actions/secrets/:setting",
767 Op::DeleteActionsSecret,
768 &[],
769 ),
770 route(
771 "GET",
772 "/repos/:owner/:name/actions/variables",
773 Op::ListActionsVariables,
774 &[],
775 ),
776 route(
777 "POST",
778 "/repos/:owner/:name/actions/variables",
779 Op::SetActionsVariable,
780 &[],
781 ),
782 route(
783 "PATCH",
784 "/repos/:owner/:name/actions/variables/:setting",
785 Op::SetActionsVariable,
786 &[],
787 ),
788 route(
789 "DELETE",
790 "/repos/:owner/:name/actions/variables/:setting",
791 Op::DeleteActionsVariable,
792 &[],
793 ),
794 route(
795 "GET",
796 "/workspaces/:workspace/actions/secrets",
797 Op::ListActionsSecrets,
798 &[],
799 ),
800 route(
801 "PUT",
802 "/workspaces/:workspace/actions/secrets/:setting",
803 Op::SetActionsSecret,
804 &[],
805 ),
806 route(
807 "DELETE",
808 "/workspaces/:workspace/actions/secrets/:setting",
809 Op::DeleteActionsSecret,
810 &[],
811 ),
812 route(
813 "GET",
814 "/workspaces/:workspace/actions/variables",
815 Op::ListActionsVariables,
816 &[],
817 ),
818 route(
819 "POST",
820 "/workspaces/:workspace/actions/variables",
821 Op::SetActionsVariable,
822 &[],
823 ),
824 route(
825 "PATCH",
826 "/workspaces/:workspace/actions/variables/:setting",
827 Op::SetActionsVariable,
828 &[],
829 ),
830 route(
831 "DELETE",
832 "/workspaces/:workspace/actions/variables/:setting",
833 Op::DeleteActionsVariable,
834 &[],
835 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents836 // Self-hosted runners: a repository's own, or a workspace's.
837 route("GET", "/repos/:owner/:name/actions/runners", Op::ListRunners, &[]),
838 route("POST", "/repos/:owner/:name/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
839 route("DELETE", "/repos/:owner/:name/actions/runners/:id", Op::RemoveRunner, &[]),
840 route("GET", "/repos/:owner/:name/actions/runner-settings", Op::GetRunnerSettings, &[]),
841 route("PATCH", "/repos/:owner/:name/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
842 route("GET", "/workspaces/:workspace/actions/runners", Op::ListRunners, &[]),
843 route("POST", "/workspaces/:workspace/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
844 route("DELETE", "/workspaces/:workspace/actions/runners/:id", Op::RemoveRunner, &[]),
845 route("GET", "/workspaces/:workspace/actions/runner-settings", Op::GetRunnerSettings, &[]),
846 route("PATCH", "/workspaces/:workspace/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
847 route("GET", "/workspaces/:workspace/actions/runner-groups", Op::ListRunnerGroups, &[]),
848 route("POST", "/workspaces/:workspace/actions/runner-groups", Op::CreateRunnerGroup, &[]),
849 route("PATCH", "/workspaces/:workspace/actions/runner-groups/:id", Op::UpdateRunnerGroup, &[]),
850 route("DELETE", "/workspaces/:workspace/actions/runner-groups/:id", Op::DeleteRunnerGroup, &[]),
Agents as a team: lifecycle, merge queue, billing and a new shell851 route("POST", "/repos/:owner/:name/plans", Op::PlanWork, &[]),
852 route("GET", "/repos/:owner/:name/plans/:plan", Op::GetPlan, &[]),
853 route(
854 "POST",
855 "/repos/:owner/:name/plans/:plan/apply",
856 Op::ApplyPlan,
857 &[],
858 ),
859 route(
860 "POST",
861 "/repos/:owner/:name/issues/:number/comments",
API and MCP server in Rust; a public index at the API root862 Op::AddComment,
863 &[],
864 ),
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts865 route("PATCH", "/repos/:owner/:name/issues/comments/:comment_id", Op::EditComment, &[]),
866 route("DELETE", "/repos/:owner/:name/issues/comments/:comment_id", Op::DeleteComment, &[]),
API and MCP server in Rust; a public index at the API root867 route(
868 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell869 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root870 Op::ListPullRequests,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar871 &[("state", "state"), ("label", "label"), ("milestone", "milestone"), ("base", "base")],
API and MCP server in Rust; a public index at the API root872 ),
873 route(
874 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell875 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root876 Op::CreatePullRequest,
877 &[],
878 ),
879 route(
880 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell881 "/repos/:owner/:name/pulls/:number",
API and MCP server in Rust; a public index at the API root882 Op::GetPullRequest,
883 &[],
884 ),
885 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar886 "PATCH",
887 "/repos/:owner/:name/pulls/:number",
888 Op::UpdatePullRequest,
889 &[],
890 ),
891 route(
API and MCP server in Rust; a public index at the API root892 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell893 "/repos/:owner/:name/pulls/:number/changes",
API and MCP server in Rust; a public index at the API root894 Op::GetPullRequestChanges,
895 &[],
896 ),
897 route(
Acceptance checks in sandboxes, line comments and review verdicts898 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell899 "/repos/:owner/:name/pulls/:number/reviews",
Acceptance checks in sandboxes, line comments and review verdicts900 Op::ReviewPullRequest,
901 &[],
902 ),
903 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar904 "POST",
905 "/repos/:owner/:name/pulls/:number/requested_reviewers",
906 Op::RequestReviewers,
907 &[],
908 ),
909 route(
910 "DELETE",
911 "/repos/:owner/:name/pulls/:number/requested_reviewers",
912 Op::RemoveRequestedReviewers,
913 &[],
914 ),
915 route(
API and MCP server in Rust; a public index at the API root916 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell917 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root918 Op::ReadSession,
919 &[("after", "after")],
920 ),
921 route(
922 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell923 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root924 Op::RecordSession,
925 &[],
926 ),
927 route(
928 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell929 "/repos/:owner/:name/pulls/:number/ready",
API and MCP server in Rust; a public index at the API root930 Op::MarkPullRequestReady,
931 &[],
932 ),
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts933 route("POST", "/repos/:owner/:name/pulls/:number/draft", Op::ConvertPullRequestToDraft, &[]),
API and MCP server in Rust; a public index at the API root934 route(
935 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell936 "/repos/:owner/:name/pulls/:number/close",
API and MCP server in Rust; a public index at the API root937 Op::ClosePullRequest,
938 &[],
939 ),
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts940 route("POST", "/repos/:owner/:name/pulls/:number/reopen", Op::ReopenPullRequest, &[]),
API and MCP server in Rust; a public index at the API root941 route(
942 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell943 "/repos/:owner/:name/pulls/:number/merge",
API and MCP server in Rust; a public index at the API root944 Op::MergePullRequest,
945 &[],
946 ),
947];
948
949impl Route {
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts950 /// Whether the route answers success with `204` and no body, as
951 /// GitHub's address for the same does. MCP still answers `true`.
952 pub fn no_content(&self) -> bool {
953 self.op == Op::DeleteComment
954 }
955
API and MCP server in Rust; a public index at the API root956 /// The names of the route's path parameters, in order.
957 pub fn params(&self) -> impl Iterator<Item = &'static str> {
958 self.path
959 .split('/')
960 .filter_map(|segment| segment.strip_prefix(':'))
961 }
962
963 /// The values of the path parameters, if `path` is this route's.
964 fn matches<'a>(&self, path: &'a str) -> Option<Vec<(&'static str, &'a str)>> {
965 let mut values = Vec::new();
966 let mut actual = path.trim_end_matches('/').split('/');
967 for expected in self.path.split('/') {
968 let segment = actual.next()?;
969 match expected.strip_prefix(':') {
970 Some(name) if !segment.is_empty() => values.push((name, segment)),
971 Some(_) => return None,
972 None if expected == segment => {}
973 None => return None,
974 }
975 }
976 actual.next().is_none().then_some(values)
977 }
978}
979
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look980/// A path segment with its `%XX` escapes decoded; as given when that is not
981/// UTF-8.
982fn percent_decoded(segment: &str) -> String {
983 let bytes = segment.as_bytes();
984 let mut out = Vec::with_capacity(bytes.len());
985 let mut i = 0;
986 while i < bytes.len() {
987 let escaped = (bytes[i] == b'%')
988 .then(|| segment.get(i + 1..i + 3))
989 .flatten()
990 .filter(|hex| hex.bytes().all(|byte| byte.is_ascii_hexdigit()))
991 .and_then(|hex| u8::from_str_radix(hex, 16).ok());
992 match escaped {
993 Some(byte) => {
994 out.push(byte);
995 i += 3;
996 }
997 None => {
998 out.push(bytes[i]);
999 i += 1;
1000 }
1001 }
1002 }
1003 String::from_utf8(out).unwrap_or_else(|_| segment.to_owned())
1004}
1005
API and MCP server in Rust; a public index at the API root1006/// The route for a request, and the operation input it describes.
1007///
1008/// The input is the JSON body, overlaid with the query parameters the route
1009/// 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 bar1010/// `repo`, as does a team's `repo` with its `workspace`, and `number`
1011/// becomes an integer.
API and MCP server in Rust; a public index at the API root1012pub fn resolve(
1013 method: &str,
1014 path: &str,
1015 query: &[(String, String)],
1016 body: Value,
1017) -> Option<(&'static Route, Value)> {
1018 let (route, params) = ROUTES
1019 .iter()
1020 .filter(|route| route.method == method)
1021 .find_map(|route| Some((route, route.matches(path)?)))?;
1022
1023 let mut input = match body {
1024 Value::Object(fields) => fields,
1025 _ => Map::new(),
1026 };
1027 for (name, key) in route.query {
1028 if let Some((_, value)) = query.iter().find(|(query_name, _)| query_name == name) {
1029 input.insert((*key).to_owned(), Value::String(value.clone()));
1030 }
1031 }
1032 let param = |wanted: &str| {
1033 params
1034 .iter()
1035 .find(|(name, _)| *name == wanted)
1036 .map(|(_, value)| *value)
1037 };
1038 if let (Some(owner), Some(name)) = (param("owner"), param("name")) {
1039 input.insert("repo".to_owned(), Value::String(format!("{owner}/{name}")));
1040 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971041 // Every other name the path gives, under that name; the ones below that
1042 // need more (a repository, a number, an encoded name) are set after.
1043 for (key, value) in &params {
1044 if !matches!(*key, "owner" | "name") {
1045 input.insert((*key).to_owned(), Value::String(percent_decoded(value)));
Docs worth reading, and kept that way1046 }
Agents as a team: lifecycle, merge queue, billing and a new shell1047 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1048 // A repository of a team's workspace, named by itself.
1049 if let (Some(workspace), Some(name)) = (param("workspace"), param("repo")) {
1050 input.insert("repo".to_owned(), Value::String(format!("{workspace}/{name}")));
1051 }
1052 // A branch name may hold slashes, sent URL-encoded as one segment, and
1053 // a label's name spaces.
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1054 if let Some(branch) = param("branch") {
1055 input.insert("branch".to_owned(), Value::String(percent_decoded(branch)));
1056 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971057 // An environment's name may hold slashes and spaces, URL-encoded.
1058 if let Some(environment) = param("environment") {
1059 input.insert("environment".to_owned(), Value::String(percent_decoded(environment)));
1060 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1061 if let Some(label) = param("label") {
1062 input.insert("label".to_owned(), Value::String(percent_decoded(label)));
1063 }
1064 if let Some(milestone) = param("milestone") {
1065 // Not a number: zero, which no milestone has.
1066 input.insert("milestone".to_owned(), milestone.parse::<u32>().unwrap_or(0).into());
1067 }
GitHub Actions on g1t, part two: running workflows1068 // GitHub says some things with the path alone.
1069 if route.path.ends_with("/enable") || route.path.ends_with("/disable") {
1070 input.insert("enabled".to_owned(), Value::Bool(route.path.ends_with("/enable")));
1071 }
1072 if route.path.ends_with("/rerun-failed-jobs") {
1073 input.insert("failed_only".to_owned(), Value::Bool(true));
1074 }
Merge Actions runs: summaries, attempts and re-runs, graceful cancel, log downloads, badges (actions 0009)1075 if route.path.ends_with("/force-cancel") {
1076 input.insert("force".to_owned(), Value::Bool(true));
1077 }
API: notifications over REST and MCP, with notifications scopes1078 // Unsaving and waking a thread are a DELETE of what PUT made.
1079 if route.method == "DELETE" && route.path.ends_with("/saved") {
1080 input.insert("saved".to_owned(), Value::Bool(false));
1081 }
1082 if route.method == "DELETE" && route.path.ends_with("/snooze") {
1083 input.remove("until");
1084 }
API and MCP server in Rust; a public index at the API root1085 if let Some(number) = param("number") {
1086 // Not a number: zero, which no issue or pull request has.
1087 input.insert(
1088 "number".to_owned(),
1089 number.parse::<u32>().unwrap_or(0).into(),
1090 );
1091 }
1092 Some((route, Value::Object(input)))
1093}
1094
1095#[cfg(test)]
1096mod tests {
1097 use serde_json::json;
1098
1099 use super::*;
1100
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971101 /// Every name a route's path gives reaches the operation: a name left
1102 /// off the lists above is dropped, and the operation answers that it
1103 /// was not given (the project routes were, until this test).
1104 #[test]
1105 fn every_path_parameter_reaches_the_input() {
1106 for route in ROUTES.iter() {
1107 let names: Vec<&str> = route.path.split('/').filter_map(|part| part.strip_prefix(':')).collect();
1108 if names.is_empty() {
1109 continue;
1110 }
1111 let path: String = route
1112 .path
1113 .split('/')
1114 .map(|part| match part.strip_prefix(':') {
1115 Some("number" | "milestone") => "7".to_owned(),
1116 Some(name) => format!("{name}-x"),
1117 None => part.to_owned(),
1118 })
1119 .collect::<Vec<_>>()
1120 .join("/");
1121 let (found, input) = resolve(route.method, &path, &[], json!({})).unwrap();
1122 // A path two routes could take is checked under the first.
1123 if found.path != route.path {
1124 continue;
1125 }
1126 for name in names {
1127 let key = match name {
1128 "owner" | "name" => "repo",
1129 "repo" if names_has_workspace(route.path) => "repo",
1130 other => other,
1131 };
1132 assert!(
1133 input.get(key).is_some_and(|value| !value.is_null()),
1134 "{} {}: :{name} does not reach the input",
1135 route.method,
1136 route.path
1137 );
1138 }
1139 }
1140 }
1141
1142 fn names_has_workspace(path: &str) -> bool {
1143 path.split('/').any(|part| part == ":workspace")
1144 }
1145
API and MCP server in Rust; a public index at the API root1146 #[test]
1147 fn a_path_resolves_to_its_operation_and_input() {
1148 let (route, input) = resolve(
1149 "POST",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1150 "/repos/flagon-io/hello/pulls/14/merge",
API and MCP server in Rust; a public index at the API root1151 &[],
1152 json!({ "keep_issue_open": true, "number": 99, "repo": "someone/else" }),
1153 )
1154 .unwrap();
1155 assert_eq!(route.op, Op::MergePullRequest);
1156 // What the path names wins over the body.
1157 assert_eq!(
1158 input,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1159 json!({ "keep_issue_open": true, "number": 14, "repo": "flagon-io/hello" })
API and MCP server in Rust; a public index at the API root1160 );
1161 }
1162
1163 #[test]
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1164 fn a_branch_with_slashes_is_one_encoded_segment() {
1165 let (route, input) = resolve(
1166 "POST",
1167 "/repos/flagon-io/hello/branches/feature%2Flogin/rename",
1168 &[],
1169 json!({ "new_name": "feature/sign-in" }),
1170 )
1171 .unwrap();
1172 assert_eq!(route.op, Op::RenameBranch);
1173 assert_eq!(
1174 input,
1175 json!({ "new_name": "feature/sign-in", "branch": "feature/login", "repo": "flagon-io/hello" })
1176 );
1177 assert_eq!(percent_decoded("100%"), "100%");
1178 assert_eq!(percent_decoded("a%2bb%zz"), "a+b%zz");
1179 }
1180
1181 #[test]
1182 fn a_collaborator_is_named_by_username() {
1183 let (route, input) = resolve(
1184 "PATCH",
1185 "/repos/flagon-io/hello/collaborators/ada",
1186 &[],
1187 json!({ "role": "maintain" }),
1188 )
1189 .unwrap();
1190 assert_eq!(route.op, Op::UpdateCollaborator);
1191 assert_eq!(input, json!({ "role": "maintain", "username": "ada", "repo": "flagon-io/hello" }));
1192 let (route, input) = resolve("DELETE", "/user/repository_invitations/rin_1", &[], Value::Null).unwrap();
1193 assert_eq!(route.op, Op::DeclineRepoInvitation);
1194 assert_eq!(input, json!({ "id": "rin_1" }));
1195 }
1196
1197 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1198 fn teams_are_addressed_by_workspace_and_slug() {
1199 let query = [("q".to_owned(), "back".to_owned())];
1200 let (route, input) = resolve("GET", "/workspaces/acme/teams", &query, Value::Null).unwrap();
1201 assert_eq!(route.op, Op::ListTeams);
1202 assert_eq!(input, json!({ "query": "back", "workspace": "acme" }));
1203 let (route, input) = resolve("PATCH", "/workspaces/acme/teams/backend", &[], json!({ "name": "Back end" })).unwrap();
1204 assert_eq!(route.op, Op::UpdateTeam);
1205 assert_eq!(input, json!({ "name": "Back end", "workspace": "acme", "team": "backend" }));
1206 let (route, input) =
1207 resolve("PUT", "/workspaces/acme/teams/backend/members/ana", &[], json!({ "role": "maintainer" })).unwrap();
1208 assert_eq!(route.op, Op::SetTeamMember);
1209 assert_eq!(input, json!({ "role": "maintainer", "workspace": "acme", "team": "backend", "username": "ana" }));
1210 let query = [("include_child_teams".to_owned(), "true".to_owned())];
1211 let (route, input) = resolve("GET", "/workspaces/acme/teams/backend/members", &query, Value::Null).unwrap();
1212 assert_eq!(route.op, Op::ListTeamMembers);
1213 assert_eq!(input, json!({ "include_child_teams": "true", "workspace": "acme", "team": "backend" }));
1214 // A repository is named by itself, in the team's workspace.
1215 let (route, input) =
1216 resolve("PUT", "/workspaces/acme/teams/backend/repos/rocket", &[], json!({ "role": "write" })).unwrap();
1217 assert_eq!(route.op, Op::SetTeamRepo);
1218 assert_eq!(input, json!({ "role": "write", "workspace": "acme", "team": "backend", "repo": "acme/rocket" }));
1219 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1220 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/repos/rocket"), Op::RemoveTeamRepo);
1221 assert_eq!(op("GET", "/workspaces/acme/teams/backend/teams"), Op::ListChildTeams);
1222 assert_eq!(op("GET", "/workspaces/acme/teams/backend/repos"), Op::ListTeamRepos);
1223 assert_eq!(op("PUT", "/workspaces/acme/teams/backend/review_assignment"), Op::SetTeamReviewAssignment);
1224 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend"), Op::DeleteTeam);
1225 assert_eq!(op("POST", "/workspaces/acme/teams"), Op::CreateTeam);
1226 assert_eq!(op("GET", "/workspaces/acme/teams/backend"), Op::GetTeam);
1227 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/members/ana"), Op::RemoveTeamMember);
1228 let (route, input) = resolve("GET", "/workspaces/acme/members/ana/teams", &[], Value::Null).unwrap();
1229 assert_eq!(route.op, Op::ListUserTeams);
1230 assert_eq!(input, json!({ "workspace": "acme", "username": "ana" }));
1231 }
1232
1233 #[test]
1234 fn reviewers_are_requested_and_code_owners_checked_on_a_repository() {
1235 let body = json!({ "reviewers": ["ana"], "team_reviewers": ["backend"] });
1236 let (route, input) = resolve("POST", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body.clone()).unwrap();
1237 assert_eq!(route.op, Op::RequestReviewers);
1238 assert_eq!(
1239 input,
1240 json!({ "reviewers": ["ana"], "team_reviewers": ["backend"], "repo": "acme/rocket", "number": 7 })
1241 );
1242 let (route, _) = resolve("DELETE", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body).unwrap();
1243 assert_eq!(route.op, Op::RemoveRequestedReviewers);
1244 let query = [("ref".to_owned(), "main".to_owned())];
1245 let (route, input) = resolve("GET", "/repos/acme/rocket/codeowners/errors", &query, Value::Null).unwrap();
1246 assert_eq!(route.op, Op::GetCodeownersErrors);
1247 assert_eq!(input, json!({ "ref": "main", "repo": "acme/rocket" }));
1248 }
1249
1250 #[test]
API: notifications over REST and MCP, with notifications scopes1251 fn notifications_are_addressed_as_threads_and_by_issue() {
1252 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1", &[], Value::Null).unwrap();
1253 assert_eq!(route.op, Op::MarkThreadDone);
1254 assert_eq!(input, json!({ "id": "ntf_1" }));
1255 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/saved", &[], Value::Null).unwrap();
1256 assert_eq!(route.op, Op::SaveThread);
1257 assert_eq!(input, json!({ "id": "ntf_1", "saved": false }));
1258 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/snooze", &[], json!({ "until": "x" })).unwrap();
1259 assert_eq!(route.op, Op::SnoozeThread);
1260 assert_eq!(input, json!({ "id": "ntf_1" }));
1261 let query = [("all".to_owned(), "true".to_owned()), ("per_page".to_owned(), "50".to_owned())];
1262 let (route, input) = resolve("GET", "/repos/acme/rocket/notifications", &query, Value::Null).unwrap();
1263 assert_eq!(route.op, Op::ListNotifications);
1264 assert_eq!(input, json!({ "all": "true", "per_page": "50", "repo": "acme/rocket" }));
1265 let (route, input) = resolve("PUT", "/repos/acme/rocket/issues/7/subscription", &[], json!({ "ignored": true })).unwrap();
1266 assert_eq!(route.op, Op::SetThreadSubscription);
1267 assert_eq!(input, json!({ "ignored": true, "number": 7, "repo": "acme/rocket" }));
1268 assert_eq!(resolve("GET", "/user/subscriptions", &[], Value::Null).unwrap().0.op, Op::ListWatchedRepos);
1269 }
1270
1271 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1272 fn labels_and_milestones_are_named_in_the_path() {
1273 let (route, input) = resolve("PATCH", "/repos/acme/web/labels/good%20first%20issue", &[], json!({ "color": "7057ff" })).unwrap();
1274 assert_eq!(route.op, Op::UpdateLabel);
1275 assert_eq!(input, json!({ "color": "7057ff", "label": "good first issue", "repo": "acme/web" }));
1276 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels/bug", &[], Value::Null).unwrap();
1277 assert_eq!(route.op, Op::RemoveIssueLabels);
1278 assert_eq!(input, json!({ "label": "bug", "number": 7, "repo": "acme/web" }));
1279 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels", &[], Value::Null).unwrap();
1280 assert_eq!(route.op, Op::RemoveIssueLabels);
1281 assert_eq!(input, json!({ "number": 7, "repo": "acme/web" }));
1282 let (route, _) = resolve("POST", "/repos/acme/web/labels/defaults", &[], Value::Null).unwrap();
1283 assert_eq!(route.op, Op::AddDefaultLabels);
1284 let (route, input) = resolve("PATCH", "/repos/acme/web/milestones/3", &[], json!({ "state": "closed" })).unwrap();
1285 assert_eq!(route.op, Op::UpdateMilestone);
1286 assert_eq!(input, json!({ "state": "closed", "milestone": 3, "repo": "acme/web" }));
1287 let (route, input) = resolve("PATCH", "/repos/acme/web/pulls/9", &[], json!({ "base": "release" })).unwrap();
1288 assert_eq!(route.op, Op::UpdatePullRequest);
1289 assert_eq!(input, json!({ "base": "release", "number": 9, "repo": "acme/web" }));
1290 }
1291
1292 #[test]
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts1293 fn pull_requests_reopen_and_turn_draft_and_comments_are_named_by_id() {
1294 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1295 assert_eq!(op("POST", "/repos/acme/web/pulls/9/reopen"), Op::ReopenPullRequest);
1296 assert_eq!(op("POST", "/repos/acme/web/pulls/9/draft"), Op::ConvertPullRequestToDraft);
1297 assert_eq!(op("POST", "/repos/acme/web/pulls/9/close"), Op::ClosePullRequest);
1298 // Reopening and closing with a PATCH, as `state`.
1299 let (route, input) = resolve("PATCH", "/repos/acme/web/pulls/9", &[], json!({ "state": "open" })).unwrap();
1300 assert_eq!(route.op, Op::UpdatePullRequest);
1301 assert_eq!(input, json!({ "state": "open", "number": 9, "repo": "acme/web" }));
1302 let (route, input) =
1303 resolve("PATCH", "/repos/acme/web/issues/comments/cmt_1", &[], json!({ "body": "Better" })).unwrap();
1304 assert_eq!(route.op, Op::EditComment);
1305 assert_eq!(input, json!({ "body": "Better", "comment_id": "cmt_1", "repo": "acme/web" }));
1306 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/comments/cmt_1", &[], Value::Null).unwrap();
1307 assert_eq!(route.op, Op::DeleteComment);
1308 assert_eq!(input, json!({ "comment_id": "cmt_1", "repo": "acme/web" }));
1309 // Still an issue's comments, labels and subscription.
1310 assert_eq!(op("POST", "/repos/acme/web/issues/7/comments"), Op::AddComment);
1311 assert_eq!(op("DELETE", "/repos/acme/web/issues/7/labels"), Op::RemoveIssueLabels);
1312 assert_eq!(op("DELETE", "/repos/acme/web/issues/7/subscription"), Op::DeleteThreadSubscription);
1313 }
1314
1315 #[test]
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1316 fn billing_is_addressed_by_workspace() {
1317 let query = [("from".to_owned(), "2026-10-01".to_owned()), ("products".to_owned(), "agent,sandboxes".to_owned())];
1318 let (route, input) = resolve("GET", "/workspaces/acme/usage", &query, Value::Null).unwrap();
1319 assert_eq!(route.op, Op::GetUsage);
1320 assert_eq!(input, json!({ "from": "2026-10-01", "products": "agent,sandboxes", "workspace": "acme" }));
1321 let (route, input) = resolve("PUT", "/workspaces/acme/budget", &[], json!({ "alerts": [50] })).unwrap();
1322 assert_eq!(route.op, Op::SetBudget);
1323 assert_eq!(input, json!({ "alerts": [50], "workspace": "acme" }));
1324 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1325 assert_eq!(op("GET", "/workspaces/acme/budget"), Op::GetBudget);
1326 assert_eq!(op("GET", "/workspaces/acme/ai_credit"), Op::GetAiCredit);
1327 assert_eq!(op("POST", "/workspaces/acme/ai_credit/checkout"), Op::BuyAiCredit);
1328 assert_eq!(op("GET", "/workspaces/acme/invoices"), Op::ListInvoices);
1329 assert_eq!(op("GET", "/workspaces/acme/billing_details"), Op::GetBillingDetails);
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens1330 assert_eq!(op("GET", "/workspaces/acme/gateway/requests"), Op::ListGatewayRequests);
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1331 }
1332
1333 #[test]
Merge checks: statuses and check runs on every commit1334 fn checks_are_at_githubs_addresses() {
1335 let sha = "a".repeat(40);
1336 let body = json!({ "state": "success", "context": "ci/build" });
1337 let (route, input) = resolve("POST", &format!("/repos/acme/web/statuses/{sha}"), &[], body).unwrap();
1338 assert_eq!(route.op, Op::Checks(ChecksOp::CreateCommitStatus));
1339 assert_eq!(input, json!({ "state": "success", "context": "ci/build", "sha": sha, "repo": "acme/web" }));
1340 let (route, input) = resolve("GET", "/repos/acme/web/commits/release%2F1.x/status", &[], Value::Null).unwrap();
1341 assert_eq!(route.op, Op::Checks(ChecksOp::GetCombinedStatus));
1342 assert_eq!(input, json!({ "ref": "release/1.x", "repo": "acme/web" }));
1343 let query = [("check_name".to_owned(), "lint".to_owned())];
1344 let (route, input) = resolve("GET", "/repos/acme/web/commits/main/check-runs", &query, Value::Null).unwrap();
1345 assert_eq!(route.op, Op::Checks(ChecksOp::ListCheckRunsForRef));
1346 assert_eq!(input, json!({ "check_name": "lint", "ref": "main", "repo": "acme/web" }));
1347 let (route, input) = resolve("PATCH", "/repos/acme/web/check-runs/cr_1", &[], json!({ "conclusion": "success" })).unwrap();
1348 assert_eq!(route.op, Op::Checks(ChecksOp::UpdateCheckRun));
1349 assert_eq!(input, json!({ "conclusion": "success", "id": "cr_1", "repo": "acme/web" }));
1350 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1351 assert_eq!(op("POST", "/repos/acme/web/check-runs"), Op::Checks(ChecksOp::CreateCheckRun));
1352 assert_eq!(op("GET", "/repos/acme/web/check-runs/cr_1/annotations"), Op::Checks(ChecksOp::ListCheckRunAnnotations));
1353 assert_eq!(op("POST", "/repos/acme/web/check-suites/cs_1/rerequest"), Op::Checks(ChecksOp::RerequestCheckSuite));
1354 assert_eq!(op("GET", "/repos/acme/web/commits/main/check-suites"), Op::Checks(ChecksOp::ListCheckSuitesForRef));
1355 }
1356
1357 #[test]
API and MCP server in Rust; a public index at the API root1358 fn query_parameters_are_renamed() {
1359 let query = [
1360 ("q".to_owned(), "parser".to_owned()),
1361 ("x".to_owned(), "y".to_owned()),
1362 ];
Agents as a team: lifecycle, merge queue, billing and a new shell1363 let (route, input) = resolve("GET", "/repos", &query, Value::Null).unwrap();
API and MCP server in Rust; a public index at the API root1364 assert_eq!(route.op, Op::ListRepos);
1365 assert_eq!(input, json!({ "query": "parser" }));
1366 }
1367
1368 #[test]
1369 fn method_and_shape_must_match() {
Agents as a team: lifecycle, merge queue, billing and a new shell1370 assert!(resolve("GET", "/repos/a/b/issues/1/close", &[], Value::Null).is_none());
1371 assert!(resolve("GET", "/repos/a", &[], Value::Null).is_none());
1372 assert!(resolve("GET", "/repos/a/b/issues/1/extra", &[], Value::Null).is_none());
1373 assert!(resolve("GET", "/repos/a/b/", &[], Value::Null).is_some());
API and MCP server in Rust; a public index at the API root1374 }
1375
1376 #[test]
1377 fn every_parameter_and_query_name_is_an_input() {
1378 for route in ROUTES {
1379 let properties = route.op.properties();
1380 for (_, key) in route.query {
1381 assert!(properties.contains_key(*key), "{}: {key}", route.path);
1382 }
1383 for name in route.params() {
1384 let covered = matches!(name, "owner" | "name") && properties.contains_key("repo")
1385 || properties.contains_key(name);
1386 assert!(covered, "{}: {name}", route.path);
1387 }
1388 }
1389 }
1390
1391 #[test]
1392 fn every_operation_has_a_route() {
1393 for op in Op::ALL {
1394 assert!(ROUTES.iter().any(|route| route.op == op), "{}", op.name());
1395 }
1396 }
1397}

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