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

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

export const CreateStorageStoresBlobRegion = {
  Arn1: "arn1",
  Bom1: "bom1",
  Cdg1: "cdg1",
  Cle1: "cle1",
  Cpt1: "cpt1",
  Dub1: "dub1",
  Dxb1: "dxb1",
  Fra1: "fra1",
  Gru1: "gru1",
  Hkg1: "hkg1",
  Hnd1: "hnd1",
  Iad1: "iad1",
  Icn1: "icn1",
  Kix1: "kix1",
  Lhr1: "lhr1",
  Pdx1: "pdx1",
  Sfo1: "sfo1",
  Sin1: "sin1",
  Syd1: "syd1",
  Yul1: "yul1",
} as const;
export type CreateStorageStoresBlobRegion = ClosedEnum<
  typeof CreateStorageStoresBlobRegion
>;

export const CreateStorageStoresBlobAccess = {
  Public: "public",
  Private: "private",
} as const;
export type CreateStorageStoresBlobAccess = ClosedEnum<
  typeof CreateStorageStoresBlobAccess
>;

export type CreateStorageStoresBlobRequestBody = {
  name: string;
  region?: CreateStorageStoresBlobRegion | undefined;
  access?: CreateStorageStoresBlobAccess | undefined;
  projectId?: string | undefined;
};

export const CreateStorageStoresBlobFramework = {
  ActixWeb: "actix-web",
  Angular: "angular",
  Ash: "ash",
  Astro: "astro",
  Axum: "axum",
  Blitzjs: "blitzjs",
  Brunch: "brunch",
  Bun: "bun",
  Container: "container",
  CreateReactApp: "create-react-app",
  Django: "django",
  Docusaurus: "docusaurus",
  Docusaurus2: "docusaurus-2",
  Dojo: "dojo",
  Eleventy: "eleventy",
  Elysia: "elysia",
  Ember: "ember",
  Eve: "eve",
  Express: "express",
  FactoryEve: "factory-eve",
  Fastapi: "fastapi",
  Fasthtml: "fasthtml",
  Fastify: "fastify",
  Flask: "flask",
  Gatsby: "gatsby",
  Go: "go",
  Gridsome: "gridsome",
  H3: "h3",
  Hexo: "hexo",
  Hono: "hono",
  Hugo: "hugo",
  Hydrogen: "hydrogen",
  IonicAngular: "ionic-angular",
  IonicReact: "ionic-react",
  Jekyll: "jekyll",
  Koa: "koa",
  Mastra: "mastra",
  Middleman: "middleman",
  Nestjs: "nestjs",
  Nextjs: "nextjs",
  Nitro: "nitro",
  Node: "node",
  Nuxtjs: "nuxtjs",
  Parcel: "parcel",
  Polymer: "polymer",
  Preact: "preact",
  Python: "python",
  ReactRouter: "react-router",
  Redwoodjs: "redwoodjs",
  Remix: "remix",
  Ruby: "ruby",
  Rust: "rust",
  Saber: "saber",
  Sanity: "sanity",
  SanityV2: "sanity-v2",
  Sapper: "sapper",
  Scully: "scully",
  Services: "services",
  Solidstart: "solidstart",
  Solidstart1: "solidstart-1",
  Stencil: "stencil",
  Storybook: "storybook",
  Svelte: "svelte",
  Sveltekit: "sveltekit",
  Sveltekit1: "sveltekit-1",
  TanstackStart: "tanstack-start",
  TanstackStartLovable: "tanstack-start-lovable",
  Umijs: "umijs",
  Vite: "vite",
  Vitepress: "vitepress",
  Vue: "vue",
  Vuepress: "vuepress",
  Xmcp: "xmcp",
  Zola: "zola",
} as const;
export type CreateStorageStoresBlobFramework = ClosedEnum<
  typeof CreateStorageStoresBlobFramework
>;

export type CreateStorageStoresBlobActions = {
  slug: string;
  environments: Array<string>;
};

export type CreateStorageStoresBlobDeployments = {
  required: boolean;
  actions: Array<CreateStorageStoresBlobActions>;
};

export type CreateStorageStoresBlobProjectsMetadata = {
  id: string;
  projectId: string;
  name: string;
  framework?: CreateStorageStoresBlobFramework | null | undefined;
  latestDeployment?: string | undefined;
  environments: Array<string>;
  envVarPrefix: string | null;
  environmentVariables: Array<string>;
  deployments?: CreateStorageStoresBlobDeployments | undefined;
  makeEnvVarsSensitive?: boolean | undefined;
};

