|
| 1 | +// this file is @generated |
| 2 | +import { |
| 3 | + IngestEndpointHeadersIn, |
| 4 | + IngestEndpointHeadersInSerializer, |
| 5 | +} from "../models/ingestEndpointHeadersIn"; |
| 6 | +import { |
| 7 | + IngestEndpointHeadersOut, |
| 8 | + IngestEndpointHeadersOutSerializer, |
| 9 | +} from "../models/ingestEndpointHeadersOut"; |
| 10 | +import { IngestEndpointIn, IngestEndpointInSerializer } from "../models/ingestEndpointIn"; |
| 11 | +import { |
| 12 | + IngestEndpointOut, |
| 13 | + IngestEndpointOutSerializer, |
| 14 | +} from "../models/ingestEndpointOut"; |
| 15 | +import { |
| 16 | + IngestEndpointSecretIn, |
| 17 | + IngestEndpointSecretInSerializer, |
| 18 | +} from "../models/ingestEndpointSecretIn"; |
| 19 | +import { |
| 20 | + IngestEndpointSecretOut, |
| 21 | + IngestEndpointSecretOutSerializer, |
| 22 | +} from "../models/ingestEndpointSecretOut"; |
| 23 | +import { |
| 24 | + IngestEndpointUpdate, |
| 25 | + IngestEndpointUpdateSerializer, |
| 26 | +} from "../models/ingestEndpointUpdate"; |
| 27 | +import { |
| 28 | + ListResponseIngestEndpointOut, |
| 29 | + ListResponseIngestEndpointOutSerializer, |
| 30 | +} from "../models/listResponseIngestEndpointOut"; |
| 31 | +import { Ordering } from "../models/ordering"; |
| 32 | +import { HttpMethod, SvixRequest, SvixRequestContext } from "../request"; |
| 33 | + |
| 34 | +export interface IngestEndpointListOptions { |
| 35 | + /** Limit the number of returned items */ |
| 36 | + limit?: number; |
| 37 | + /** The iterator returned from a prior invocation */ |
| 38 | + iterator?: string | null; |
| 39 | + /** The sorting order of the returned items */ |
| 40 | + order?: Ordering; |
| 41 | +} |
| 42 | + |
| 43 | +export interface IngestEndpointCreateOptions { |
| 44 | + idempotencyKey?: string; |
| 45 | +} |
| 46 | + |
| 47 | +export interface IngestEndpointRotateSecretOptions { |
| 48 | + idempotencyKey?: string; |
| 49 | +} |
| 50 | + |
| 51 | +export class IngestEndpoint { |
| 52 | + public constructor(private readonly requestCtx: SvixRequestContext) {} |
| 53 | + |
| 54 | + /** List ingest endpoints. */ |
| 55 | + public list( |
| 56 | + options?: IngestEndpointListOptions |
| 57 | + ): Promise<ListResponseIngestEndpointOut> { |
| 58 | + const request = new SvixRequest( |
| 59 | + HttpMethod.GET, |
| 60 | + "/ingest/api/v1/source/{source_id}/endpoint" |
| 61 | + ); |
| 62 | + |
| 63 | + request.setQueryParam("limit", options?.limit); |
| 64 | + request.setQueryParam("iterator", options?.iterator); |
| 65 | + request.setQueryParam("order", options?.order); |
| 66 | + |
| 67 | + return request.send( |
| 68 | + this.requestCtx, |
| 69 | + ListResponseIngestEndpointOutSerializer._fromJsonObject |
| 70 | + ); |
| 71 | + } |
| 72 | + |
| 73 | + /** Create an ingest endpoint. */ |
| 74 | + public create( |
| 75 | + ingestEndpointIn: IngestEndpointIn, |
| 76 | + options?: IngestEndpointCreateOptions |
| 77 | + ): Promise<IngestEndpointOut> { |
| 78 | + const request = new SvixRequest( |
| 79 | + HttpMethod.POST, |
| 80 | + "/ingest/api/v1/source/{source_id}/endpoint" |
| 81 | + ); |
| 82 | + |
| 83 | + request.setHeaderParam("idempotency-key", options?.idempotencyKey); |
| 84 | + request.setBody(IngestEndpointInSerializer._toJsonObject(ingestEndpointIn)); |
| 85 | + |
| 86 | + return request.send(this.requestCtx, IngestEndpointOutSerializer._fromJsonObject); |
| 87 | + } |
| 88 | + |
| 89 | + /** Get an ingest endpoint. */ |
| 90 | + public get(endpointId: string): Promise<IngestEndpointOut> { |
| 91 | + const request = new SvixRequest( |
| 92 | + HttpMethod.GET, |
| 93 | + "/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}" |
| 94 | + ); |
| 95 | + |
| 96 | + request.setPathParam("endpoint_id", endpointId); |
| 97 | + |
| 98 | + return request.send(this.requestCtx, IngestEndpointOutSerializer._fromJsonObject); |
| 99 | + } |
| 100 | + |
| 101 | + /** Update an ingest endpoint. */ |
| 102 | + public update( |
| 103 | + endpointId: string, |
| 104 | + ingestEndpointUpdate: IngestEndpointUpdate |
| 105 | + ): Promise<IngestEndpointOut> { |
| 106 | + const request = new SvixRequest( |
| 107 | + HttpMethod.PUT, |
| 108 | + "/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}" |
| 109 | + ); |
| 110 | + |
| 111 | + request.setPathParam("endpoint_id", endpointId); |
| 112 | + request.setBody(IngestEndpointUpdateSerializer._toJsonObject(ingestEndpointUpdate)); |
| 113 | + |
| 114 | + return request.send(this.requestCtx, IngestEndpointOutSerializer._fromJsonObject); |
| 115 | + } |
| 116 | + |
| 117 | + /** Delete an ingest endpoint. */ |
| 118 | + public delete(endpointId: string): Promise<void> { |
| 119 | + const request = new SvixRequest( |
| 120 | + HttpMethod.DELETE, |
| 121 | + "/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}" |
| 122 | + ); |
| 123 | + |
| 124 | + request.setPathParam("endpoint_id", endpointId); |
| 125 | + |
| 126 | + return request.sendNoResponseBody(this.requestCtx); |
| 127 | + } |
| 128 | + |
| 129 | + /** Get the additional headers to be sent with the ingest. */ |
| 130 | + public getHeaders(endpointId: string): Promise<IngestEndpointHeadersOut> { |
| 131 | + const request = new SvixRequest( |
| 132 | + HttpMethod.GET, |
| 133 | + "/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/headers" |
| 134 | + ); |
| 135 | + |
| 136 | + request.setPathParam("endpoint_id", endpointId); |
| 137 | + |
| 138 | + return request.send( |
| 139 | + this.requestCtx, |
| 140 | + IngestEndpointHeadersOutSerializer._fromJsonObject |
| 141 | + ); |
| 142 | + } |
| 143 | + |
| 144 | + /** Set the additional headers to be sent to the endpoint. */ |
| 145 | + public updateHeaders( |
| 146 | + endpointId: string, |
| 147 | + ingestEndpointHeadersIn: IngestEndpointHeadersIn |
| 148 | + ): Promise<void> { |
| 149 | + const request = new SvixRequest( |
| 150 | + HttpMethod.PUT, |
| 151 | + "/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/headers" |
| 152 | + ); |
| 153 | + |
| 154 | + request.setPathParam("endpoint_id", endpointId); |
| 155 | + request.setBody( |
| 156 | + IngestEndpointHeadersInSerializer._toJsonObject(ingestEndpointHeadersIn) |
| 157 | + ); |
| 158 | + |
| 159 | + return request.sendNoResponseBody(this.requestCtx); |
| 160 | + } |
| 161 | + |
| 162 | + /** |
| 163 | + * Get an ingest endpoint's signing secret. |
| 164 | + * |
| 165 | + * This is used to verify the authenticity of the webhook. |
| 166 | + * For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/). |
| 167 | + */ |
| 168 | + public getSecret(endpointId: string): Promise<IngestEndpointSecretOut> { |
| 169 | + const request = new SvixRequest( |
| 170 | + HttpMethod.GET, |
| 171 | + "/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/secret" |
| 172 | + ); |
| 173 | + |
| 174 | + request.setPathParam("endpoint_id", endpointId); |
| 175 | + |
| 176 | + return request.send( |
| 177 | + this.requestCtx, |
| 178 | + IngestEndpointSecretOutSerializer._fromJsonObject |
| 179 | + ); |
| 180 | + } |
| 181 | + |
| 182 | + /** |
| 183 | + * Rotates an ingest endpoint's signing secret. |
| 184 | + * |
| 185 | + * The previous secret will remain valid for the next 24 hours. |
| 186 | + */ |
| 187 | + public rotateSecret( |
| 188 | + endpointId: string, |
| 189 | + ingestEndpointSecretIn: IngestEndpointSecretIn, |
| 190 | + options?: IngestEndpointRotateSecretOptions |
| 191 | + ): Promise<void> { |
| 192 | + const request = new SvixRequest( |
| 193 | + HttpMethod.POST, |
| 194 | + "/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/secret/rotate" |
| 195 | + ); |
| 196 | + |
| 197 | + request.setPathParam("endpoint_id", endpointId); |
| 198 | + request.setHeaderParam("idempotency-key", options?.idempotencyKey); |
| 199 | + request.setBody( |
| 200 | + IngestEndpointSecretInSerializer._toJsonObject(ingestEndpointSecretIn) |
| 201 | + ); |
| 202 | + |
| 203 | + return request.sendNoResponseBody(this.requestCtx); |
| 204 | + } |
| 205 | +} |
0 commit comments