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