export const CreateStorageStoresBlobProviders2 = {
  Wildcard: "*",
} as const;
export type CreateStorageStoresBlobProviders2 = ClosedEnum<
  typeof CreateStorageStoresBlobProviders2
>;

export const CreateStorageStoresBlobProviders1 = {
  Bitbucket: "bitbucket",
  Github: "github",
  Gitlab: "gitlab",
} as const;
export type CreateStorageStoresBlobProviders1 = ClosedEnum<
  typeof CreateStorageStoresBlobProviders1
>;

export type CreateStorageStoresBlobProviders =
  | Array<CreateStorageStoresBlobProviders1>
  | CreateStorageStoresBlobProviders2;

export type CreateStorageStoresBlobGit = {
  providers:
    | Array<CreateStorageStoresBlobProviders1>
    | CreateStorageStoresBlobProviders2;
  owners?: Array<string> | undefined;
  repos?: Array<string> | undefined;
};

export type CreateStorageStoresBlobProjectFilter = {
  git?: CreateStorageStoresBlobGit | undefined;
};

export const CreateStorageStoresBlobStatus = {
  Available: "available",
  Error: "error",
  Initializing: "initializing",
  LimitsExceededSuspended: "limits-exceeded-suspended",
  LimitsExceededSuspendedStoreCount: "limits-exceeded-suspended-store-count",
  Onboarding: "onboarding",
  Suspended: "suspended",
  Uninstalled: "uninstalled",
} as const;
export type CreateStorageStoresBlobStatus = ClosedEnum<
  typeof CreateStorageStoresBlobStatus
>;

export const CreateStorageStoresBlobStorageAccess = {
  Private: "private",
  Public: "public",
} as const;
export type CreateStorageStoresBlobStorageAccess = ClosedEnum<
  typeof CreateStorageStoresBlobStorageAccess
>;

/**
 * A project-default store is a private blob store that is lazily created per-project, uses OIDC auth instead of read-write tokens, and cannot be modified through standard store mutation APIs. Undefined for legacy stores.
 */
export const CreateStorageStoresBlobKind = {
  ProjectDefault: "project-default",
  UserCreated: "user-created",
} as const;
/**
 * A project-default store is a private blob store that is lazily created per-project, uses OIDC auth instead of read-write tokens, and cannot be modified through standard store mutation APIs. Undefined for legacy stores.
 */
export type CreateStorageStoresBlobKind = ClosedEnum<
  typeof CreateStorageStoresBlobKind
>;

export const CreateStorageStoresBlobStorageRegion = {
  Arn1: "arn1",
  Bom1: "bom1",
  Cdg1: "cdg1",
  Cle1: "cle1",
  Cpt1: "cpt1",
  Dub1: "dub1",
  Dxb1: "dxb1",
  Fra1: "fra1",
  Gru1: "gru1",
  Hkg1: "hkg1",
  Hnd1: "hnd1",
  Iad1: "iad1",
  Icn1: "icn1",
  Kix1: "kix1",
  Lhr1: "lhr1",
  Pdx1: "pdx1",
  Sfo1: "sfo1",
  Sin1: "sin1",
  Syd1: "syd1",
  Yul1: "yul1",
} as const;
export type CreateStorageStoresBlobStorageRegion = ClosedEnum<
  typeof CreateStorageStoresBlobStorageRegion
>;

export type CreateStorageStoresBlobStore = {
  projectsMetadata: Array<CreateStorageStoresBlobProjectsMetadata>;
  projectFilter?: CreateStorageStoresBlobProjectFilter | undefined;
  totalConnectedProjects?: number | undefined;
  usageQuotaExceeded: boolean;
  status: CreateStorageStoresBlobStatus | null;
  access?: CreateStorageStoresBlobStorageAccess | undefined;
  /**
   * A project-default store is a private blob store that is lazily created per-project, uses OIDC auth instead of read-write tokens, and cannot be modified through standard store mutation APIs. Undefined for legacy stores.
   */
  kind?: CreateStorageStoresBlobKind | undefined;
  /**
   * The project this store is scoped to. Set for project-default stores and user-created stores with enforced project association.
   */
  projectId?: string | undefined;
  size: number;
  count: number;
  region: CreateStorageStoresBlobStorageRegion;
  isTokenExpired: boolean;
};

