postfeatureflag.ts•2.9 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 { Result as SafeParseResult } from "../../types/fp.js";
import * as components from "../components/index.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type PostFeatureFlagRequest = {
/**
* The project key
*/
projectKey: string;
/**
* The key of the feature flag to be cloned. The key identifies the flag in your code. For example, setting `clone=flagKey` copies the full targeting configuration for all environments, including `on/off` state, from the original flag to the new flag.
*/
clone?: string | undefined;
featureFlagBody: components.FeatureFlagBody;
};
/** @internal */
export const PostFeatureFlagRequest$inboundSchema: z.ZodType<
PostFeatureFlagRequest,
z.ZodTypeDef,
unknown
> = z.object({
projectKey: z.string(),
clone: z.string().optional(),
FeatureFlagBody: components.FeatureFlagBody$inboundSchema,
}).transform((v) => {
return remap$(v, {
"FeatureFlagBody": "featureFlagBody",
});
});
/** @internal */
export type PostFeatureFlagRequest$Outbound = {
projectKey: string;
clone?: string | undefined;
FeatureFlagBody: components.FeatureFlagBody$Outbound;
};
/** @internal */
export const PostFeatureFlagRequest$outboundSchema: z.ZodType<
PostFeatureFlagRequest$Outbound,
z.ZodTypeDef,
PostFeatureFlagRequest
> = z.object({
projectKey: z.string(),
clone: z.string().optional(),
featureFlagBody: components.FeatureFlagBody$outboundSchema,
}).transform((v) => {
return remap$(v, {
featureFlagBody: "FeatureFlagBody",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace PostFeatureFlagRequest$ {
/** @deprecated use `PostFeatureFlagRequest$inboundSchema` instead. */
export const inboundSchema = PostFeatureFlagRequest$inboundSchema;
/** @deprecated use `PostFeatureFlagRequest$outboundSchema` instead. */
export const outboundSchema = PostFeatureFlagRequest$outboundSchema;
/** @deprecated use `PostFeatureFlagRequest$Outbound` instead. */
export type Outbound = PostFeatureFlagRequest$Outbound;
}
export function postFeatureFlagRequestToJSON(
postFeatureFlagRequest: PostFeatureFlagRequest,
): string {
return JSON.stringify(
PostFeatureFlagRequest$outboundSchema.parse(postFeatureFlagRequest),
);
}
export function postFeatureFlagRequestFromJSON(
jsonString: string,
): SafeParseResult<PostFeatureFlagRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => PostFeatureFlagRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'PostFeatureFlagRequest' from JSON`,
);
}