Skip to content

Cover the whole Consul CE HTTP API - #70

Open
lyrixx wants to merge 22 commits into
mainfrom
more-services
Open

lyrixx wants to merge 22 commits into
mainfrom
more-services

Conversation

@lyrixx

@lyrixx lyrixx commented Sep 27, 2026

Copy link
Copy Markdown
Member

This PR adds all the Consul Community Edition (v2.0.x) HTTP API endpoints to the SDK. It can be reviewed commit by commit.

New services

ACL, Config, Connect (CA + intentions), Coordinate, DiscoveryChain, Event, Operator (raft, keyring, autopilot, usage), Peering (+ exported / imported services), PreparedQuery, Snapshot and Status.

Existing services

  • Agent, Catalog and Health now cover all their endpoints
  • All documented options are whitelisted (blocking queries, consistency modes, filter, ...) in Agent, Catalog, Health, KV and Session
  • Fix Agent::join() and Agent::forceLeave(): they sent GET, Consul only accepts PUT (405)

No BC break: nothing is removed nor renamed, only new optional arguments.

Client

  • The ACL token is read from the CONSUL_HTTP_TOKEN environment variable (like the Consul CLI); an explicit X-Consul-Token header wins
  • Multi-valued options are supported: ['tag' => ['v1', 'primary']] is sent as ?tag=v1&tag=primary (Symfony HttpClient would send ?tag[0]=v1&tag[1]=primary, which Consul does not understand)
  • The dc option is allowed on all endpoints, except the ones local to the agent, the datacenter listings, and the catalog (de)registration (where it goes in the payload). A test checks every method forwards it.

Out of scope

  • Enterprise-only endpoints and parameters (ns, partition, operator area / license / segment / audit / utilization, OIDC...)
  • Deprecated endpoints (intentions by ID, POST /v1/connect/intentions)
  • Streaming endpoints (/v1/agent/monitor, /v1/agent/metrics/stream)
  • /v1/internal/*

Tests & tooling

  • The CI Consul agent now runs with ACLs enabled (default_policy = allow, root management token)
  • Integration tests against a real Consul 2.0 agent for almost every method; endpoints that can't run on a single dev agent, or would break it (leave, force-leave, raft, keyring, peering establish, ACL bootstrap), are tested with MockHttpClient
  • PHPStan now runs against PHP 8.2 (the minimum supported version)
  • README: services table, badges removed

Add the missing /v1/agent endpoints, whitelist documented options, and fix join() and forceLeave() which used GET while Consul only accepts PUT.
Add connect(), nodeServices() and gatewayServices(), and whitelist the documented options.
Add connect() and ingress(), and whitelist the documented options.
Allow blocking queries (index, wait) on get() and check-and-set (cas) on delete().
Allow blocking queries and consistency modes on info(), node() and all().
Consul expects multi-valued parameters to be repeated (?tag=a&tag=b), but
Symfony HttpClient encodes arrays PHP-style (?tag[0]=a&tag[1]=b).
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.

1 participant