// 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 SavedSearchesAPI from './saved-searches'; export class SavedSearches extends APIResource { /** * Get a saved search by id. */ retrieve( id: string, params?: SavedSearchRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; retrieve( id: string, params: SavedSearchRetrieveParams | 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/saved_searches/${id}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Gracefully creates a new saved search from the provided schema. * * If a saved search with the same name already exists, the saved search's fields * are replaced. */ update(params: SavedSearchUpdateParams, options?: Core.RequestOptions): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.put('/api/saved_searches/', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete a saved search by id. */ delete(id: string, params?: SavedSearchDeleteParams, options?: Core.RequestOptions): Core.APIPromise; delete(id: string, options?: Core.RequestOptions): Core.APIPromise; delete( id: string, params: SavedSearchDeleteParams | 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/saved_searches/${id}`, { ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Query for saved searches. */ filter( params?: SavedSearchFilterParams, options?: Core.RequestOptions, ): Core.APIPromise; filter(options?: Core.RequestOptions): Core.APIPromise; filter( params: SavedSearchFilterParams | 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/saved_searches/filter', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } /** * An ORM representation of saved search data. Represents a set of filter criteria. */ export interface SavedSearch { /** * The name of the saved search. */ name: string; id?: string; created?: string | null; /** * The filter set for the saved search. */ filters?: Array; updated?: string | null; } export namespace SavedSearch { /** * A filter for a saved search model. Intended for use by the Prefect UI. */ export interface Filter { /** * The object over which to filter. */ object: string; /** * The operator to apply to the object. For example, `equals`. */ operation: string; /** * The property of the object on which to filter. */ property: string; /** * The type of the property. */ type: string; /** * A JSON-compatible value for the filter. */ value: unknown; } } export type SavedSearchFilterResponse = Array; export interface SavedSearchRetrieveParams { 'x-prefect-api-version'?: string; } export interface SavedSearchUpdateParams { /** * Body param: The name of the saved search. */ name: string; /** * Body param: The filter set for the saved search. */ filters?: Array; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace SavedSearchUpdateParams { /** * A filter for a saved search model. Intended for use by the Prefect UI. */ export interface Filter { /** * The object over which to filter. */ object: string; /** * The operator to apply to the object. For example, `equals`. */ operation: string; /** * The property of the object on which to filter. */ property: string; /** * The type of the property. */ type: string; /** * A JSON-compatible value for the filter. */ value: unknown; } } export interface SavedSearchDeleteParams { 'x-prefect-api-version'?: string; } export interface SavedSearchFilterParams { /** * 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 namespace SavedSearches { export import SavedSearch = SavedSearchesAPI.SavedSearch; export import SavedSearchFilterResponse = SavedSearchesAPI.SavedSearchFilterResponse; export import SavedSearchRetrieveParams = SavedSearchesAPI.SavedSearchRetrieveParams; export import SavedSearchUpdateParams = SavedSearchesAPI.SavedSearchUpdateParams; export import SavedSearchDeleteParams = SavedSearchesAPI.SavedSearchDeleteParams; export import SavedSearchFilterParams = SavedSearchesAPI.SavedSearchFilterParams; }