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

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import {
  GlobalConfigItemValue,
  GlobalConfigItemValue$inboundSchema,
} from "./globalconfigitemvalue.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest =
  {
    integrationConfigurationId: string;
    resourceId: string;
  };

export const HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose =
  {
    Experimentation: "experimentation",
    Flags: "flags",
  } as const;
export type HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose =
  ClosedEnum<
    typeof HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose
  >;

/**
 * The Global Config data
 */
export type HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigResponseBody =
  {
    items: { [k: string]: GlobalConfigItemValue | null };
    updatedAt: number;
    digest: string;
    purpose?:
      | HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose
      | undefined;
  };

/** @internal */
export type HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest$Outbound =
  {
    integrationConfigurationId: string;
    resourceId: string;
  };

/** @internal */
export const HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest$outboundSchema:
  z.ZodType<
    HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest$Outbound,
    z.ZodTypeDef,
    HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest
  > = z.object({
    integrationConfigurationId: z.string(),
    resourceId: z.string(),
  });

export function headInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequestToJSON(
  headInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest:
    HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest,
): string {
  return JSON.stringify(
    HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest$outboundSchema
      .parse(
        headInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigRequest,
      ),
  );
}

/** @internal */
export const HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose$inboundSchema:
  z.ZodNativeEnum<
    typeof HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose
  > = z.nativeEnum(
    HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose,
  );

/** @internal */
export const HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigResponseBody$inboundSchema:
  z.ZodType<
    HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigResponseBody,
    z.ZodTypeDef,
    unknown
  > = z.object({
    items: z.record(types.nullable(GlobalConfigItemValue$inboundSchema)),
    updatedAt: types.number(),
    digest: types.string(),
    purpose: types.optional(
      HeadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationGlobalConfigPurpose$inboundSchema,
    ),
  });

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