Skip to content
1,342 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, &[]),
Email confirmation gate: a code and a link, nothing else until confirmed47 route("POST", "/user/emails/confirm", Op::ConfirmEmail, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look48 route("DELETE", "/user/emails/:email", Op::RemoveEmail, &[]),
49 route("PATCH", "/user/email-settings", Op::UpdateEmailSettings, &[]),
50 route("GET", "/user/invites", Op::ListInvites, &[]),
51 route("POST", "/user/invites", Op::CreateInvite, &[]),
52 route("DELETE", "/user/invites/:id", Op::RevokeInvite, &[]),
53 route("GET", "/workspaces/:workspace/invitations", Op::ListWorkspaceInvites, &[]),
API and MCP for a workspace's personal access token rules, members' tokens and approvals54 // A workspace's rules for personal access tokens, and its members' tokens.
55 route("GET", "/workspaces/:workspace/personal-access-token-policy", Op::Tokens(TokenOp::GetTokenPolicy), &[]),
56 route("PATCH", "/workspaces/:workspace/personal-access-token-policy", Op::Tokens(TokenOp::SetTokenPolicy), &[]),
57 route("GET", "/workspaces/:workspace/personal-access-tokens", Op::Tokens(TokenOp::ListMemberTokens), &[("kind", "kind")]),
58 route("POST", "/workspaces/:workspace/personal-access-tokens/:id", Op::Tokens(TokenOp::RevokeMemberToken), &[]),
59 route("GET", "/workspaces/:workspace/personal-access-token-requests", Op::Tokens(TokenOp::ListTokenRequests), &[]),
60 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 look61 route("POST", "/workspaces/:workspace/invitations", Op::InviteMember, &[]),
62 route("DELETE", "/workspaces/:workspace/invitations/:id", Op::RevokeWorkspaceInvite, &[]),
63 // Who has access. GitHub's addresses, but for adding someone, which
64 // takes an email address as well as a username.
65 route("GET", "/repos/:owner/:name/collaborators", Op::ListCollaborators, &[]),
66 route("POST", "/repos/:owner/:name/collaborators", Op::AddCollaborator, &[]),
67 route("PATCH", "/repos/:owner/:name/collaborators/:username", Op::UpdateCollaborator, &[]),
68 route("DELETE", "/repos/:owner/:name/collaborators/:username", Op::RemoveCollaborator, &[]),
69 route(
70 "GET",
71 "/repos/:owner/:name/collaborators/:username/permission",
72 Op::GetCollaboratorPermission,
73 &[],
74 ),
75 route("GET", "/repos/:owner/:name/invitations", Op::ListRepoInvitations, &[]),
76 route("DELETE", "/repos/:owner/:name/invitations/:id", Op::RevokeRepoInvitation, &[]),
77 route("GET", "/user/repository_invitations", Op::ListMyRepoInvitations, &[]),
Merge branch 'worktree-agent-a5a5de74d8863d554' into worktree-agent-a16631325aecf58ca78 // Deploy keys, at GitHub's addresses.
79 route("GET", "/repos/:owner/:name/keys", Op::DeployKeys(DeployKeysOp::ListDeployKeys), &[]),
80 route("POST", "/repos/:owner/:name/keys", Op::DeployKeys(DeployKeysOp::CreateDeployKey), &[]),
81 route("GET", "/repos/:owner/:name/keys/:id", Op::DeployKeys(DeployKeysOp::GetDeployKey), &[]),
82 route("DELETE", "/repos/:owner/:name/keys/:id", Op::DeployKeys(DeployKeysOp::DeleteDeployKey), &[]),
API: notifications over REST and MCP, with notifications scopes83 // Your notifications: threads, marking them, and what you subscribe
84 // to and watch. GitHub's addresses, with g1t's saved and snoozed.
85 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")]),
86 route("PUT", "/notifications", Op::MarkNotificationsRead, &[]),
87 route("GET", "/notifications/threads/:id", Op::GetNotificationThread, &[]),
88 route("PATCH", "/notifications/threads/:id", Op::MarkThreadRead, &[]),
89 route("DELETE", "/notifications/threads/:id", Op::MarkThreadDone, &[]),
90 route("PUT", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
91 route("DELETE", "/notifications/threads/:id/saved", Op::SaveThread, &[]),
92 route("PUT", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
93 route("DELETE", "/notifications/threads/:id/snooze", Op::SnoozeThread, &[]),
94 route("GET", "/notifications/threads/:id/subscription", Op::GetThreadSubscription, &[]),
95 route("PUT", "/notifications/threads/:id/subscription", Op::SetThreadSubscription, &[]),
96 route("DELETE", "/notifications/threads/:id/subscription", Op::DeleteThreadSubscription, &[]),
97 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")]),
98 route("PUT", "/repos/:owner/:name/notifications", Op::MarkNotificationsRead, &[]),
99 route("GET", "/repos/:owner/:name/subscription", Op::GetRepoSubscription, &[]),
100 route("PUT", "/repos/:owner/:name/subscription", Op::SetRepoSubscription, &[]),
101 route("DELETE", "/repos/:owner/:name/subscription", Op::DeleteRepoSubscription, &[]),
102 route("GET", "/repos/:owner/:name/issues/:number/subscription", Op::GetThreadSubscription, &[]),
103 route("PUT", "/repos/:owner/:name/issues/:number/subscription", Op::SetThreadSubscription, &[]),
104 route("DELETE", "/repos/:owner/:name/issues/:number/subscription", Op::DeleteThreadSubscription, &[]),
105 route("GET", "/user/subscriptions", Op::ListWatchedRepos, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97106 // Stars: yours, and who starred a repository.
107 route("GET", "/user/starred", Op::About(AboutOp::ListStarred), &[]),
108 route("GET", "/user/starred/:owner/:name", Op::About(AboutOp::CheckStarred), &[]),
109 route("PUT", "/user/starred/:owner/:name", Op::About(AboutOp::Star), &[]),
110 route("DELETE", "/user/starred/:owner/:name", Op::About(AboutOp::Unstar), &[]),
111 route("GET", "/repos/:owner/:name/stargazers", Op::About(AboutOp::ListStargazers), &[("page", "page")]),
112 // What the default branch says about a repository, kept by commit.
113 route("GET", "/repos/:owner/:name/languages", Op::About(AboutOp::GetLanguages), &[]),
114 route("GET", "/repos/:owner/:name/contributors", Op::About(AboutOp::ListContributors), &[]),
115 route("GET", "/repos/:owner/:name/license", Op::About(AboutOp::GetLicense), &[]),
116 // Releases: `latest` and `tags/…` before an id.
117 route("GET", "/repos/:owner/:name/releases", Op::About(AboutOp::ListReleases), &[]),
118 route("POST", "/repos/:owner/:name/releases", Op::About(AboutOp::CreateRelease), &[]),
119 route("GET", "/repos/:owner/:name/releases/latest", Op::About(AboutOp::GetLatestRelease), &[]),
120 route("GET", "/repos/:owner/:name/releases/tags/:tag", Op::About(AboutOp::GetReleaseByTag), &[]),
121 route("GET", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::GetRelease), &[]),
122 route("PATCH", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::UpdateRelease), &[]),
123 route("DELETE", "/repos/:owner/:name/releases/:id", Op::About(AboutOp::DeleteRelease), &[]),
API: pinned projects over REST and MCP124 // Your pinned projects in a workspace, in your order.
125 route("GET", "/user/pinned_projects/:workspace", Op::ListPinnedProjects, &[]),
126 route("PUT", "/user/pinned_projects/:workspace", Op::ReorderPinnedProjects, &[]),
127 route("PUT", "/user/pinned_projects/:workspace/:project", Op::PinProject, &[]),
128 route("DELETE", "/user/pinned_projects/:workspace/:project", Op::UnpinProject, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look129 route("PATCH", "/user/repository_invitations/:id", Op::AcceptRepoInvitation, &[]),
130 route("DELETE", "/user/repository_invitations/:id", Op::DeclineRepoInvitation, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily131 route("PATCH", "/workspaces/:workspace", Op::UpdateWorkspace, &[]),
Merge main (membership, two-factor, GitHub repo roles) into tokens132 // Members and owners: GitHub's organization members, by username.
133 route("GET", "/workspaces/:workspace/members", Op::ListMembers, &[]),
134 route("PATCH", "/workspaces/:workspace/members/:username", Op::UpdateMember, &[]),
135 route("DELETE", "/workspaces/:workspace/members/:username", Op::RemoveMember, &[]),
136 route("POST", "/workspaces/:workspace/transfer_ownership", Op::TransferOwnership, &[]),
137 route("DELETE", "/user/memberships/:workspace", Op::LeaveWorkspace, &[]),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97138 // A workspace's projects: what each is, where it runs, its links.
139 route("GET", "/workspaces/:workspace/projects", Op::ListProjects, &[]),
140 route("GET", "/workspaces/:workspace/projects/:project", Op::GetProject, &[]),
141 route("PATCH", "/workspaces/:workspace/projects/:project", Op::UpdateProject, &[]),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily142 route("PUT", "/workspaces/:workspace/base_permission", Op::SetBasePermission, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look143 route(
144 "GET",
145 "/workspaces/:workspace/outside_collaborators",
146 Op::ListOutsideCollaborators,
147 &[],
148 ),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar149 // Teams: a workspace's groups of members, with roles on repositories.
150 route("GET", "/workspaces/:workspace/teams", Op::ListTeams, &[("q", "query")]),
151 route("POST", "/workspaces/:workspace/teams", Op::CreateTeam, &[]),
152 route("GET", "/workspaces/:workspace/teams/:team", Op::GetTeam, &[]),
153 route("PATCH", "/workspaces/:workspace/teams/:team", Op::UpdateTeam, &[]),
154 route("DELETE", "/workspaces/:workspace/teams/:team", Op::DeleteTeam, &[]),
155 route(
156 "GET",
157 "/workspaces/:workspace/teams/:team/members",
158 Op::ListTeamMembers,
159 &[("include_child_teams", "include_child_teams")],
160 ),
161 route("PUT", "/workspaces/:workspace/teams/:team/members/:username", Op::SetTeamMember, &[]),
162 route("DELETE", "/workspaces/:workspace/teams/:team/members/:username", Op::RemoveTeamMember, &[]),
163 route("GET", "/workspaces/:workspace/teams/:team/teams", Op::ListChildTeams, &[]),
164 route("GET", "/workspaces/:workspace/teams/:team/repos", Op::ListTeamRepos, &[]),
165 route("PUT", "/workspaces/:workspace/teams/:team/repos/:repo", Op::SetTeamRepo, &[]),
166 route("DELETE", "/workspaces/:workspace/teams/:team/repos/:repo", Op::RemoveTeamRepo, &[]),
167 route(
168 "PUT",
169 "/workspaces/:workspace/teams/:team/review_assignment",
170 Op::SetTeamReviewAssignment,
171 &[],
172 ),
173 route("GET", "/workspaces/:workspace/members/:username/teams", Op::ListUserTeams, &[]),
Usage, Billing settings and prepaid AI credit; fixes from the UX audit174 // A workspace's billing: usage, budget, AI credit and invoices.
175 route(
176 "GET",
177 "/workspaces/:workspace/usage",
178 Op::GetUsage,
179 &[("from", "from"), ("until", "until"), ("products", "products"), ("projects", "projects"), ("group_by", "group_by")],
180 ),
181 route("GET", "/workspaces/:workspace/budget", Op::GetBudget, &[]),
182 route("PUT", "/workspaces/:workspace/budget", Op::SetBudget, &[]),
183 route("GET", "/workspaces/:workspace/ai_credit", Op::GetAiCredit, &[]),
184 route("POST", "/workspaces/:workspace/ai_credit/checkout", Op::BuyAiCredit, &[]),
185 route("GET", "/workspaces/:workspace/invoices", Op::ListInvoices, &[]),
186 route("GET", "/workspaces/:workspace/billing_details", Op::GetBillingDetails, &[]),
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens187 // The AI Gateway's log of a workspace's requests.
188 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 bar189 // Code owners: the CODEOWNERS file, checked.
190 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 daily191 // Security alerts: secrets and vulnerable dependencies.
192 route(
193 "GET",
194 "/repos/:owner/:name/security/alerts",
195 Op::ListSecurityAlerts,
196 &[("state", "state"), ("kind", "kind")],
197 ),
198 route("POST", "/repos/:owner/:name/security/alerts/:id/dismiss", Op::DismissSecurityAlert, &[]),
199 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 bar200 // The security suite: secret scanning, code scanning, vulnerability
201 // alerts and the supply chain, at the common addresses.
202 route("GET", "/repos/:owner/:name/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
203 route("GET", "/workspaces/:workspace/secret-scanning/alerts", Op::Security(SecurityOp::ListSecretAlerts), &[("state", "state"), ("secret_type", "secret_type"), ("validity", "validity"), ("bypassed", "bypassed")]),
204 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::GetSecretAlert), &[]),
205 route("PATCH", "/repos/:owner/:name/secret-scanning/alerts/:id", Op::Security(SecurityOp::UpdateSecretAlert), &[]),
206 route("GET", "/repos/:owner/:name/secret-scanning/alerts/:id/locations", Op::Security(SecurityOp::ListSecretLocations), &[]),
207 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/bypass", Op::Security(SecurityOp::BypassPushProtection), &[]),
208 route("POST", "/repos/:owner/:name/secret-scanning/alerts/:id/validity", Op::Security(SecurityOp::CheckSecretValidity), &[]),
209 route("GET", "/workspaces/:workspace/secret-scanning/bypass-requests", Op::Security(SecurityOp::ListBypassRequests), &[("state", "state"), ("repo", "repo")]),
210 route("PATCH", "/workspaces/:workspace/secret-scanning/bypass-requests/:id", Op::Security(SecurityOp::ReviewBypassRequest), &[]),
211 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
212 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns/dry-run", Op::Security(SecurityOp::DryRunCustomPattern), &[]),
213 route("GET", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
214 route("GET", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::ListCustomPatterns), &[]),
215 route("POST", "/repos/:owner/:name/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
216 route("POST", "/workspaces/:workspace/secret-scanning/custom-patterns", Op::Security(SecurityOp::CreateCustomPattern), &[]),
217 route("PATCH", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
218 route("PATCH", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::UpdateCustomPattern), &[]),
219 route("DELETE", "/repos/:owner/:name/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
220 route("DELETE", "/workspaces/:workspace/secret-scanning/custom-patterns/:id", Op::Security(SecurityOp::DeleteCustomPattern), &[]),
221 route("GET", "/repos/:owner/:name/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
222 route("GET", "/workspaces/:workspace/code-scanning/alerts", Op::Security(SecurityOp::ListCodeAlerts), &[("state", "state"), ("severity", "severity"), ("tool", "tool"), ("rule_id", "rule_id")]),
223 route("GET", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::GetCodeAlert), &[]),
224 route("PATCH", "/repos/:owner/:name/code-scanning/alerts/:number", Op::Security(SecurityOp::UpdateCodeAlert), &[]),
225 route("GET", "/repos/:owner/:name/code-scanning/analyses", Op::Security(SecurityOp::ListAnalyses), &[]),
226 route("POST", "/repos/:owner/:name/code-scanning/sarifs", Op::Security(SecurityOp::UploadSarif), &[]),
227 route("GET", "/repos/:owner/:name/code-scanning/sarifs/:id", Op::Security(SecurityOp::GetSarifUpload), &[]),
228 route("GET", "/repos/:owner/:name/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
229 route("GET", "/workspaces/:workspace/vulnerability-alerts", Op::Security(SecurityOp::ListVulnerabilityAlerts), &[("state", "state"), ("severity", "severity"), ("ecosystem", "ecosystem"), ("package", "package")]),
230 route("GET", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::GetVulnerabilityAlert), &[]),
231 route("PATCH", "/repos/:owner/:name/vulnerability-alerts/:id", Op::Security(SecurityOp::UpdateVulnerabilityAlert), &[]),
232 route("POST", "/repos/:owner/:name/security/alerts/:id/fix", Op::Security(SecurityOp::FixAlert), &[]),
233 route("GET", "/repos/:owner/:name/dependency-graph", Op::Security(SecurityOp::GetDependencyGraph), &[]),
234 route("GET", "/repos/:owner/:name/dependency-graph/sbom", Op::Security(SecurityOp::GetSbom), &[]),
235 route("GET", "/repos/:owner/:name/dependency-graph/compare/:basehead", Op::Security(SecurityOp::CompareDependencies), &[]),
236 route("GET", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::GetSettings), &[]),
237 route("PATCH", "/repos/:owner/:name/security/settings", Op::Security(SecurityOp::UpdateSettings), &[]),
238 route("GET", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::GetWorkspaceSettings), &[]),
239 route("PATCH", "/workspaces/:workspace/security/settings", Op::Security(SecurityOp::UpdateWorkspaceSettings), &[]),
240 route("GET", "/workspaces/:workspace/security/overview", Op::Security(SecurityOp::GetOverview), &[("days", "days")]),
Agents as a team: lifecycle, merge queue, billing and a new shell241 route("GET", "/repos", Op::ListRepos, &[("q", "query")]),
Search across all of g1t, Explore, and a command palette242 route(
243 "GET",
244 "/search",
245 Op::Search,
246 &[("q", "query"), ("type", "type"), ("page", "page"), ("per_page", "per_page")],
247 ),
Agents as a team: lifecycle, merge queue, billing and a new shell248 route("POST", "/repos", Op::CreateRepo, &[]),
249 route("GET", "/repos/:owner/:name", Op::GetRepo, &[]),
250 route("PATCH", "/repos/:owner/:name", Op::UpdateRepo, &[]),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look251 route("POST", "/repos/:owner/:name/transfer", Op::TransferRepo, &[]),
252 route("DELETE", "/repos/:owner/:name", Op::DeleteRepo, &[]),
253 route(
254 "GET",
255 "/workspaces/:workspace/repos/deleted",
256 Op::ListDeletedRepos,
257 &[],
258 ),
259 route("POST", "/repos/:owner/:name/restore", Op::RestoreRepo, &[]),
260 route("POST", "/repos/:owner/:name/purge", Op::PurgeRepo, &[]),
261 route("POST", "/repos/:owner/:name/rename", Op::RenameRepo, &[]),
262 route("POST", "/repos/:owner/:name/archive", Op::ArchiveRepo, &[]),
263 route("POST", "/repos/:owner/:name/unarchive", Op::UnarchiveRepo, &[]),
264 route(
265 "POST",
266 "/repos/:owner/:name/visibility",
267 Op::SetRepoVisibility,
268 &[],
269 ),
270 route(
271 "POST",
272 "/repos/:owner/:name/branches/:branch/rename",
273 Op::RenameBranch,
274 &[],
275 ),
Agents as a team: lifecycle, merge queue, billing and a new shell276 route(
277 "GET",
278 "/repos/:owner/:name/settings",
279 Op::GetRepoSettings,
280 &[],
281 ),
282 route(
283 "PATCH",
284 "/repos/:owner/:name/settings",
285 Op::UpdateRepoSettings,
286 &[],
287 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents288 route("GET", "/repos/:owner/:name/check-names", Op::ListCheckNames, &[]),
Merge checks: statuses and check runs on every commit289 // Checks: GitHub's addresses for statuses, check runs and check suites.
290 route("POST", "/repos/:owner/:name/statuses/:sha", Op::Checks(ChecksOp::CreateCommitStatus), &[]),
291 route("GET", "/repos/:owner/:name/commits/:ref/statuses", Op::Checks(ChecksOp::ListCommitStatuses), &[]),
292 route("GET", "/repos/:owner/:name/commits/:ref/status", Op::Checks(ChecksOp::GetCombinedStatus), &[]),
293 route(
294 "GET",
295 "/repos/:owner/:name/commits/:ref/check-runs",
296 Op::Checks(ChecksOp::ListCheckRunsForRef),
297 &[("check_name", "check_name"), ("status", "status"), ("app", "app"), ("filter", "filter")],
298 ),
299 route(
300 "GET",
301 "/repos/:owner/:name/commits/:ref/check-suites",
302 Op::Checks(ChecksOp::ListCheckSuitesForRef),
303 &[("app", "app"), ("check_name", "check_name")],
304 ),
305 route("POST", "/repos/:owner/:name/check-runs", Op::Checks(ChecksOp::CreateCheckRun), &[]),
306 route("GET", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::GetCheckRun), &[]),
307 route("PATCH", "/repos/:owner/:name/check-runs/:id", Op::Checks(ChecksOp::UpdateCheckRun), &[]),
308 route("GET", "/repos/:owner/:name/check-runs/:id/annotations", Op::Checks(ChecksOp::ListCheckRunAnnotations), &[]),
309 route("POST", "/repos/:owner/:name/check-runs/:id/rerequest", Op::Checks(ChecksOp::RerequestCheckRun), &[]),
310 route("GET", "/repos/:owner/:name/check-suites/:id", Op::Checks(ChecksOp::GetCheckSuite), &[]),
311 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 merge312 // Rulesets: a repository's, a workspace's, the rules of one branch,
313 // and how they judged pushes and merges.
314 route("GET", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::ListRepoRulesets), &[("include_parents", "include_parents")]),
315 route("POST", "/repos/:owner/:name/rulesets", Op::Rules(RulesOp::CreateRepoRuleset), &[]),
316 route("GET", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::GetRepoRuleset), &[]),
317 route("PUT", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::UpdateRepoRuleset), &[]),
318 route("DELETE", "/repos/:owner/:name/rulesets/:id", Op::Rules(RulesOp::DeleteRepoRuleset), &[]),
319 route("GET", "/repos/:owner/:name/rules/branches/:branch", Op::Rules(RulesOp::GetBranchRules), &[("target", "target")]),
320 route(
321 "GET",
322 "/repos/:owner/:name/rules/evaluations",
323 Op::Rules(RulesOp::ListRuleEvaluations),
324 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
325 ),
326 route("GET", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::ListWorkspaceRulesets), &[]),
327 route("POST", "/workspaces/:workspace/rulesets", Op::Rules(RulesOp::CreateWorkspaceRuleset), &[]),
328 route("GET", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::GetWorkspaceRuleset), &[]),
329 route("PUT", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::UpdateWorkspaceRuleset), &[]),
330 route("DELETE", "/workspaces/:workspace/rulesets/:id", Op::Rules(RulesOp::DeleteWorkspaceRuleset), &[]),
331 route(
332 "GET",
333 "/workspaces/:workspace/rules/evaluations",
334 Op::Rules(RulesOp::ListWorkspaceRuleEvaluations),
335 &[("ruleset_id", "ruleset_id"), ("verdict", "verdict"), ("problems_only", "problems_only"), ("before", "before"), ("limit", "limit")],
336 ),
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97337 // Deployments wherever they run, their statuses, and environments.
338 route(
339 "GET",
340 "/repos/:owner/:name/deployments",
341 Op::Deployments(DeploymentsOp::ListDeployments),
342 &[("environment", "environment"), ("ref", "ref"), ("sha", "sha"), ("task", "task"), ("state", "state"), ("source", "source"), ("creator", "creator"), ("page", "page"), ("per_page", "per_page")],
343 ),
344 route("POST", "/repos/:owner/:name/deployments", Op::Deployments(DeploymentsOp::CreateDeployment), &[]),
345 route("GET", "/repos/:owner/:name/deployments/:id", Op::Deployments(DeploymentsOp::GetDeployment), &[]),
346 route("GET", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::ListDeploymentStatuses), &[]),
347 route("POST", "/repos/:owner/:name/deployments/:id/statuses", Op::Deployments(DeploymentsOp::CreateDeploymentStatus), &[]),
348 route("GET", "/repos/:owner/:name/environments", Op::Deployments(DeploymentsOp::ListEnvironments), &[]),
349 route("GET", "/repos/:owner/:name/environments/:environment", Op::Deployments(DeploymentsOp::GetEnvironment), &[]),
Merge branch 'worktree-agent-a3abfcce648e87dca'350 // Environments' protection rules, and the runs they hold.
351 route("PUT", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::UpdateEnvironment), &[]),
352 route("DELETE", "/repos/:owner/:name/environments/:environment", Op::Protection(ProtectionOp::DeleteEnvironment), &[]),
353 route(
354 "GET",
355 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
356 Op::Protection(ProtectionOp::GetPendingDeployments),
357 &[],
358 ),
359 route(
360 "POST",
361 "/repos/:owner/:name/actions/runs/:id/pending_deployments",
362 Op::Protection(ProtectionOp::ReviewPendingDeployments),
363 &[],
364 ),
365 route("POST", "/repos/:owner/:name/actions/runs/:id/approve", Op::Protection(ProtectionOp::ApproveWorkflowRun), &[]),
366 route("GET", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::GetWorkflowPermissions), &[]),
367 route("PUT", "/repos/:owner/:name/actions/permissions/workflow", Op::Protection(ProtectionOp::SetWorkflowPermissions), &[]),
368 route(
369 "GET",
370 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
371 Op::Protection(ProtectionOp::GetForkPrApproval),
372 &[],
373 ),
374 route(
375 "PUT",
376 "/repos/:owner/:name/actions/permissions/fork-pr-contributor-approval",
377 Op::Protection(ProtectionOp::SetForkPrApproval),
378 &[],
379 ),
380 route("POST", "/repos/:owner/:name/dispatches", Op::Protection(ProtectionOp::CreateRepositoryDispatch), &[]),
381 route(
382 "GET",
383 "/workspaces/:workspace/actions/permissions/workflow",
384 Op::Protection(ProtectionOp::GetWorkspaceWorkflowPermissions),
385 &[],
386 ),
387 route(
388 "PUT",
389 "/workspaces/:workspace/actions/permissions/workflow",
390 Op::Protection(ProtectionOp::SetWorkspaceWorkflowPermissions),
391 &[],
392 ),
Agents as a team: lifecycle, merge queue, billing and a new shell393 route("GET", "/repos/:owner/:name/queue", Op::GetMergeQueue, &[]),
API and MCP server in Rust; a public index at the API root394 route(
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request395 "POST",
396 "/repos/:owner/:name/pulls/:number/messages",
397 Op::MessageAgent,
398 &[],
399 ),
400 route(
401 "POST",
402 "/repos/:owner/:name/pulls/:number/messages/take",
403 Op::TakeMessages,
404 &[],
405 ),
406 route(
Docs worth reading, and kept that way407 "POST",
408 "/repos/:owner/:name/messages/:id/answer",
409 Op::AnswerMessage,
410 &[],
411 ),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains412 route("POST", "/repos/:owner/:name/memory", Op::Remember, &[]),
413 route(
414 "GET",
415 "/repos/:owner/:name/memory",
416 Op::Recall,
417 &[("q", "query"), ("limit", "limit")],
418 ),
Docs worth reading, and kept that way419 route(
API and MCP server in Rust; a public index at the API root420 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell421 "/repos/:owner/:name/events",
API and MCP server in Rust; a public index at the API root422 Op::ListEvents,
423 &[("before", "before")],
424 ),
Agents as a team: lifecycle, merge queue, billing and a new shell425 route("GET", "/repos/:owner/:name/labels", Op::ListLabels, &[]),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar426 route("POST", "/repos/:owner/:name/labels", Op::CreateLabel, &[]),
427 route("POST", "/repos/:owner/:name/labels/defaults", Op::AddDefaultLabels, &[]),
428 route("PATCH", "/repos/:owner/:name/labels/:label", Op::UpdateLabel, &[]),
429 route("DELETE", "/repos/:owner/:name/labels/:label", Op::DeleteLabel, &[]),
430 route("GET", "/repos/:owner/:name/issues/:number/labels", Op::ListIssueLabels, &[]),
431 route("POST", "/repos/:owner/:name/issues/:number/labels", Op::AddIssueLabels, &[]),
432 route("PUT", "/repos/:owner/:name/issues/:number/labels", Op::SetIssueLabels, &[]),
433 route("DELETE", "/repos/:owner/:name/issues/:number/labels", Op::RemoveIssueLabels, &[]),
434 route("DELETE", "/repos/:owner/:name/issues/:number/labels/:label", Op::RemoveIssueLabels, &[]),
435 route("GET", "/repos/:owner/:name/milestones", Op::ListMilestones, &[("state", "state")]),
436 route("POST", "/repos/:owner/:name/milestones", Op::CreateMilestone, &[]),
437 route("GET", "/repos/:owner/:name/milestones/:milestone", Op::GetMilestone, &[]),
438 route("PATCH", "/repos/:owner/:name/milestones/:milestone", Op::UpdateMilestone, &[]),
439 route("DELETE", "/repos/:owner/:name/milestones/:milestone", Op::DeleteMilestone, &[]),
API and MCP server in Rust; a public index at the API root440 route(
441 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell442 "/repos/:owner/:name/issues",
API and MCP server in Rust; a public index at the API root443 Op::ListIssues,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar444 &[("state", "state"), ("label", "label"), ("milestone", "milestone")],
API and MCP server in Rust; a public index at the API root445 ),
Agents as a team: lifecycle, merge queue, billing and a new shell446 route("POST", "/repos/:owner/:name/issues", Op::CreateIssue, &[]),
API and MCP server in Rust; a public index at the API root447 route(
448 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell449 "/repos/:owner/:name/issues/:number",
API and MCP server in Rust; a public index at the API root450 Op::GetIssue,
451 &[],
452 ),
453 route(
454 "PATCH",
Agents as a team: lifecycle, merge queue, billing and a new shell455 "/repos/:owner/:name/issues/:number",
API and MCP server in Rust; a public index at the API root456 Op::UpdateIssue,
457 &[],
458 ),
459 route(
460 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell461 "/repos/:owner/:name/issues/:number/close",
API and MCP server in Rust; a public index at the API root462 Op::CloseIssue,
463 &[],
464 ),
465 route(
466 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell467 "/repos/:owner/:name/issues/:number/reopen",
API and MCP server in Rust; a public index at the API root468 Op::ReopenIssue,
469 &[],
470 ),
471 route(
472 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell473 "/repos/:owner/:name/issues/:number/assign",
474 Op::AssignIssue,
475 &[],
476 ),
Integrations: your own model provider, alerts that open issues, tickets agents read477 route(
478 "POST",
479 "/repos/:owner/:name/issues/import",
480 Op::ImportIssue,
481 &[],
482 ),
483 route(
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step484 "POST",
485 "/repos/:owner/:name/issues/delegate",
486 Op::Delegate,
487 &[],
488 ),
489 route(
Integrations: your own model provider, alerts that open issues, tickets agents read490 "GET",
491 "/repos/:owner/:name/context",
492 Op::GetContext,
493 &[("reference", "reference")],
494 ),
495 route(
496 "GET",
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API497 "/workspaces/:workspace/context/search",
498 Op::SearchContext,
499 &[("q", "query"), ("project", "project"), ("kinds", "kinds"), ("limit", "limit")],
500 ),
501 route(
502 "GET",
503 "/workspaces/:workspace/context/:kind/:id",
504 Op::GetEntity,
505 &[],
506 ),
507 route(
508 "GET",
Integrations: your own model provider, alerts that open issues, tickets agents read509 "/workspaces/:workspace/integrations",
510 Op::ListIntegrations,
511 &[],
512 ),
513 route(
514 "POST",
515 "/workspaces/:workspace/integrations",
516 Op::ConnectIntegration,
517 &[],
518 ),
519 route(
Models per workspace: several providers, routed by kind of work520 "GET",
Webhooks: every event, to your own addresses, signed and retried521 "/repos/:owner/:name/hooks",
522 Op::ListWebhooks,
523 &[],
524 ),
525 route(
526 "POST",
527 "/repos/:owner/:name/hooks",
528 Op::CreateWebhook,
529 &[],
530 ),
531 route(
532 "PATCH",
533 "/repos/:owner/:name/hooks/:id",
534 Op::UpdateWebhook,
535 &[],
536 ),
537 route(
538 "DELETE",
539 "/repos/:owner/:name/hooks/:id",
540 Op::DeleteWebhook,
541 &[],
542 ),
543 route(
544 "POST",
545 "/repos/:owner/:name/hooks/:id/pings",
546 Op::PingWebhook,
547 &[],
548 ),
549 route(
550 "GET",
551 "/repos/:owner/:name/hooks/:id/deliveries",
552 Op::ListWebhookDeliveries,
553 &[],
554 ),
555 route(
556 "POST",
557 "/repos/:owner/:name/hooks/:id/deliveries/:delivery/redeliver",
558 Op::RedeliverWebhook,
559 &[],
560 ),
561 route(
562 "GET",
563 "/workspaces/:workspace/hooks",
564 Op::ListWebhooks,
565 &[],
566 ),
567 route(
568 "POST",
569 "/workspaces/:workspace/hooks",
570 Op::CreateWebhook,
571 &[],
572 ),
573 route(
574 "PATCH",
575 "/workspaces/:workspace/hooks/:id",
576 Op::UpdateWebhook,
577 &[],
578 ),
579 route(
580 "DELETE",
581 "/workspaces/:workspace/hooks/:id",
582 Op::DeleteWebhook,
583 &[],
584 ),
585 route(
586 "POST",
587 "/workspaces/:workspace/hooks/:id/pings",
588 Op::PingWebhook,
589 &[],
590 ),
591 route(
592 "GET",
593 "/workspaces/:workspace/hooks/:id/deliveries",
594 Op::ListWebhookDeliveries,
595 &[],
596 ),
597 route(
598 "POST",
599 "/workspaces/:workspace/hooks/:id/deliveries/:delivery/redeliver",
600 Op::RedeliverWebhook,
601 &[],
602 ),
603 route(
604 "GET",
Models per workspace: several providers, routed by kind of work605 "/workspaces/:workspace/model-routes",
606 Op::GetModelRoutes,
607 &[],
608 ),
609 route(
610 "PUT",
611 "/workspaces/:workspace/model-routes",
612 Op::SetModelRoutes,
613 &[],
614 ),
615 route(
AI Gateway: OpenAI's format, open models, and your own providers616 "PATCH",
617 "/workspaces/:workspace/integrations/:id",
618 Op::UpdateIntegration,
619 &[],
620 ),
621 route(
Integrations: your own model provider, alerts that open issues, tickets agents read622 "DELETE",
623 "/workspaces/:workspace/integrations/:id",
624 Op::DisconnectIntegration,
625 &[],
626 ),
627 route(
628 "POST",
629 "/workspaces/:workspace/integrations/:id/test",
630 Op::TestIntegration,
631 &[],
632 ),
Automations: rules in .g1t/automations that act when something happens633 route(
634 "GET",
GitHub Actions on g1t, part two: running workflows635 "/repos/:owner/:name/actions/workflows",
636 Op::ListWorkflows,
637 &[],
638 ),
639 route(
640 "GET",
641 "/repos/:owner/:name/actions/workflows/:workflow/runs",
642 Op::ListWorkflowRuns,
643 &[("branch", "branch"), ("event", "event"), ("per_page", "limit")],
644 ),
645 route(
646 "POST",
647 "/repos/:owner/:name/actions/workflows/:workflow/dispatches",
648 Op::DispatchWorkflow,
649 &[],
650 ),
651 route(
652 "PATCH",
653 "/repos/:owner/:name/actions/workflows/:workflow",
654 Op::UpdateWorkflow,
655 &[],
656 ),
657 route(
658 "PUT",
659 "/repos/:owner/:name/actions/workflows/:workflow/enable",
660 Op::UpdateWorkflow,
661 &[],
662 ),
663 route(
664 "PUT",
665 "/repos/:owner/:name/actions/workflows/:workflow/disable",
666 Op::UpdateWorkflow,
667 &[],
668 ),
669 route(
670 "GET",
671 "/repos/:owner/:name/actions/runs",
672 Op::ListWorkflowRuns,
673 &[("workflow", "workflow"), ("branch", "branch"), ("event", "event"), ("pull", "pull"), ("head_sha", "sha"), ("per_page", "limit")],
674 ),
675 route(
676 "GET",
677 "/repos/:owner/:name/actions/runs/:id",
678 Op::GetWorkflowRun,
679 &[],
680 ),
681 route(
682 "POST",
683 "/repos/:owner/:name/actions/runs/:id/cancel",
684 Op::CancelWorkflowRun,
685 &[],
686 ),
687 route(
688 "POST",
689 "/repos/:owner/:name/actions/runs/:id/rerun",
690 Op::RerunWorkflowRun,
691 &[],
692 ),
693 route(
694 "POST",
695 "/repos/:owner/:name/actions/runs/:id/rerun-failed-jobs",
696 Op::RerunWorkflowRun,
697 &[],
698 ),
699 route(
700 "GET",
701 "/repos/:owner/:name/actions/jobs/:job/logs",
702 Op::GetJobLogs,
703 &[("after", "after")],
704 ),
Merge packages: roles, Actions access, source label, soft delete, API705 // Packages, at GitHub's addresses with the workspace in place of the
706 // organization. A name with a slash is one URL-encoded segment.
707 route("GET", "/workspaces/:workspace/packages", Op::Packages(PackagesOp::ListPackages), &[("package_type", "package_type"), ("q", "q"), ("state", "state")]),
708 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::GetPackage), &[]),
709 route("PATCH", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::UpdatePackage), &[]),
710 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name", Op::Packages(PackagesOp::DeletePackage), &[]),
711 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/restore", Op::Packages(PackagesOp::RestorePackage), &[]),
712 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions", Op::Packages(PackagesOp::ListVersions), &[("state", "state")]),
713 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::GetVersion), &[]),
714 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id", Op::Packages(PackagesOp::DeleteVersion), &[]),
715 route("POST", "/workspaces/:workspace/packages/:package_type/:package_name/versions/:version_id/restore", Op::Packages(PackagesOp::RestoreVersion), &[]),
716 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::LinkPackage), &[]),
717 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/repository", Op::Packages(PackagesOp::UnlinkPackage), &[]),
718 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::ListAccess), &[]),
719 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::SetAccess), &[]),
720 route("DELETE", "/workspaces/:workspace/packages/:package_type/:package_name/access", Op::Packages(PackagesOp::RemoveAccess), &[("username", "username"), ("team", "team")]),
721 route("GET", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::ListActionsAccess), &[]),
722 route("PUT", "/workspaces/:workspace/packages/:package_type/:package_name/actions-access", Op::Packages(PackagesOp::SetActionsAccess), &[]),
723 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 R2724 // Artifacts, at GitHub's addresses. `…/zip` answers with a redirect to
725 // a signed link (lib.rs).
726 route("GET", "/repos/:owner/:name/actions/artifacts", Op::Artifacts(ArtifactsOp::ListArtifacts), &[("name", "name"), ("page", "page"), ("per_page", "per_page")]),
727 route("GET", "/repos/:owner/:name/actions/runs/:id/artifacts", Op::Artifacts(ArtifactsOp::ListRunArtifacts), &[("name", "name")]),
728 route("GET", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::GetArtifact), &[]),
729 route("GET", "/repos/:owner/:name/actions/artifacts/:id/zip", Op::Artifacts(ArtifactsOp::DownloadArtifact), &[]),
730 route("DELETE", "/repos/:owner/:name/actions/artifacts/:id", Op::Artifacts(ArtifactsOp::DeleteArtifact), &[]),
731 route("GET", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::GetArtifactRetention), &[]),
732 route("PUT", "/repos/:owner/:name/actions/permissions/artifact-and-log-retention", Op::Artifacts(ArtifactsOp::SetArtifactRetention), &[]),
GitHub Actions on g1t, part two: running workflows733 route(
734 "GET",
735 "/repos/:owner/:name/actions/secrets",
736 Op::ListActionsSecrets,
737 &[],
738 ),
739 route(
740 "PUT",
741 "/repos/:owner/:name/actions/secrets/:setting",
742 Op::SetActionsSecret,
743 &[],
744 ),
745 route(
746 "DELETE",
747 "/repos/:owner/:name/actions/secrets/:setting",
748 Op::DeleteActionsSecret,
749 &[],
750 ),
751 route(
752 "GET",
753 "/repos/:owner/:name/actions/variables",
754 Op::ListActionsVariables,
755 &[],
756 ),
757 route(
758 "POST",
759 "/repos/:owner/:name/actions/variables",
760 Op::SetActionsVariable,
761 &[],
762 ),
763 route(
764 "PATCH",
765 "/repos/:owner/:name/actions/variables/:setting",
766 Op::SetActionsVariable,
767 &[],
768 ),
769 route(
770 "DELETE",
771 "/repos/:owner/:name/actions/variables/:setting",
772 Op::DeleteActionsVariable,
773 &[],
774 ),
775 route(
776 "GET",
777 "/workspaces/:workspace/actions/secrets",
778 Op::ListActionsSecrets,
779 &[],
780 ),
781 route(
782 "PUT",
783 "/workspaces/:workspace/actions/secrets/:setting",
784 Op::SetActionsSecret,
785 &[],
786 ),
787 route(
788 "DELETE",
789 "/workspaces/:workspace/actions/secrets/:setting",
790 Op::DeleteActionsSecret,
791 &[],
792 ),
793 route(
794 "GET",
795 "/workspaces/:workspace/actions/variables",
796 Op::ListActionsVariables,
797 &[],
798 ),
799 route(
800 "POST",
801 "/workspaces/:workspace/actions/variables",
802 Op::SetActionsVariable,
803 &[],
804 ),
805 route(
806 "PATCH",
807 "/workspaces/:workspace/actions/variables/:setting",
808 Op::SetActionsVariable,
809 &[],
810 ),
811 route(
812 "DELETE",
813 "/workspaces/:workspace/actions/variables/:setting",
814 Op::DeleteActionsVariable,
815 &[],
816 ),
Fast pages, required checks on the branch, self-hosted runners, honest incidents817 // Self-hosted runners: a repository's own, or a workspace's.
818 route("GET", "/repos/:owner/:name/actions/runners", Op::ListRunners, &[]),
819 route("POST", "/repos/:owner/:name/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
820 route("DELETE", "/repos/:owner/:name/actions/runners/:id", Op::RemoveRunner, &[]),
821 route("GET", "/repos/:owner/:name/actions/runner-settings", Op::GetRunnerSettings, &[]),
822 route("PATCH", "/repos/:owner/:name/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
823 route("GET", "/workspaces/:workspace/actions/runners", Op::ListRunners, &[]),
824 route("POST", "/workspaces/:workspace/actions/runners/registration-token", Op::CreateRunnerRegistrationToken, &[]),
825 route("DELETE", "/workspaces/:workspace/actions/runners/:id", Op::RemoveRunner, &[]),
826 route("GET", "/workspaces/:workspace/actions/runner-settings", Op::GetRunnerSettings, &[]),
827 route("PATCH", "/workspaces/:workspace/actions/runner-settings", Op::UpdateRunnerSettings, &[]),
828 route("GET", "/workspaces/:workspace/actions/runner-groups", Op::ListRunnerGroups, &[]),
829 route("POST", "/workspaces/:workspace/actions/runner-groups", Op::CreateRunnerGroup, &[]),
830 route("PATCH", "/workspaces/:workspace/actions/runner-groups/:id", Op::UpdateRunnerGroup, &[]),
831 route("DELETE", "/workspaces/:workspace/actions/runner-groups/:id", Op::DeleteRunnerGroup, &[]),
Agents as a team: lifecycle, merge queue, billing and a new shell832 route("POST", "/repos/:owner/:name/plans", Op::PlanWork, &[]),
833 route("GET", "/repos/:owner/:name/plans/:plan", Op::GetPlan, &[]),
834 route(
835 "POST",
836 "/repos/:owner/:name/plans/:plan/apply",
837 Op::ApplyPlan,
838 &[],
839 ),
840 route(
841 "POST",
842 "/repos/:owner/:name/issues/:number/comments",
API and MCP server in Rust; a public index at the API root843 Op::AddComment,
844 &[],
845 ),
846 route(
847 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell848 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root849 Op::ListPullRequests,
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar850 &[("state", "state"), ("label", "label"), ("milestone", "milestone"), ("base", "base")],
API and MCP server in Rust; a public index at the API root851 ),
852 route(
853 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell854 "/repos/:owner/:name/pulls",
API and MCP server in Rust; a public index at the API root855 Op::CreatePullRequest,
856 &[],
857 ),
858 route(
859 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell860 "/repos/:owner/:name/pulls/:number",
API and MCP server in Rust; a public index at the API root861 Op::GetPullRequest,
862 &[],
863 ),
864 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar865 "PATCH",
866 "/repos/:owner/:name/pulls/:number",
867 Op::UpdatePullRequest,
868 &[],
869 ),
870 route(
API and MCP server in Rust; a public index at the API root871 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell872 "/repos/:owner/:name/pulls/:number/changes",
API and MCP server in Rust; a public index at the API root873 Op::GetPullRequestChanges,
874 &[],
875 ),
876 route(
Acceptance checks in sandboxes, line comments and review verdicts877 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell878 "/repos/:owner/:name/pulls/:number/reviews",
Acceptance checks in sandboxes, line comments and review verdicts879 Op::ReviewPullRequest,
880 &[],
881 ),
882 route(
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar883 "POST",
884 "/repos/:owner/:name/pulls/:number/requested_reviewers",
885 Op::RequestReviewers,
886 &[],
887 ),
888 route(
889 "DELETE",
890 "/repos/:owner/:name/pulls/:number/requested_reviewers",
891 Op::RemoveRequestedReviewers,
892 &[],
893 ),
894 route(
API and MCP server in Rust; a public index at the API root895 "GET",
Agents as a team: lifecycle, merge queue, billing and a new shell896 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root897 Op::ReadSession,
898 &[("after", "after")],
899 ),
900 route(
901 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell902 "/repos/:owner/:name/pulls/:number/session",
API and MCP server in Rust; a public index at the API root903 Op::RecordSession,
904 &[],
905 ),
906 route(
907 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell908 "/repos/:owner/:name/pulls/:number/ready",
API and MCP server in Rust; a public index at the API root909 Op::MarkPullRequestReady,
910 &[],
911 ),
912 route(
913 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell914 "/repos/:owner/:name/pulls/:number/close",
API and MCP server in Rust; a public index at the API root915 Op::ClosePullRequest,
916 &[],
917 ),
918 route(
919 "POST",
Agents as a team: lifecycle, merge queue, billing and a new shell920 "/repos/:owner/:name/pulls/:number/merge",
API and MCP server in Rust; a public index at the API root921 Op::MergePullRequest,
922 &[],
923 ),
924];
925
926impl Route {
927 /// The names of the route's path parameters, in order.
928 pub fn params(&self) -> impl Iterator<Item = &'static str> {
929 self.path
930 .split('/')
931 .filter_map(|segment| segment.strip_prefix(':'))
932 }
933
934 /// The values of the path parameters, if `path` is this route's.
935 fn matches<'a>(&self, path: &'a str) -> Option<Vec<(&'static str, &'a str)>> {
936 let mut values = Vec::new();
937 let mut actual = path.trim_end_matches('/').split('/');
938 for expected in self.path.split('/') {
939 let segment = actual.next()?;
940 match expected.strip_prefix(':') {
941 Some(name) if !segment.is_empty() => values.push((name, segment)),
942 Some(_) => return None,
943 None if expected == segment => {}
944 None => return None,
945 }
946 }
947 actual.next().is_none().then_some(values)
948 }
949}
950
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look951/// A path segment with its `%XX` escapes decoded; as given when that is not
952/// UTF-8.
953fn percent_decoded(segment: &str) -> String {
954 let bytes = segment.as_bytes();
955 let mut out = Vec::with_capacity(bytes.len());
956 let mut i = 0;
957 while i < bytes.len() {
958 let escaped = (bytes[i] == b'%')
959 .then(|| segment.get(i + 1..i + 3))
960 .flatten()
961 .filter(|hex| hex.bytes().all(|byte| byte.is_ascii_hexdigit()))
962 .and_then(|hex| u8::from_str_radix(hex, 16).ok());
963 match escaped {
964 Some(byte) => {
965 out.push(byte);
966 i += 3;
967 }
968 None => {
969 out.push(bytes[i]);
970 i += 1;
971 }
972 }
973 }
974 String::from_utf8(out).unwrap_or_else(|_| segment.to_owned())
975}
976
API and MCP server in Rust; a public index at the API root977/// The route for a request, and the operation input it describes.
978///
979/// The input is the JSON body, overlaid with the query parameters the route
980/// 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 bar981/// `repo`, as does a team's `repo` with its `workspace`, and `number`
982/// becomes an integer.
API and MCP server in Rust; a public index at the API root983pub fn resolve(
984 method: &str,
985 path: &str,
986 query: &[(String, String)],
987 body: Value,
988) -> Option<(&'static Route, Value)> {
989 let (route, params) = ROUTES
990 .iter()
991 .filter(|route| route.method == method)
992 .find_map(|route| Some((route, route.matches(path)?)))?;
993
994 let mut input = match body {
995 Value::Object(fields) => fields,
996 _ => Map::new(),
997 };
998 for (name, key) in route.query {
999 if let Some((_, value)) = query.iter().find(|(query_name, _)| query_name == name) {
1000 input.insert((*key).to_owned(), Value::String(value.clone()));
1001 }
1002 }
1003 let param = |wanted: &str| {
1004 params
1005 .iter()
1006 .find(|(name, _)| *name == wanted)
1007 .map(|(_, value)| *value)
1008 };
1009 if let (Some(owner), Some(name)) = (param("owner"), param("name")) {
1010 input.insert("repo".to_owned(), Value::String(format!("{owner}/{name}")));
1011 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971012 // Every other name the path gives, under that name; the ones below that
1013 // need more (a repository, a number, an encoded name) are set after.
1014 for (key, value) in &params {
1015 if !matches!(*key, "owner" | "name") {
1016 input.insert((*key).to_owned(), Value::String(percent_decoded(value)));
Docs worth reading, and kept that way1017 }
Agents as a team: lifecycle, merge queue, billing and a new shell1018 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1019 // A repository of a team's workspace, named by itself.
1020 if let (Some(workspace), Some(name)) = (param("workspace"), param("repo")) {
1021 input.insert("repo".to_owned(), Value::String(format!("{workspace}/{name}")));
1022 }
1023 // A branch name may hold slashes, sent URL-encoded as one segment, and
1024 // a label's name spaces.
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1025 if let Some(branch) = param("branch") {
1026 input.insert("branch".to_owned(), Value::String(percent_decoded(branch)));
1027 }
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971028 // An environment's name may hold slashes and spaces, URL-encoded.
1029 if let Some(environment) = param("environment") {
1030 input.insert("environment".to_owned(), Value::String(percent_decoded(environment)));
1031 }
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1032 if let Some(label) = param("label") {
1033 input.insert("label".to_owned(), Value::String(percent_decoded(label)));
1034 }
1035 if let Some(milestone) = param("milestone") {
1036 // Not a number: zero, which no milestone has.
1037 input.insert("milestone".to_owned(), milestone.parse::<u32>().unwrap_or(0).into());
1038 }
GitHub Actions on g1t, part two: running workflows1039 // GitHub says some things with the path alone.
1040 if route.path.ends_with("/enable") || route.path.ends_with("/disable") {
1041 input.insert("enabled".to_owned(), Value::Bool(route.path.ends_with("/enable")));
1042 }
1043 if route.path.ends_with("/rerun-failed-jobs") {
1044 input.insert("failed_only".to_owned(), Value::Bool(true));
1045 }
API: notifications over REST and MCP, with notifications scopes1046 // Unsaving and waking a thread are a DELETE of what PUT made.
1047 if route.method == "DELETE" && route.path.ends_with("/saved") {
1048 input.insert("saved".to_owned(), Value::Bool(false));
1049 }
1050 if route.method == "DELETE" && route.path.ends_with("/snooze") {
1051 input.remove("until");
1052 }
API and MCP server in Rust; a public index at the API root1053 if let Some(number) = param("number") {
1054 // Not a number: zero, which no issue or pull request has.
1055 input.insert(
1056 "number".to_owned(),
1057 number.parse::<u32>().unwrap_or(0).into(),
1058 );
1059 }
1060 Some((route, Value::Object(input)))
1061}
1062
1063#[cfg(test)]
1064mod tests {
1065 use serde_json::json;
1066
1067 use super::*;
1068
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb971069 /// Every name a route's path gives reaches the operation: a name left
1070 /// off the lists above is dropped, and the operation answers that it
1071 /// was not given (the project routes were, until this test).
1072 #[test]
1073 fn every_path_parameter_reaches_the_input() {
1074 for route in ROUTES.iter() {
1075 let names: Vec<&str> = route.path.split('/').filter_map(|part| part.strip_prefix(':')).collect();
1076 if names.is_empty() {
1077 continue;
1078 }
1079 let path: String = route
1080 .path
1081 .split('/')
1082 .map(|part| match part.strip_prefix(':') {
1083 Some("number" | "milestone") => "7".to_owned(),
1084 Some(name) => format!("{name}-x"),
1085 None => part.to_owned(),
1086 })
1087 .collect::<Vec<_>>()
1088 .join("/");
1089 let (found, input) = resolve(route.method, &path, &[], json!({})).unwrap();
1090 // A path two routes could take is checked under the first.
1091 if found.path != route.path {
1092 continue;
1093 }
1094 for name in names {
1095 let key = match name {
1096 "owner" | "name" => "repo",
1097 "repo" if names_has_workspace(route.path) => "repo",
1098 other => other,
1099 };
1100 assert!(
1101 input.get(key).is_some_and(|value| !value.is_null()),
1102 "{} {}: :{name} does not reach the input",
1103 route.method,
1104 route.path
1105 );
1106 }
1107 }
1108 }
1109
1110 fn names_has_workspace(path: &str) -> bool {
1111 path.split('/').any(|part| part == ":workspace")
1112 }
1113
API and MCP server in Rust; a public index at the API root1114 #[test]
1115 fn a_path_resolves_to_its_operation_and_input() {
1116 let (route, input) = resolve(
1117 "POST",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1118 "/repos/flagon-io/hello/pulls/14/merge",
API and MCP server in Rust; a public index at the API root1119 &[],
1120 json!({ "keep_issue_open": true, "number": 99, "repo": "someone/else" }),
1121 )
1122 .unwrap();
1123 assert_eq!(route.op, Op::MergePullRequest);
1124 // What the path names wins over the body.
1125 assert_eq!(
1126 input,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1127 json!({ "keep_issue_open": true, "number": 14, "repo": "flagon-io/hello" })
API and MCP server in Rust; a public index at the API root1128 );
1129 }
1130
1131 #[test]
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1132 fn a_branch_with_slashes_is_one_encoded_segment() {
1133 let (route, input) = resolve(
1134 "POST",
1135 "/repos/flagon-io/hello/branches/feature%2Flogin/rename",
1136 &[],
1137 json!({ "new_name": "feature/sign-in" }),
1138 )
1139 .unwrap();
1140 assert_eq!(route.op, Op::RenameBranch);
1141 assert_eq!(
1142 input,
1143 json!({ "new_name": "feature/sign-in", "branch": "feature/login", "repo": "flagon-io/hello" })
1144 );
1145 assert_eq!(percent_decoded("100%"), "100%");
1146 assert_eq!(percent_decoded("a%2bb%zz"), "a+b%zz");
1147 }
1148
1149 #[test]
1150 fn a_collaborator_is_named_by_username() {
1151 let (route, input) = resolve(
1152 "PATCH",
1153 "/repos/flagon-io/hello/collaborators/ada",
1154 &[],
1155 json!({ "role": "maintain" }),
1156 )
1157 .unwrap();
1158 assert_eq!(route.op, Op::UpdateCollaborator);
1159 assert_eq!(input, json!({ "role": "maintain", "username": "ada", "repo": "flagon-io/hello" }));
1160 let (route, input) = resolve("DELETE", "/user/repository_invitations/rin_1", &[], Value::Null).unwrap();
1161 assert_eq!(route.op, Op::DeclineRepoInvitation);
1162 assert_eq!(input, json!({ "id": "rin_1" }));
1163 }
1164
1165 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1166 fn teams_are_addressed_by_workspace_and_slug() {
1167 let query = [("q".to_owned(), "back".to_owned())];
1168 let (route, input) = resolve("GET", "/workspaces/acme/teams", &query, Value::Null).unwrap();
1169 assert_eq!(route.op, Op::ListTeams);
1170 assert_eq!(input, json!({ "query": "back", "workspace": "acme" }));
1171 let (route, input) = resolve("PATCH", "/workspaces/acme/teams/backend", &[], json!({ "name": "Back end" })).unwrap();
1172 assert_eq!(route.op, Op::UpdateTeam);
1173 assert_eq!(input, json!({ "name": "Back end", "workspace": "acme", "team": "backend" }));
1174 let (route, input) =
1175 resolve("PUT", "/workspaces/acme/teams/backend/members/ana", &[], json!({ "role": "maintainer" })).unwrap();
1176 assert_eq!(route.op, Op::SetTeamMember);
1177 assert_eq!(input, json!({ "role": "maintainer", "workspace": "acme", "team": "backend", "username": "ana" }));
1178 let query = [("include_child_teams".to_owned(), "true".to_owned())];
1179 let (route, input) = resolve("GET", "/workspaces/acme/teams/backend/members", &query, Value::Null).unwrap();
1180 assert_eq!(route.op, Op::ListTeamMembers);
1181 assert_eq!(input, json!({ "include_child_teams": "true", "workspace": "acme", "team": "backend" }));
1182 // A repository is named by itself, in the team's workspace.
1183 let (route, input) =
1184 resolve("PUT", "/workspaces/acme/teams/backend/repos/rocket", &[], json!({ "role": "write" })).unwrap();
1185 assert_eq!(route.op, Op::SetTeamRepo);
1186 assert_eq!(input, json!({ "role": "write", "workspace": "acme", "team": "backend", "repo": "acme/rocket" }));
1187 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1188 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/repos/rocket"), Op::RemoveTeamRepo);
1189 assert_eq!(op("GET", "/workspaces/acme/teams/backend/teams"), Op::ListChildTeams);
1190 assert_eq!(op("GET", "/workspaces/acme/teams/backend/repos"), Op::ListTeamRepos);
1191 assert_eq!(op("PUT", "/workspaces/acme/teams/backend/review_assignment"), Op::SetTeamReviewAssignment);
1192 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend"), Op::DeleteTeam);
1193 assert_eq!(op("POST", "/workspaces/acme/teams"), Op::CreateTeam);
1194 assert_eq!(op("GET", "/workspaces/acme/teams/backend"), Op::GetTeam);
1195 assert_eq!(op("DELETE", "/workspaces/acme/teams/backend/members/ana"), Op::RemoveTeamMember);
1196 let (route, input) = resolve("GET", "/workspaces/acme/members/ana/teams", &[], Value::Null).unwrap();
1197 assert_eq!(route.op, Op::ListUserTeams);
1198 assert_eq!(input, json!({ "workspace": "acme", "username": "ana" }));
1199 }
1200
1201 #[test]
1202 fn reviewers_are_requested_and_code_owners_checked_on_a_repository() {
1203 let body = json!({ "reviewers": ["ana"], "team_reviewers": ["backend"] });
1204 let (route, input) = resolve("POST", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body.clone()).unwrap();
1205 assert_eq!(route.op, Op::RequestReviewers);
1206 assert_eq!(
1207 input,
1208 json!({ "reviewers": ["ana"], "team_reviewers": ["backend"], "repo": "acme/rocket", "number": 7 })
1209 );
1210 let (route, _) = resolve("DELETE", "/repos/acme/rocket/pulls/7/requested_reviewers", &[], body).unwrap();
1211 assert_eq!(route.op, Op::RemoveRequestedReviewers);
1212 let query = [("ref".to_owned(), "main".to_owned())];
1213 let (route, input) = resolve("GET", "/repos/acme/rocket/codeowners/errors", &query, Value::Null).unwrap();
1214 assert_eq!(route.op, Op::GetCodeownersErrors);
1215 assert_eq!(input, json!({ "ref": "main", "repo": "acme/rocket" }));
1216 }
1217
1218 #[test]
API: notifications over REST and MCP, with notifications scopes1219 fn notifications_are_addressed_as_threads_and_by_issue() {
1220 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1", &[], Value::Null).unwrap();
1221 assert_eq!(route.op, Op::MarkThreadDone);
1222 assert_eq!(input, json!({ "id": "ntf_1" }));
1223 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/saved", &[], Value::Null).unwrap();
1224 assert_eq!(route.op, Op::SaveThread);
1225 assert_eq!(input, json!({ "id": "ntf_1", "saved": false }));
1226 let (route, input) = resolve("DELETE", "/notifications/threads/ntf_1/snooze", &[], json!({ "until": "x" })).unwrap();
1227 assert_eq!(route.op, Op::SnoozeThread);
1228 assert_eq!(input, json!({ "id": "ntf_1" }));
1229 let query = [("all".to_owned(), "true".to_owned()), ("per_page".to_owned(), "50".to_owned())];
1230 let (route, input) = resolve("GET", "/repos/acme/rocket/notifications", &query, Value::Null).unwrap();
1231 assert_eq!(route.op, Op::ListNotifications);
1232 assert_eq!(input, json!({ "all": "true", "per_page": "50", "repo": "acme/rocket" }));
1233 let (route, input) = resolve("PUT", "/repos/acme/rocket/issues/7/subscription", &[], json!({ "ignored": true })).unwrap();
1234 assert_eq!(route.op, Op::SetThreadSubscription);
1235 assert_eq!(input, json!({ "ignored": true, "number": 7, "repo": "acme/rocket" }));
1236 assert_eq!(resolve("GET", "/user/subscriptions", &[], Value::Null).unwrap().0.op, Op::ListWatchedRepos);
1237 }
1238
1239 #[test]
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar1240 fn labels_and_milestones_are_named_in_the_path() {
1241 let (route, input) = resolve("PATCH", "/repos/acme/web/labels/good%20first%20issue", &[], json!({ "color": "7057ff" })).unwrap();
1242 assert_eq!(route.op, Op::UpdateLabel);
1243 assert_eq!(input, json!({ "color": "7057ff", "label": "good first issue", "repo": "acme/web" }));
1244 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels/bug", &[], Value::Null).unwrap();
1245 assert_eq!(route.op, Op::RemoveIssueLabels);
1246 assert_eq!(input, json!({ "label": "bug", "number": 7, "repo": "acme/web" }));
1247 let (route, input) = resolve("DELETE", "/repos/acme/web/issues/7/labels", &[], Value::Null).unwrap();
1248 assert_eq!(route.op, Op::RemoveIssueLabels);
1249 assert_eq!(input, json!({ "number": 7, "repo": "acme/web" }));
1250 let (route, _) = resolve("POST", "/repos/acme/web/labels/defaults", &[], Value::Null).unwrap();
1251 assert_eq!(route.op, Op::AddDefaultLabels);
1252 let (route, input) = resolve("PATCH", "/repos/acme/web/milestones/3", &[], json!({ "state": "closed" })).unwrap();
1253 assert_eq!(route.op, Op::UpdateMilestone);
1254 assert_eq!(input, json!({ "state": "closed", "milestone": 3, "repo": "acme/web" }));
1255 let (route, input) = resolve("PATCH", "/repos/acme/web/pulls/9", &[], json!({ "base": "release" })).unwrap();
1256 assert_eq!(route.op, Op::UpdatePullRequest);
1257 assert_eq!(input, json!({ "base": "release", "number": 9, "repo": "acme/web" }));
1258 }
1259
1260 #[test]
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1261 fn billing_is_addressed_by_workspace() {
1262 let query = [("from".to_owned(), "2026-10-01".to_owned()), ("products".to_owned(), "agent,sandboxes".to_owned())];
1263 let (route, input) = resolve("GET", "/workspaces/acme/usage", &query, Value::Null).unwrap();
1264 assert_eq!(route.op, Op::GetUsage);
1265 assert_eq!(input, json!({ "from": "2026-10-01", "products": "agent,sandboxes", "workspace": "acme" }));
1266 let (route, input) = resolve("PUT", "/workspaces/acme/budget", &[], json!({ "alerts": [50] })).unwrap();
1267 assert_eq!(route.op, Op::SetBudget);
1268 assert_eq!(input, json!({ "alerts": [50], "workspace": "acme" }));
1269 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1270 assert_eq!(op("GET", "/workspaces/acme/budget"), Op::GetBudget);
1271 assert_eq!(op("GET", "/workspaces/acme/ai_credit"), Op::GetAiCredit);
1272 assert_eq!(op("POST", "/workspaces/acme/ai_credit/checkout"), Op::BuyAiCredit);
1273 assert_eq!(op("GET", "/workspaces/acme/invoices"), Op::ListInvoices);
1274 assert_eq!(op("GET", "/workspaces/acme/billing_details"), Op::GetBillingDetails);
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens1275 assert_eq!(op("GET", "/workspaces/acme/gateway/requests"), Op::ListGatewayRequests);
Usage, Billing settings and prepaid AI credit; fixes from the UX audit1276 }
1277
1278 #[test]
Merge checks: statuses and check runs on every commit1279 fn checks_are_at_githubs_addresses() {
1280 let sha = "a".repeat(40);
1281 let body = json!({ "state": "success", "context": "ci/build" });
1282 let (route, input) = resolve("POST", &format!("/repos/acme/web/statuses/{sha}"), &[], body).unwrap();
1283 assert_eq!(route.op, Op::Checks(ChecksOp::CreateCommitStatus));
1284 assert_eq!(input, json!({ "state": "success", "context": "ci/build", "sha": sha, "repo": "acme/web" }));
1285 let (route, input) = resolve("GET", "/repos/acme/web/commits/release%2F1.x/status", &[], Value::Null).unwrap();
1286 assert_eq!(route.op, Op::Checks(ChecksOp::GetCombinedStatus));
1287 assert_eq!(input, json!({ "ref": "release/1.x", "repo": "acme/web" }));
1288 let query = [("check_name".to_owned(), "lint".to_owned())];
1289 let (route, input) = resolve("GET", "/repos/acme/web/commits/main/check-runs", &query, Value::Null).unwrap();
1290 assert_eq!(route.op, Op::Checks(ChecksOp::ListCheckRunsForRef));
1291 assert_eq!(input, json!({ "check_name": "lint", "ref": "main", "repo": "acme/web" }));
1292 let (route, input) = resolve("PATCH", "/repos/acme/web/check-runs/cr_1", &[], json!({ "conclusion": "success" })).unwrap();
1293 assert_eq!(route.op, Op::Checks(ChecksOp::UpdateCheckRun));
1294 assert_eq!(input, json!({ "conclusion": "success", "id": "cr_1", "repo": "acme/web" }));
1295 let op = |method: &str, path: &str| resolve(method, path, &[], Value::Null).unwrap().0.op;
1296 assert_eq!(op("POST", "/repos/acme/web/check-runs"), Op::Checks(ChecksOp::CreateCheckRun));
1297 assert_eq!(op("GET", "/repos/acme/web/check-runs/cr_1/annotations"), Op::Checks(ChecksOp::ListCheckRunAnnotations));
1298 assert_eq!(op("POST", "/repos/acme/web/check-suites/cs_1/rerequest"), Op::Checks(ChecksOp::RerequestCheckSuite));
1299 assert_eq!(op("GET", "/repos/acme/web/commits/main/check-suites"), Op::Checks(ChecksOp::ListCheckSuitesForRef));
1300 }
1301
1302 #[test]
API and MCP server in Rust; a public index at the API root1303 fn query_parameters_are_renamed() {
1304 let query = [
1305 ("q".to_owned(), "parser".to_owned()),
1306 ("x".to_owned(), "y".to_owned()),
1307 ];
Agents as a team: lifecycle, merge queue, billing and a new shell1308 let (route, input) = resolve("GET", "/repos", &query, Value::Null).unwrap();
API and MCP server in Rust; a public index at the API root1309 assert_eq!(route.op, Op::ListRepos);
1310 assert_eq!(input, json!({ "query": "parser" }));
1311 }
1312
1313 #[test]
1314 fn method_and_shape_must_match() {
Agents as a team: lifecycle, merge queue, billing and a new shell1315 assert!(resolve("GET", "/repos/a/b/issues/1/close", &[], Value::Null).is_none());
1316 assert!(resolve("GET", "/repos/a", &[], Value::Null).is_none());
1317 assert!(resolve("GET", "/repos/a/b/issues/1/extra", &[], Value::Null).is_none());
1318 assert!(resolve("GET", "/repos/a/b/", &[], Value::Null).is_some());
API and MCP server in Rust; a public index at the API root1319 }
1320
1321 #[test]
1322 fn every_parameter_and_query_name_is_an_input() {
1323 for route in ROUTES {
1324 let properties = route.op.properties();
1325 for (_, key) in route.query {
1326 assert!(properties.contains_key(*key), "{}: {key}", route.path);
1327 }
1328 for name in route.params() {
1329 let covered = matches!(name, "owner" | "name") && properties.contains_key("repo")
1330 || properties.contains_key(name);
1331 assert!(covered, "{}: {name}", route.path);
1332 }
1333 }
1334 }
1335
1336 #[test]
1337 fn every_operation_has_a_route() {
1338 for op in Op::ALL {
1339 assert!(ROUTES.iter().any(|route| route.op == op), "{}", op.name());
1340 }
1341 }
1342}

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