UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

3,170 lines 89 kB
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../lib/primitives.js";
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 { smartUnion } from "../types/smartUnion.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export const CreateDrainProjects = {
  Some: "some",
  All: "all",
} as const;
export type CreateDrainProjects = ClosedEnum<typeof CreateDrainProjects>;

export type Filter2 = {
  type: string;
  text: string;
};

export type CreateDrainFilterProject = {
  ids?: Array<string> | undefined;
};

export const FilterSources = {
  Build: "build",
  Edge: "edge",
  Lambda: "lambda",
  Static: "static",
  External: "external",
  Firewall: "firewall",
  Redirect: "redirect",
} as const;
export type FilterSources = ClosedEnum<typeof FilterSources>;

export type Log = {
  sources?: Array<FilterSources> | undefined;
};

export const FilterEnvironments = {
  Production: "production",
  Preview: "preview",
} as const;
export type FilterEnvironments = ClosedEnum<typeof FilterEnvironments>;

export type CreateDrainFilterDeployment = {
  environments?: Array<FilterEnvironments> | undefined;
};

export type Filter1 = {
  type: string;
  project?: CreateDrainFilterProject | undefined;
  log?: Log | undefined;
  deployment?: CreateDrainFilterDeployment | undefined;
};

export type CreateDrainFilter = Filter2 | Filter1;

export type Filter = {
  version: string;
  filter: Filter2 | Filter1;
};

export type Schemas = {
  version: string;
};

export const CreateDrainDeliveryDrainsEncoding = {
  Json: "json",
  Ndjson: "ndjson",
} as const;
export type CreateDrainDeliveryDrainsEncoding = ClosedEnum<
  typeof CreateDrainDeliveryDrainsEncoding
>;

export const DeliveryCompression = {
  None: "none",
} as const;
export type DeliveryCompression = ClosedEnum<typeof DeliveryCompression>;

export const FileStructure = {
  Hive: "hive",
} as const;
export type FileStructure = ClosedEnum<typeof FileStructure>;

export const ServerSideEncryption = {
  Aes256: "AES256",
  AwsKms: "aws:kms",
  AwsKmsDsse: "aws:kms:dsse",
} as const;
export type ServerSideEncryption = ClosedEnum<typeof ServerSideEncryption>;

export const ObjectAcl = {
  Private: "private",
  BucketOwnerRead: "bucket-owner-read",
  BucketOwnerFullControl: "bucket-owner-full-control",
} as const;
export type ObjectAcl = ClosedEnum<typeof ObjectAcl>;

export type Delivery3 = {
  type: string;
  endpoint: string;
  encoding: CreateDrainDeliveryDrainsEncoding;
  compression: DeliveryCompression;
  fileStructure: FileStructure;
  roleArn: string;
  region: string;
  serverSideEncryption?: ServerSideEncryption | undefined;
  objectAcl?: ObjectAcl | undefined;
};

export type Endpoint1 = {
  traces: string;
};

export type CreateDrainDeliveryEndpoint = Endpoint1;

export const CreateDrainDeliveryEncoding = {
  Proto: "proto",
  Json: "json",
} as const;
export type CreateDrainDeliveryEncoding = ClosedEnum<
  typeof CreateDrainDeliveryEncoding
>;

export type Delivery2 = {
  type: string;
  endpoint: Endpoint1;
  encoding: CreateDrainDeliveryEncoding;
  headers: { [k: string]: string };
  secret?: string | undefined;
};

export const Compression = {
  Gzip: "gzip",
  None: "none",
} as const;
export type Compression = ClosedEnum<typeof Compression>;

export const DeliveryEncoding = {
  Json: "json",
  Ndjson: "ndjson",
} as const;
export type DeliveryEncoding = ClosedEnum<typeof DeliveryEncoding>;

export type Delivery1 = {
  type: string;
  endpoint: string;
  compression?: Compression | undefined;
  encoding: DeliveryEncoding;
  headers: { [k: string]: string };
  secret?: string | undefined;
};

export type Delivery = Delivery3 | Delivery1 | Delivery2;

/**
 * Environment to apply sampling to
 */
export const Env = {
  Production: "production",
  Preview: "preview",
} as const;
/**
 * Environment to apply sampling to
 */
export type Env = ClosedEnum<typeof Env>;

export type Sampling = {
  type: string;
  /**
   * Sampling rate from 0 to 1 (e.g., 0.1 for 10%)
   */
  rate: number;
  /**
   * Environment to apply sampling to
   */
  env?: Env | undefined;
  /**
   * Request path prefix to apply the sampling rule to
   */
  requestPath?: string | undefined;
};

export type Transforms = {
  id: string;
};

export type Source2 = {
  kind?: string | undefined;
};

export type One3 = {
  kind?: string | undefined;
};

export type One2 = {
  kind?: string | undefined;
  resourceId: string;
};

export type CreateDrain11 = {
  kind?: string | undefined;
  externalResourceId: string;
};

export type Source1 = CreateDrain11 | One2 | One3;

export type CreateDrainSource = CreateDrain11 | One2 | One3 | Source2;

export type CreateDrainRequestBody = {
  name: string;
  projects: CreateDrainProjects;
  projectIds?: Array<string> | undefined;
  filter?: Filter | undefined;
  schemas: { [k: string]: Schemas };
  delivery?: Delivery3 | Delivery1 | Delivery2 | undefined;
  sampling?: Array<Sampling> | undefined;
  transforms?: Array<Transforms> | undefined;
  source?: CreateDrain11 | One2 | One3 | Source2 | undefined;
};

export type CreateDrainRequest = {
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId?: string | undefined;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
  requestBody?: CreateDrainRequestBody | undefined;
};

export const CreateDrainResponseBodyDrainsStatus = {
  Disabled: "disabled",
  Enabled: "enabled",
  Errored: "errored",
} as const;
export type CreateDrainResponseBodyDrainsStatus = ClosedEnum<
  typeof CreateDrainResponseBodyDrainsStatus
>;

export const ResponseBodyDisabledReason = {
  AccountPlanDowngrade: "account-plan-downgrade",
  DisabledByAdmin: "disabled-by-admin",
  DisabledByOwner: "disabled-by-owner",
  FeatureNotAvailable: "feature-not-available",
} as const;
export type ResponseBodyDisabledReason = ClosedEnum<
  typeof ResponseBodyDisabledReason
>;

export type CreateDrainResponseBodyLog = {};

export type ResponseBodyTrace = {};

export type CreateDrainResponseBodyDrainsAnalytics = {};

export type CreateDrainResponseBodyDrainsSpeedInsights = {};

export type ResponseBodyAiGateway = {};

export type ResponseBodyAuditLog = {};

export type CreateDrainResponseBodySchemas = {
  log?: CreateDrainResponseBodyLog | undefined;
  trace?: ResponseBodyTrace | undefined;
  analytics?: CreateDrainResponseBodyDrainsAnalytics | undefined;
  speedInsights?: CreateDrainResponseBodyDrainsSpeedInsights | undefined;
  aiGateway?: ResponseBodyAiGateway | undefined;
  auditLog?: ResponseBodyAuditLog | undefined;
};

export const CreateDrainDeliveryTarget = {
  VercelOtelTracesDb: "vercel-otel-traces-db",
} as const;
export type CreateDrainDeliveryTarget = ClosedEnum<
  typeof CreateDrainDeliveryTarget
>;

export type CreateDrainDelivery5 = {
  type: "internal";
  target: CreateDrainDeliveryTarget;
};

export const CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody24Encoding =
  {
    Json: "json",
    Ndjson: "ndjson",
  } as const;
export type CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody24Encoding =
  ClosedEnum<
    typeof CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody24Encoding
  >;

export const CreateDrainDeliveryDrainsResponse200Compression = {
  None: "none",
} as const;
export type CreateDrainDeliveryDrainsResponse200Compression = ClosedEnum<
  typeof CreateDrainDeliveryDrainsResponse200Compression
>;

export const CreateDrainDeliveryFileStructure = {
  Hive: "hive",
} as const;
export type CreateDrainDeliveryFileStructure = ClosedEnum<
  typeof CreateDrainDeliveryFileStructure
>;

export const CreateDrainDeliveryServerSideEncryption = {
  Aes256: "AES256",
  AwsKms: "aws:kms",
  AwsKmsDsse: "aws:kms:dsse",
} as const;
export type CreateDrainDeliveryServerSideEncryption = ClosedEnum<
  typeof CreateDrainDeliveryServerSideEncryption
>;

