canonical: https://jentic.com/apis/googleapis.com/servicedirectory

# Google Service Directory API

Service Directory is Google Cloud's managed service registry for discovering, publishing, and connecting services across GCP, on-prem, and other clouds. The API organises services into namespaces, registers individual services with metadata, and tracks endpoints with addresses, ports, and annotations. A resolve operation returns all healthy endpoints for a service so clients can do client-side load balancing or DNS lookup.

## For AI agents

Register services and endpoints in a central registry, then resolve them by name for clients running across GCP and hybrid environments.

## Scope

Does not handle health checking, traffic routing, or DNS resolution itself - use for service registration, endpoint metadata, and resolve lookups only.

## Capabilities

- Create, list, and delete namespaces that group services within a region
- Register, update, and delete services with arbitrary metadata annotations
- Add, list, and remove endpoints (address, port, annotations) for each service
- Resolve a service to retrieve all of its current endpoints in one call
- Filter and search services or endpoints with a flexible filter expression
- Manage IAM bindings on namespaces, services, and endpoints

## Use cases

### Hybrid Service Registry

Use Service Directory as a single registry across GCP, on-prem, and other clouds. Services running in any environment register themselves with their network address and port, and clients resolve by service name regardless of where the workload lives. Pairs with Cloud DNS to expose entries through DNS and with VPC private connectivity for hybrid endpoints.

Example prompt: Call POST /v1/{+parent}/services/{serviceId}/endpoints with address, port, and annotations to register a new instance, then call services:resolve to confirm it appears.

### Microservice Discovery for Internal Apps

Internal apps and serverless workloads call services:resolve at startup to discover the addresses of dependent services. Service Directory tracks endpoint metadata so clients can pick by region, version, or any custom annotation, and updates propagate quickly when endpoints register or de-register.

Example prompt: Call POST /v1/{+name}:resolve on the service to retrieve every endpoint, then pick one matching annotation 'version=v2'.

### Decommissioning Audit

Run periodic audits that list every service in every namespace, identify ones with no recent registrations or no healthy endpoints, and flag them for cleanup. The API supports filter expressions on labels, regions, and last-update timestamps to make this kind of housekeeping straightforward.

Example prompt: List namespaces, then for each namespace call services.list with filter='annotations.tier="critical"' and assert at least one endpoint is registered.

### AI Agent Topology Mapper

An AI agent that reasons about a deployment's topology pulls services and endpoints from Service Directory to build a live dependency map. Through Jentic the agent searches by intent and never holds the GCP service account credentials directly, so the same agent can run across multiple GCP organizations safely.

Example prompt: List every namespace, list every service in each namespace, list every endpoint per service, and emit a graph of service-to-endpoint relationships.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /v1/{+parent}/namespaces | List namespaces in a project and region |
| POST | /v1/{+parent}/services | Register a new service |
| GET | /v1/{+parent}/endpoints | List endpoints for a service |
| POST | /v1/{+parent}/endpoints | Register a new endpoint |
| POST | /v1/{+name}:resolve | Resolve a service to its endpoints |
| DELETE | /v1/{+name} | Delete a namespace, service, or endpoint |

## Key resources

- **namespaces** — Group services within a project and region
- **services** — Register, update, list, delete, and resolve services
- **endpoints** — Track endpoint address, port, and annotations for each service
- **iam** — Manage IAM bindings on registry resources

## Why Jentic

- **Setup:** Wiring Google Service Directory by hand means setting up a service account, minting OAuth access tokens against servicedirectory.googleapis.com, and navigating its namespace and service hierarchy yourself. Through Jentic you install once, import the Service Directory API from the API Directory, store the OAuth credential once, and your agent calls it.
- **Permission scoping:** Service Directory puts the namespace or service in the URL path (/v1/{parent}/services, /v1/{name}:resolve), so a rule can pin your agent to one namespace: it can register services and resolve endpoints there and nothing else. You choose the operations it may call, so deleting a service is not included unless you add it.
- **Credential handling:** Your Service Directory OAuth credential is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'resolve a service to its endpoints' or 'register a new service', and Jentic returns the matching Service Directory operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Google Cloud DNS API** — Exposes Service Directory namespaces as private DNS zones for clients that resolve by hostname.
- **Google Compute Engine API** — Hosts most of the workloads that register endpoints in Service Directory.
- **HashiCorp Nomad API** — Nomad's built-in service registry plus Consul integration for non-GCP environments.
- **Google Cloud IAM API** — Controls who can read or write each namespace, service, or endpoint in Service Directory.

## FAQ

### What authentication does the Service Directory API use?

Service Directory uses OAuth 2.0 with the cloud-platform scope and IAM permissions like roles/servicedirectory.editor on the namespace, service, or endpoint. Through Jentic the credentials are stored encrypted in your Jentic One instance and a scoped token is provided at execution.

### Can I use Service Directory for on-prem services?

Yes. Endpoints record arbitrary address and port values, so you can register on-prem or third-cloud services and resolve them from clients running in GCP or via Cloud DNS forwarding zones.

### What are the rate limits for the Service Directory API?

Google enforces a default per-project quota of 600 read requests per minute and 60 write requests per minute on the registry resources. Resolve calls have higher per-region limits because they sit on the discovery hot path.

### How do I resolve a service through Jentic?

Run the Jentic search query 'resolve service directory endpoints', load POST /v1/{+name}:resolve, and execute it with the service resource name. Jentic injects the GCP credentials so the agent only needs the service name and an optional max-endpoints filter.

### Does Service Directory health-check endpoints?

No. Service Directory stores the endpoints you register; health checking is the responsibility of the registering workload or a fronting load balancer. Clients should still validate health on their side after resolving.

### Can I expose Service Directory entries through DNS?

Yes. Cloud DNS supports a Service Directory zone type that mirrors a namespace as a private DNS zone. Updates to endpoints propagate to the DNS view automatically without separate record management.

### Can I limit what my agent is allowed to do with the Service Directory API?

Yes. Because Jentic One is self-hosted, you set the rules that decide which Service Directory operations and credentials your agent may use. Since the namespace and service sit in the URL path (like /v1/{parent}/services and /v1/{name}:resolve), you can pin the agent to a single namespace so it registers services and resolves endpoints there and nothing else. You pick the exact operations it may call, so an action like deleting a service is excluded unless you add it, and the OAuth credential stays with your own instance rather than the agent's context.
