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

import * as z from "zod";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type CancelWorkflowInstanceRequest = {
  /**
   * The unique identifier of the account.
   */
  accountId: string;
  /**
   * The unique identifier of the workflow.
   */
  workflowId: string;
  /**
   * Unique identifier for the workflow instance
   */
  instanceId: string;
};

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

/** @internal */
export type CancelWorkflowInstanceRequest$Outbound = {
  accountId: string;
  workflowId: string;
  instanceId: string;
};

/** @internal */
export const CancelWorkflowInstanceRequest$outboundSchema: z.ZodType<
  CancelWorkflowInstanceRequest$Outbound,
  z.ZodTypeDef,
  CancelWorkflowInstanceRequest
> = z.object({
  accountId: z.string(),
  workflowId: z.string(),
  instanceId: z.string(),
});

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

export function cancelWorkflowInstanceRequestToJSON(
  cancelWorkflowInstanceRequest: CancelWorkflowInstanceRequest,
): string {
  return JSON.stringify(
    CancelWorkflowInstanceRequest$outboundSchema.parse(
      cancelWorkflowInstanceRequest,
    ),
  );
}

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