export const CreateDrainDeliveryObjectAcl = {
  AuthenticatedRead: "authenticated-read",
  AwsExecRead: "aws-exec-read",
  BucketOwnerFullControl: "bucket-owner-full-control",
  BucketOwnerRead: "bucket-owner-read",
  Private: "private",
  PublicRead: "public-read",
  PublicReadWrite: "public-read-write",
} as const;
export type CreateDrainDeliveryObjectAcl = ClosedEnum<
  typeof CreateDrainDeliveryObjectAcl
>;

export type CreateDrainDelivery4 = {
  type: "s3";
  endpoint: string;
  encoding:
    CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody24Encoding;
  compression: CreateDrainDeliveryDrainsResponse200Compression;
  fileStructure: CreateDrainDeliveryFileStructure;
  roleArn: string;
  region: string;
  serverSideEncryption?: CreateDrainDeliveryServerSideEncryption | undefined;
  objectAcl?: CreateDrainDeliveryObjectAcl | undefined;
};

export type CreateDrainDeliveryDrains3 = {
  type: "clickhouse";
  endpoint: string;
  table: string;
};

export type CreateDrainDeliveryDrainsResponseEndpoint = {
  traces: string;
};

export const CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody2Encoding =
  {
    Json: "json",
    Proto: "proto",
  } as const;
export type CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody2Encoding =
  ClosedEnum<
    typeof CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody2Encoding
  >;

export const CreateDrainSecretDrainsResponseKind = {
  IntegrationSecret: "INTEGRATION_SECRET",
} as const;
export type CreateDrainSecretDrainsResponseKind = ClosedEnum<
  typeof CreateDrainSecretDrainsResponseKind
>;

export type CreateDrainSecretDrainsResponse2 = {
  kind: CreateDrainSecretDrainsResponseKind;
};

export type CreateDrainDeliveryDrainsSecret =
  | CreateDrainSecretDrainsResponse2
  | string;

export type CreateDrainDeliveryDrains2 = {
  type: "otlphttp";
  endpoint: CreateDrainDeliveryDrainsResponseEndpoint;
  encoding:
    CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody2Encoding;
  headers: { [k: string]: string };
  secret?: CreateDrainSecretDrainsResponse2 | string | undefined;
};

export const CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBodyEncoding =
  {
    Json: "json",
    Ndjson: "ndjson",
  } as const;
export type CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBodyEncoding =
  ClosedEnum<
    typeof CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBodyEncoding
  >;

export const CreateDrainDeliveryDrainsResponseCompression = {
  Gzip: "gzip",
  None: "none",
} as const;
export type CreateDrainDeliveryDrainsResponseCompression = ClosedEnum<
  typeof CreateDrainDeliveryDrainsResponseCompression
>;

export const CreateDrainSecretDrainsKind = {
  IntegrationSecret: "INTEGRATION_SECRET",
} as const;
export type CreateDrainSecretDrainsKind = ClosedEnum<
  typeof CreateDrainSecretDrainsKind
>;

export type CreateDrainSecretDrains2 = {
  kind: CreateDrainSecretDrainsKind;
};

export type CreateDrainDeliverySecret = CreateDrainSecretDrains2 | string;

export type CreateDrainDeliveryDrains1 = {
  type: "http";
  endpoint: string;
  encoding:
    CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBodyEncoding;
  compression?: CreateDrainDeliveryDrainsResponseCompression | undefined;
  headers: { [k: string]: string };
  secret?: CreateDrainSecretDrains2 | string | undefined;
};

export type CreateDrainResponseBodyDelivery =
  | CreateDrainDeliveryDrains1
  | CreateDrainDeliveryDrains2
  | CreateDrainDeliveryDrains3
  | CreateDrainDelivery4
  | CreateDrainDelivery5;

export const CreateDrainResponseBodyDrainsType = {
  HeadSampling: "head_sampling",
} as const;
export type CreateDrainResponseBodyDrainsType = ClosedEnum<
  typeof CreateDrainResponseBodyDrainsType
>;

export const CreateDrainResponseBodyEnv = {
  Preview: "preview",
  Production: "production",
} as const;
export type CreateDrainResponseBodyEnv = ClosedEnum<
  typeof CreateDrainResponseBodyEnv
>;

export type CreateDrainResponseBodySampling = {
  type: CreateDrainResponseBodyDrainsType;
  rate: number;
  env?: CreateDrainResponseBodyEnv | undefined;
  requestPath?: string | undefined;
};

export type CreateDrainSourceDrains2 = {
  kind: "integration";
  resourceId?: string | undefined;
  externalResourceId?: string | undefined;
  integrationId: string;
  integrationConfigurationId: string;
};

export type CreateDrainSourceDrains1 = {
  kind: "self-served";
};

export type CreateDrainResponseBodyDrainsSource =
  | CreateDrainSourceDrains1
  | CreateDrainSourceDrains2;

export const CreateDrainResponseBodyDrainsVersion = {
  V2: "v2",
} as const;
export type CreateDrainResponseBodyDrainsVersion = ClosedEnum<
  typeof CreateDrainResponseBodyDrainsVersion
>;

export type CreateDrainFilterDrains2 = {
  type: "odata";
  text: string;
};

export type CreateDrainFilterDrainsResponseProject = {
  ids?: Array<string> | undefined;
};

export const CreateDrainFilterDrainsSources = {
  Build: "build",
  Edge: "edge",
  External: "external",
  Firewall: "firewall",
  Lambda: "lambda",
  Redirect: "redirect",
  Static: "static",
} as const;
export type CreateDrainFilterDrainsSources = ClosedEnum<
  typeof CreateDrainFilterDrainsSources
>;

export type CreateDrainFilterLog = {
  sources?: Array<CreateDrainFilterDrainsSources> | undefined;
  legacyExcludeCachedStaticAssetLogs?: boolean | undefined;
};

export const CreateDrainFilterDrainsEnvironments = {
  Preview: "preview",
  Production: "production",
} as const;
export type CreateDrainFilterDrainsEnvironments = ClosedEnum<
  typeof CreateDrainFilterDrainsEnvironments
>;

export type CreateDrainFilterDrainsResponseDeployment = {
  environments?: Array<CreateDrainFilterDrainsEnvironments> | undefined;
};

export type CreateDrainFilterDrains1 = {
  type: "basic";
  project?: CreateDrainFilterDrainsResponseProject | undefined;
  log?: CreateDrainFilterLog | undefined;
  deployment?: CreateDrainFilterDrainsResponseDeployment | undefined;
};

export type CreateDrainResponseBodyFilter =
  | CreateDrainFilterDrains1
  | CreateDrainFilterDrains2;

export type ResponseBodyFilterV2 = {
  version: CreateDrainResponseBodyDrainsVersion;
  filter: CreateDrainFilterDrains1 | CreateDrainFilterDrains2;
};

export const ProjectAccessManagedBy = {
  Drain: "drain",
  Integration: "integration",
} as const;
export type ProjectAccessManagedBy = ClosedEnum<typeof ProjectAccessManagedBy>;

export type ProjectAccess2 = {
  access: "some";
  projectIds: Array<string>;
  managedBy: ProjectAccessManagedBy;
};

export const ManagedBy = {
  Drain: "drain",
  Integration: "integration",
} as const;
export type ManagedBy = ClosedEnum<typeof ManagedBy>;

export type ProjectAccess1 = {
  access: "all";
  managedBy: ManagedBy;
};

export type ProjectAccess = ProjectAccess1 | ProjectAccess2;

export type CreateDrainResponseBody2 = {
  id: string;
  createdAt: number;
  updatedAt: number;
  projectIds?: Array<string> | undefined;
  name: string;
  teamId?: string | null | undefined;
  ownerId: string;
  status?: CreateDrainResponseBodyDrainsStatus | undefined;
  firstErrorTimestamp?: number | undefined;
  disabledAt?: number | undefined;
  disabledBy?: string | undefined;
  disabledReason?: ResponseBodyDisabledReason | undefined;
  schemas: CreateDrainResponseBodySchemas;
  delivery:
    | CreateDrainDeliveryDrains1
    | CreateDrainDeliveryDrains2
    | CreateDrainDeliveryDrains3
    | CreateDrainDelivery4
    | CreateDrainDelivery5;
  sampling?: Array<CreateDrainResponseBodySampling> | undefined;
  source: CreateDrainSourceDrains1 | CreateDrainSourceDrains2;
  filterV2?: ResponseBodyFilterV2 | undefined;
  integrationIcon?: string | undefined;
  integrationConfigurationUri?: string | undefined;
  integrationWebsite?: string | undefined;
  projectAccess?: ProjectAccess1 | ProjectAccess2 | undefined;
};

