// 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 VariablesAPI from './variables'; import * as Shared from './shared'; export class Variables extends APIResource { /** * Create Variable */ create(params: VariableCreateParams, options?: Core.RequestOptions): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/variables/', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Read Variable */ retrieve( id: string, params?: VariableRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; retrieve( id: string, params: VariableRetrieveParams | 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/variables/${id}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Update Variable */ update(id: string, params: VariableUpdateParams, options?: Core.RequestOptions): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.patch(`/api/variables/${id}`, { body, ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete Variable */ delete(id: string, params?: VariableDeleteParams, options?: Core.RequestOptions): Core.APIPromise; delete(id: string, options?: Core.RequestOptions): Core.APIPromise; delete( id: string, params: VariableDeleteParams | 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/variables/${id}`, { ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Count Variables */ count(params?: VariableCountParams, options?: Core.RequestOptions): Core.APIPromise; count(options?: Core.RequestOptions): Core.APIPromise; count( params: VariableCountParams | 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/variables/count', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Read Variables */ filter( params?: VariableFilterParams, options?: Core.RequestOptions, ): Core.APIPromise; filter(options?: Core.RequestOptions): Core.APIPromise; filter( params: VariableFilterParams | 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/variables/filter', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Update Variable By Name */ updateName(params: VariableUpdateNameParams, options?: Core.RequestOptions): Core.APIPromise { const { path_name, body_name, 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.patch(`/api/variables/name/${path_name}`, { body: { name: body_name, ...body }, ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export type VariableCountResponse = number; export type VariableFilterResponse = Array; export interface VariableCreateParams { /** * Body param: The name of the variable */ name: string; /** * Body param: The value of the variable */ value: string | boolean | number | unknown | Array | null; /** * Body param: A list of variable tags */ tags?: Array; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface VariableRetrieveParams { 'x-prefect-api-version'?: string; } export interface VariableUpdateParams { /** * Body param: The name of the variable */ name?: string | null; /** * Body param: A list of variable tags */ tags?: Array | null; /** * Body param: The value of the variable */ value?: string | boolean | number | unknown | Array | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface VariableDeleteParams { 'x-prefect-api-version'?: string; } export interface VariableCountParams { /** * Body param: Filter variables. Only variables matching all criteria will be * returned */ variables?: VariableCountParams.Variables | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace VariableCountParams { /** * Filter variables. Only variables matching all criteria will be returned */ export interface Variables { /** * Filter by `Variable.id`. */ id?: Variables.ID | null; /** * Filter by `Variable.name`. */ name?: Variables.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `Variable.tags`. */ tags?: Variables.Tags | null; } export namespace Variables { /** * Filter by `Variable.id`. */ export interface ID { /** * A list of variable ids to include */ any_?: Array | null; } /** * Filter by `Variable.name`. */ export interface Name { /** * A list of variables names to include */ any_?: Array | null; /** * A string to match variable names against. This can include SQL wildcard * characters like `%` and `_`. */ like_?: string | null; } /** * Filter by `Variable.tags`. */ export interface Tags { /** * A list of tags. Variables will be returned only if their tags are a superset of * the list */ all_?: Array | null; /** * If true, only include Variables without tags */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } } } export interface VariableFilterParams { /** * Body param: Defaults to PREFECT_API_DEFAULT_LIMIT if not provided. */ limit?: number; /** * Body param: */ offset?: number; /** * Body param: Defines variables sorting options. */ sort?: 'CREATED_DESC' | 'UPDATED_DESC' | 'NAME_DESC' | 'NAME_ASC'; /** * Body param: Filter variables. Only variables matching all criteria will be * returned */ variables?: VariableFilterParams.Variables | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace VariableFilterParams { /** * Filter variables. Only variables matching all criteria will be returned */ export interface Variables { /** * Filter by `Variable.id`. */ id?: Variables.ID | null; /** * Filter by `Variable.name`. */ name?: Variables.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `Variable.tags`. */ tags?: Variables.Tags | null; } export namespace Variables { /** * Filter by `Variable.id`. */ export interface ID { /** * A list of variable ids to include */ any_?: Array | null; } /** * Filter by `Variable.name`. */ export interface Name { /** * A list of variables names to include */ any_?: Array | null; /** * A string to match variable names against. This can include SQL wildcard * characters like `%` and `_`. */ like_?: string | null; } /** * Filter by `Variable.tags`. */ export interface Tags { /** * A list of tags. Variables will be returned only if their tags are a superset of * the list */ all_?: Array | null; /** * If true, only include Variables without tags */ is_null_?: boolean | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } } } export interface VariableUpdateNameParams { /** * Path param: */ path_name: string; /** * Body param: The name of the variable */ body_name?: string | null; /** * Body param: A list of variable tags */ tags?: Array | null; /** * Body param: The value of the variable */ value?: string | boolean | number | unknown | Array | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace Variables { export import VariableCountResponse = VariablesAPI.VariableCountResponse; export import VariableFilterResponse = VariablesAPI.VariableFilterResponse; export import VariableCreateParams = VariablesAPI.VariableCreateParams; export import VariableRetrieveParams = VariablesAPI.VariableRetrieveParams; export import VariableUpdateParams = VariablesAPI.VariableUpdateParams; export import VariableDeleteParams = VariablesAPI.VariableDeleteParams; export import VariableCountParams = VariablesAPI.VariableCountParams; export import VariableFilterParams = VariablesAPI.VariableFilterParams; export import VariableUpdateNameParams = VariablesAPI.VariableUpdateNameParams; }