transport.go (package eai)
Source: sdks/go/transport.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 CallOption
CallOption customizes one call.
Definition: func(*callConfig).
Model Response
Response is a JSON response with its headers.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
Status | int | yes | HTTP status code of the response. |
Header | http.Header | yes | Header carrying the key for api_key. Default X-API-Key. |
Body | json.RawMessage | yes | Raw 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...).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
q | map[string]string | yes | Query 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.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
n | int | yes | Page 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.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
cur | string | yes | Cursor 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.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
k | string | yes | Idempotency 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.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
tp | string | yes | W3C 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).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | string | yes | Name of the header; it replaces a client header of the same name. | |
value | string | yes | Value 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.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
tpl | string | yes | Path template such as /v1/runs/{id}, its placeholders filled by the following parameters in order. | |
params | ...string | no | Extra 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.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
v | string | yes | Value 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.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
raw | json.RawMessage | yes | Return 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.