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