export const CreateDrainResponseBodyStatus = {
  Disabled: "disabled",
  Enabled: "enabled",
  Errored: "errored",
} as const;
export type CreateDrainResponseBodyStatus = ClosedEnum<
  typeof CreateDrainResponseBodyStatus
>;

export const DisabledReason = {
  AccountPlanDowngrade: "account-plan-downgrade",
  DisabledByAdmin: "disabled-by-admin",
  DisabledByOwner: "disabled-by-owner",
  FeatureNotAvailable: "feature-not-available",
} as const;
export type DisabledReason = ClosedEnum<typeof DisabledReason>;

export type ResponseBodyLog = {};

export type Trace = {};

export type CreateDrainResponseBodyAnalytics = {};

export type CreateDrainResponseBodySpeedInsights = {};

export type AiGateway = {};

export type AuditLog = {};

export type ResponseBodySchemas = {
  log?: ResponseBodyLog | undefined;
  trace?: Trace | undefined;
  analytics?: CreateDrainResponseBodyAnalytics | undefined;
  speedInsights?: CreateDrainResponseBodySpeedInsights | undefined;
  aiGateway?: AiGateway | undefined;
  auditLog?: AuditLog | undefined;
};

export const DeliveryTarget = {
  VercelOtelTracesDb: "vercel-otel-traces-db",
} as const;
export type DeliveryTarget = ClosedEnum<typeof DeliveryTarget>;

export type Delivery5 = {
  type: "internal";
  target: DeliveryTarget;
};

export const CreateDrainDeliveryDrainsResponse200ApplicationJSONEncoding = {
  Json: "json",
  Ndjson: "ndjson",
} as const;
export type CreateDrainDeliveryDrainsResponse200ApplicationJSONEncoding =
  ClosedEnum<
    typeof CreateDrainDeliveryDrainsResponse200ApplicationJSONEncoding
  >;

export const CreateDrainDeliveryDrainsCompression = {
  None: "none",
} as const;
export type CreateDrainDeliveryDrainsCompression = ClosedEnum<
  typeof CreateDrainDeliveryDrainsCompression
>;

export const CreateDrainDeliveryDrainsFileStructure = {
  Hive: "hive",
} as const;
export type CreateDrainDeliveryDrainsFileStructure = ClosedEnum<
  typeof CreateDrainDeliveryDrainsFileStructure
>;

export const CreateDrainDeliveryDrainsServerSideEncryption = {
  Aes256: "AES256",
  AwsKms: "aws:kms",
  AwsKmsDsse: "aws:kms:dsse",
} as const;
export type CreateDrainDeliveryDrainsServerSideEncryption = ClosedEnum<
  typeof CreateDrainDeliveryDrainsServerSideEncryption
>;

export const CreateDrainDeliveryDrainsObjectAcl = {
  AuthenticatedRead: "authenticated-read",
  AwsExecRead: "aws-exec-read",
  BucketOwnerFullControl: "bucket-owner-full-control",
  BucketOwnerRead: "bucket-owner-read",
  Private: "private",
  PublicRead: "public-read",
  PublicReadWrite: "public-read-write",
} as const;
export type CreateDrainDeliveryDrainsObjectAcl = ClosedEnum<
  typeof CreateDrainDeliveryDrainsObjectAcl
>;

export type Delivery4 = {
  type: "s3";
  endpoint: string;
  encoding: CreateDrainDeliveryDrainsResponse200ApplicationJSONEncoding;
  compression: CreateDrainDeliveryDrainsCompression;
  fileStructure: CreateDrainDeliveryDrainsFileStructure;
  roleArn: string;
  region: string;
  serverSideEncryption?:
    | CreateDrainDeliveryDrainsServerSideEncryption
    | undefined;
  objectAcl?: CreateDrainDeliveryDrainsObjectAcl | undefined;
};

export type CreateDrainDelivery3 = {
  type: "clickhouse";
  endpoint: string;
  table: string;
};

export type CreateDrainDeliveryDrainsEndpoint = {
  traces: string;
};

export const CreateDrainDeliveryDrainsResponse200Encoding = {
  Json: "json",
  Proto: "proto",
} as const;
export type CreateDrainDeliveryDrainsResponse200Encoding = ClosedEnum<
  typeof CreateDrainDeliveryDrainsResponse200Encoding
>;

export const CreateDrainSecretKind = {
  IntegrationSecret: "INTEGRATION_SECRET",
} as const;
export type CreateDrainSecretKind = ClosedEnum<typeof CreateDrainSecretKind>;

export type CreateDrainSecret2 = {
  kind: CreateDrainSecretKind;
};

export type DeliverySecret = CreateDrainSecret2 | string;

export type CreateDrainDelivery2 = {
  type: "otlphttp";
  endpoint: CreateDrainDeliveryDrainsEndpoint;
  encoding: CreateDrainDeliveryDrainsResponse200Encoding;
  headers: { [k: string]: string };
  secret?: CreateDrainSecret2 | string | undefined;
};

export const CreateDrainDeliveryDrainsResponseEncoding = {
  Json: "json",
  Ndjson: "ndjson",
} as const;
export type CreateDrainDeliveryDrainsResponseEncoding = ClosedEnum<
  typeof CreateDrainDeliveryDrainsResponseEncoding
>;

export const CreateDrainDeliveryCompression = {
  Gzip: "gzip",
  None: "none",
} as const;
export type CreateDrainDeliveryCompression = ClosedEnum<
  typeof CreateDrainDeliveryCompression
>;

export const SecretKind = {
  IntegrationSecret: "INTEGRATION_SECRET",
} as const;
export type SecretKind = ClosedEnum<typeof SecretKind>;

export type Secret2 = {
  kind: SecretKind;
};

export type Secret = Secret2 | string;

export type CreateDrainDelivery1 = {
  type: "http";
  endpoint: string;
  encoding: CreateDrainDeliveryDrainsResponseEncoding;
  compression?: CreateDrainDeliveryCompression | undefined;
  headers: { [k: string]: string };
  secret?: Secret2 | string | undefined;
};

export type ResponseBodyDelivery =
  | CreateDrainDelivery1
  | CreateDrainDelivery2
  | CreateDrainDelivery3
  | Delivery4
  | Delivery5;

export const CreateDrainResponseBodyType = {
  HeadSampling: "head_sampling",
} as const;
export type CreateDrainResponseBodyType = ClosedEnum<
  typeof CreateDrainResponseBodyType
>;

export const CreateDrainResponseBodyDrainsEnv = {
  Preview: "preview",
  Production: "production",
} as const;
export type CreateDrainResponseBodyDrainsEnv = ClosedEnum<
  typeof CreateDrainResponseBodyDrainsEnv
>;

export type ResponseBodySampling = {
  type: CreateDrainResponseBodyType;
  rate: number;
  env?: CreateDrainResponseBodyDrainsEnv | undefined;
  requestPath?: string | undefined;
};

export type CreateDrainSource2 = {
  kind: "integration";
  resourceId?: string | undefined;
  externalResourceId?: string | undefined;
  integrationId: string;
  integrationConfigurationId: string;
};

export type CreateDrainSource1 = {
  kind: "self-served";
};

export type CreateDrainResponseBodySource =
  | CreateDrainSource1
  | CreateDrainSource2;

export const CreateDrainResponseBodyVersion = {
  V2: "v2",
} as const;
export type CreateDrainResponseBodyVersion = ClosedEnum<
  typeof CreateDrainResponseBodyVersion
>;

export type CreateDrainFilter2 = {
  type: "odata";
  text: string;
};

export type CreateDrainFilterDrainsProject = {
  ids?: Array<string> | undefined;
};

export const CreateDrainFilterSources = {
  Build: "build",
  Edge: "edge",
  External: "external",
  Firewall: "firewall",
  Lambda: "lambda",
  Redirect: "redirect",
  Static: "static",
} as const;
export type CreateDrainFilterSources = ClosedEnum<
  typeof CreateDrainFilterSources
>;

export type CreateDrainFilterDrainsLog = {
  sources?: Array<CreateDrainFilterSources> | undefined;
  legacyExcludeCachedStaticAssetLogs?: boolean | undefined;
};

export const CreateDrainFilterEnvironments = {
  Preview: "preview",
  Production: "production",
} as const;
export type CreateDrainFilterEnvironments = ClosedEnum<
  typeof CreateDrainFilterEnvironments
>;

export type CreateDrainFilterDrainsDeployment = {
  environments?: Array<CreateDrainFilterEnvironments> | undefined;
};

