|
| 1 | +// this file is @generated |
| 2 | +import { |
| 3 | + PollingEndpointConsumerSeekIn, |
| 4 | + PollingEndpointConsumerSeekInSerializer, |
| 5 | +} from "../models/pollingEndpointConsumerSeekIn"; |
| 6 | +import { |
| 7 | + PollingEndpointConsumerSeekOut, |
| 8 | + PollingEndpointConsumerSeekOutSerializer, |
| 9 | +} from "../models/pollingEndpointConsumerSeekOut"; |
| 10 | +import { |
| 11 | + PollingEndpointOut, |
| 12 | + PollingEndpointOutSerializer, |
| 13 | +} from "../models/pollingEndpointOut"; |
| 14 | +import { HttpMethod, SvixRequest, SvixRequestContext } from "../request"; |
| 15 | + |
| 16 | +export interface EventsPublicConsumerOptions { |
| 17 | + /** Limit the number of returned items */ |
| 18 | + limit?: number; |
| 19 | + /** The iterator returned from a prior invocation */ |
| 20 | + iterator?: string | null; |
| 21 | + /** Filters messages sent with this event type (optional). */ |
| 22 | + eventType?: string; |
| 23 | + /** Filters messages sent with this channel (optional). */ |
| 24 | + channel?: string; |
| 25 | +} |
| 26 | + |
| 27 | +export interface EventsPublicConsumerSeekOptions { |
| 28 | + idempotencyKey?: string; |
| 29 | +} |
| 30 | + |
| 31 | +export class EventsPublic { |
| 32 | + public constructor(private readonly requestCtx: SvixRequestContext) {} |
| 33 | + |
| 34 | + /** |
| 35 | + * Reads the stream of created messages for an application, filtered on the Sink's event types and |
| 36 | + * Channels, using server-managed iterator tracking. |
| 37 | + */ |
| 38 | + public consumer( |
| 39 | + appId: string, |
| 40 | + sinkId: string, |
| 41 | + consumerId: string, |
| 42 | + options?: EventsPublicConsumerOptions |
| 43 | + ): Promise<PollingEndpointOut> { |
| 44 | + const request = new SvixRequest( |
| 45 | + HttpMethod.GET, |
| 46 | + "/api/v1/app/{app_id}/poller/{sink_id}/consumer/{consumer_id}" |
| 47 | + ); |
| 48 | + |
| 49 | + request.setPathParam("app_id", appId); |
| 50 | + request.setPathParam("sink_id", sinkId); |
| 51 | + request.setPathParam("consumer_id", consumerId); |
| 52 | + request.setQueryParam("limit", options?.limit); |
| 53 | + request.setQueryParam("iterator", options?.iterator); |
| 54 | + request.setQueryParam("event_type", options?.eventType); |
| 55 | + request.setQueryParam("channel", options?.channel); |
| 56 | + |
| 57 | + return request.send(this.requestCtx, PollingEndpointOutSerializer._fromJsonObject); |
| 58 | + } |
| 59 | + |
| 60 | + /** Sets the starting offset for the consumer of a polling endpoint. */ |
| 61 | + public consumerSeek( |
| 62 | + appId: string, |
| 63 | + sinkId: string, |
| 64 | + consumerId: string, |
| 65 | + pollingEndpointConsumerSeekIn: PollingEndpointConsumerSeekIn, |
| 66 | + options?: EventsPublicConsumerSeekOptions |
| 67 | + ): Promise<PollingEndpointConsumerSeekOut> { |
| 68 | + const request = new SvixRequest( |
| 69 | + HttpMethod.POST, |
| 70 | + "/api/v1/app/{app_id}/poller/{sink_id}/consumer/{consumer_id}/seek" |
| 71 | + ); |
| 72 | + |
| 73 | + request.setPathParam("app_id", appId); |
| 74 | + request.setPathParam("sink_id", sinkId); |
| 75 | + request.setPathParam("consumer_id", consumerId); |
| 76 | + request.setHeaderParam("idempotency-key", options?.idempotencyKey); |
| 77 | + request.setBody( |
| 78 | + PollingEndpointConsumerSeekInSerializer._toJsonObject(pollingEndpointConsumerSeekIn) |
| 79 | + ); |
| 80 | + |
| 81 | + return request.send( |
| 82 | + this.requestCtx, |
| 83 | + PollingEndpointConsumerSeekOutSerializer._fromJsonObject |
| 84 | + ); |
| 85 | + } |
| 86 | +} |
0 commit comments