Skip to main content

transport.go (package eai)

Source: sdks/go/transport.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 CallOption​

CallOption customizes one call.

Definition: func(*callConfig).

Model Response​

Response is a JSON response with its headers.

Fields:

NameTypeRequiredDescription
StatusintyesHTTP status code of the response.
Headerhttp.HeaderyesHeader carrying the key for api_key. Default X-API-Key.
Bodyjson.RawMessageyesRaw JSON body, null when the response was empty.

Functions​

WithQuery​

WithQuery(q map[string]string) CallOption

WithQuery adds query parameters (filters, limit, cursor, group_by...).

NameTypeDefaultRequiredDescription
qmap[string]stringyesQuery parameters by name; each one replaces a previous value of the same name.

Returns: CallOption. A CallOption: CallOption customizes one call.

WithLimit​

WithLimit(n int) CallOption

WithLimit sets ?limit= for paginated lists.

NameTypeDefaultRequiredDescription
nintyesPage size sent as the limit query parameter.

Returns: CallOption. A CallOption: CallOption customizes one call.

WithCursor​

WithCursor(cur string) CallOption

WithCursor sets ?cursor= for paginated lists.

NameTypeDefaultRequiredDescription
curstringyesCursor of the page to read, the next_cursor of the previous page.

Returns: CallOption. A CallOption: CallOption customizes one call.

WithIdempotencyKey​

WithIdempotencyKey(k string) CallOption

WithIdempotencyKey sets the Idempotency-Key of a call: a POST gets a generated one otherwise (kept across retries); other methods (a PUT such as RagAgent.UpdateBranding) send it only when given.

NameTypeDefaultRequiredDescription
kstringyesIdempotency key sent as Idempotency-Key on a POST.

Returns: CallOption. A CallOption: CallOption customizes one call.

WithCallTraceparent​

WithCallTraceparent(tp string) CallOption

WithCallTraceparent sets the W3C traceparent of this call.

NameTypeDefaultRequiredDescription
tpstringyesW3C traceparent value; it wins over WithTraceparent and the generated one.

Returns: CallOption. A CallOption: CallOption customizes one call.

WithCallHeader​

WithCallHeader(name string, value string) CallOption

WithCallHeader sets a header on this call only (for example to forward the caller credentials).

NameTypeDefaultRequiredDescription
namestringyesName of the header; it replaces a client header of the same name.
valuestringyesValue of the header.

Returns: CallOption. A CallOption: CallOption customizes one call.

NewTraceparent​

NewTraceparent() string

NewTraceparent returns a random W3C traceparent "00-<trace id>--01".

This element takes no parameter.

Returns: string. A traceparent value with a random 32 hex trace id and 16 hex span id.

NewRequestID​

NewRequestID() string

NewRequestID returns a random request id.

This element takes no parameter.

Returns: string. 32 random hex characters.

ExpandPath​

ExpandPath(tpl string, params ...string) (string, error)

ExpandPath fills {name} placeholders in order; {path} keeps its slashes.

NameTypeDefaultRequiredDescription
tplstringyesPath template such as /v1/runs/{id}, its placeholders filled by the following parameters in order.
params...stringnoExtra fields merged into the request.

Returns: (string, error). The path with URL escaped values; the error is set when a parameter is missing or empty.

Raises: error.

ParseRetryAfter​

ParseRetryAfter(v string) (time.Duration, bool)

ParseRetryAfter reads Retry-After as delta seconds or HTTP-date; ok is false when absent or invalid.

NameTypeDefaultRequiredDescription
vstringyesValue of the Retry-After header.

Returns: (time.Duration, bool). The delay to wait (never negative) and true, or 0 and false when the value is empty or unreadable.

Decode​

Decode(raw json.RawMessage) (T, error)

Decode unmarshals a raw JSON response into T.

NameTypeDefaultRequiredDescription
rawjson.RawMessageyesReturn an ApiResponse (data, status, headers) instead of the decoded body.

Returns: (T, error). The value of type T and the json.Unmarshal error, nil on success.

Raises: error.