export type CreateDrainFilter1 = {
  type: "basic";
  project?: CreateDrainFilterDrainsProject | undefined;
  log?: CreateDrainFilterDrainsLog | undefined;
  deployment?: CreateDrainFilterDrainsDeployment | undefined;
};

export type ResponseBodyFilter = CreateDrainFilter1 | CreateDrainFilter2;

export type FilterV2 = {
  version: CreateDrainResponseBodyVersion;
  filter: CreateDrainFilter1 | CreateDrainFilter2;
};

export type CreateDrainResponseBody1 = {
  id: string;
  createdAt: number;
  updatedAt: number;
  projectIds?: Array<string> | undefined;
  name: string;
  teamId?: string | null | undefined;
  ownerId: string;
  status?: CreateDrainResponseBodyStatus | undefined;
  firstErrorTimestamp?: number | undefined;
  disabledAt?: number | undefined;
  disabledBy?: string | undefined;
  disabledReason?: DisabledReason | undefined;
  schemas: ResponseBodySchemas;
  delivery:
    | CreateDrainDelivery1
    | CreateDrainDelivery2
    | CreateDrainDelivery3
    | Delivery4
    | Delivery5;
  sampling?: Array<ResponseBodySampling> | undefined;
  source: CreateDrainSource1 | CreateDrainSource2;
  filterV2?: FilterV2 | undefined;
};

export type CreateDrainResponseBody =
  | CreateDrainResponseBody1
  | CreateDrainResponseBody2;

/** @internal */
export const CreateDrainProjects$outboundSchema: z.ZodNativeEnum<
  typeof CreateDrainProjects
> = z.nativeEnum(CreateDrainProjects);

/** @internal */
export type Filter2$Outbound = {
  type: string;
  text: string;
};

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

export function filter2ToJSON(filter2: Filter2): string {
  return JSON.stringify(Filter2$outboundSchema.parse(filter2));
}

/** @internal */
export type CreateDrainFilterProject$Outbound = {
  ids?: Array<string> | undefined;
};

/** @internal */
export const CreateDrainFilterProject$outboundSchema: z.ZodType<
  CreateDrainFilterProject$Outbound,
  z.ZodTypeDef,
  CreateDrainFilterProject
> = z.object({
  ids: z.array(z.string()).optional(),
});

export function createDrainFilterProjectToJSON(
  createDrainFilterProject: CreateDrainFilterProject,
): string {
  return JSON.stringify(
    CreateDrainFilterProject$outboundSchema.parse(createDrainFilterProject),
  );
}

/** @internal */
export const FilterSources$outboundSchema: z.ZodNativeEnum<
  typeof FilterSources
> = z.nativeEnum(FilterSources);

/** @internal */
export type Log$Outbound = {
  sources?: Array<string> | undefined;
};

/** @internal */
export const Log$outboundSchema: z.ZodType<Log$Outbound, z.ZodTypeDef, Log> = z
  .object({
    sources: z.array(FilterSources$outboundSchema).optional(),
  });

export function logToJSON(log: Log): string {
  return JSON.stringify(Log$outboundSchema.parse(log));
}

/** @internal */
export const FilterEnvironments$outboundSchema: z.ZodNativeEnum<
  typeof FilterEnvironments
> = z.nativeEnum(FilterEnvironments);

/** @internal */
export type CreateDrainFilterDeployment$Outbound = {
  environments?: Array<string> | undefined;
};

/** @internal */
export const CreateDrainFilterDeployment$outboundSchema: z.ZodType<
  CreateDrainFilterDeployment$Outbound,
  z.ZodTypeDef,
  CreateDrainFilterDeployment
> = z.object({
  environments: z.array(FilterEnvironments$outboundSchema).optional(),
});

export function createDrainFilterDeploymentToJSON(
  createDrainFilterDeployment: CreateDrainFilterDeployment,
): string {
  return JSON.stringify(
    CreateDrainFilterDeployment$outboundSchema.parse(
      createDrainFilterDeployment,
    ),
  );
}

/** @internal */
export type Filter1$Outbound = {
  type: string;
  project?: CreateDrainFilterProject$Outbound | undefined;
  log?: Log$Outbound | undefined;
  deployment?: CreateDrainFilterDeployment$Outbound | undefined;
};

/** @internal */
export const Filter1$outboundSchema: z.ZodType<
  Filter1$Outbound,
  z.ZodTypeDef,
  Filter1
> = z.object({
  type: z.string(),
  project: z.lazy(() => CreateDrainFilterProject$outboundSchema).optional(),
  log: z.lazy(() => Log$outboundSchema).optional(),
  deployment: z.lazy(() => CreateDrainFilterDeployment$outboundSchema)
    .optional(),
});

export function filter1ToJSON(filter1: Filter1): string {
  return JSON.stringify(Filter1$outboundSchema.parse(filter1));
}

/** @internal */
export type CreateDrainFilter$Outbound = Filter2$Outbound | Filter1$Outbound;

/** @internal */
export const CreateDrainFilter$outboundSchema: z.ZodType<
  CreateDrainFilter$Outbound,
  z.ZodTypeDef,
  CreateDrainFilter
> = smartUnion([
  z.lazy(() => Filter2$outboundSchema),
  z.lazy(() => Filter1$outboundSchema),
]);

export function createDrainFilterToJSON(
  createDrainFilter: CreateDrainFilter,
): string {
  return JSON.stringify(
    CreateDrainFilter$outboundSchema.parse(createDrainFilter),
  );
}

/** @internal */
export type Filter$Outbound = {
  version: string;
  filter: Filter2$Outbound | Filter1$Outbound;
};

/** @internal */
export const Filter$outboundSchema: z.ZodType<
  Filter$Outbound,
  z.ZodTypeDef,
  Filter
> = z.object({
  version: z.string(),
  filter: smartUnion([
    z.lazy(() => Filter2$outboundSchema),
    z.lazy(() => Filter1$outboundSchema),
  ]),
});

export function filterToJSON(filter: Filter): string {
  return JSON.stringify(Filter$outboundSchema.parse(filter));
}

/** @internal */
export type Schemas$Outbound = {
  version: string;
};

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

export function schemasToJSON(schemas: Schemas): string {
  return JSON.stringify(Schemas$outboundSchema.parse(schemas));
}

/** @internal */
export const CreateDrainDeliveryDrainsEncoding$outboundSchema: z.ZodNativeEnum<
  typeof CreateDrainDeliveryDrainsEncoding
> = z.nativeEnum(CreateDrainDeliveryDrainsEncoding);

/** @internal */
export const DeliveryCompression$outboundSchema: z.ZodNativeEnum<
  typeof DeliveryCompression
> = z.nativeEnum(DeliveryCompression);

/** @internal */
export const FileStructure$outboundSchema: z.ZodNativeEnum<
  typeof FileStructure
> = z.nativeEnum(FileStructure);

/** @internal */
export const ServerSideEncryption$outboundSchema: z.ZodNativeEnum<
  typeof ServerSideEncryption
> = z.nativeEnum(ServerSideEncryption);

/** @internal */
export const ObjectAcl$outboundSchema: z.ZodNativeEnum<typeof ObjectAcl> = z
  .nativeEnum(ObjectAcl);

/** @internal */
export type Delivery3$Outbound = {
  type: string;
  endpoint: string;
  encoding: string;
  compression: string;
  fileStructure: string;
  roleArn: string;
  region: string;
  serverSideEncryption?: string | undefined;
  objectAcl?: string | undefined;
};

/** @internal */
export const Delivery3$outboundSchema: z.ZodType<
  Delivery3$Outbound,
  z.ZodTypeDef,
  Delivery3
> = z.object({
  type: z.string(),
  endpoint: z.string(),
  encoding: CreateDrainDeliveryDrainsEncoding$outboundSchema,
  compression: DeliveryCompression$outboundSchema,
  fileStructure: FileStructure$outboundSchema,
  roleArn: z.string(),
  region: z.string(),
  serverSideEncryption: ServerSideEncryption$outboundSchema.optional(),
  objectAcl: ObjectAcl$outboundSchema.optional(),
});

export function delivery3ToJSON(delivery3: Delivery3): string {
  return JSON.stringify(Delivery3$outboundSchema.parse(delivery3));
}

/** @internal */
export type Endpoint1$Outbound = {
  traces: string;
};

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

export function endpoint1ToJSON(endpoint1: Endpoint1): string {
  return JSON.stringify(Endpoint1$outboundSchema.parse(endpoint1));
}

