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

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 {
  OutboundAuthenticationType,
  OutboundAuthenticationType$inboundSchema,
} from "./outboundauthenticationtype.js";

export type AuthenticationConfiguration = {
  name: string;
  authenticationType: OutboundAuthenticationType;
  scope: ConsumerType;
  isDefault: boolean;
};

/** @internal */
export const AuthenticationConfiguration$inboundSchema: z.ZodType<
  AuthenticationConfiguration,
  unknown
> = z.object({
  name: z.string(),
  authentication_type: OutboundAuthenticationType$inboundSchema,
  scope: ConsumerType$inboundSchema,
  is_default: z.boolean().default(false),
}).transform((v) => {
  return remap$(v, {
    "authentication_type": "authenticationType",
    "is_default": "isDefault",
  });
});

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