/*
 * 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 type CreateSharedEnvVariableRequestBodyEvs = {
  /**
   * The name of the Shared Environment Variable
   */
  key: string;
  /**
   * The value of the Shared Environment Variable
   */
  value: string;
  /**
   * A comment to add context on what this Shared Environment Variable is for
   */
  comment?: string | undefined;
};

/**
 * The type of environment variable
 */
export const CreateSharedEnvVariableRequestBodyEnvironmentRequestType = {
  Encrypted: "encrypted",
  Sensitive: "sensitive",
} as const;
/**
 * The type of environment variable
 */
export type CreateSharedEnvVariableRequestBodyEnvironmentRequestType =
  ClosedEnum<typeof CreateSharedEnvVariableRequestBodyEnvironmentRequestType>;

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

export type CreateSharedEnvVariableRequestBody3 = {
  evs: Array<CreateSharedEnvVariableRequestBodyEvs>;
  /**
   * The type of environment variable
   */
  type?: CreateSharedEnvVariableRequestBodyEnvironmentRequestType | undefined;
  /**
   * The target environment of the Shared Environment Variable
   */
  target?:
    | Array<CreateSharedEnvVariableRequestBodyEnvironmentTarget>
    | undefined;
  /**
   * Associate a Shared Environment Variable to projects.
   *
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  projectId?: Array<string> | undefined;
};

export type RequestBodyEvs = {
  /**
   * The name of the Shared Environment Variable
   */
  key: string;
  /**
   * The value of the Shared Environment Variable
   */
  value: string;
  /**
   * A comment to add context on what this Shared Environment Variable is for
   */
  comment?: string | undefined;
};

/**
 * The type of environment variable
 */
export const CreateSharedEnvVariableRequestBodyEnvironmentType = {
  Encrypted: "encrypted",
  Sensitive: "sensitive",
} as const;
/**
 * The type of environment variable
 */
export type CreateSharedEnvVariableRequestBodyEnvironmentType = ClosedEnum<
  typeof CreateSharedEnvVariableRequestBodyEnvironmentType
>;

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

export type CreateSharedEnvVariableRequestBody2 = {
  evs: Array<RequestBodyEvs>;
  /**
   * The type of environment variable
   */
  type?: CreateSharedEnvVariableRequestBodyEnvironmentType | undefined;
  /**
   * The target environment of the Shared Environment Variable
   */
  target?: Array<CreateSharedEnvVariableRequestBodyTarget> | undefined;
  /**
   * Associate a Shared Environment Variable to projects.
   *
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  projectId?: Array<string> | undefined;
};

export type Evs = {
  /**
   * The name of the Shared Environment Variable
   */
  key: string;
  /**
   * The value of the Shared Environment Variable
   */
  value: string;
  /**
   * A comment to add context on what this Shared Environment Variable is for
   */
  comment?: string | undefined;
};

/**
 * The type of environment variable
 */
export const CreateSharedEnvVariableRequestBodyType = {
  Encrypted: "encrypted",
  Sensitive: "sensitive",
} as const;
/**
 * The type of environment variable
 */
export type CreateSharedEnvVariableRequestBodyType = ClosedEnum<
  typeof CreateSharedEnvVariableRequestBodyType
>;

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

export type CreateSharedEnvVariableRequestBody1 = {
  evs: Array<Evs>;
  /**
   * The type of environment variable
   */
  type?: CreateSharedEnvVariableRequestBodyType | undefined;
  /**
   * The target environment of the Shared Environment Variable
   */
  target: Array<RequestBodyTarget>;
  /**
   * Associate a Shared Environment Variable to projects.
   *
   * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
   */
  projectId?: Array<string> | undefined;
};

export type CreateSharedEnvVariableRequestBody =
  | CreateSharedEnvVariableRequestBody1
  | CreateSharedEnvVariableRequestBody2
  | CreateSharedEnvVariableRequestBody3;

