Skip to content

hosted agents: add ListRegions - #1199

Merged
DO-rrao merged 3 commits into
mainfrom
marsohs-list-regions-godo
Nov 4, 2026
Merged

DO-rrao merged 3 commits into
mainfrom
marsohs-list-regions-godo

Conversation

@amandhaw

Copy link
Copy Markdown
Contributor

Summary

Adds ListRegions — GET /v2/harness-runtime/regions, the per-team region catalog.

regions, _, err := client.HostedAgents.ListRegions(ctx)
// {"regions":[{"slug":"mem1","is_default":false},{"slug":"ric1","is_default":true}]}

slug, ok := regions.DefaultRegion() // "ric1", true

The default region is always listed and marked is_default; every other open region is listed only when the team holds its grant. The set is exactly what CreateSession and CreateSessionFromEnvironment placement admit, so a slug returned here is accepted and a slug missing here is refused — a picker built from the catalog never offers a region a create rejects.

This is the SDK support the CLI's agents regions command needs; that work follows separately.

Draft: do not merge yet

The endpoint is not in production. The implementing service change is merged but not yet deployed, and the route is still refused at the edge until the matching allow-list change lands. Opened early so CI runs and the CLI work has something to build against.

Changes

File
hosted_agent_regions.go types, ListRegions, DefaultRegion()
hosted_agent_regions_test.go tests
hosted_agents.go path const and the interface method

Types live in a per-concern file with the interface method central, matching hosted_agent_checkpoints.go, hosted_agent_configs.go and the other siblings.

Notes

  • Team-scoped, not host-scoped. The catalog is the same on every regional host, so one call enumerates the regions rather than one call per HostedAgentsRegionalBaseURL.
  • DefaultRegion() exists because every caller rendering a picker needs "which one is preselected", and the alternative is each of them looping over the slice. It reports not-found rather than falling back to the first entry: guessing a default would place a session in a region the caller never chose.
  • No CHANGELOG.md or version bump, per CONTRIBUTING.md step 3 — those are a release-time change in their own PR.

Testing

gofmt and go vet clean. Four new tests: the catalog, the default-only case a team with no grants sees, the error path, and a table for DefaultRegion() including the nil receiver. Full root package suite passes with no regressions from the interface change.

Adds GET /v2/harness-runtime/regions, the per-team region catalog. The
default region is always listed and marked is_default; every other open
region is listed only when the team holds its grant, so the catalog
agrees slug for slug with what CreateSession and
CreateSessionFromEnvironment placement admit.

The catalog is team-scoped rather than host-scoped: it is the same on
every regional host, so one call enumerates the regions instead of one
call per HostedAgentsRegionalBaseURL.

DefaultRegion() reports the marked slug for callers rendering a picker,
so they preselect from the catalog rather than hardcoding ric1. It
reports not-found rather than falling back to the first entry: guessing
a default would place sessions in a region the caller never chose.

Implemented by the harness-api ListRegions endpoint.
@amandhaw
amandhaw marked this pull request as ready for review November 2, 2026 16:39
@DO-rrao
DO-rrao merged commit 526cf39 into main Nov 4, 2026
8 checks passed
@DO-rrao
DO-rrao deleted the marsohs-list-regions-godo branch November 4, 2026 16:50
amandhaw added a commit that referenced this pull request Nov 10, 2026
Follow-up to #1199. The comments describe a slug as "the region a
session or environment is created in" and IsDefault as "the region a
create lands in when none is named". Both read as a placement choice.
The API works the other way: a create is placed in the region of the
host that served it, and the optional region field on a create request
is a check against that host.

Slug now names the regional API host to point a client at, IsDefault
names the region the region-less host serves, and the interface comment
points at HostedAgentsRegionalBaseURL for building the host.

Comments only; no behaviour change. Matches the wording agreed on the
OpenAPI spec in digitalocean/openapi#1296. Reported in review by
@DO-rrao on that PR; it missed #1199 because the fix came after it
merged.

Co-authored-by: Radhika Rao <rrao@digitalocean.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址