/** @internal */
export type CreateDrainDeliveryEndpoint$Outbound = Endpoint1$Outbound;

/** @internal */
export const CreateDrainDeliveryEndpoint$outboundSchema: z.ZodType<
  CreateDrainDeliveryEndpoint$Outbound,
  z.ZodTypeDef,
  CreateDrainDeliveryEndpoint
> = z.lazy(() => Endpoint1$outboundSchema);

export function createDrainDeliveryEndpointToJSON(
  createDrainDeliveryEndpoint: CreateDrainDeliveryEndpoint,
): string {
  return JSON.stringify(
    CreateDrainDeliveryEndpoint$outboundSchema.parse(
      createDrainDeliveryEndpoint,
    ),
  );
}

/** @internal */
export const CreateDrainDeliveryEncoding$outboundSchema: z.ZodNativeEnum<
  typeof CreateDrainDeliveryEncoding
> = z.nativeEnum(CreateDrainDeliveryEncoding);

/** @internal */
export type Delivery2$Outbound = {
  type: string;
  endpoint: Endpoint1$Outbound;
  encoding: string;
  headers: { [k: string]: string };
  secret?: string | undefined;
};

/** @internal */
export const Delivery2$outboundSchema: z.ZodType<
  Delivery2$Outbound,
  z.ZodTypeDef,
  Delivery2
> = z.object({
  type: z.string(),
  endpoint: z.lazy(() => Endpoint1$outboundSchema),
  encoding: CreateDrainDeliveryEncoding$outboundSchema,
  headers: z.record(z.string()),
  secret: z.string().optional(),
});

export function delivery2ToJSON(delivery2: Delivery2): string {
  return JSON.stringify(Delivery2$outboundSchema.parse(delivery2));
}

/** @internal */
export const Compression$outboundSchema: z.ZodNativeEnum<typeof Compression> = z
  .nativeEnum(Compression);

/** @internal */
export const DeliveryEncoding$outboundSchema: z.ZodNativeEnum<
  typeof DeliveryEncoding
> = z.nativeEnum(DeliveryEncoding);

/** @internal */
export type Delivery1$Outbound = {
  type: string;
  endpoint: string;
  compression?: string | undefined;
  encoding: string;
  headers: { [k: string]: string };
  secret?: string | undefined;
};

/** @internal */
export const Delivery1$outboundSchema: z.ZodType<
  Delivery1$Outbound,
  z.ZodTypeDef,
  Delivery1
> = z.object({
  type: z.string(),
  endpoint: z.string(),
  compression: Compression$outboundSchema.optional(),
  encoding: DeliveryEncoding$outboundSchema,
  headers: z.record(z.string()),
  secret: z.string().optional(),
});

export function delivery1ToJSON(delivery1: Delivery1): string {
  return JSON.stringify(Delivery1$outboundSchema.parse(delivery1));
}

/** @internal */
export type Delivery$Outbound =
  | Delivery3$Outbound
  | Delivery1$Outbound
  | Delivery2$Outbound;

/** @internal */
export const Delivery$outboundSchema: z.ZodType<
  Delivery$Outbound,
  z.ZodTypeDef,
  Delivery
> = smartUnion([
  z.lazy(() => Delivery3$outboundSchema),
  z.lazy(() => Delivery1$outboundSchema),
  z.lazy(() => Delivery2$outboundSchema),
]);

export function deliveryToJSON(delivery: Delivery): string {
  return JSON.stringify(Delivery$outboundSchema.parse(delivery));
}

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

/** @internal */
export type Sampling$Outbound = {
  type: string;
  rate: number;
  env?: string | undefined;
  requestPath?: string | undefined;
};

/** @internal */
export const Sampling$outboundSchema: z.ZodType<
  Sampling$Outbound,
  z.ZodTypeDef,
  Sampling
> = z.object({
  type: z.string(),
  rate: z.number(),
  env: Env$outboundSchema.optional(),
  requestPath: z.string().optional(),
});

export function samplingToJSON(sampling: Sampling): string {
  return JSON.stringify(Sampling$outboundSchema.parse(sampling));
}

/** @internal */
export type Transforms$Outbound = {
  id: string;
};

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

export function transformsToJSON(transforms: Transforms): string {
  return JSON.stringify(Transforms$outboundSchema.parse(transforms));
}

/** @internal */
export type Source2$Outbound = {
  kind: string;
};

/** @internal */
export const Source2$outboundSchema: z.ZodType<
  Source2$Outbound,
  z.ZodTypeDef,
  Source2
> = z.object({
  kind: z.string().default("self-served"),
});

export function source2ToJSON(source2: Source2): string {
  return JSON.stringify(Source2$outboundSchema.parse(source2));
}

/** @internal */
export type One3$Outbound = {
  kind: string;
};

/** @internal */
export const One3$outboundSchema: z.ZodType<One3$Outbound, z.ZodTypeDef, One3> =
  z.object({
    kind: z.string().default("integration"),
  });

export function one3ToJSON(one3: One3): string {
  return JSON.stringify(One3$outboundSchema.parse(one3));
}

/** @internal */
export type One2$Outbound = {
  kind: string;
  resourceId: string;
};

/** @internal */
export const One2$outboundSchema: z.ZodType<One2$Outbound, z.ZodTypeDef, One2> =
  z.object({
    kind: z.string().default("integration"),
    resourceId: z.string(),
  });

export function one2ToJSON(one2: One2): string {
  return JSON.stringify(One2$outboundSchema.parse(one2));
}

/** @internal */
export type CreateDrain11$Outbound = {
  kind: string;
  externalResourceId: string;
};

/** @internal */
export const CreateDrain11$outboundSchema: z.ZodType<
  CreateDrain11$Outbound,
  z.ZodTypeDef,
  CreateDrain11
> = z.object({
  kind: z.string().default("integration"),
  externalResourceId: z.string(),
});

export function createDrain11ToJSON(createDrain11: CreateDrain11): string {
  return JSON.stringify(CreateDrain11$outboundSchema.parse(createDrain11));
}

/** @internal */
export type Source1$Outbound =
  | CreateDrain11$Outbound
  | One2$Outbound
  | One3$Outbound;

/** @internal */
export const Source1$outboundSchema: z.ZodType<
  Source1$Outbound,
  z.ZodTypeDef,
  Source1
> = smartUnion([
  z.lazy(() => CreateDrain11$outboundSchema),
  z.lazy(() => One2$outboundSchema),
  z.lazy(() => One3$outboundSchema),
]);

export function source1ToJSON(source1: Source1): string {
  return JSON.stringify(Source1$outboundSchema.parse(source1));
}

/** @internal */
export type CreateDrainSource$Outbound =
  | CreateDrain11$Outbound
  | One2$Outbound
  | One3$Outbound
  | Source2$Outbound;

/** @internal */
export const CreateDrainSource$outboundSchema: z.ZodType<
  CreateDrainSource$Outbound,
  z.ZodTypeDef,
  CreateDrainSource
> = smartUnion([
  smartUnion([
    z.lazy(() => CreateDrain11$outboundSchema),
    z.lazy(() => One2$outboundSchema),
    z.lazy(() => One3$outboundSchema),
  ]),
  z.lazy(() => Source2$outboundSchema),
]);

export function createDrainSourceToJSON(
  createDrainSource: CreateDrainSource,
): string {
  return JSON.stringify(
    CreateDrainSource$outboundSchema.parse(createDrainSource),
  );
}

/** @internal */
export type CreateDrainRequestBody$Outbound = {
  name: string;
  projects: string;
  projectIds?: Array<string> | undefined;
  filter?: Filter$Outbound | undefined;
  schemas: { [k: string]: Schemas$Outbound };
  delivery?:
    | Delivery3$Outbound
    | Delivery1$Outbound
    | Delivery2$Outbound
    | undefined;
  sampling?: Array<Sampling$Outbound> | undefined;
  transforms?: Array<Transforms$Outbound> | undefined;
  source?:
    | CreateDrain11$Outbound
    | One2$Outbound
    | One3$Outbound
    | Source2$Outbound
    | undefined;
};

/** @internal */
export const CreateDrainRequestBody$outboundSchema: z.ZodType<
  CreateDrainRequestBody$Outbound,
  z.ZodTypeDef,
  CreateDrainRequestBody
