// 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 ConcurrencyLimitsAPI from './concurrency-limits'; import * as Shared from '../shared'; import * as TagAPI from './tag'; import * as TagsAPI from './tags'; export class ConcurrencyLimits extends APIResource { tag: TagAPI.Tag = new TagAPI.Tag(this._client); tags: TagsAPI.Tags = new TagsAPI.Tags(this._client); /** * Create Concurrency Limit */ create( params: ConcurrencyLimitCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/concurrency_limits/', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Get a concurrency limit by id. * * The `active slots` field contains a list of TaskRun IDs currently using a * concurrency slot for the specified tag. */ retrieve( id: string, params?: ConcurrencyLimitRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; retrieve( id: string, params: ConcurrencyLimitRetrieveParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.retrieve(id, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion } = params; return this._client.get(`/api/concurrency_limits/${id}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete Concurrency Limit */ delete( id: string, params?: ConcurrencyLimitDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise; delete(id: string, options?: Core.RequestOptions): Core.APIPromise; delete( id: string, params: ConcurrencyLimitDeleteParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.delete(id, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion } = params; return this._client.delete(`/api/concurrency_limits/${id}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Decrement Concurrency Limits V1 */ decrement( params: ConcurrencyLimitDecrementParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/concurrency_limits/decrement', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Query for concurrency limits. * * For each concurrency limit the `active slots` field contains a list of TaskRun * IDs currently using a concurrency slot for the specified tag. */ filter( params?: ConcurrencyLimitFilterParams, options?: Core.RequestOptions, ): Core.APIPromise; filter(options?: Core.RequestOptions): Core.APIPromise; filter( params: ConcurrencyLimitFilterParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.filter({}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/concurrency_limits/filter', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Increment Concurrency Limits V1 */ increment( params: ConcurrencyLimitIncrementParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/concurrency_limits/increment', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export type ConcurrencyLimitDeleteResponse = unknown; export type ConcurrencyLimitDecrementResponse = unknown; export type ConcurrencyLimitFilterResponse = Array; export type ConcurrencyLimitIncrementResponse = Array; export interface ConcurrencyLimitCreateParams { /** * Body param: The concurrency limit. */ concurrency_limit: number; /** * Body param: A tag the concurrency limit is applied to. */ tag: string; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface ConcurrencyLimitRetrieveParams { 'x-prefect-api-version'?: string; } export interface ConcurrencyLimitDeleteParams { 'x-prefect-api-version'?: string; } export interface ConcurrencyLimitDecrementParams { /** * Body param: The tags to release a slot for */ names: Array; /** * Body param: The ID of the task run releasing the slot */ task_run_id: string; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface ConcurrencyLimitFilterParams { /** * Body param: Defaults to PREFECT_API_DEFAULT_LIMIT if not provided. */ limit?: number; /** * Body param: */ offset?: number; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface ConcurrencyLimitIncrementParams { /** * Body param: The tags to acquire a slot for */ names: Array; /** * Body param: The ID of the task run acquiring the slot */ task_run_id: string; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace ConcurrencyLimits { export import ConcurrencyLimitDeleteResponse = ConcurrencyLimitsAPI.ConcurrencyLimitDeleteResponse; export import ConcurrencyLimitDecrementResponse = ConcurrencyLimitsAPI.ConcurrencyLimitDecrementResponse; export import ConcurrencyLimitFilterResponse = ConcurrencyLimitsAPI.ConcurrencyLimitFilterResponse; export import ConcurrencyLimitIncrementResponse = ConcurrencyLimitsAPI.ConcurrencyLimitIncrementResponse; export import ConcurrencyLimitCreateParams = ConcurrencyLimitsAPI.ConcurrencyLimitCreateParams; export import ConcurrencyLimitRetrieveParams = ConcurrencyLimitsAPI.ConcurrencyLimitRetrieveParams; export import ConcurrencyLimitDeleteParams = ConcurrencyLimitsAPI.ConcurrencyLimitDeleteParams; export import ConcurrencyLimitDecrementParams = ConcurrencyLimitsAPI.ConcurrencyLimitDecrementParams; export import ConcurrencyLimitFilterParams = ConcurrencyLimitsAPI.ConcurrencyLimitFilterParams; export import ConcurrencyLimitIncrementParams = ConcurrencyLimitsAPI.ConcurrencyLimitIncrementParams; export import Tag = TagAPI.Tag; export import TagDeleteResponse = TagAPI.TagDeleteResponse; export import TagDeleteParams = TagAPI.TagDeleteParams; export import Tags = TagsAPI.Tags; export import TagResetResponse = TagsAPI.TagResetResponse; export import TagRetrieveParams = TagsAPI.TagRetrieveParams; export import TagResetParams = TagsAPI.TagResetParams; }