// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; import * as Core from '../../core'; import * as FlowRunsAPI from './flow-runs'; import * as Shared from '../shared'; export class FlowRuns extends APIResource { /** * Create a flow run from a deployment. * * Any parameters not provided will be inferred from the deployment's parameters. * If tags are not provided, the deployment's tags will be used. * * If no state is provided, the flow run will be created in a SCHEDULED state. */ createFlowRun( id: string, params: FlowRunCreateFlowRunParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post(`/api/deployments/${id}/create_flow_run`, { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export interface FlowRunCreateFlowRunParams { /** * Body param: */ context?: unknown; /** * Body param: The empirical policy for the flow run. */ empirical_policy?: FlowRunCreateFlowRunParams.EmpiricalPolicy; /** * Body param: Whether or not to enforce the parameter schema on this run. */ enforce_parameter_schema?: boolean | null; /** * Body param: An optional idempotency key. If a flow run with the same idempotency * key has already been created, the existing flow run will be returned. */ idempotency_key?: string | null; /** * Body param: */ infrastructure_document_id?: string | null; /** * Body param: */ job_variables?: unknown | null; /** * Body param: The name of the flow run. Defaults to a random slug if not * specified. */ name?: string; /** * Body param: */ parameters?: unknown; /** * Body param: */ parent_task_run_id?: string | null; /** * Body param: Data used by the Prefect REST API to create a new state. */ state?: FlowRunCreateFlowRunParams.State | null; /** * Body param: A list of tags for the flow run. */ tags?: Array; /** * Body param: */ work_queue_name?: string | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace FlowRunCreateFlowRunParams { /** * The empirical policy for the flow run. */ export interface EmpiricalPolicy { /** * @deprecated: The maximum number of retries. Field is not used. Please use * `retries` instead. */ max_retries?: number; /** * Tracks pauses this run has observed. */ pause_keys?: Array | null; /** * Indicates if this run is resuming from a pause. */ resuming?: boolean | null; /** * The number of retries. */ retries?: number | null; /** * The delay time between retries, in seconds. */ retry_delay?: number | null; /** * @deprecated: The delay between retries. Field is not used. Please use * `retry_delay` instead. */ retry_delay_seconds?: number; } /** * Data used by the Prefect REST API to create a new state. */ export interface State { /** * The type of the state to create */ type: | 'SCHEDULED' | 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'CRASHED' | 'PAUSED' | 'CANCELLING'; /** * The data of the state to create */ data?: unknown | null; /** * The message of the state to create */ message?: string | null; /** * The name of the state to create */ name?: string | null; /** * The details of the state to create */ state_details?: State.StateDetails; } export namespace State { /** * The details of the state to create */ export interface StateDetails { cache_expiration?: string | null; cache_key?: string | null; child_flow_run_id?: string | null; deferred?: boolean | null; flow_run_id?: string | null; pause_key?: string | null; pause_reschedule?: boolean; pause_timeout?: string | null; refresh_cache?: boolean | null; retriable?: boolean | null; run_input_keyset?: Record | null; scheduled_time?: string | null; task_parameters_id?: string | null; task_run_id?: string | null; transition_id?: string | null; untrackable_result?: boolean; } } } export namespace FlowRuns { export import FlowRunCreateFlowRunParams = FlowRunsAPI.FlowRunCreateFlowRunParams; }