patchaiconfigvariation.ts•4.64 kB
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import * as components from "../components/index.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
/**
* Version of the endpoint.
*/
export const PatchAIConfigVariationLDAPIVersion = {
Beta: "beta",
} as const;
/**
* Version of the endpoint.
*/
export type PatchAIConfigVariationLDAPIVersion = ClosedEnum<
typeof PatchAIConfigVariationLDAPIVersion
>;
export type PatchAIConfigVariationRequest = {
/**
* Version of the endpoint.
*/
ldAPIVersion: PatchAIConfigVariationLDAPIVersion;
projectKey: string;
configKey: string;
variationKey: string;
/**
* AI Config variation object to update
*/
aiConfigVariationPatch?: components.AIConfigVariationPatch | undefined;
};
/** @internal */
export const PatchAIConfigVariationLDAPIVersion$inboundSchema: z.ZodNativeEnum<
typeof PatchAIConfigVariationLDAPIVersion
> = z.nativeEnum(PatchAIConfigVariationLDAPIVersion);
/** @internal */
export const PatchAIConfigVariationLDAPIVersion$outboundSchema: z.ZodNativeEnum<
typeof PatchAIConfigVariationLDAPIVersion
> = PatchAIConfigVariationLDAPIVersion$inboundSchema;
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PatchAIConfigVariationLDAPIVersion$ {
/** @deprecated use `PatchAIConfigVariationLDAPIVersion$inboundSchema` instead. */
export const inboundSchema = PatchAIConfigVariationLDAPIVersion$inboundSchema;
/** @deprecated use `PatchAIConfigVariationLDAPIVersion$outboundSchema` instead. */
export const outboundSchema =
PatchAIConfigVariationLDAPIVersion$outboundSchema;
}
/** @internal */
export const PatchAIConfigVariationRequest$inboundSchema: z.ZodType<
PatchAIConfigVariationRequest,
z.ZodTypeDef,
unknown
> = z.object({
"LD-API-Version": PatchAIConfigVariationLDAPIVersion$inboundSchema,
projectKey: z.string(),
configKey: z.string(),
variationKey: z.string(),
AIConfigVariationPatch: components.AIConfigVariationPatch$inboundSchema
.optional(),
}).transform((v) => {
return remap$(v, {
"LD-API-Version": "ldAPIVersion",
"AIConfigVariationPatch": "aiConfigVariationPatch",
});
});
/** @internal */
export type PatchAIConfigVariationRequest$Outbound = {
"LD-API-Version": string;
projectKey: string;
configKey: string;
variationKey: string;
AIConfigVariationPatch?:
| components.AIConfigVariationPatch$Outbound
| undefined;
};
/** @internal */
export const PatchAIConfigVariationRequest$outboundSchema: z.ZodType<
PatchAIConfigVariationRequest$Outbound,
z.ZodTypeDef,
PatchAIConfigVariationRequest
> = z.object({
ldAPIVersion: PatchAIConfigVariationLDAPIVersion$outboundSchema,
projectKey: z.string(),
configKey: z.string(),
variationKey: z.string(),
aiConfigVariationPatch: components.AIConfigVariationPatch$outboundSchema
.optional(),
}).transform((v) => {
return remap$(v, {
ldAPIVersion: "LD-API-Version",
aiConfigVariationPatch: "AIConfigVariationPatch",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PatchAIConfigVariationRequest$ {
/** @deprecated use `PatchAIConfigVariationRequest$inboundSchema` instead. */
export const inboundSchema = PatchAIConfigVariationRequest$inboundSchema;
/** @deprecated use `PatchAIConfigVariationRequest$outboundSchema` instead. */
export const outboundSchema = PatchAIConfigVariationRequest$outboundSchema;
/** @deprecated use `PatchAIConfigVariationRequest$Outbound` instead. */
export type Outbound = PatchAIConfigVariationRequest$Outbound;
}
export function patchAIConfigVariationRequestToJSON(
patchAIConfigVariationRequest: PatchAIConfigVariationRequest,
): string {
return JSON.stringify(
PatchAIConfigVariationRequest$outboundSchema.parse(
patchAIConfigVariationRequest,
),
);
}
export function patchAIConfigVariationRequestFromJSON(
jsonString: string,
): SafeParseResult<PatchAIConfigVariationRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => PatchAIConfigVariationRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PatchAIConfigVariationRequest' from JSON`,
);
}