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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { smartUnion } from "../../types/smartUnion.js";
import * as components from "../components/index.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type ConnectorListToolsV1Request = {
  page?: number | undefined;
  pageSize?: number | undefined;
  refresh?: boolean | undefined;
  /**
   * Return a simplified payload with only name, description, annotations, and a compact inputSchema.
   */
  pretty?: boolean | undefined;
  credentialsName?: string | null | undefined;
  connectorIdOrName: string;
};

/**
 * Successful Response
 */
export type ResponseConnectorListToolsV1 =
  | Array<components.ConnectorTool>
  | Array<components.MCPTool>
  | Array<{ [k: string]: any }>;

/** @internal */
export type ConnectorListToolsV1Request$Outbound = {
  page: number;
  page_size: number;
  refresh: boolean;
  pretty: boolean;
  credentials_name?: string | null | undefined;
  connector_id_or_name: string;
};

/** @internal */
export const ConnectorListToolsV1Request$outboundSchema: z.ZodType<
  ConnectorListToolsV1Request$Outbound,
  ConnectorListToolsV1Request
> = z.object({
  page: z.int().default(1),
  pageSize: z.int().default(100),
  refresh: z.boolean().default(false),
  pretty: z.boolean().default(false),
  credentialsName: z.nullable(z.string()).optional(),
  connectorIdOrName: z.string(),
}).transform((v) => {
  return remap$(v, {
    pageSize: "page_size",
    credentialsName: "credentials_name",
    connectorIdOrName: "connector_id_or_name",
  });
});

export function connectorListToolsV1RequestToJSON(
  connectorListToolsV1Request: ConnectorListToolsV1Request,
): string {
  return JSON.stringify(
    ConnectorListToolsV1Request$outboundSchema.parse(
      connectorListToolsV1Request,
    ),
  );
}

/** @internal */
export const ResponseConnectorListToolsV1$inboundSchema: z.ZodType<
  ResponseConnectorListToolsV1,
  unknown
> = smartUnion([
  z.array(components.ConnectorTool$inboundSchema),
  z.array(components.MCPTool$inboundSchema),
  z.array(z.record(z.string(), z.any())),
]);

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