client.go (package eai)
Source: sdks/go/client.go. Back to the Go SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Model Client
Client is safe for concurrent use.
This model declares no field.
Client.BaseURL
BaseURL() string
BaseURL returns the configured base URL.
This element takes no parameter.
Returns: string. Base URL of the Control Plane set with WithBaseURL, without trailing slash.
Client.Locale
Locale() string
Locale returns "en" or "fr".
This element takes no parameter.
Returns: string. Message language of the client, en or fr.
Client.Tenant
Tenant() string
Tenant returns the configured tenant slug.
This element takes no parameter.
Returns: string. Tenant slug set with WithTenant, empty when none was given.
Type alias Option
Option configures a Client.
Definition: func(*Client) error.
Functions
WithBaseURL
WithBaseURL(u string) Option
WithBaseURL sets the Control Plane URL (without /v1). Required.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
u | string | yes | Control Plane URL without /v1; trailing slashes are removed. |
Returns: Option. An Option to pass to NewClient.
WithAPIKey
WithAPIKey(k string) Option
WithAPIKey sets the tenant API key sent as X-API-Key.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
k | string | yes | Tenant API key, sent as X-API-Key on every request. |
Returns: Option. An Option to pass to NewClient.
WithToken
WithToken(t string) Option
WithToken sets an OIDC access token sent as Authorization: Bearer.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
t | string | yes | OIDC access token, sent as Authorization: Bearer <t>. |
Returns: Option. An Option to pass to NewClient.
WithTenant
WithTenant(t string) Option
WithTenant sets the tenant slug. The server resolves the tenant from the credential; without any credential the slug is sent as X-Dev-Tenant (development mode, EAI_AUTH_DEV=1).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
t | string | yes | Tenant slug, sent as X-Dev-Tenant only when no API key nor token is set. |
Returns: Option. An Option to pass to NewClient.
WithProject
WithProject(p string) Option
WithProject sets X-Project.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
p | string | yes | Project sent as X-Project on every request. |
Returns: Option. An Option to pass to NewClient.
WithEnvironment
WithEnvironment(e string) Option
WithEnvironment sets X-Environment (dev, test, staging, prod).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
e | string | yes | Environment sent as X-Environment: dev, test, staging or prod. |
Returns: Option. An Option to pass to NewClient.
WithLocale
WithLocale(l string) Option
WithLocale selects the message language, "en" (default) or "fr"; sent as Accept-Language.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
l | string | yes | Language code; any value starting with fr selects French, anything else English. |
Returns: Option. An Option to pass to NewClient.
WithRetries
WithRetries(n int) Option
WithRetries sets how many times network errors and HTTP 408/429/502/503/504 are retried (default 2).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
n | int | yes | Number of retries, 0 or more; a negative value makes NewClient fail. |
Returns: Option. An Option to pass to NewClient.
WithRetryBaseDelay
WithRetryBaseDelay(d time.Duration) Option
WithRetryBaseDelay sets the first backoff delay, doubled at each attempt; Retry-After wins when present.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
d | time.Duration | yes | Delay before the first retry (250 ms by default). |
Returns: Option. An Option to pass to NewClient.
WithHTTPClient
WithHTTPClient(h *http.Client) Option
WithHTTPClient sets a custom *http.Client (timeouts, proxy, TLS, mTLS).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
h | *http.Client | yes | HTTP client used for every request instead of the default one (60 second timeout). |
Returns: Option. An Option to pass to NewClient.
WithHeader
WithHeader(name string, value string) Option
WithHeader adds a header sent on every request.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | string | yes | Name of the HTTP header to send on every request. | |
value | string | yes | Value of the header; a later WithHeader with the same name replaces it. |
Returns: Option. An Option to pass to NewClient.
WithTraceparent
WithTraceparent(f func() string) Option
WithTraceparent sets a function returning the W3C traceparent of the current span; a random one is generated per request otherwise (a per call WithCallTraceparent wins).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
f | func() string | yes | Function called for each request that returns the W3C traceparent header value. |
Returns: Option. An Option to pass to NewClient.
NewClient
NewClient(opts ...Option) (*Client, error)
NewClient builds a client.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
opts | ...Option | no | Per call options (query, idempotency key, traceparent, headers). |
Returns: (*Client, error). The configured *Client of the Control Plane API, its services ready. The error is set when an option fails, the base URL is missing or the TLS settings are invalid, nil on success.
Raises: error.