|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../../core/resource'; |
| 4 | +import { APIPromise } from '../../core/api-promise'; |
| 5 | +import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../../core/pagination'; |
| 6 | +import { buildHeaders } from '../../internal/headers'; |
| 7 | +import { RequestOptions } from '../../internal/request-options'; |
| 8 | +import { path } from '../../internal/utils/path'; |
| 9 | + |
| 10 | +/** |
| 11 | + * Stream live telemetry events from a browser session, and manage the destinations sessions export them to. |
| 12 | + */ |
| 13 | +export class Destinations extends APIResource { |
| 14 | + /** |
| 15 | + * Create an OTLP export destination in the resolved project. Names must be unique |
| 16 | + * within the project. |
| 17 | + */ |
| 18 | + create(body: DestinationCreateParams, options?: RequestOptions): APIPromise<OtlpDestination> { |
| 19 | + return this._client.post('/telemetry/destinations', { body, ...options }); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * Retrieve a single OTLP destination in the resolved project by its ID or name. |
| 24 | + */ |
| 25 | + retrieve(idOrName: string, options?: RequestOptions): APIPromise<OtlpDestination> { |
| 26 | + return this._client.get(path`/telemetry/destinations/${idOrName}`, options); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Update an OTLP destination. Sessions already exporting to it pick up the new |
| 31 | + * values without restarting, which makes this the way to rotate credentials |
| 32 | + * without interrupting export. |
| 33 | + * |
| 34 | + * Names must be unique within the project. Renaming is refused with a 409 while a |
| 35 | + * managed auth connection selects this destination by name, since that connection |
| 36 | + * resolves the name on every login. Every other field, including `headers`, stays |
| 37 | + * editable. |
| 38 | + */ |
| 39 | + update( |
| 40 | + idOrName: string, |
| 41 | + body: DestinationUpdateParams, |
| 42 | + options?: RequestOptions, |
| 43 | + ): APIPromise<OtlpDestination> { |
| 44 | + return this._client.patch(path`/telemetry/destinations/${idOrName}`, { body, ...options }); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * List OTLP export destinations in the resolved project. |
| 49 | + */ |
| 50 | + list( |
| 51 | + query: DestinationListParams | null | undefined = {}, |
| 52 | + options?: RequestOptions, |
| 53 | + ): PagePromise<OtlpDestinationsOffsetPagination, OtlpDestination> { |
| 54 | + return this._client.getAPIList('/telemetry/destinations', OffsetPagination<OtlpDestination>, { |
| 55 | + query, |
| 56 | + ...options, |
| 57 | + }); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Delete an OTLP destination. Sessions bound to it are still exporting, so the |
| 62 | + * delete is refused with a 409 while any exist; either wait for those sessions to |
| 63 | + * end or delete them first. It is refused the same way while a managed auth |
| 64 | + * connection still selects it, because that connection re-resolves the destination |
| 65 | + * on every login, and while a managed auth login using it is still in progress. |
| 66 | + */ |
| 67 | + delete(idOrName: string, options?: RequestOptions): APIPromise<void> { |
| 68 | + return this._client.delete(path`/telemetry/destinations/${idOrName}`, { |
| 69 | + ...options, |
| 70 | + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), |
| 71 | + }); |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +export type OtlpDestinationsOffsetPagination = OffsetPagination<OtlpDestination>; |
| 76 | + |
| 77 | +/** |
| 78 | + * An OTLP endpoint to export browser session telemetry to. Reference one from |
| 79 | + * `telemetry.export.otlp.destination` when creating a browser to export that |
| 80 | + * session's captured telemetry to it. |
| 81 | + */ |
| 82 | +export interface OtlpDestination { |
| 83 | + id: string; |
| 84 | + |
| 85 | + created_at: string; |
| 86 | + |
| 87 | + /** |
| 88 | + * OTLP/HTTP endpoint telemetry is sent to. |
| 89 | + */ |
| 90 | + endpoint: string; |
| 91 | + |
| 92 | + /** |
| 93 | + * Headers sent with each export request. Names are returned in canonical form |
| 94 | + * (`Authorization`, not `authorization`). Values are returned redacted as empty |
| 95 | + * strings, so the keys are visible but the credentials are not. |
| 96 | + */ |
| 97 | + headers: { [key: string]: string }; |
| 98 | + |
| 99 | + /** |
| 100 | + * Unique within the project. Usable in place of the ID when selecting a |
| 101 | + * destination, so it cannot be shaped like an ID. |
| 102 | + */ |
| 103 | + name: string; |
| 104 | + |
| 105 | + updated_at: string; |
| 106 | + |
| 107 | + description?: string; |
| 108 | +} |
| 109 | + |
| 110 | +export interface DestinationCreateParams { |
| 111 | + /** |
| 112 | + * Base endpoint of the OTLP/HTTP collector, without a signal path. Kernel appends |
| 113 | + * the signal path itself, so pass `https://api.honeycomb.io` rather than |
| 114 | + * `https://api.honeycomb.io/v1/logs`. If your provider's docs give you a |
| 115 | + * signal-specific URL, drop the trailing `/v1/logs`, `/v1/traces`, or |
| 116 | + * `/v1/metrics` — an endpoint that already carries one is rejected. |
| 117 | + * |
| 118 | + * Must be http or https, must resolve to a public address, and must carry no query |
| 119 | + * string or fragment. Examples: `https://api.honeycomb.io`, |
| 120 | + * `https://otlp-gateway-prod-us-east-0.grafana.net/otlp`, |
| 121 | + * `https://otlp.datadoghq.com` (Datadog's OTLP intake for US1, not its logs |
| 122 | + * intake). |
| 123 | + */ |
| 124 | + endpoint: string; |
| 125 | + |
| 126 | + /** |
| 127 | + * Unique within the project. |
| 128 | + */ |
| 129 | + name: string; |
| 130 | + |
| 131 | + description?: string; |
| 132 | + |
| 133 | + /** |
| 134 | + * Headers sent with each export request, typically an ingestion key. Encrypted at |
| 135 | + * rest and returned redacted. Names and values must be valid HTTP header tokens, |
| 136 | + * and the names and values together cannot exceed 8192 bytes. Names are matched |
| 137 | + * case-insensitively and stored canonicalized, so supplying two spellings of one |
| 138 | + * header is rejected. |
| 139 | + */ |
| 140 | + headers?: { [key: string]: string }; |
| 141 | +} |
| 142 | + |
| 143 | +export interface DestinationUpdateParams { |
| 144 | + description?: string; |
| 145 | + |
| 146 | + /** |
| 147 | + * Base endpoint of the OTLP/HTTP collector, without a signal path. Same rules as |
| 148 | + * on create. |
| 149 | + */ |
| 150 | + endpoint?: string; |
| 151 | + |
| 152 | + /** |
| 153 | + * Edits stored headers key by key rather than replacing the map. A string value |
| 154 | + * adds or replaces that header, `null` deletes it, and any key you omit is left as |
| 155 | + * it is. Names are matched case-insensitively, so `authorization` replaces a |
| 156 | + * stored `Authorization` rather than adding a second entry. This is the credential |
| 157 | + * rotation path; sessions already exporting pick up the new values without |
| 158 | + * restarting. Names and values must be valid HTTP header tokens, and the names and |
| 159 | + * values together cannot exceed 8192 bytes. |
| 160 | + */ |
| 161 | + headers?: { [key: string]: string | null }; |
| 162 | + |
| 163 | + name?: string; |
| 164 | +} |
| 165 | + |
| 166 | +export interface DestinationListParams extends OffsetPaginationParams { |
| 167 | + /** |
| 168 | + * Exact-match filter on destination name using the database collation. In |
| 169 | + * production, matching is case- and accent-insensitive. |
| 170 | + */ |
| 171 | + name?: string; |
| 172 | + |
| 173 | + /** |
| 174 | + * Case-insensitive substring match against destination name or endpoint. IDs match |
| 175 | + * by exact value. |
| 176 | + */ |
| 177 | + query?: string; |
| 178 | +} |
| 179 | + |
| 180 | +export declare namespace Destinations { |
| 181 | + export { |
| 182 | + type OtlpDestination as OtlpDestination, |
| 183 | + type OtlpDestinationsOffsetPagination as OtlpDestinationsOffsetPagination, |
| 184 | + type DestinationCreateParams as DestinationCreateParams, |
| 185 | + type DestinationUpdateParams as DestinationUpdateParams, |
| 186 | + type DestinationListParams as DestinationListParams, |
| 187 | + }; |
| 188 | +} |
0 commit comments