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

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { smartUnion } from "../types/smartUnion.js";
import { Pagination, Pagination$inboundSchema } from "./pagination.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type ListPromoteAliasesRequest = {
  projectId: string;
  /**
   * Maximum number of aliases to list from a request (max 100).
   */
  limit?: number | undefined;
  /**
   * Get aliases created after this epoch timestamp.
   */
  since?: number | undefined;
  /**
   * Get aliases created before this epoch timestamp.
   */
  until?: number | undefined;
  /**
   * Filter results down to aliases that failed to map to the requested deployment
   */
  failedOnly?: boolean | undefined;
  /**
   * 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;
};

export type ResponseBodyAliases = {
  status: string;
  alias: string;
  id: string;
};

export type ListPromoteAliasesResponseBody2 = {
  aliases: Array<ResponseBodyAliases>;
  /**
   * This object contains information related to the pagination of the current request, including the necessary parameters to get the next or previous page of data.
   */
  pagination: Pagination;
};

export type ListPromoteAliasesResponseBody1 = {};

export type ListPromoteAliasesResponseBody =
  | ListPromoteAliasesResponseBody2
  | ListPromoteAliasesResponseBody1;

/** @internal */
export type ListPromoteAliasesRequest$Outbound = {
  projectId: string;
  limit?: number | undefined;
  since?: number | undefined;
  until?: number | undefined;
  failedOnly?: boolean | undefined;
  teamId?: string | undefined;
  slug?: string | undefined;
};

/** @internal */
export const ListPromoteAliasesRequest$outboundSchema: z.ZodType<
  ListPromoteAliasesRequest$Outbound,
  z.ZodTypeDef,
  ListPromoteAliasesRequest
> = z.object({
  projectId: z.string(),
  limit: z.number().optional(),
  since: z.number().optional(),
  until: z.number().optional(),
  failedOnly: z.boolean().optional(),
  teamId: z.string().optional(),
  slug: z.string().optional(),
});

export function listPromoteAliasesRequestToJSON(
  listPromoteAliasesRequest: ListPromoteAliasesRequest,
): string {
  return JSON.stringify(
    ListPromoteAliasesRequest$outboundSchema.parse(listPromoteAliasesRequest),
  );
}

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

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

/** @internal */
export const ListPromoteAliasesResponseBody2$inboundSchema: z.ZodType<
  ListPromoteAliasesResponseBody2,
  z.ZodTypeDef,
  unknown
> = z.object({
  aliases: z.array(z.lazy(() => ResponseBodyAliases$inboundSchema)),
  pagination: Pagination$inboundSchema,
});

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

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

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

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

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