manager/client.go (package manager)
Source: sdks/go/manager/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.
Type alias Option
Option configures New.
Definition: func(*settings) error.
Class Client
Client calls the Platform Manager API; its fields are the generated operation groups.
Client.Call
Call(ctx context.Context, operationID string, body any, opts []eai.CallOption, params ...string) (json.RawMessage, error)
Call runs an operation of manager-openapi.json by operationId (path parameters in template order).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ctx | context.Context | yes | Context of the call: cancellation and deadline. | |
operationID | string | yes | operationId of manager-openapi.json, a key of Operations; an unknown one returns an error. | |
body | any | yes | Request body, serialized as JSON. | |
opts | []eai.CallOption | yes | Per call options (query, idempotency key, traceparent, headers). | |
params | ...string | no | Extra fields merged into the request. |
Returns: (json.RawMessage, error). Raw JSON body of the answer, null for an empty body. The error is a typed *eai.APIError, nil on success.
Raises: error.
Client.Call
Call(ctx context.Context, method string, tpl string, body any, opts []CallOption, params ...string) (json.RawMessage, error)
Call performs a JSON call and returns the raw JSON body ("null" for empty bodies).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ctx | context.Context | yes | Context of the call: cancellation and deadline. | |
method | string | yes | HTTP method of the call, for example GET or POST. | |
tpl | string | yes | Path template such as /v1/runs/{id}, its placeholders filled by the path parameters in order. | |
body | any | yes | Request body, serialized as JSON. | |
opts | []CallOption | yes | Per call options (query, idempotency key, traceparent, headers). | |
params | ...string | no | Extra fields merged into the request. |
Returns: (json.RawMessage, error). Raw JSON body of the answer, null for an empty body. The error is a typed *eai.APIError, nil on success.
Raises: error.
Client.Do
Do(ctx context.Context, method string, tpl string, body any, accept string, opts []CallOption, params ...string) (*http.Response, error)
Do sends one request with retries and returns the successful response (caller closes the body). body may be nil, []byte (sent as is) or any JSON serializable value.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ctx | context.Context | yes | Context of the call: cancellation and deadline. | |
method | string | yes | HTTP method; a POST gets an Idempotency-Key kept across retries. | |
tpl | string | yes | Path template such as /v1/runs/{id}, its placeholders filled by the path parameters in order. | |
body | any | yes | Request body, serialized as JSON. | |
accept | string | yes | Value of the Accept header, for example application/json or text/event-stream. | |
opts | []CallOption | yes | Per call options (query, idempotency key, traceparent, headers). | |
params | ...string | no | Extra fields merged into the request. |
Returns: (*http.Response, error). The *http.Response of a status below 400, its body still open. The error is a typed *APIError for an HTTP error or a network failure, nil on success.
Raises: error.
Client.Exchange
Exchange(ctx context.Context, method string, tpl string, body any, opts []CallOption, params ...string) (*Response, error)
Exchange performs a JSON call and returns status, headers and body.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ctx | context.Context | yes | Context of the call: cancellation and deadline. | |
method | string | yes | HTTP method of the call, for example GET or POST. | |
tpl | string | yes | Path template such as /v1/runs/{id}, its placeholders filled by the path parameters in order. | |
body | any | yes | Request body, serialized as JSON. | |
opts | []CallOption | yes | Per call options (query, idempotency key, traceparent, headers). | |
params | ...string | no | Extra fields merged into the request. |
Returns: (*Response, error). A Response: Response is a JSON response with its headers. The error is a typed error of the SDK, nil on success.
Raises: error.
Client.GoString
GoString() string
GoString keeps %#v from printing secrets.
This element takes no parameter.
Returns: string. Same text as String, secrets masked.
Client.Headers
Headers(opts ...CallOption) http.Header
Headers returns the headers sent on every request (auth, tenancy, language, trace) for this call.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
opts | ...CallOption | no | Per call options (query, idempotency key, traceparent, headers). |
Returns: http.Header. A copy of the headers, with traceparent and the per call headers applied.
Client.OnBehalfOf
OnBehalfOf(user string) (*Client, error)
OnBehalfOf returns a client with the same settings acting for user.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
user | string | yes | User the new client acts for, sent as X-NM-On-Behalf-Of; the token needs the auth:delegate permission. |
Returns: (*Client, error). A Client: Client calls the Platform Manager API; its fields are the generated operation groups. The error is a typed error of the SDK, nil on success.
Raises: error.
Client.String
String() string
String never shows the token.
This element takes no parameter.
Returns: string. A description with the base URL and, for the manager client, the on behalf user; secrets are never printed.
Client.String
String() string
String never prints the API key or the token.
This element takes no parameter.
Returns: string. A description with the base URL and, for the manager client, the on behalf user; secrets are never printed.
Functions
WithBaseURL
WithBaseURL(u string) Option
WithBaseURL sets the manager URL (https, or http on localhost).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
u | string | yes | Platform Manager URL; New refuses http except for localhost and 127.0.0.1. |
Returns: Option. A Option: Option configures New.
WithToken
WithToken(t string) Option
WithToken sets the manager API token nmt_<12 hex>_<secret>.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
t | string | yes | Manager API token nmt_<12 hex>_<secret>; another format makes New fail. |
Returns: Option. A Option: Option configures New.
WithOnBehalfOf
WithOnBehalfOf(user string) Option
WithOnBehalfOf sends X-NM-On-Behalf-Of on every call.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
user | string | yes | User a service token acts for; the token needs the auth:delegate permission. |
Returns: Option. A Option: Option configures New.
WithLocale
WithLocale(l string) Option
WithLocale selects the language of error messages ("en" or "fr").
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
l | string | yes | Language code; any value starting with fr selects French, anything else English. |
Returns: Option. A Option: Option configures New.
WithCABundle
WithCABundle(pem []byte) Option
WithCABundle trusts the PEM encoded manager CA in addition to the system pool.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
pem | []byte | yes | PEM encoded CA of the manager; empty keeps the system pool only. |
Returns: Option. A Option: Option configures New.
WithHTTPClient
WithHTTPClient(h *http.Client) Option
WithHTTPClient sets the *http.Client (tests, proxies, mTLS).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
h | *http.Client | yes | HTTP client used by the transport, instead of the default one of the eai package. |
Returns: Option. A Option: Option configures New.
WithRetries
WithRetries(n int) Option
WithRetries sets the retries of GET, PUT and DELETE calls (default 2).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
n | int | yes | Number of retries of GET, PUT and DELETE, 0 or more; other methods are never retried. |
Returns: Option. A Option: Option configures New.
WithRetryBaseDelay
WithRetryBaseDelay(d time.Duration) Option
WithRetryBaseDelay sets the first backoff delay of the retried calls.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
d | time.Duration | yes | Delay before the first retry (250 ms by default), doubled at each attempt. |
Returns: Option. A Option: Option configures New.
WithHeader
WithHeader(name string, value string) Option
WithHeader adds a header sent on every call.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | string | yes | Name of the HTTP header to send on every call. | |
value | string | yes | Value of the header; a later WithHeader with the same name replaces it. |
Returns: Option. A Option: Option configures New.
New
New(opts ...Option) (*Client, error)
New builds a manager client.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
opts | ...Option | no | Per call options (query, idempotency key, traceparent, headers). |
Returns: (*Client, error). A Client: Client calls the Platform Manager API; its fields are the generated operation groups. The error is a typed error of the SDK, nil on success.
Raises: error.