File size: 1,755 Bytes
1477a90 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | // Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
import { type Client } from '../core.js'
import { unwrap, type RequestOptions } from '../lib/types.js'
import { paginateCursor } from '../lib/paginate.js'
import { listMeteringEvents, ingestMeteringEvents } from '../funcs/events.js'
import type {
ListMeteringEventsRequest,
ListMeteringEventsResponse,
IngestMeteringEventsRequest,
IngestMeteringEventsResponse,
} from '../models/operations/events.js'
import type { IngestedEvent } from '../models/types.js'
export class Events {
constructor(private readonly _client: Client) {}
/**
* List metering events
*
* List ingested events.
*
* GET /openmeter/events
*/
async list(
request?: ListMeteringEventsRequest,
options?: RequestOptions,
): Promise<ListMeteringEventsResponse> {
return unwrap(await listMeteringEvents(this._client, request, options))
}
/**
* List metering events
*
* List ingested events.
*
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
*
* GET /openmeter/events
*/
listAll(
request?: ListMeteringEventsRequest,
options?: RequestOptions,
): AsyncIterable<IngestedEvent> {
return paginateCursor(
(req, opts) => listMeteringEvents(this._client, req, opts),
request ?? {},
options,
)
}
/**
* Ingest metering events
*
* Ingests an event or batch of events following the CloudEvents specification.
*
* POST /openmeter/events
*/
async ingest(
request: IngestMeteringEventsRequest,
options?: RequestOptions,
): Promise<IngestMeteringEventsResponse> {
return unwrap(await ingestMeteringEvents(this._client, request, options))
}
}
|