export type CreateStorageStoresBlobResponseBody = {
  store: CreateStorageStoresBlobStore | null;
};

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

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

/** @internal */
export type CreateStorageStoresBlobRequestBody$Outbound = {
  name: string;
  region?: string | undefined;
  access: string;
  projectId?: string | undefined;
};

/** @internal */
export const CreateStorageStoresBlobRequestBody$outboundSchema: z.ZodType<
  CreateStorageStoresBlobRequestBody$Outbound,
  z.ZodTypeDef,
  CreateStorageStoresBlobRequestBody
> = z.object({
  name: z.string(),
  region: CreateStorageStoresBlobRegion$outboundSchema.optional(),
  access: CreateStorageStoresBlobAccess$outboundSchema.default("public"),
  projectId: z.string().optional(),
});

export function createStorageStoresBlobRequestBodyToJSON(
  createStorageStoresBlobRequestBody: CreateStorageStoresBlobRequestBody,
): string {
  return JSON.stringify(
    CreateStorageStoresBlobRequestBody$outboundSchema.parse(
      createStorageStoresBlobRequestBody,
    ),
  );
}

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

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

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

/** @internal */
export const CreateStorageStoresBlobDeployments$inboundSchema: z.ZodType<
  CreateStorageStoresBlobDeployments,
  z.ZodTypeDef,
  unknown
> = z.object({
  required: types.boolean(),
  actions: z.array(z.lazy(() => CreateStorageStoresBlobActions$inboundSchema)),
});

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

/** @internal */
export const CreateStorageStoresBlobProjectsMetadata$inboundSchema: z.ZodType<
  CreateStorageStoresBlobProjectsMetadata,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  projectId: types.string(),
  name: types.string(),
  framework: z.nullable(CreateStorageStoresBlobFramework$inboundSchema)
    .optional(),
  latestDeployment: types.optional(types.string()),
  environments: z.array(types.string()),
  envVarPrefix: types.nullable(types.string()),
  environmentVariables: z.array(types.string()),
  deployments: types.optional(
    z.lazy(() => CreateStorageStoresBlobDeployments$inboundSchema),
  ),
  makeEnvVarsSensitive: types.optional(types.boolean()),
});

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

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

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

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

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

/** @internal */
export const CreateStorageStoresBlobGit$inboundSchema: z.ZodType<
  CreateStorageStoresBlobGit,
  z.ZodTypeDef,
  unknown
> = z.object({
  providers: smartUnion([
    z.array(CreateStorageStoresBlobProviders1$inboundSchema),
    CreateStorageStoresBlobProviders2$inboundSchema,
  ]),
  owners: types.optional(z.array(types.string())),
  repos: types.optional(z.array(types.string())),
});

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

/** @internal */
export const CreateStorageStoresBlobProjectFilter$inboundSchema: z.ZodType<
  CreateStorageStoresBlobProjectFilter,
  z.ZodTypeDef,
  unknown
> = z.object({
  git: types.optional(z.lazy(() => CreateStorageStoresBlobGit$inboundSchema)),
});

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

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

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

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

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

/** @internal */
export const CreateStorageStoresBlobStore$inboundSchema: z.ZodType<
  CreateStorageStoresBlobStore,
  z.ZodTypeDef,
  unknown
> = z.object({
  projectsMetadata: z.array(
    z.lazy(() => CreateStorageStoresBlobProjectsMetadata$inboundSchema),
  ),
  projectFilter: types.optional(
    z.lazy(() => CreateStorageStoresBlobProjectFilter$inboundSchema),
  ),
  totalConnectedProjects: types.optional(types.number()),
  usageQuotaExceeded: types.boolean(),
  status: types.nullable(CreateStorageStoresBlobStatus$inboundSchema),
  access: types.optional(CreateStorageStoresBlobStorageAccess$inboundSchema),
  kind: types.optional(CreateStorageStoresBlobKind$inboundSchema),
  projectId: types.optional(types.string()),
  size: types.number(),
  count: types.number(),
  region: CreateStorageStoresBlobStorageRegion$inboundSchema,
  isTokenExpired: types.boolean(),
});

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

/** @internal */
export const CreateStorageStoresBlobResponseBody$inboundSchema: z.ZodType<
  CreateStorageStoresBlobResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  store: types.nullable(
    z.lazy(() => CreateStorageStoresBlobStore$inboundSchema),
  ),
});

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