// 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 TaskRunsAPI from './task-runs'; import * as DashboardAPI from './dashboard'; export class TaskRuns extends APIResource { dashboard: DashboardAPI.Dashboard = new DashboardAPI.Dashboard(this._client); /** * Read Task Run Counts By State */ count(params?: TaskRunCountParams, options?: Core.RequestOptions): Core.APIPromise; count(options?: Core.RequestOptions): Core.APIPromise; count( params: TaskRunCountParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.count({}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/ui/task_runs/count', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export interface CountByState { CANCELLED?: number; CANCELLING?: number; COMPLETED?: number; CRASHED?: number; FAILED?: number; PAUSED?: number; PENDING?: number; RUNNING?: number; SCHEDULED?: number; } export interface TaskRunCountParams { /** * Body param: Filter for deployments. Only deployments matching all criteria will * be returned. */ deployments?: TaskRunCountParams.Deployments | null; /** * Body param: Filter flow runs. Only flow runs matching all criteria will be * returned */ flow_runs?: TaskRunCountParams.FlowRuns | null; /** * Body param: Filter for flows. Only flows matching all criteria will be returned. */ flows?: TaskRunCountParams.Flows | null; /** * Body param: Filter task runs. Only task runs matching all criteria will be * returned */ task_runs?: TaskRunCountParams.TaskRuns | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace TaskRunCountParams { /** * 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_'; } } } export namespace TaskRuns { export import CountByState = TaskRunsAPI.CountByState; export import TaskRunCountParams = TaskRunsAPI.TaskRunCountParams; export import Dashboard = DashboardAPI.Dashboard; export import TaskRunCount = DashboardAPI.TaskRunCount; export import DashboardCountsResponse = DashboardAPI.DashboardCountsResponse; export import DashboardCountsParams = DashboardAPI.DashboardCountsParams; }