// 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 QueuesAPI from './queues'; import * as Shared from '../shared'; export class Queues extends APIResource { /** * Creates a new work pool queue. If a work pool queue with the same name already * exists, an error will be raised. */ create( workPoolName: string, params: QueueCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post(`/api/work_pools/${workPoolName}/queues`, { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Read a work pool queue */ retrieve( workPoolName: string, name: string, params?: QueueRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve( workPoolName: string, name: string, options?: Core.RequestOptions, ): Core.APIPromise; retrieve( workPoolName: string, name: string, params: QueueRetrieveParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.retrieve(workPoolName, name, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion } = params; return this._client.get(`/api/work_pools/${workPoolName}/queues/${name}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Update a work pool queue */ update( workPoolName: string, params: QueueUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { path_name, body_name, 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.patch(`/api/work_pools/${workPoolName}/queues/${path_name}`, { body: { name: body_name, ...body }, ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete a work pool queue */ delete( workPoolName: string, name: string, params?: QueueDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise; delete(workPoolName: string, name: string, options?: Core.RequestOptions): Core.APIPromise; delete( workPoolName: string, name: string, params: QueueDeleteParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.delete(workPoolName, name, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion } = params; return this._client.delete(`/api/work_pools/${workPoolName}/queues/${name}`, { ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Read all work pool queues */ filter( workPoolName: string, params?: QueueFilterParams, options?: Core.RequestOptions, ): Core.APIPromise; filter(workPoolName: string, options?: Core.RequestOptions): Core.APIPromise; filter( workPoolName: string, params: QueueFilterParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.filter(workPoolName, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post(`/api/work_pools/${workPoolName}/queues/filter`, { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export type QueueFilterResponse = Array; export interface QueueCreateParams { /** * Body param: The name of the work queue. */ name: string; /** * Body param: The work queue's concurrency limit. */ concurrency_limit?: number | null; /** * Body param: An optional description for the work queue. */ description?: string | null; /** * Body param: Filter criteria definition for a work queue. */ filter?: QueueCreateParams.Filter | null; /** * Body param: Whether or not the work queue is paused. */ is_paused?: boolean; /** * Body param: The queue's priority. Lower values are higher priority (1 is the * highest). */ priority?: number | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace QueueCreateParams { /** * @deprecated: Filter criteria definition for a work queue. */ export interface Filter { /** * Only include flow runs from these deployments in the work queue. */ deployment_ids?: Array | null; /** * Only include flow runs with these tags in the work queue. */ tags?: Array | null; } } export interface QueueRetrieveParams { 'x-prefect-api-version'?: string; } export interface QueueUpdateParams { /** * Path param: The work pool queue name */ path_name: string; /** * Body param: */ concurrency_limit?: number | null; /** * Body param: */ description?: string | null; /** * Body param: Filter criteria definition for a work queue. */ filter?: QueueUpdateParams.Filter | null; /** * Body param: Whether or not the work queue is paused. */ is_paused?: boolean; /** * Body param: */ last_polled?: string | null; /** * Body param: */ body_name?: string | null; /** * Body param: */ priority?: number | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace QueueUpdateParams { /** * @deprecated: Filter criteria definition for a work queue. */ export interface Filter { /** * Only include flow runs from these deployments in the work queue. */ deployment_ids?: Array | null; /** * Only include flow runs with these tags in the work queue. */ tags?: Array | null; } } export interface QueueDeleteParams { 'x-prefect-api-version'?: string; } export interface QueueFilterParams { /** * Body param: Defaults to PREFECT_API_DEFAULT_LIMIT if not provided. */ limit?: number; /** * Body param: */ offset?: number; /** * Body param: Filter work queues. Only work queues matching all criteria will be * returned */ work_queues?: QueueFilterParams.WorkQueues; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace QueueFilterParams { /** * Filter work queues. Only work queues matching all criteria will be returned */ export interface WorkQueues { /** * Filter by `WorkQueue.id`. */ id?: WorkQueues.ID | null; /** * Filter by `WorkQueue.name`. */ name?: WorkQueues.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } export namespace WorkQueues { /** * Filter by `WorkQueue.id`. */ export interface ID { /** * A list of work queue ids to include */ any_?: Array | null; } /** * Filter by `WorkQueue.name`. */ export interface Name { /** * A list of work queue names to include */ any_?: Array | null; /** * A list of case-insensitive starts-with matches. For example, passing 'marvin' * will match 'marvin', and 'Marvin-robot', but not 'sad-marvin'. */ startswith_?: Array | null; } } } export namespace Queues { export import QueueFilterResponse = QueuesAPI.QueueFilterResponse; export import QueueCreateParams = QueuesAPI.QueueCreateParams; export import QueueRetrieveParams = QueuesAPI.QueueRetrieveParams; export import QueueUpdateParams = QueuesAPI.QueueUpdateParams; export import QueueDeleteParams = QueuesAPI.QueueDeleteParams; export import QueueFilterParams = QueuesAPI.QueueFilterParams; }