> = z.object({
  name: z.string(),
  projects: CreateDrainProjects$outboundSchema,
  projectIds: z.array(z.string()).optional(),
  filter: z.lazy(() => Filter$outboundSchema).optional(),
  schemas: z.record(z.lazy(() => Schemas$outboundSchema)),
  delivery: smartUnion([
    z.lazy(() => Delivery3$outboundSchema),
    z.lazy(() => Delivery1$outboundSchema),
    z.lazy(() => Delivery2$outboundSchema),
  ]).optional(),
  sampling: z.array(z.lazy(() => Sampling$outboundSchema)).optional(),
  transforms: z.array(z.lazy(() => Transforms$outboundSchema)).optional(),
  source: smartUnion([
    smartUnion([
      z.lazy(() => CreateDrain11$outboundSchema),
      z.lazy(() => One2$outboundSchema),
      z.lazy(() => One3$outboundSchema),
    ]),
    z.lazy(() => Source2$outboundSchema),
  ]).optional(),
});

export function createDrainRequestBodyToJSON(
  createDrainRequestBody: CreateDrainRequestBody,
): string {
  return JSON.stringify(
    CreateDrainRequestBody$outboundSchema.parse(createDrainRequestBody),
  );
}

/** @internal */
export type CreateDrainRequest$Outbound = {
  teamId?: string | undefined;
  slug?: string | undefined;
  RequestBody?: CreateDrainRequestBody$Outbound | undefined;
};

/** @internal */
export const CreateDrainRequest$outboundSchema: z.ZodType<
  CreateDrainRequest$Outbound,
  z.ZodTypeDef,
  CreateDrainRequest
> = z.object({
  teamId: z.string().optional(),
  slug: z.string().optional(),
  requestBody: z.lazy(() => CreateDrainRequestBody$outboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    requestBody: "RequestBody",
  });
});

export function createDrainRequestToJSON(
  createDrainRequest: CreateDrainRequest,
): string {
  return JSON.stringify(
    CreateDrainRequest$outboundSchema.parse(createDrainRequest),
  );
}

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

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

/** @internal */
export const CreateDrainResponseBodyLog$inboundSchema: z.ZodType<
  CreateDrainResponseBodyLog,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const ResponseBodyTrace$inboundSchema: z.ZodType<
  ResponseBodyTrace,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const CreateDrainResponseBodyDrainsAnalytics$inboundSchema: z.ZodType<
  CreateDrainResponseBodyDrainsAnalytics,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const CreateDrainResponseBodyDrainsSpeedInsights$inboundSchema:
  z.ZodType<CreateDrainResponseBodyDrainsSpeedInsights, z.ZodTypeDef, unknown> =
    z.object({});

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

/** @internal */
export const ResponseBodyAiGateway$inboundSchema: z.ZodType<
  ResponseBodyAiGateway,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const ResponseBodyAuditLog$inboundSchema: z.ZodType<
  ResponseBodyAuditLog,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const CreateDrainResponseBodySchemas$inboundSchema: z.ZodType<
  CreateDrainResponseBodySchemas,
  z.ZodTypeDef,
  unknown
> = z.object({
  log: types.optional(z.lazy(() => CreateDrainResponseBodyLog$inboundSchema)),
  trace: types.optional(z.lazy(() => ResponseBodyTrace$inboundSchema)),
  analytics: types.optional(
    z.lazy(() => CreateDrainResponseBodyDrainsAnalytics$inboundSchema),
  ),
  speed_insights: types.optional(
    z.lazy(() => CreateDrainResponseBodyDrainsSpeedInsights$inboundSchema),
  ),
  ai_gateway: types.optional(z.lazy(() => ResponseBodyAiGateway$inboundSchema)),
  audit_log: types.optional(z.lazy(() => ResponseBodyAuditLog$inboundSchema)),
}).transform((v) => {
  return remap$(v, {
    "speed_insights": "speedInsights",
    "ai_gateway": "aiGateway",
    "audit_log": "auditLog",
  });
});

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

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

/** @internal */
export const CreateDrainDelivery5$inboundSchema: z.ZodType<
  CreateDrainDelivery5,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("internal"),
  target: CreateDrainDeliveryTarget$inboundSchema,
});

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

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

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

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

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

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

/** @internal */
export const CreateDrainDelivery4$inboundSchema: z.ZodType<
  CreateDrainDelivery4,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("s3"),
  endpoint: types.string(),
  encoding:
    CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody24Encoding$inboundSchema,
  compression: CreateDrainDeliveryDrainsResponse200Compression$inboundSchema,
  fileStructure: CreateDrainDeliveryFileStructure$inboundSchema,
  roleArn: types.string(),
  region: types.string(),
  serverSideEncryption: types.optional(
    CreateDrainDeliveryServerSideEncryption$inboundSchema,
  ),
  objectAcl: types.optional(CreateDrainDeliveryObjectAcl$inboundSchema),
});

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

/** @internal */
export const CreateDrainDeliveryDrains3$inboundSchema: z.ZodType<
  CreateDrainDeliveryDrains3,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("clickhouse"),
  endpoint: types.string(),
  table: types.string(),
});

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

/** @internal */
export const CreateDrainDeliveryDrainsResponseEndpoint$inboundSchema: z.ZodType<
  CreateDrainDeliveryDrainsResponseEndpoint,
  z.ZodTypeDef,
  unknown
> = z.object({
  traces: types.string(),
});

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

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

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

/** @internal */
export const CreateDrainSecretDrainsResponse2$inboundSchema: z.ZodType<
  CreateDrainSecretDrainsResponse2,
  z.ZodTypeDef,
  unknown
> = z.object({
  kind: CreateDrainSecretDrainsResponseKind$inboundSchema,
});

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

/** @internal */
export const CreateDrainDeliveryDrainsSecret$inboundSchema: z.ZodType<
  CreateDrainDeliveryDrainsSecret,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => CreateDrainSecretDrainsResponse2$inboundSchema),
  types.string(),
]);

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

/** @internal */
export const CreateDrainDeliveryDrains2$inboundSchema: z.ZodType<
  CreateDrainDeliveryDrains2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("otlphttp"),
  endpoint: z.lazy(() =>
    CreateDrainDeliveryDrainsResponseEndpoint$inboundSchema
  ),
  encoding:
    CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBody2Encoding$inboundSchema,
  headers: z.record(types.string()),
  secret: types.optional(
    smartUnion([
      z.lazy(() => CreateDrainSecretDrainsResponse2$inboundSchema),
      types.string(),
    ]),
  ),
});

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

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

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

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

/** @internal */
export const CreateDrainSecretDrains2$inboundSchema: z.ZodType<
  CreateDrainSecretDrains2,
  z.ZodTypeDef,
  unknown
> = z.object({
  kind: CreateDrainSecretDrainsKind$inboundSchema,
});

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

/** @internal */
export const CreateDrainDeliverySecret$inboundSchema: z.ZodType<
  CreateDrainDeliverySecret,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => CreateDrainSecretDrains2$inboundSchema),
  types.string(),
]);

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

/** @internal */
export const CreateDrainDeliveryDrains1$inboundSchema: z.ZodType<
  CreateDrainDeliveryDrains1,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("http"),
  endpoint: types.string(),
  encoding:
    CreateDrainDeliveryDrainsResponse200ApplicationJSONResponseBodyEncoding$inboundSchema,
  compression: types.optional(
    CreateDrainDeliveryDrainsResponseCompression$inboundSchema,
  ),
  headers: z.record(types.string()),
  secret: types.optional(
    smartUnion([
      z.lazy(() => CreateDrainSecretDrains2$inboundSchema),
      types.string(),
    ]),
  ),
});

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

/** @internal */
export const CreateDrainResponseBodyDelivery$inboundSchema: z.ZodType<
  CreateDrainResponseBodyDelivery,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => CreateDrainDeliveryDrains1$inboundSchema),
  z.lazy(() => CreateDrainDeliveryDrains2$inboundSchema),
  z.lazy(() => CreateDrainDeliveryDrains3$inboundSchema),
  z.lazy(() => CreateDrainDelivery4$inboundSchema),
  z.lazy(() => CreateDrainDelivery5$inboundSchema),
]);

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

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

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

/** @internal */
export const CreateDrainResponseBodySampling$inboundSchema: z.ZodType<
  CreateDrainResponseBodySampling,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: CreateDrainResponseBodyDrainsType$inboundSchema,
  rate: types.number(),
  env: types.optional(CreateDrainResponseBodyEnv$inboundSchema),
  requestPath: types.optional(types.string()),
});

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

/** @internal */
export const CreateDrainSourceDrains2$inboundSchema: z.ZodType<
  CreateDrainSourceDrains2,
  z.ZodTypeDef,
  unknown
> = z.object({
  kind: types.literal("integration"),
  resourceId: types.optional(types.string()),
  externalResourceId: types.optional(types.string()),
  integrationId: types.string(),
  integrationConfigurationId: types.string(),
});

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

