[PR #7026] [MERGED] [management] Align agent-network API contracts for API clients #30101

Closed
opened 2026-08-05 08:10:06 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/7026
Author: @mlsmaycon
Created: 8/2/2026
Status: Merged
Merged: 8/3/2026
Merged by: @mlsmaycon

Base: mainHead: agent-network-api-terraform


📝 Commits (7)

  • 1843568 [management] Fix agent-network settings and provider update contracts
  • d88bee4 [management] Add agent-network APIs to the REST client
  • 30ca6a9 [management] Return agent-network settings defaults before bootstrap
  • 0f13bba [management] Align agent-network provider updates with full-state PUT
  • a98ffa5 [management] Cover settings-first bootstrap in the agent-network e2e suite
  • 7436a1c [management] Make the settings update transactional; harden the bootstrap e2e
  • 0d76591 Merge remote-tracking branch 'origin/main' into agent-network-api-terraform

📊 Changes

16 files changed (+1463 additions, -139 deletions)

View changed files

📝 e2e/agentnetwork/management_test.go (+11 -0)
e2e/agentnetwork/settings_bootstrap_test.go (+114 -0)
📝 management/internals/modules/agentnetwork/handlers/handlers_test.go (+15 -1)
📝 management/internals/modules/agentnetwork/handlers/providers_handler_test.go (+49 -0)
📝 management/internals/modules/agentnetwork/handlers/settings_handler.go (+9 -16)
management/internals/modules/agentnetwork/handlers/settings_handler_test.go (+137 -0)
📝 management/internals/modules/agentnetwork/manager.go (+98 -53)
📝 management/internals/modules/agentnetwork/types/provider.go (+15 -21)
📝 management/internals/modules/agentnetwork/types/provider_test.go (+38 -0)
📝 management/internals/modules/agentnetwork/types/settings.go (+39 -9)
📝 management/server/agentnetwork_budgetrule_realstack_test.go (+12 -3)
shared/management/client/rest/agentnetwork.go (+381 -0)
shared/management/client/rest/agentnetwork_test.go (+497 -0)
📝 shared/management/client/rest/client.go (+5 -0)
📝 shared/management/http/api/openapi.yml (+24 -20)
📝 shared/management/http/api/types.gen.go (+19 -16)

📄 Description

Describe your changes

Work on the Terraform provider (terraform-provider-netbird #177–#183) surfaced places where the agent-network API broke its own contracts or deviated from the conventions the rest of the management API follows, forcing client-side workarounds.

Settings reads now follow the settings-endpoint convention: GET always answers with a JSON object. Before bootstrap it returns the defaults with an empty cluster/subdomain/endpoint (previously 200 with a JSON null body, while the spec said 404). The settings PUT can bootstrap the account by carrying a cluster — previously the row could only come into existence through the first provider create, and a settings-first setup was impossible; a differing cluster on a bootstrapped account is rejected instead of silently ignored. PUT remains full-state.

The provider PUT schema promised omit-preserves semantics for several operator-editable fields that the handler never delivered (it builds the row from the request, like every other update handler). The schema wording now matches the shipped full-state behavior; only the api_key (secret) and session keys stay preserved by the manager. Identity headers are always present in provider responses so an explicitly cleared value round-trips as an empty string.

The Go REST client gains the full agent-network surface (catalog, providers, policies, guardrails, budget rules, settings), including a shim translating the legacy 200+null settings body from older servers into an IsNotFound error.

Note for reviewers: the dashboard special-cased the null settings body; it needs a small follow-up for the new defaults response (in progress).

NET-1465

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • I ran and tested this change locally — I did not rely on CI to find out whether it works
  • This PR has a single purpose (not a fix + refactor + feature in one)
  • This change is a trivial fix, OR it links an issue the NetBird team agreed on beforehand. Changes to the public API, gRPC protocols, functionality behavior, CLI / service flags, or new features always need that agreement first. See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why): the API reference is generated from the OpenAPI spec, which this PR updates in-repo.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added REST client support for Agent Network providers, policies, guardrails, budget rules, and settings.
    • Unbootstrapped accounts now show default settings and can be initialized by providing a cluster.
    • Provider responses consistently include identity-header fields, including explicitly cleared values.
  • Bug Fixes

    • Prevented changes to an account’s pinned cluster after bootstrap.
    • Improved settings validation, provider update replacement behavior, and server-controlled endpoint details.
  • Documentation

    • Clarified Agent Network API request and response behavior, including bootstrap and validation rules.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/7026 **Author:** [@mlsmaycon](https://github.com/mlsmaycon) **Created:** 8/2/2026 **Status:** ✅ Merged **Merged:** 8/3/2026 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `agent-network-api-terraform` --- ### 📝 Commits (7) - [`1843568`](https://github.com/netbirdio/netbird/commit/1843568bb8b8617d4ffe2b16370e2a48d512e8dc) [management] Fix agent-network settings and provider update contracts - [`d88bee4`](https://github.com/netbirdio/netbird/commit/d88bee43470355b8bd4a76147016bea1cb6eafc1) [management] Add agent-network APIs to the REST client - [`30ca6a9`](https://github.com/netbirdio/netbird/commit/30ca6a9809b3f68f995f0c0dc27c35bd34783feb) [management] Return agent-network settings defaults before bootstrap - [`0f13bba`](https://github.com/netbirdio/netbird/commit/0f13bbab145bd103c36e5b37738ef1f7164b6d2b) [management] Align agent-network provider updates with full-state PUT - [`a98ffa5`](https://github.com/netbirdio/netbird/commit/a98ffa50eda9b2c0c6bb04bbed17d9395839835e) [management] Cover settings-first bootstrap in the agent-network e2e suite - [`7436a1c`](https://github.com/netbirdio/netbird/commit/7436a1cbf3b7986bba802a7d6e607f4f86f5cc96) [management] Make the settings update transactional; harden the bootstrap e2e - [`0d76591`](https://github.com/netbirdio/netbird/commit/0d765917782f4006473928d0820957d927c19ef8) Merge remote-tracking branch 'origin/main' into agent-network-api-terraform ### 📊 Changes **16 files changed** (+1463 additions, -139 deletions) <details> <summary>View changed files</summary> 📝 `e2e/agentnetwork/management_test.go` (+11 -0) ➕ `e2e/agentnetwork/settings_bootstrap_test.go` (+114 -0) 📝 `management/internals/modules/agentnetwork/handlers/handlers_test.go` (+15 -1) 📝 `management/internals/modules/agentnetwork/handlers/providers_handler_test.go` (+49 -0) 📝 `management/internals/modules/agentnetwork/handlers/settings_handler.go` (+9 -16) ➕ `management/internals/modules/agentnetwork/handlers/settings_handler_test.go` (+137 -0) 📝 `management/internals/modules/agentnetwork/manager.go` (+98 -53) 📝 `management/internals/modules/agentnetwork/types/provider.go` (+15 -21) 📝 `management/internals/modules/agentnetwork/types/provider_test.go` (+38 -0) 📝 `management/internals/modules/agentnetwork/types/settings.go` (+39 -9) 📝 `management/server/agentnetwork_budgetrule_realstack_test.go` (+12 -3) ➕ `shared/management/client/rest/agentnetwork.go` (+381 -0) ➕ `shared/management/client/rest/agentnetwork_test.go` (+497 -0) 📝 `shared/management/client/rest/client.go` (+5 -0) 📝 `shared/management/http/api/openapi.yml` (+24 -20) 📝 `shared/management/http/api/types.gen.go` (+19 -16) </details> ### 📄 Description ## Describe your changes Work on the Terraform provider (terraform-provider-netbird #177–#183) surfaced places where the agent-network API broke its own contracts or deviated from the conventions the rest of the management API follows, forcing client-side workarounds. Settings reads now follow the settings-endpoint convention: GET always answers with a JSON object. Before bootstrap it returns the defaults with an empty cluster/subdomain/endpoint (previously 200 with a JSON `null` body, while the spec said 404). The settings PUT can bootstrap the account by carrying a `cluster` — previously the row could only come into existence through the first provider create, and a settings-first setup was impossible; a differing cluster on a bootstrapped account is rejected instead of silently ignored. PUT remains full-state. The provider PUT schema promised omit-preserves semantics for several operator-editable fields that the handler never delivered (it builds the row from the request, like every other update handler). The schema wording now matches the shipped full-state behavior; only the api_key (secret) and session keys stay preserved by the manager. Identity headers are always present in provider responses so an explicitly cleared value round-trips as an empty string. The Go REST client gains the full agent-network surface (catalog, providers, policies, guardrails, budget rules, settings), including a shim translating the legacy 200+`null` settings body from older servers into an `IsNotFound` error. Note for reviewers: the dashboard special-cased the `null` settings body; it needs a small follow-up for the new defaults response (in progress). ## Issue ticket number and link [NET-1465](https://linear.app/netbird/issue/NET-1465/agent-network-rest-api-settings-defaults-bootstrap-via-put-provider) ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] Created tests that fail without the change (if possible) - [x] I ran and tested this change locally — I did not rely on CI to find out whether it works - [x] This PR has a single purpose (not a fix + refactor + feature in one) - [x] This change is a trivial fix, **OR** it links an issue the NetBird team agreed on beforehand. Changes to the public API, gRPC protocols, functionality behavior, CLI / service flags, or new features always need that agreement first. See [CONTRIBUTING.md](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTING.md#ticket-first-pr-second). > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why): the API reference is generated from the OpenAPI spec, which this PR updates in-repo. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ --- _Generated by [Claude Code](https://claude.ai/code/session_01PmYTYTyVvcoDXCVHescbgs)_ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added REST client support for Agent Network providers, policies, guardrails, budget rules, and settings. * Unbootstrapped accounts now show default settings and can be initialized by providing a cluster. * Provider responses consistently include identity-header fields, including explicitly cleared values. * **Bug Fixes** * Prevented changes to an account’s pinned cluster after bootstrap. * Improved settings validation, provider update replacement behavior, and server-controlled endpoint details. * **Documentation** * Clarified Agent Network API request and response behavior, including bootstrap and validation rules. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:10:06 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#30101