Skip to main content

manager/client.go (package manager)

Source: sdks/go/manager/client.go. Back to the Go SDK reference index.

note

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).

NameTypeDefaultRequiredDescription
ctxcontext.ContextyesContext of the call: cancellation and deadline.
operationIDstringyesoperationId of manager-openapi.json, a key of Operations; an unknown one returns an error.
bodyanyyesRequest body, serialized as JSON.
opts[]eai.CallOptionyesPer call options (query, idempotency key, traceparent, headers).
params...stringnoExtra 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).

NameTypeDefaultRequiredDescription
ctxcontext.ContextyesContext of the call: cancellation and deadline.
methodstringyesHTTP method of the call, for example GET or POST.
tplstringyesPath template such as /v1/runs/{id}, its placeholders filled by the path parameters in order.
bodyanyyesRequest body, serialized as JSON.
opts[]CallOptionyesPer call options (query, idempotency key, traceparent, headers).
params...stringnoExtra 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.

NameTypeDefaultRequiredDescription
ctxcontext.ContextyesContext of the call: cancellation and deadline.
methodstringyesHTTP method; a POST gets an Idempotency-Key kept across retries.
tplstringyesPath template such as /v1/runs/{id}, its placeholders filled by the path parameters in order.
bodyanyyesRequest body, serialized as JSON.
acceptstringyesValue of the Accept header, for example application/json or text/event-stream.
opts[]CallOptionyesPer call options (query, idempotency key, traceparent, headers).
params...stringnoExtra 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.

NameTypeDefaultRequiredDescription
ctxcontext.ContextyesContext of the call: cancellation and deadline.
methodstringyesHTTP method of the call, for example GET or POST.
tplstringyesPath template such as /v1/runs/{id}, its placeholders filled by the path parameters in order.
bodyanyyesRequest body, serialized as JSON.
opts[]CallOptionyesPer call options (query, idempotency key, traceparent, headers).
params...stringnoExtra 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.

NameTypeDefaultRequiredDescription
opts...CallOptionnoPer 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.

NameTypeDefaultRequiredDescription
userstringyesUser 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).

NameTypeDefaultRequiredDescription
ustringyesPlatform 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>.

NameTypeDefaultRequiredDescription
tstringyesManager 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.

NameTypeDefaultRequiredDescription
userstringyesUser 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").

NameTypeDefaultRequiredDescription
lstringyesLanguage 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.

NameTypeDefaultRequiredDescription
pem[]byteyesPEM 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).

NameTypeDefaultRequiredDescription
h*http.ClientyesHTTP 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).

NameTypeDefaultRequiredDescription
nintyesNumber 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.

NameTypeDefaultRequiredDescription
dtime.DurationyesDelay 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.

NameTypeDefaultRequiredDescription
namestringyesName of the HTTP header to send on every call.
valuestringyesValue 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.

NameTypeDefaultRequiredDescription
opts...OptionnoPer 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.