/** @internal */
export const CreateDrainSourceDrains1$inboundSchema: z.ZodType<
  CreateDrainSourceDrains1,
  z.ZodTypeDef,
  unknown
> = z.object({
  kind: types.literal("self-served"),
});

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

/** @internal */
export const CreateDrainResponseBodyDrainsSource$inboundSchema: z.ZodType<
  CreateDrainResponseBodyDrainsSource,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => CreateDrainSourceDrains1$inboundSchema),
  z.lazy(() => CreateDrainSourceDrains2$inboundSchema),
]);

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

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

/** @internal */
export const CreateDrainFilterDrains2$inboundSchema: z.ZodType<
  CreateDrainFilterDrains2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("odata"),
  text: types.string(),
});

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

/** @internal */
export const CreateDrainFilterDrainsResponseProject$inboundSchema: z.ZodType<
  CreateDrainFilterDrainsResponseProject,
  z.ZodTypeDef,
  unknown
> = z.object({
  ids: types.optional(z.array(types.string())),
});

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

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

/** @internal */
export const CreateDrainFilterLog$inboundSchema: z.ZodType<
  CreateDrainFilterLog,
  z.ZodTypeDef,
  unknown
> = z.object({
  sources: types.optional(
    z.array(CreateDrainFilterDrainsSources$inboundSchema),
  ),
  legacy_excludeCachedStaticAssetLogs: types.optional(types.boolean()),
}).transform((v) => {
  return remap$(v, {
    "legacy_excludeCachedStaticAssetLogs": "legacyExcludeCachedStaticAssetLogs",
  });
});

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

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

/** @internal */
export const CreateDrainFilterDrainsResponseDeployment$inboundSchema: z.ZodType<
  CreateDrainFilterDrainsResponseDeployment,
  z.ZodTypeDef,
  unknown
> = z.object({
  environments: types.optional(
    z.array(CreateDrainFilterDrainsEnvironments$inboundSchema),
  ),
});

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

/** @internal */
export const CreateDrainFilterDrains1$inboundSchema: z.ZodType<
  CreateDrainFilterDrains1,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("basic"),
  project: types.optional(
    z.lazy(() => CreateDrainFilterDrainsResponseProject$inboundSchema),
  ),
  log: types.optional(z.lazy(() => CreateDrainFilterLog$inboundSchema)),
  deployment: types.optional(
    z.lazy(() => CreateDrainFilterDrainsResponseDeployment$inboundSchema),
  ),
});

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

/** @internal */
export const CreateDrainResponseBodyFilter$inboundSchema: z.ZodType<
  CreateDrainResponseBodyFilter,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => CreateDrainFilterDrains1$inboundSchema),
  z.lazy(() => CreateDrainFilterDrains2$inboundSchema),
]);

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

/** @internal */
export const ResponseBodyFilterV2$inboundSchema: z.ZodType<
  ResponseBodyFilterV2,
  z.ZodTypeDef,
  unknown
> = z.object({
  version: CreateDrainResponseBodyDrainsVersion$inboundSchema,
  filter: z.union([
    z.lazy(() => CreateDrainFilterDrains1$inboundSchema),
    z.lazy(() => CreateDrainFilterDrains2$inboundSchema),
  ]),
});

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

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

/** @internal */
export const ProjectAccess2$inboundSchema: z.ZodType<
  ProjectAccess2,
  z.ZodTypeDef,
  unknown
> = z.object({
  access: types.literal("some"),
  projectIds: z.array(types.string()),
  managedBy: ProjectAccessManagedBy$inboundSchema,
});

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

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

/** @internal */
export const ProjectAccess1$inboundSchema: z.ZodType<
  ProjectAccess1,
  z.ZodTypeDef,
  unknown
> = z.object({
  access: types.literal("all"),
  managedBy: ManagedBy$inboundSchema,
});

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

/** @internal */
export const ProjectAccess$inboundSchema: z.ZodType<
  ProjectAccess,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => ProjectAccess1$inboundSchema),
  z.lazy(() => ProjectAccess2$inboundSchema),
]);

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

/** @internal */
export const CreateDrainResponseBody2$inboundSchema: z.ZodType<
  CreateDrainResponseBody2,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  createdAt: types.number(),
  updatedAt: types.number(),
  projectIds: types.optional(z.array(types.string())),
  name: types.string(),
  teamId: z.nullable(types.string()).optional(),
  ownerId: types.string(),
  status: types.optional(CreateDrainResponseBodyDrainsStatus$inboundSchema),
  firstErrorTimestamp: types.optional(types.number()),
  disabledAt: types.optional(types.number()),
  disabledBy: types.optional(types.string()),
  disabledReason: types.optional(ResponseBodyDisabledReason$inboundSchema),
  schemas: z.lazy(() => CreateDrainResponseBodySchemas$inboundSchema),
  delivery: z.union([
    z.lazy(() => CreateDrainDeliveryDrains1$inboundSchema),
    z.lazy(() => CreateDrainDeliveryDrains2$inboundSchema),
    z.lazy(() => CreateDrainDeliveryDrains3$inboundSchema),
    z.lazy(() => CreateDrainDelivery4$inboundSchema),
    z.lazy(() => CreateDrainDelivery5$inboundSchema),
  ]),
  sampling: types.optional(
    z.array(z.lazy(() => CreateDrainResponseBodySampling$inboundSchema)),
  ),
  source: z.union([
    z.lazy(() => CreateDrainSourceDrains1$inboundSchema),
    z.lazy(() => CreateDrainSourceDrains2$inboundSchema),
  ]),
  filterV2: types.optional(z.lazy(() => ResponseBodyFilterV2$inboundSchema)),
  integrationIcon: types.optional(types.string()),
  integrationConfigurationUri: types.optional(types.string()),
  integrationWebsite: types.optional(types.string()),
  projectAccess: types.optional(
    z.union([
      z.lazy(() => ProjectAccess1$inboundSchema),
      z.lazy(() => ProjectAccess2$inboundSchema),
    ]),
  ),
});

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

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

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

/** @internal */
export const ResponseBodyLog$inboundSchema: z.ZodType<
  ResponseBodyLog,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const Trace$inboundSchema: z.ZodType<Trace, z.ZodTypeDef, unknown> = z
  .object({});

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

/** @internal */
export const CreateDrainResponseBodyAnalytics$inboundSchema: z.ZodType<
  CreateDrainResponseBodyAnalytics,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const CreateDrainResponseBodySpeedInsights$inboundSchema: z.ZodType<
  CreateDrainResponseBodySpeedInsights,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const AiGateway$inboundSchema: z.ZodType<
  AiGateway,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const AuditLog$inboundSchema: z.ZodType<
  AuditLog,
  z.ZodTypeDef,
  unknown
> = z.object({});

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

/** @internal */
export const ResponseBodySchemas$inboundSchema: z.ZodType<
  ResponseBodySchemas,
  z.ZodTypeDef,
  unknown
> = z.object({
  log: types.optional(z.lazy(() => ResponseBodyLog$inboundSchema)),
  trace: types.optional(z.lazy(() => Trace$inboundSchema)),
  analytics: types.optional(
    z.lazy(() => CreateDrainResponseBodyAnalytics$inboundSchema),
  ),
  speed_insights: types.optional(
    z.lazy(() => CreateDrainResponseBodySpeedInsights$inboundSchema),
  ),
  ai_gateway: types.optional(z.lazy(() => AiGateway$inboundSchema)),
  audit_log: types.optional(z.lazy(() => AuditLog$inboundSchema)),
}).transform((v) => {
  return remap$(v, {
    "speed_insights": "speedInsights",
    "ai_gateway": "aiGateway",
    "audit_log": "auditLog",
  });
});

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

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

/** @internal */
export const Delivery5$inboundSchema: z.ZodType<
  Delivery5,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("internal"),
  target: DeliveryTarget$inboundSchema,
});

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

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

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

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

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

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

/** @internal */
export const Delivery4$inboundSchema: z.ZodType<
  Delivery4,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("s3"),
  endpoint: types.string(),
  encoding:
    CreateDrainDeliveryDrainsResponse200ApplicationJSONEncoding$inboundSchema,
  compression: CreateDrainDeliveryDrainsCompression$inboundSchema,
  fileStructure: CreateDrainDeliveryDrainsFileStructure$inboundSchema,
  roleArn: types.string(),
  region: types.string(),
  serverSideEncryption: types.optional(
    CreateDrainDeliveryDrainsServerSideEncryption$inboundSchema,
  ),
  objectAcl: types.optional(CreateDrainDeliveryDrainsObjectAcl$inboundSchema),
});

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

