Skip to main content

manager/client.ts

Source: sdks/typescript/packages/sdk/src/manager/client.ts. Back to the TypeScript 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.

Interface ManagerClientOptions​

Options of ManagerClient: URL, token, on behalf of user, locale, fetch, retries, timeout and headers.

Fields:

NameTypeRequiredDescription
baseUrlstringyesPlatform Manager URL, for example <manager-url> (https, or http on localhost).
tokenstring | (() => string | Promise<string>)noManager API token nmt_<12 hex>_<secret> (string or async provider reading a secret store).
onBehalfOfstringnoUser the service token acts for: sends X-NM-On-Behalf-Of (token with the explicit auth:delegate permission).
localeLocalenoLanguage of the messages, en (default) or fr.
fetchFetchLikenofetch implementation to use; defaults to the global fetch.
retriesnumbernoNumber of retries of GET, PUT and DELETE on 429, 5xx and network errors (default 2); POST is never retried.
timeoutMsnumbernoPer request timeout in ms (default 60000, 0 disables).
headersRecord<stringnoHeaders of the event, string values. The trace context is added.
sleep(ms: number) => Promise<void>noSleep function used between retries (injectable for tests).

Interface ManagerClient​

Client of the Platform Manager API (hosts, clusters, services, HA, backups, restores, DR), one generated sub-client per group of manager-openapi.json.

Groups

This model declares no field.

Class ManagerClient​

Client of the Platform Manager API (hosts, clusters, services, HA, backups, restores, DR), one generated sub-client per group of manager-openapi.json.

Attributes:

NameTypeRequiredDescription
httpHttpClientyesHTTP transport shared by every sub-client.

Constructor ManagerClient​

new ManagerClient(options: ManagerClientOptions)

Checks the token format nmt_<12 hex>_<secret>, sets X-NM-On-Behalf-Of when asked and creates every sub-client.

NameTypeDefaultRequiredDescription
optionsManagerClientOptionsyesPer call options (idempotency key, traceparent, headers, abort signal).

ManagerClient.onBehalfOf​

onBehalfOf(user: string): ManagerClient

A client with the same settings acting on behalf of user.

NameTypeDefaultRequiredDescription
userstringyesUser the service token acts for, sent as X-NM-On-Behalf-Of.

Returns: ManagerClient. A new ManagerClient; the current one is unchanged.

ManagerClient.operation​

operation(operationId: string): (...args: unknown[]) => Promise<unknown>

Calls an operation of manager-openapi.json by operationId (path parameters in template order).

NameTypeDefaultRequiredDescription
operationIdstringyesoperationId of manager-openapi.json; an unknown one throws an Error.

Returns: (...args: unknown[]) => Promise<unknown>. The bound method of the sub-client that wraps the operation.

Raises: Error.

ManagerClient.toJSON​

toJSON(): Record<string, unknown>

Safe view of the client for logs: base URL, locale, masked token and onBehalfOf.

This element takes no parameter.

Returns: Record<string, unknown>. Object without any clear secret.