Skip to content

feat(MARSOHS-2085): expose region on Hosted Agents sessions and environments - #1192

Merged
SSharma-10 merged 1 commit into
digitalocean:mainfrom
nkurraDO:naveen/MARSOHS-2085/hosted-agents-region
Oct 24, 2026
Merged

SSharma-10 merged 1 commit into
digitalocean:mainfrom
nkurraDO:naveen/MARSOHS-2085/hosted-agents-region

Conversation

@nkurraDO

Copy link
Copy Markdown
Contributor

Why

Hosted Agents resources are now regional (MARSOHS-2085). The API host a request reaches decides where a create is placed and where a resource can be found: api.digitalocean.com places in and serves the default region (ric1); api-<region>.digitalocean.com places in and serves that region. A resource is a 404 on every other region's host; there is no redirect, forwarding or fan-out. godo had no way to see or state a region.

What

  • HostedAgentSession.Region, HostedAgentConfig.Region, HostedAgentConfigSummary.Region (json:"region,omitempty"), returned on create/get/list for teams on the regional routing rollout, omitted otherwise.
  • HostedAgentSessionFromEnvironmentRequest.Region (omitempty): an optional placement check that must match the host called, else the server answers 4xx region_mismatch. Not sent when empty, so today's body is byte-for-byte unchanged. The YAML manifest create and the Environment create carry no region (the server rejects unknown body fields); placement is the host.
  • Location (json:"-") on HostedAgentSession and HostedAgentConfig, lifted from the create response's Location header on every create method; the canonical URL on the owning region's host.
  • HostedAgentsRegionalBaseURL(region): returns https://api-<region>.digitalocean.com/ in the form SetBaseURL accepts (empty region → default base URL). No new dialers: callers build a client per region.
c, _ := godo.New(httpClient, godo.SetBaseURL(godo.HostedAgentsRegionalBaseURL("mem1")))
sess, _, err := c.HostedAgents.CreateSessionFromEnvironment(ctx, &godo.HostedAgentSessionFromEnvironmentRequest{
    Name: "review-bot", ConfigID: cfg.ID, Region: "mem1",
})
// sess.Region == "mem1"; sess.Location is on api-mem1; keep using c for follow-ups.

Tests

  • TestHostedAgents_CreateSessionFromEnvironment_RegionAndLocation: body region sent as given; Region, Location and X-DO-Region surface.
  • TestHostedAgents_CreateSessionFromEnvironment_NoRegionIsOmitted: no region key when empty; no header → empty Location.
  • TestHostedAgents_CreateEnvironment_RegionAndLocation, TestHostedAgents_ListEnvironments_Region: environment create has no body region; response region/Location surface on create and list.
  • TestHostedAgentsRegionalBaseURL.

go vet ./... && go test . green. CHANGELOG left for the release PR per CONTRIBUTING.

…onments

Sessions and Environments are regional resources: the API host a request
reaches decides where a create is placed and where a resource can be found.
Add Region to HostedAgentSession, HostedAgentConfig and
HostedAgentConfigSummary, Region (placement check) to
HostedAgentSessionFromEnvironmentRequest, lift the create response's
Location header onto the created resource, and add
HostedAgentsRegionalBaseURL so callers can point a client at
api-<region>.digitalocean.com. No new dialers; empty fields are omitted so
existing bodies are unchanged.

@SSharma-10 SSharma-10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SSharma-10
SSharma-10 merged commit 7417a63 into digitalocean:main Oct 24, 2026
8 checks passed
@SSharma-10 SSharma-10 mentioned this pull request Oct 26, 2026
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

⌂ 换网址