/** @internal */
export const CreateDrainDelivery3$inboundSchema: z.ZodType<
  CreateDrainDelivery3,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("clickhouse"),
  endpoint: types.string(),
  table: types.string(),
});

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

/** @internal */
export const CreateDrainDeliveryDrainsEndpoint$inboundSchema: z.ZodType<
  CreateDrainDeliveryDrainsEndpoint,
  z.ZodTypeDef,
  unknown
> = z.object({
  traces: types.string(),
});

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

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

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

/** @internal */
export const CreateDrainSecret2$inboundSchema: z.ZodType<
  CreateDrainSecret2,
  z.ZodTypeDef,
  unknown
> = z.object({
  kind: CreateDrainSecretKind$inboundSchema,
});

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

/** @internal */
export const DeliverySecret$inboundSchema: z.ZodType<
  DeliverySecret,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => CreateDrainSecret2$inboundSchema),
  types.string(),
]);

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

/** @internal */
export const CreateDrainDelivery2$inboundSchema: z.ZodType<
  CreateDrainDelivery2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("otlphttp"),
  endpoint: z.lazy(() => CreateDrainDeliveryDrainsEndpoint$inboundSchema),
  encoding: CreateDrainDeliveryDrainsResponse200Encoding$inboundSchema,
  headers: z.record(types.string()),
  secret: types.optional(
    smartUnion([
      z.lazy(() => CreateDrainSecret2$inboundSchema),
      types.string(),
    ]),
  ),
});

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

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

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

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

/** @internal */
export const Secret2$inboundSchema: z.ZodType<Secret2, z.ZodTypeDef, unknown> =
  z.object({
    kind: SecretKind$inboundSchema,
  });

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

/** @internal */
export const Secret$inboundSchema: z.ZodType<Secret, z.ZodTypeDef, unknown> =
  smartUnion([z.lazy(() => Secret2$inboundSchema), types.string()]);

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

/** @internal */
export const CreateDrainDelivery1$inboundSchema: z.ZodType<
  CreateDrainDelivery1,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("http"),
  endpoint: types.string(),
  encoding: CreateDrainDeliveryDrainsResponseEncoding$inboundSchema,
  compression: types.optional(CreateDrainDeliveryCompression$inboundSchema),
  headers: z.record(types.string()),
  secret: types.optional(
    smartUnion([z.lazy(() => Secret2$inboundSchema), types.string()]),
  ),
});

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

/** @internal */
export const ResponseBodyDelivery$inboundSchema: z.ZodType<
  ResponseBodyDelivery,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => CreateDrainDelivery1$inboundSchema),
  z.lazy(() => CreateDrainDelivery2$inboundSchema),
  z.lazy(() => CreateDrainDelivery3$inboundSchema),
  z.lazy(() => Delivery4$inboundSchema),
  z.lazy(() => Delivery5$inboundSchema),
]);

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

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

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

/** @internal */
export const ResponseBodySampling$inboundSchema: z.ZodType<
  ResponseBodySampling,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: CreateDrainResponseBodyType$inboundSchema,
  rate: types.number(),
  env: types.optional(CreateDrainResponseBodyDrainsEnv$inboundSchema),
  requestPath: types.optional(types.string()),
});

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

/** @internal */
export const CreateDrainSource2$inboundSchema: z.ZodType<
  CreateDrainSource2,
  z.ZodTypeDef,
  unknown
> = z.object({
  kind: types.literal("integration"),
  resourceId: types.optional(types.string()),
  externalResourceId: types.optional(types.string()),
  integrationId: types.string(),
  integrationConfigurationId: types.string(),
});

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

/** @internal */
export const CreateDrainSource1$inboundSchema: z.ZodType<
  CreateDrainSource1,
  z.ZodTypeDef,
  unknown
> = z.object({
  kind: types.literal("self-served"),
});

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

/** @internal */
export const CreateDrainResponseBodySource$inboundSchema: z.ZodType<
  CreateDrainResponseBodySource,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => CreateDrainSource1$inboundSchema),
  z.lazy(() => CreateDrainSource2$inboundSchema),
]);

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

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

/** @internal */
export const CreateDrainFilter2$inboundSchema: z.ZodType<
  CreateDrainFilter2,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("odata"),
  text: types.string(),
});

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

/** @internal */
export const CreateDrainFilterDrainsProject$inboundSchema: z.ZodType<
  CreateDrainFilterDrainsProject,
  z.ZodTypeDef,
  unknown
> = z.object({
  ids: types.optional(z.array(types.string())),
});

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

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

/** @internal */
export const CreateDrainFilterDrainsLog$inboundSchema: z.ZodType<
  CreateDrainFilterDrainsLog,
  z.ZodTypeDef,
  unknown
> = z.object({
  sources: types.optional(z.array(CreateDrainFilterSources$inboundSchema)),
  legacy_excludeCachedStaticAssetLogs: types.optional(types.boolean()),
}).transform((v) => {
  return remap$(v, {
    "legacy_excludeCachedStaticAssetLogs": "legacyExcludeCachedStaticAssetLogs",
  });
});

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

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

/** @internal */
export const CreateDrainFilterDrainsDeployment$inboundSchema: z.ZodType<
  CreateDrainFilterDrainsDeployment,
  z.ZodTypeDef,
  unknown
> = z.object({
  environments: types.optional(
    z.array(CreateDrainFilterEnvironments$inboundSchema),
  ),
});

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

/** @internal */
export const CreateDrainFilter1$inboundSchema: z.ZodType<
  CreateDrainFilter1,
  z.ZodTypeDef,
  unknown
> = z.object({
  type: types.literal("basic"),
  project: types.optional(
    z.lazy(() => CreateDrainFilterDrainsProject$inboundSchema),
  ),
  log: types.optional(z.lazy(() => CreateDrainFilterDrainsLog$inboundSchema)),
  deployment: types.optional(
    z.lazy(() => CreateDrainFilterDrainsDeployment$inboundSchema),
  ),
});

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

/** @internal */
export const ResponseBodyFilter$inboundSchema: z.ZodType<
  ResponseBodyFilter,
  z.ZodTypeDef,
  unknown
> = z.union([
  z.lazy(() => CreateDrainFilter1$inboundSchema),
  z.lazy(() => CreateDrainFilter2$inboundSchema),
]);

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

/** @internal */
export const FilterV2$inboundSchema: z.ZodType<
  FilterV2,
  z.ZodTypeDef,
  unknown
> = z.object({
  version: CreateDrainResponseBodyVersion$inboundSchema,
  filter: z.union([
    z.lazy(() => CreateDrainFilter1$inboundSchema),
    z.lazy(() => CreateDrainFilter2$inboundSchema),
  ]),
});

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

/** @internal */
export const CreateDrainResponseBody1$inboundSchema: z.ZodType<
  CreateDrainResponseBody1,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  createdAt: types.number(),
  updatedAt: types.number(),
  projectIds: types.optional(z.array(types.string())),
  name: types.string(),
  teamId: z.nullable(types.string()).optional(),
  ownerId: types.string(),
  status: types.optional(CreateDrainResponseBodyStatus$inboundSchema),
  firstErrorTimestamp: types.optional(types.number()),
  disabledAt: types.optional(types.number()),
  disabledBy: types.optional(types.string()),
  disabledReason: types.optional(DisabledReason$inboundSchema),
  schemas: z.lazy(() => ResponseBodySchemas$inboundSchema),
  delivery: z.union([
    z.lazy(() => CreateDrainDelivery1$inboundSchema),
    z.lazy(() => CreateDrainDelivery2$inboundSchema),
    z.lazy(() => CreateDrainDelivery3$inboundSchema),
    z.lazy(() => Delivery4$inboundSchema),
    z.lazy(() => Delivery5$inboundSchema),
  ]),
  sampling: types.optional(
    z.array(z.lazy(() => ResponseBodySampling$inboundSchema)),
  ),
  source: z.union([
    z.lazy(() => CreateDrainSource1$inboundSchema),
    z.lazy(() => CreateDrainSource2$inboundSchema),
  ]),
  filterV2: types.optional(z.lazy(() => FilterV2$inboundSchema)),
});

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

/** @internal */
export const CreateDrainResponseBody$inboundSchema: z.ZodType<
  CreateDrainResponseBody,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.lazy(() => CreateDrainResponseBody1$inboundSchema),
  z.lazy(() => CreateDrainResponseBody2$inboundSchema),
]);

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