/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 4b4aede044ad
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { ConsumerType, ConsumerType$inboundSchema } from "./consumertype.js";
import {
  ToolExecutionConfiguration,
  ToolExecutionConfiguration$inboundSchema,
} from "./toolexecutionconfiguration.js";

export type ConnectionPreference = {
  name: string;
  toolConfiguration: ToolExecutionConfiguration;
  isDefault?: boolean | null | undefined;
  consumerType?: ConsumerType | null | undefined;
};

/** @internal */
export const ConnectionPreference$inboundSchema: z.ZodType<
  ConnectionPreference,
  unknown
> = z.object({
  name: z.string(),
  tool_configuration: ToolExecutionConfiguration$inboundSchema,
  is_default: z.nullable(z.boolean()).optional(),
  consumer_type: z.nullable(ConsumerType$inboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    "tool_configuration": "toolConfiguration",
    "is_default": "isDefault",
    "consumer_type": "consumerType",
  });
});

export function connectionPreferenceFromJSON(
  jsonString: string,
): SafeParseResult<ConnectionPreference, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ConnectionPreference$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ConnectionPreference' from JSON`,
  );
}
