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

export type UnlinkSharedEnvVariableRequest = {
  /**
   * The unique ID for the Shared Environment Variable to unlink from the project.
   */
  id: string;
  projectId: string;
  /**
   * 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 UnlinkSharedEnvVariableResponseBody = {
  id: string;
};

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

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

export function unlinkSharedEnvVariableRequestToJSON(
  unlinkSharedEnvVariableRequest: UnlinkSharedEnvVariableRequest,
): string {
  return JSON.stringify(
    UnlinkSharedEnvVariableRequest$outboundSchema.parse(
      unlinkSharedEnvVariableRequest,
    ),
  );
}

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

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