diff --git a/src/funcs/generateRandomNumber.ts b/src/funcs/generateRandomNumber.ts new file mode 100644 index 0000000..aafe18a --- /dev/null +++ b/src/funcs/generateRandomNumber.ts @@ -0,0 +1,183 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { NovuCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +export async function generateRandomNumber( + client: NovuCore, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + Result< + operations.HealthControllerGenerateRandomNumberResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input: operations.HealthControllerGenerateRandomNumberRequest = { + idempotencyKey: idempotencyKey, + }; + + const parsed = safeParse( + input, + (value) => + operations.HealthControllerGenerateRandomNumberRequest$outboundSchema + .parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const path = pathToFunc("/v1/health-check/test-idempotency")(); + + const headers = new Headers(compactMap({ + Accept: "application/json", + "idempotency-key": encodeSimple( + "idempotency-key", + payload["idempotency-key"], + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "HealthController_generateRandomNumber", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 1000, + maxInterval: 30000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "403", + "404", + "405", + "409", + "413", + "414", + "415", + "422", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.HealthControllerGenerateRandomNumberResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json( + 201, + operations.HealthControllerGenerateRandomNumberResponse$inboundSchema, + { hdrs: true, key: "Result" }, + ), + M.jsonErr( + [400, 401, 403, 404, 405, 409, 413, 415], + errors.ErrorDto$inboundSchema, + { hdrs: true }, + ), + M.jsonErr(414, errors.ErrorDto$inboundSchema), + M.jsonErr(422, errors.ValidationErrorDto$inboundSchema, { hdrs: true }), + M.fail(429), + M.jsonErr(500, errors.ErrorDto$inboundSchema, { hdrs: true }), + M.fail(503), + M.fail("4XX"), + M.fail("5XX"), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/src/funcs/healthControllerHealthCheck.ts b/src/funcs/healthControllerHealthCheck.ts new file mode 100644 index 0000000..2bcb8a9 --- /dev/null +++ b/src/funcs/healthControllerHealthCheck.ts @@ -0,0 +1,153 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { NovuCore } from "../core.js"; +import { encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +export async function healthControllerHealthCheck( + client: NovuCore, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + Result< + operations.HealthControllerHealthCheckResponseBody, + | errors.HealthControllerHealthCheckResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input: operations.HealthControllerHealthCheckRequest = { + idempotencyKey: idempotencyKey, + }; + + const parsed = safeParse( + input, + (value) => + operations.HealthControllerHealthCheckRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = null; + + const path = pathToFunc("/v1/health-check")(); + + const headers = new Headers(compactMap({ + Accept: "application/json", + "idempotency-key": encodeSimple( + "idempotency-key", + payload["idempotency-key"], + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "HealthController_healthCheck", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 1000, + maxInterval: 30000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "GET", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["4XX", "503", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.HealthControllerHealthCheckResponseBody, + | errors.HealthControllerHealthCheckResponseBody + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json( + 200, + operations.HealthControllerHealthCheckResponseBody$inboundSchema, + ), + M.jsonErr( + 503, + errors.HealthControllerHealthCheckResponseBody$inboundSchema, + ), + M.fail("4XX"), + M.fail("5XX"), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/src/funcs/testIdempotency.ts b/src/funcs/testIdempotency.ts new file mode 100644 index 0000000..7059b58 --- /dev/null +++ b/src/funcs/testIdempotency.ts @@ -0,0 +1,190 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { NovuCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +export async function testIdempotency( + client: NovuCore, + idempotencyTestingDto: components.IdempotencyTestingDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + Result< + operations.HealthControllerTestIdempotencyResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const input: operations.HealthControllerTestIdempotencyRequest = { + idempotencyTestingDto: idempotencyTestingDto, + idempotencyKey: idempotencyKey, + }; + + const parsed = safeParse( + input, + (value) => + operations.HealthControllerTestIdempotencyRequest$outboundSchema.parse( + value, + ), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.IdempotencyTestingDto, { + explode: true, + }); + + const path = pathToFunc("/v1/health-check/test-idempotency")(); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "idempotency-key": encodeSimple( + "idempotency-key", + payload["idempotency-key"], + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "HealthController_testIdempotency", + oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 1000, + maxInterval: 30000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: [ + "400", + "401", + "403", + "404", + "405", + "409", + "413", + "414", + "415", + "422", + "429", + "4XX", + "500", + "503", + "5XX", + ], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.HealthControllerTestIdempotencyResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json( + 201, + operations.HealthControllerTestIdempotencyResponse$inboundSchema, + { hdrs: true, key: "Result" }, + ), + M.jsonErr( + [400, 401, 403, 404, 405, 409, 413, 415], + errors.ErrorDto$inboundSchema, + { hdrs: true }, + ), + M.jsonErr(414, errors.ErrorDto$inboundSchema), + M.jsonErr(422, errors.ValidationErrorDto$inboundSchema, { hdrs: true }), + M.fail(429), + M.jsonErr(500, errors.ErrorDto$inboundSchema, { hdrs: true }), + M.fail(503), + M.fail("4XX"), + M.fail("5XX"), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +}