/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type TopicsControllerUpsertTopicRequest = { /** * If true, the request will fail if a topic with the same key already exists */ failIfExists?: boolean | undefined; /** * A header for idempotency purposes */ idempotencyKey?: string | undefined; createUpdateTopicRequestDto: components.CreateUpdateTopicRequestDto; }; export type TopicsControllerUpsertTopicResponse = { headers: { [k: string]: Array }; result: components.TopicResponseDto; }; /** @internal */ export type TopicsControllerUpsertTopicRequest$Outbound = { failIfExists?: boolean | undefined; "idempotency-key"?: string | undefined; CreateUpdateTopicRequestDto: components.CreateUpdateTopicRequestDto$Outbound; }; /** @internal */ export const TopicsControllerUpsertTopicRequest$outboundSchema: z.ZodType< TopicsControllerUpsertTopicRequest$Outbound, z.ZodTypeDef, TopicsControllerUpsertTopicRequest > = z.object({ failIfExists: z.boolean().optional(), idempotencyKey: z.string().optional(), createUpdateTopicRequestDto: components.CreateUpdateTopicRequestDto$outboundSchema, }).transform((v) => { return remap$(v, { idempotencyKey: "idempotency-key", createUpdateTopicRequestDto: "CreateUpdateTopicRequestDto", }); }); export function topicsControllerUpsertTopicRequestToJSON( topicsControllerUpsertTopicRequest: TopicsControllerUpsertTopicRequest, ): string { return JSON.stringify( TopicsControllerUpsertTopicRequest$outboundSchema.parse( topicsControllerUpsertTopicRequest, ), ); } /** @internal */ export const TopicsControllerUpsertTopicResponse$inboundSchema: z.ZodType< TopicsControllerUpsertTopicResponse, z.ZodTypeDef, unknown > = z.object({ Headers: z.record(z.array(z.string())).default({}), Result: components.TopicResponseDto$inboundSchema, }).transform((v) => { return remap$(v, { "Headers": "headers", "Result": "result", }); }); export function topicsControllerUpsertTopicResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TopicsControllerUpsertTopicResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TopicsControllerUpsertTopicResponse' from JSON`, ); }