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

import * as z from "zod";
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 {
  SelectOption,
  SelectOption$inboundSchema,
  SelectOption$Outbound,
  SelectOption$outboundSchema,
} from "../components/selectoption.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * Whether the attribute is on an object or a list.
 */
export const GetV2TargetIdentifierAttributesAttributeOptionsTarget = {
  Objects: "objects",
  Lists: "lists",
} as const;
/**
 * Whether the attribute is on an object or a list.
 */
export type GetV2TargetIdentifierAttributesAttributeOptionsTarget = ClosedEnum<
  typeof GetV2TargetIdentifierAttributesAttributeOptionsTarget
>;

export type GetV2TargetIdentifierAttributesAttributeOptionsRequest = {
  /**
   * Whether the attribute is on an object or a list.
   */
  target: GetV2TargetIdentifierAttributesAttributeOptionsTarget;
  identifier: string;
  attribute: string;
  showArchived?: boolean | undefined;
};

/**
 * Success
 */
export type GetV2TargetIdentifierAttributesAttributeOptionsResponse = {
  data: Array<SelectOption>;
};

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

/** @internal */
export const GetV2TargetIdentifierAttributesAttributeOptionsTarget$outboundSchema:
  z.ZodNativeEnum<
    typeof GetV2TargetIdentifierAttributesAttributeOptionsTarget
  > = GetV2TargetIdentifierAttributesAttributeOptionsTarget$inboundSchema;

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetV2TargetIdentifierAttributesAttributeOptionsTarget$ {
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsTarget$inboundSchema` instead. */
  export const inboundSchema =
    GetV2TargetIdentifierAttributesAttributeOptionsTarget$inboundSchema;
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsTarget$outboundSchema` instead. */
  export const outboundSchema =
    GetV2TargetIdentifierAttributesAttributeOptionsTarget$outboundSchema;
}

/** @internal */
export const GetV2TargetIdentifierAttributesAttributeOptionsRequest$inboundSchema:
  z.ZodType<
    GetV2TargetIdentifierAttributesAttributeOptionsRequest,
    z.ZodTypeDef,
    unknown
  > = z.object({
    target: GetV2TargetIdentifierAttributesAttributeOptionsTarget$inboundSchema,
    identifier: z.string(),
    attribute: z.string(),
    show_archived: z.boolean().optional(),
  }).transform((v) => {
    return remap$(v, {
      "show_archived": "showArchived",
    });
  });

/** @internal */
export type GetV2TargetIdentifierAttributesAttributeOptionsRequest$Outbound = {
  target: string;
  identifier: string;
  attribute: string;
  show_archived?: boolean | undefined;
};

/** @internal */
export const GetV2TargetIdentifierAttributesAttributeOptionsRequest$outboundSchema:
  z.ZodType<
    GetV2TargetIdentifierAttributesAttributeOptionsRequest$Outbound,
    z.ZodTypeDef,
    GetV2TargetIdentifierAttributesAttributeOptionsRequest
  > = z.object({
    target:
      GetV2TargetIdentifierAttributesAttributeOptionsTarget$outboundSchema,
    identifier: z.string(),
    attribute: z.string(),
    showArchived: z.boolean().optional(),
  }).transform((v) => {
    return remap$(v, {
      showArchived: "show_archived",
    });
  });

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetV2TargetIdentifierAttributesAttributeOptionsRequest$ {
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsRequest$inboundSchema` instead. */
  export const inboundSchema =
    GetV2TargetIdentifierAttributesAttributeOptionsRequest$inboundSchema;
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsRequest$outboundSchema` instead. */
  export const outboundSchema =
    GetV2TargetIdentifierAttributesAttributeOptionsRequest$outboundSchema;
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsRequest$Outbound` instead. */
  export type Outbound =
    GetV2TargetIdentifierAttributesAttributeOptionsRequest$Outbound;
}

export function getV2TargetIdentifierAttributesAttributeOptionsRequestToJSON(
  getV2TargetIdentifierAttributesAttributeOptionsRequest:
    GetV2TargetIdentifierAttributesAttributeOptionsRequest,
): string {
  return JSON.stringify(
    GetV2TargetIdentifierAttributesAttributeOptionsRequest$outboundSchema.parse(
      getV2TargetIdentifierAttributesAttributeOptionsRequest,
    ),
  );
}

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

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

/** @internal */
export type GetV2TargetIdentifierAttributesAttributeOptionsResponse$Outbound = {
  data: Array<SelectOption$Outbound>;
};

/** @internal */
export const GetV2TargetIdentifierAttributesAttributeOptionsResponse$outboundSchema:
  z.ZodType<
    GetV2TargetIdentifierAttributesAttributeOptionsResponse$Outbound,
    z.ZodTypeDef,
    GetV2TargetIdentifierAttributesAttributeOptionsResponse
  > = z.object({
    data: z.array(SelectOption$outboundSchema),
  });

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace GetV2TargetIdentifierAttributesAttributeOptionsResponse$ {
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsResponse$inboundSchema` instead. */
  export const inboundSchema =
    GetV2TargetIdentifierAttributesAttributeOptionsResponse$inboundSchema;
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsResponse$outboundSchema` instead. */
  export const outboundSchema =
    GetV2TargetIdentifierAttributesAttributeOptionsResponse$outboundSchema;
  /** @deprecated use `GetV2TargetIdentifierAttributesAttributeOptionsResponse$Outbound` instead. */
  export type Outbound =
    GetV2TargetIdentifierAttributesAttributeOptionsResponse$Outbound;
}

export function getV2TargetIdentifierAttributesAttributeOptionsResponseToJSON(
  getV2TargetIdentifierAttributesAttributeOptionsResponse:
    GetV2TargetIdentifierAttributesAttributeOptionsResponse,
): string {
  return JSON.stringify(
    GetV2TargetIdentifierAttributesAttributeOptionsResponse$outboundSchema
      .parse(getV2TargetIdentifierAttributesAttributeOptionsResponse),
  );
}

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