/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation =
  {
    /**
     * Whether contexts can be reassigned to new buckets
     */
    canReshuffle: boolean;
    /**
     * Index of the default variation
     */
    defaultVariation: number;
    /**
     * The allocation type
     */
    type: string;
  };

/** @internal */
export const AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation$inboundSchema:
  z.ZodType<
    AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation,
    z.ZodTypeDef,
    unknown
  > = z.object({
    canReshuffle: z.boolean(),
    defaultVariation: z.number().int(),
    type: z.string(),
  });
/** @internal */
export type AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation$Outbound =
  {
    canReshuffle: boolean;
    defaultVariation: number;
    type: string;
  };

/** @internal */
export const AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation$outboundSchema:
  z.ZodType<
    AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation$Outbound,
    z.ZodTypeDef,
    AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation
  > = z.object({
    canReshuffle: z.boolean(),
    defaultVariation: z.number().int(),
    type: z.string(),
  });

export function aiConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocationToJSON(
  aiConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation:
    AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation,
): string {
  return JSON.stringify(
    AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation$outboundSchema
      .parse(
        aiConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation,
      ),
  );
}
export function aiConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocationFromJSON(
  jsonString: string,
): SafeParseResult<
  AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation,
  SDKValidationError
> {
  return safeParse(
    jsonString,
    (x) =>
      AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation$inboundSchema
        .parse(JSON.parse(x)),
    `Failed to parse 'AIConfigTargetingEnvironmentFallthroughRolloutExperimentationAllocation' from JSON`,
  );
}
