/*
 * 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 { SDKValidationError } from "./sdkvalidationerror.js";

export type DeleteDeploymentRequest = {
  /**
   * The ID of the deployment to be deleted
   */
  id: string;
  /**
   * A Deployment or Alias URL. In case it is passed, the ID will be ignored
   */
  url?: string | 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;
};

/**
 * A constant with the final state of the deployment.
 */
export const DeleteDeploymentState = {
  Deleted: "DELETED",
} as const;
/**
 * A constant with the final state of the deployment.
 */
export type DeleteDeploymentState = ClosedEnum<typeof DeleteDeploymentState>;

/**
 * The deployment was successfully deleted
 */
export type DeleteDeploymentResponseBody = {
  /**
   * The removed deployment ID.
   */
  uid: string;
  /**
   * A constant with the final state of the deployment.
   */
  state: DeleteDeploymentState;
};

/** @internal */
export type DeleteDeploymentRequest$Outbound = {
  id: string;
  url?: string | undefined;
  teamId?: string | undefined;
  slug?: string | undefined;
};

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

export function deleteDeploymentRequestToJSON(
  deleteDeploymentRequest: DeleteDeploymentRequest,
): string {
  return JSON.stringify(
    DeleteDeploymentRequest$outboundSchema.parse(deleteDeploymentRequest),
  );
}

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

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

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