// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; import { isRequestOptions } from '../../core'; import * as Core from '../../core'; import * as FlowRunsAPI from './flow-runs'; export class FlowRuns extends APIResource { /** * Get task run counts by flow run id. */ countTaskRuns( params: FlowRunCountTaskRunsParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/ui/flow_runs/count-task-runs', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Read Flow Run History */ history( params?: FlowRunHistoryParams, options?: Core.RequestOptions, ): Core.APIPromise; history(options?: Core.RequestOptions): Core.APIPromise; history( params: FlowRunHistoryParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.history({}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/ui/flow_runs/history', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export interface SimpleFlowRun { /** * The flow run id. */ id: string; /** * The total run time of the run. */ duration: number; /** * The delay between the expected and actual start time. */ lateness: number; /** * The state type. */ state_type: | 'SCHEDULED' | 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'CRASHED' | 'PAUSED' | 'CANCELLING'; /** * The start time of the run, or the expected start time if it hasn't run yet. */ timestamp: string; } export type FlowRunCountTaskRunsResponse = Record; export type FlowRunHistoryResponse = Array; export interface FlowRunCountTaskRunsParams { /** * Body param: */ flow_run_ids: Array; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface FlowRunHistoryParams { /** * Body param: Filter for deployments. Only deployments matching all criteria will * be returned. */ deployments?: FlowRunHistoryParams.Deployments; /** * Body param: Filter flow runs. Only flow runs matching all criteria will be * returned */ flow_runs?: FlowRunHistoryParams.FlowRuns; /** * Body param: Filter for flows. Only flows matching all criteria will be returned. */ flows?: FlowRunHistoryParams.Flows; /** * Body param: */ limit?: number; /** * Body param: */ offset?: number; /** * Body param: Defines flow run sorting options. */ sort?: | 'ID_DESC' | 'START_TIME_ASC' | 'START_TIME_DESC' | 'EXPECTED_START_TIME_ASC' | 'EXPECTED_START_TIME_DESC' | 'NAME_ASC' | 'NAME_DESC' | 'NEXT_SCHEDULED_START_TIME_ASC' | 'END_TIME_DESC'; /** * Body param: Filter task runs. Only task runs matching all criteria will be * returned */ task_runs?: FlowRunHistoryParams.TaskRuns; /** * Body param: Filter work pools. Only work pools matching all criteria will be * returned */ work_pools?: FlowRunHistoryParams.WorkPools; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace FlowRunHistoryParams { /** * Filter for deployments. Only deployments matching all criteria will be returned. */ export interface Deployments { /** * Filter by `Deployment.id`. */ id?: Deployments.ID | null; /** * Filter by `Deployment.concurrency_limit`. */ concurrency_limit?: Deployments.ConcurrencyLimit | null; /** * Filter by `Deployment.name` or `Flow.name` with a single input string for ilike * filtering. */ flow_or_deployment_name?: Deployments.FlowOrDeploymentName | null; /** * Filter by `Deployment.name`. */ name?: Deployments.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `Deployment.paused`. */ paused?: Deployments.Paused | null; /** * Filter by `Deployment.tags`. */ tags?: Deployments.Tags | null; /** * Filter by `Deployment.work_queue_name`. */ work_queue_name?: Deployments.WorkQueueName | null; } export namespace Deployments { /** * Filter by `Deployment.id`. */ export interface ID { /** * A list of deployment ids to include */ any_?: Array | null; } /** * Filter by `Deployment.concurrency_limit`. */ export interface ConcurrencyLimit { /** * Only include deployments with a concurrency limit greater than or equal to this * value */ ge_?: number | null; /** * If true, only include deployments without a concurrency limit */ is_null_?: boolean | null; /** * Only include deployments with a concurrency limit less than or equal to this * value */ le_?: number | null; } /** * Filter by `Deployment.name` or `Flow.name` with a single input string for ilike * filtering. */ export interface FlowOrDeploymentName { /** * A case-insensitive partial match on deployment or flow names. For example, * passing 'example' might match deployments or flows with 'example' in their * names. */ like_?: string | null; } /** * Filter by `Deployment.name`. */ export interface Name { /** * A list of deployment names to include */ any_?: Array | null; /** * A case-insensitive partial match. For example, passing 'marvin' will match * 'marvin', 'sad-Marvin', and 'marvin-robot'. */ like_?: string | null; } /** * Filter by `Deployment.paused`. */ export interface Paused { /** * Only returns where deployment is/is not paused */ eq_?: boolean | null; } /** * Filter by `Deployment.tags`. */ export interface Tags { /** * A list of tags. Deployments will be returned only if their tags are a superset * of the list */ all_?: Array | null; /** * If true, only include deployments without tags */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } /** * Filter by `Deployment.work_queue_name`. */ export interface WorkQueueName { /** * A list of work queue names to include */ any_?: Array | null; } } /** * Filter flow runs. Only flow runs matching all criteria will be returned */ export interface FlowRuns { /** * Filter by `FlowRun.id`. */ id?: FlowRuns.ID | null; /** * Filter by `FlowRun.deployment_id`. */ deployment_id?: FlowRuns.DeploymentID | null; /** * Filter by `FlowRun.expected_start_time`. */ expected_start_time?: FlowRuns.ExpectedStartTime | null; /** * Filter by `FlowRun.flow_version`. */ flow_version?: FlowRuns.FlowVersion | null; /** * Filter by FlowRun.idempotency_key. */ idempotency_key?: FlowRuns.IdempotencyKey | null; /** * Filter by `FlowRun.name`. */ name?: FlowRuns.Name | null; /** * Filter by `FlowRun.next_scheduled_start_time`. */ next_scheduled_start_time?: FlowRuns.NextScheduledStartTime | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter for subflows of a given flow run */ parent_flow_run_id?: FlowRuns.ParentFlowRunID | null; /** * Filter by `FlowRun.parent_task_run_id`. */ parent_task_run_id?: FlowRuns.ParentTaskRunID | null; /** * Filter by `FlowRun.start_time`. */ start_time?: FlowRuns.StartTime | null; /** * Filter by `FlowRun.state_type` and `FlowRun.state_name`. */ state?: FlowRuns.State | null; /** * Filter by `FlowRun.tags`. */ tags?: FlowRuns.Tags | null; /** * Filter by `FlowRun.work_queue_name`. */ work_queue_name?: FlowRuns.WorkQueueName | null; } export namespace FlowRuns { /** * Filter by `FlowRun.id`. */ export interface ID { /** * A list of flow run ids to include */ any_?: Array | null; /** * A list of flow run ids to exclude */ not_any_?: Array | null; } /** * Filter by `FlowRun.deployment_id`. */ export interface DeploymentID { /** * A list of flow run deployment ids to include */ any_?: Array | null; /** * If true, only include flow runs without deployment ids */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } /** * Filter by `FlowRun.expected_start_time`. */ export interface ExpectedStartTime { /** * Only include flow runs scheduled to start at or after this time */ after_?: string | null; /** * Only include flow runs scheduled to start at or before this time */ before_?: string | null; } /** * Filter by `FlowRun.flow_version`. */ export interface FlowVersion { /** * A list of flow run flow_versions to include */ any_?: Array | null; } /** * Filter by FlowRun.idempotency_key. */ export interface IdempotencyKey { /** * A list of flow run idempotency keys to include */ any_?: Array | null; /** * A list of flow run idempotency keys to exclude */ not_any_?: Array | null; } /** * Filter by `FlowRun.name`. */ export interface Name { /** * A list of flow run names to include */ any_?: Array | null; /** * A case-insensitive partial match. For example, passing 'marvin' will match * 'marvin', 'sad-Marvin', and 'marvin-robot'. */ like_?: string | null; } /** * Filter by `FlowRun.next_scheduled_start_time`. */ export interface NextScheduledStartTime { /** * Only include flow runs with a next_scheduled_start_time at or after this time */ after_?: string | null; /** * Only include flow runs with a next_scheduled_start_time or before this time */ before_?: string | null; } /** * Filter for subflows of a given flow run */ export interface ParentFlowRunID { /** * A list of parent flow run ids to include */ any_?: Array | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } /** * Filter by `FlowRun.parent_task_run_id`. */ export interface ParentTaskRunID { /** * A list of flow run parent_task_run_ids to include */ any_?: Array | null; /** * If true, only include flow runs without parent_task_run_id */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } /** * Filter by `FlowRun.start_time`. */ export interface StartTime { /** * Only include flow runs starting at or after this time */ after_?: string | null; /** * Only include flow runs starting at or before this time */ before_?: string | null; /** * If true, only return flow runs without a start time */ is_null_?: boolean | null; } /** * Filter by `FlowRun.state_type` and `FlowRun.state_name`. */ export interface State { /** * Filter by `FlowRun.state_name`. */ name?: State.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `FlowRun.state_type`. */ type?: State.Type | null; } export namespace State { /** * Filter by `FlowRun.state_name`. */ export interface Name { /** * A list of flow run state names to include */ any_?: Array | null; /** * A list of flow run state names to exclude */ not_any_?: Array | null; } /** * Filter by `FlowRun.state_type`. */ export interface Type { /** * A list of flow run state types to include */ any_?: Array< | 'SCHEDULED' | 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'CRASHED' | 'PAUSED' | 'CANCELLING' > | null; /** * A list of flow run state types to exclude */ not_any_?: Array< | 'SCHEDULED' | 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'CRASHED' | 'PAUSED' | 'CANCELLING' > | null; } } /** * Filter by `FlowRun.tags`. */ export interface Tags { /** * A list of tags. Flow runs will be returned only if their tags are a superset of * the list */ all_?: Array | null; /** * If true, only include flow runs without tags */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } /** * Filter by `FlowRun.work_queue_name`. */ export interface WorkQueueName { /** * A list of work queue names to include */ any_?: Array | null; /** * If true, only include flow runs without work queue names */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } } /** * Filter for flows. Only flows matching all criteria will be returned. */ export interface Flows { /** * Filter by `Flow.id`. */ id?: Flows.ID | null; /** * Filter by flows by deployment */ deployment?: Flows.Deployment | null; /** * Filter by `Flow.name`. */ name?: Flows.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `Flow.tags`. */ tags?: Flows.Tags | null; } export namespace Flows { /** * Filter by `Flow.id`. */ export interface ID { /** * A list of flow ids to include */ any_?: Array | null; } /** * Filter by flows by deployment */ export interface Deployment { /** * If true, only include flows without deployments */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } /** * Filter by `Flow.name`. */ export interface Name { /** * A list of flow names to include */ any_?: Array | null; /** * A case-insensitive partial match. For example, passing 'marvin' will match * 'marvin', 'sad-Marvin', and 'marvin-robot'. */ like_?: string | null; } /** * Filter by `Flow.tags`. */ export interface Tags { /** * A list of tags. Flows will be returned only if their tags are a superset of the * list */ all_?: Array | null; /** * If true, only include flows without tags */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } } /** * Filter task runs. Only task runs matching all criteria will be returned */ export interface TaskRuns { /** * Filter by `TaskRun.id`. */ id?: TaskRuns.ID | null; /** * Filter by `TaskRun.expected_start_time`. */ expected_start_time?: TaskRuns.ExpectedStartTime | null; /** * Filter by `TaskRun.flow_run_id`. */ flow_run_id?: TaskRuns.FlowRunID | null; /** * Filter by `TaskRun.name`. */ name?: TaskRuns.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `TaskRun.start_time`. */ start_time?: TaskRuns.StartTime | null; /** * Filter by `TaskRun.type` and `TaskRun.name`. */ state?: TaskRuns.State | null; /** * Filter by `TaskRun.subflow_run`. */ subflow_runs?: TaskRuns.SubflowRuns | null; /** * Filter by `TaskRun.tags`. */ tags?: TaskRuns.Tags | null; } export namespace TaskRuns { /** * Filter by `TaskRun.id`. */ export interface ID { /** * A list of task run ids to include */ any_?: Array | null; } /** * Filter by `TaskRun.expected_start_time`. */ export interface ExpectedStartTime { /** * Only include task runs expected to start at or after this time */ after_?: string | null; /** * Only include task runs expected to start at or before this time */ before_?: string | null; } /** * Filter by `TaskRun.flow_run_id`. */ export interface FlowRunID { /** * A list of task run flow run ids to include */ any_?: Array | null; /** * Filter for task runs with None as their flow run id */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } /** * Filter by `TaskRun.name`. */ export interface Name { /** * A list of task run names to include */ any_?: Array | null; /** * A case-insensitive partial match. For example, passing 'marvin' will match * 'marvin', 'sad-Marvin', and 'marvin-robot'. */ like_?: string | null; } /** * Filter by `TaskRun.start_time`. */ export interface StartTime { /** * Only include task runs starting at or after this time */ after_?: string | null; /** * Only include task runs starting at or before this time */ before_?: string | null; /** * If true, only return task runs without a start time */ is_null_?: boolean | null; } /** * Filter by `TaskRun.type` and `TaskRun.name`. */ export interface State { /** * Filter by `TaskRun.state_name`. */ name?: State.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `TaskRun.state_type`. */ type?: State.Type | null; } export namespace State { /** * Filter by `TaskRun.state_name`. */ export interface Name { /** * A list of task run state names to include */ any_?: Array | null; } /** * Filter by `TaskRun.state_type`. */ export interface Type { /** * A list of task run state types to include */ any_?: Array< | 'SCHEDULED' | 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'CRASHED' | 'PAUSED' | 'CANCELLING' > | null; } } /** * Filter by `TaskRun.subflow_run`. */ export interface SubflowRuns { /** * If true, only include task runs that are subflow run parents; if false, exclude * parent task runs */ exists_?: boolean | null; } /** * Filter by `TaskRun.tags`. */ export interface Tags { /** * A list of tags. Task runs will be returned only if their tags are a superset of * the list */ all_?: Array | null; /** * If true, only include task runs without tags */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } } /** * Filter work pools. Only work pools matching all criteria will be returned */ export interface WorkPools { /** * Filter by `WorkPool.id`. */ id?: WorkPools.ID | null; /** * Filter by `WorkPool.name`. */ name?: WorkPools.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `WorkPool.type`. */ type?: WorkPools.Type | null; } export namespace WorkPools { /** * Filter by `WorkPool.id`. */ export interface ID { /** * A list of work pool ids to include */ any_?: Array | null; } /** * Filter by `WorkPool.name`. */ export interface Name { /** * A list of work pool names to include */ any_?: Array | null; } /** * Filter by `WorkPool.type`. */ export interface Type { /** * A list of work pool types to include */ any_?: Array | null; } } } export namespace FlowRuns { export import SimpleFlowRun = FlowRunsAPI.SimpleFlowRun; export import FlowRunCountTaskRunsResponse = FlowRunsAPI.FlowRunCountTaskRunsResponse; export import FlowRunHistoryResponse = FlowRunsAPI.FlowRunHistoryResponse; export import FlowRunCountTaskRunsParams = FlowRunsAPI.FlowRunCountTaskRunsParams; export import FlowRunHistoryParams = FlowRunsAPI.FlowRunHistoryParams; }