export type CreateSharedEnvVariableRequest = {
  /**
   * 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?:
    | CreateSharedEnvVariableRequestBody1
    | CreateSharedEnvVariableRequestBody2
    | CreateSharedEnvVariableRequestBody3
    | undefined;
};

/**
 * The type of this cosmos doc instance, if blank, assume secret.
 */
export const CreateSharedEnvVariableType = {
  Encrypted: "encrypted",
  Plain: "plain",
  Sensitive: "sensitive",
  System: "system",
} as const;
/**
 * The type of this cosmos doc instance, if blank, assume secret.
 */
export type CreateSharedEnvVariableType = ClosedEnum<
  typeof CreateSharedEnvVariableType
>;

/**
 * environments this env variable targets
 */
export const CreateSharedEnvVariableTarget = {
  Development: "development",
  Preview: "preview",
  Production: "production",
} as const;
/**
 * environments this env variable targets
 */
export type CreateSharedEnvVariableTarget = ClosedEnum<
  typeof CreateSharedEnvVariableTarget
>;

export type Created = {
  /**
   * The date when the Shared Env Var was created.
   */
  created?: Date | undefined;
  /**
   * The name of the Shared Env Var.
   */
  key?: string | undefined;
  /**
   * The unique identifier of the owner (team) the Shared Env Var was created for.
   */
  ownerId?: string | null | undefined;
  /**
   * The unique identifier of the Shared Env Var.
   */
  id?: string | undefined;
  /**
   * The unique identifier of the user who created the Shared Env Var.
   */
  createdBy?: string | null | undefined;
  /**
   * The unique identifier of the user who deleted the Shared Env Var.
   */
  deletedBy?: string | null | undefined;
  /**
   * The unique identifier of the user who last updated the Shared Env Var.
   */
  updatedBy?: string | null | undefined;
  /**
   * Timestamp for when the Shared Env Var was created.
   */
  createdAt?: number | undefined;
  /**
   * Timestamp for when the Shared Env Var was (soft) deleted.
   */
  deletedAt?: number | undefined;
  /**
   * Timestamp for when the Shared Env Var was last updated.
   */
  updatedAt?: number | undefined;
  /**
   * The value of the Shared Env Var.
   */
  value?: string | undefined;
  /**
   * The unique identifiers of the projects which the Shared Env Var is linked to.
   */
  projectId?: Array<string> | undefined;
  /**
   * The type of this cosmos doc instance, if blank, assume secret.
   */
  type?: CreateSharedEnvVariableType | undefined;
  /**
   * environments this env variable targets
   */
  target?: Array<CreateSharedEnvVariableTarget> | undefined;
  /**
   * whether or not this env varible applies to custom environments
   */
  applyToAllCustomEnvironments?: boolean | undefined;
  /**
   * The custom environment IDs that this Shared Env Var is scoped to.
   */
  customEnvironmentIds?: Array<string> | undefined;
  /**
   * whether or not this env variable is decrypted
   */
  decrypted?: boolean | undefined;
  /**
   * A user provided comment that describes what this Shared Env Var is for.
   */
  comment?: string | undefined;
  /**
   * The last editor full name or username.
   */
  lastEditedByDisplayName?: string | undefined;
};

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

export type CreateSharedEnvVariableValue = string | Array<Value2>;

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

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

export type CreateSharedEnvVariableEnvironmentTarget =
  | Array<CreateSharedEnvVariableTarget1>
  | CreateSharedEnvVariableTarget2;

export type CreateSharedEnvVariableError = {
  code: string;
  message: string;
  key?: string | undefined;
  envVarId?: string | undefined;
  envVarKey?: string | undefined;
  action?: string | undefined;
  link?: string | undefined;
  value?: string | Array<Value2> | undefined;
  gitBranch?: string | undefined;
  target?:
    | Array<CreateSharedEnvVariableTarget1>
    | CreateSharedEnvVariableTarget2
    | undefined;
  project?: string | undefined;
};

export type Failed = {
  error: CreateSharedEnvVariableError;
};

export type CreateSharedEnvVariableResponseBody = {
  created: Array<Created>;
  failed: Array<Failed>;
};

/** @internal */
export type CreateSharedEnvVariableRequestBodyEvs$Outbound = {
  key: string;
  value: string;
  comment?: string | undefined;
};

/** @internal */
export const CreateSharedEnvVariableRequestBodyEvs$outboundSchema: z.ZodType<
  CreateSharedEnvVariableRequestBodyEvs$Outbound,
  z.ZodTypeDef,
  CreateSharedEnvVariableRequestBodyEvs
> = z.object({
  key: z.string(),
  value: z.string(),
  comment: z.string().optional(),
});

export function createSharedEnvVariableRequestBodyEvsToJSON(
  createSharedEnvVariableRequestBodyEvs: CreateSharedEnvVariableRequestBodyEvs,
): string {
  return JSON.stringify(
    CreateSharedEnvVariableRequestBodyEvs$outboundSchema.parse(
      createSharedEnvVariableRequestBodyEvs,
    ),
  );
}

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

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

/** @internal */
export type CreateSharedEnvVariableRequestBody3$Outbound = {
  evs: Array<CreateSharedEnvVariableRequestBodyEvs$Outbound>;
  type?: string | undefined;
  target?: Array<string> | undefined;
  projectId?: Array<string> | undefined;
};

/** @internal */
export const CreateSharedEnvVariableRequestBody3$outboundSchema: z.ZodType<
  CreateSharedEnvVariableRequestBody3$Outbound,
  z.ZodTypeDef,
  CreateSharedEnvVariableRequestBody3
> = z.object({
  evs: z.array(
    z.lazy(() => CreateSharedEnvVariableRequestBodyEvs$outboundSchema),
  ),
  type: CreateSharedEnvVariableRequestBodyEnvironmentRequestType$outboundSchema
    .optional(),
  target: z.array(
    CreateSharedEnvVariableRequestBodyEnvironmentTarget$outboundSchema,
  ).optional(),
  projectId: z.array(z.string()).optional(),
});

export function createSharedEnvVariableRequestBody3ToJSON(
  createSharedEnvVariableRequestBody3: CreateSharedEnvVariableRequestBody3,
): string {
  return JSON.stringify(
    CreateSharedEnvVariableRequestBody3$outboundSchema.parse(
      createSharedEnvVariableRequestBody3,
    ),
  );
}

/** @internal */
export type RequestBodyEvs$Outbound = {
  key: string;
  value: string;
  comment?: string | undefined;
};

/** @internal */
export const RequestBodyEvs$outboundSchema: z.ZodType<
  RequestBodyEvs$Outbound,
  z.ZodTypeDef,
  RequestBodyEvs
> = z.object({
  key: z.string(),
  value: z.string(),
  comment: z.string().optional(),
});

export function requestBodyEvsToJSON(requestBodyEvs: RequestBodyEvs): string {
  return JSON.stringify(RequestBodyEvs$outboundSchema.parse(requestBodyEvs));
}

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

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

/** @internal */
export type CreateSharedEnvVariableRequestBody2$Outbound = {
  evs: Array<RequestBodyEvs$Outbound>;
  type?: string | undefined;
  target?: Array<string> | undefined;
  projectId?: Array<string> | undefined;
};

/** @internal */
export const CreateSharedEnvVariableRequestBody2$outboundSchema: z.ZodType<
  CreateSharedEnvVariableRequestBody2$Outbound,
  z.ZodTypeDef,
  CreateSharedEnvVariableRequestBody2
> = z.object({
  evs: z.array(z.lazy(() => RequestBodyEvs$outboundSchema)),
  type: CreateSharedEnvVariableRequestBodyEnvironmentType$outboundSchema
    .optional(),
  target: z.array(CreateSharedEnvVariableRequestBodyTarget$outboundSchema)
    .optional(),
  projectId: z.array(z.string()).optional(),
});

export function createSharedEnvVariableRequestBody2ToJSON(
  createSharedEnvVariableRequestBody2: CreateSharedEnvVariableRequestBody2,
): string {
  return JSON.stringify(
    CreateSharedEnvVariableRequestBody2$outboundSchema.parse(
      createSharedEnvVariableRequestBody2,
    ),
  );
}

/** @internal */
export type Evs$Outbound = {
  key: string;
  value: string;
  comment?: string | undefined;
};

/** @internal */
export const Evs$outboundSchema: z.ZodType<Evs$Outbound, z.ZodTypeDef, Evs> = z
  .object({
    key: z.string(),
    value: z.string(),
    comment: z.string().optional(),
  });

export function evsToJSON(evs: Evs): string {
  return JSON.stringify(Evs$outboundSchema.parse(evs));
}

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

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

/** @internal */
export type CreateSharedEnvVariableRequestBody1$Outbound = {
  evs: Array<Evs$Outbound>;
  type?: string | undefined;
  target: Array<string>;
  projectId?: Array<string> | undefined;
};

/** @internal */
export const CreateSharedEnvVariableRequestBody1$outboundSchema: z.ZodType<
  CreateSharedEnvVariableRequestBody1$Outbound,
  z.ZodTypeDef,
  CreateSharedEnvVariableRequestBody1
> = z.object({
  evs: z.array(z.lazy(() => Evs$outboundSchema)),
  type: CreateSharedEnvVariableRequestBodyType$outboundSchema.optional(),
  target: z.array(RequestBodyTarget$outboundSchema),
  projectId: z.array(z.string()).optional(),
});

export function createSharedEnvVariableRequestBody1ToJSON(
  createSharedEnvVariableRequestBody1: CreateSharedEnvVariableRequestBody1,
): string {
  return JSON.stringify(
    CreateSharedEnvVariableRequestBody1$outboundSchema.parse(
      createSharedEnvVariableRequestBody1,
    ),
  );
}

/** @internal */
export type CreateSharedEnvVariableRequestBody$Outbound =
  | CreateSharedEnvVariableRequestBody1$Outbound
  | CreateSharedEnvVariableRequestBody2$Outbound
  | CreateSharedEnvVariableRequestBody3$Outbound;

/** @internal */
export const CreateSharedEnvVariableRequestBody$outboundSchema: z.ZodType<
  CreateSharedEnvVariableRequestBody$Outbound,
  z.ZodTypeDef,
  CreateSharedEnvVariableRequestBody
> = smartUnion([
  z.lazy(() => CreateSharedEnvVariableRequestBody1$outboundSchema),
  z.lazy(() => CreateSharedEnvVariableRequestBody2$outboundSchema),
  z.lazy(() => CreateSharedEnvVariableRequestBody3$outboundSchema),
]);

export function createSharedEnvVariableRequestBodyToJSON(
  createSharedEnvVariableRequestBody: CreateSharedEnvVariableRequestBody,
): string {
  return JSON.stringify(
    CreateSharedEnvVariableRequestBody$outboundSchema.parse(
      createSharedEnvVariableRequestBody,
    ),
  );
}

/** @internal */
export type CreateSharedEnvVariableRequest$Outbound = {
  teamId?: string | undefined;
  slug?: string | undefined;
  RequestBody?:
    | CreateSharedEnvVariableRequestBody1$Outbound
    | CreateSharedEnvVariableRequestBody2$Outbound
    | CreateSharedEnvVariableRequestBody3$Outbound
    | undefined;
};

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

export function createSharedEnvVariableRequestToJSON(
  createSharedEnvVariableRequest: CreateSharedEnvVariableRequest,
): string {
  return JSON.stringify(
    CreateSharedEnvVariableRequest$outboundSchema.parse(
      createSharedEnvVariableRequest,
    ),
  );
}

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

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

/** @internal */
export const Created$inboundSchema: z.ZodType<Created, z.ZodTypeDef, unknown> =
  z.object({
    created: types.optional(types.date()),
    key: types.optional(types.string()),
    ownerId: z.nullable(types.string()).optional(),
    id: types.optional(types.string()),
    createdBy: z.nullable(types.string()).optional(),
    deletedBy: z.nullable(types.string()).optional(),
    updatedBy: z.nullable(types.string()).optional(),
    createdAt: types.optional(types.number()),
    deletedAt: types.optional(types.number()),
    updatedAt: types.optional(types.number()),
    value: types.optional(types.string()),
    projectId: types.optional(z.array(types.string())),
    type: types.optional(CreateSharedEnvVariableType$inboundSchema),
    target: types.optional(
      z.array(CreateSharedEnvVariableTarget$inboundSchema),
    ),
    applyToAllCustomEnvironments: types.optional(types.boolean()),
    customEnvironmentIds: types.optional(z.array(types.string())),
    decrypted: types.optional(types.boolean()),
    comment: types.optional(types.string()),
    lastEditedByDisplayName: types.optional(types.string()),
  });

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

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

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

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

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

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

/** @internal */
export const CreateSharedEnvVariableEnvironmentTarget$inboundSchema: z.ZodType<
  CreateSharedEnvVariableEnvironmentTarget,
  z.ZodTypeDef,
  unknown
> = smartUnion([
  z.array(CreateSharedEnvVariableTarget1$inboundSchema),
  CreateSharedEnvVariableTarget2$inboundSchema,
]);

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

/** @internal */
export const CreateSharedEnvVariableError$inboundSchema: z.ZodType<
  CreateSharedEnvVariableError,
  z.ZodTypeDef,
  unknown
> = z.object({
  code: types.string(),
  message: types.string(),
  key: types.optional(types.string()),
  envVarId: types.optional(types.string()),
  envVarKey: types.optional(types.string()),
  action: types.optional(types.string()),
  link: types.optional(types.string()),
  value: types.optional(
    smartUnion([types.string(), z.array(Value2$inboundSchema)]),
  ),
  gitBranch: types.optional(types.string()),
  target: types.optional(
    smartUnion([
      z.array(CreateSharedEnvVariableTarget1$inboundSchema),
      CreateSharedEnvVariableTarget2$inboundSchema,
    ]),
  ),
  project: types.optional(types.string()),
});

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

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

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

/** @internal */
export const CreateSharedEnvVariableResponseBody$inboundSchema: z.ZodType<
  CreateSharedEnvVariableResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  created: z.array(z.lazy(() => Created$inboundSchema)),
  failed: z.array(z.lazy(() => Failed$inboundSchema)),
});

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