// 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 BlockDocumentsAPI from './block-documents'; import * as Shared from './shared'; export class BlockDocuments extends APIResource { /** * Create a new block document. */ create( params: BlockDocumentCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/block_documents/', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Read Block Document By Id */ retrieve( id: string, params?: BlockDocumentRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; retrieve( id: string, params: BlockDocumentRetrieveParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.retrieve(id, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion, ...query } = params; return this._client.get(`/api/block_documents/${id}`, { query, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Update Block Document Data */ update( id: string, params: BlockDocumentUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.patch(`/api/block_documents/${id}`, { body, ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete Block Document */ delete( id: string, params?: BlockDocumentDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise; delete(id: string, options?: Core.RequestOptions): Core.APIPromise; delete( id: string, params: BlockDocumentDeleteParams | 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/block_documents/${id}`, { ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Count block documents. */ count( params?: BlockDocumentCountParams, options?: Core.RequestOptions, ): Core.APIPromise; count(options?: Core.RequestOptions): Core.APIPromise; count( params: BlockDocumentCountParams | 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/block_documents/count', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Query for block documents. */ filter( params?: BlockDocumentFilterParams, options?: Core.RequestOptions, ): Core.APIPromise; filter(options?: Core.RequestOptions): Core.APIPromise; filter( params: BlockDocumentFilterParams | 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/block_documents/filter', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export type BlockDocumentCountResponse = number; export type BlockDocumentFilterResponse = Array; export interface BlockDocumentCreateParams { /** * Body param: A block schema ID */ block_schema_id: string; /** * Body param: A block type ID */ block_type_id: string; /** * Body param: The block document's data */ data?: unknown; /** * Body param: Whether the block is anonymous (anonymous blocks are usually created * by Prefect automatically) */ is_anonymous?: boolean; /** * Body param: The block document's name. Not required for anonymous block * documents. */ name?: string | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface BlockDocumentRetrieveParams { /** * Query param: Whether to include sensitive values in the block document. */ include_secrets?: boolean; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface BlockDocumentUpdateParams { /** * Body param: A block schema ID */ block_schema_id?: string | null; /** * Body param: The block document's data */ data?: unknown; /** * Body param: */ merge_existing_data?: boolean; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface BlockDocumentDeleteParams { 'x-prefect-api-version'?: string; } export interface BlockDocumentCountParams { /** * Body param: Filter BlockDocuments. Only BlockDocuments matching all criteria * will be returned */ block_documents?: BlockDocumentCountParams.BlockDocuments | null; /** * Body param: Filter BlockSchemas */ block_schemas?: BlockDocumentCountParams.BlockSchemas | null; /** * Body param: Filter BlockTypes */ block_types?: BlockDocumentCountParams.BlockTypes | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace BlockDocumentCountParams { /** * Filter BlockDocuments. Only BlockDocuments matching all criteria will be * returned */ export interface BlockDocuments { /** * Filter by `BlockDocument.id`. */ id?: BlockDocuments.ID | null; /** * Filter by `BlockDocument.block_type_id`. */ block_type_id?: BlockDocuments.BlockTypeID | null; /** * Filter by `BlockDocument.is_anonymous`. */ is_anonymous?: BlockDocuments.IsAnonymous | null; /** * Filter by `BlockDocument.name`. */ name?: BlockDocuments.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } export namespace BlockDocuments { /** * Filter by `BlockDocument.id`. */ export interface ID { /** * A list of block ids to include */ any_?: Array | null; } /** * Filter by `BlockDocument.block_type_id`. */ export interface BlockTypeID { /** * A list of block type ids to include */ any_?: Array | null; } /** * Filter by `BlockDocument.is_anonymous`. */ export interface IsAnonymous { /** * Filter block documents for only those that are or are not anonymous. */ eq_?: boolean | null; } /** * Filter by `BlockDocument.name`. */ export interface Name { /** * A list of block names to include */ any_?: Array | null; /** * A string to match block names against. This can include SQL wildcard characters * like `%` and `_`. */ like_?: string | null; } } /** * Filter BlockSchemas */ export interface BlockSchemas { /** * Filter by BlockSchema.id */ id?: BlockSchemas.ID | null; /** * Filter by `BlockSchema.capabilities` */ block_capabilities?: BlockSchemas.BlockCapabilities | null; /** * Filter by `BlockSchema.block_type_id`. */ block_type_id?: BlockSchemas.BlockTypeID | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `BlockSchema.capabilities` */ version?: BlockSchemas.Version | null; } export namespace BlockSchemas { /** * Filter by BlockSchema.id */ export interface ID { /** * A list of IDs to include */ any_?: Array | null; } /** * Filter by `BlockSchema.capabilities` */ export interface BlockCapabilities { /** * A list of block capabilities. Block entities will be returned only if an * associated block schema has a superset of the defined capabilities. */ all_?: Array | null; } /** * Filter by `BlockSchema.block_type_id`. */ export interface BlockTypeID { /** * A list of block type ids to include */ any_?: Array | null; } /** * Filter by `BlockSchema.capabilities` */ export interface Version { /** * A list of block schema versions. */ any_?: Array | null; } } /** * Filter BlockTypes */ export interface BlockTypes { /** * Filter by `BlockType.name` */ name?: BlockTypes.Name | null; /** * Filter by `BlockType.slug` */ slug?: BlockTypes.Slug | null; } export namespace BlockTypes { /** * Filter by `BlockType.name` */ export interface Name { /** * A case-insensitive partial match. For example, passing 'marvin' will match * 'marvin', 'sad-Marvin', and 'marvin-robot'. */ like_?: string | null; } /** * Filter by `BlockType.slug` */ export interface Slug { /** * A list of slugs to match */ any_?: Array | null; } } } export interface BlockDocumentFilterParams { /** * Body param: Filter BlockDocuments. Only BlockDocuments matching all criteria * will be returned */ block_documents?: BlockDocumentFilterParams.BlockDocuments | null; /** * Body param: Filter BlockSchemas */ block_schemas?: BlockDocumentFilterParams.BlockSchemas | null; /** * Body param: Filter BlockTypes */ block_types?: BlockDocumentFilterParams.BlockTypes | null; /** * Body param: Whether to include sensitive values in the block document. */ include_secrets?: boolean; /** * Body param: Defaults to PREFECT_API_DEFAULT_LIMIT if not provided. */ limit?: number; /** * Body param: */ offset?: number; /** * Body param: Defines block document sorting options. */ sort?: 'NAME_DESC' | 'NAME_ASC' | 'BLOCK_TYPE_AND_NAME_ASC' | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace BlockDocumentFilterParams { /** * Filter BlockDocuments. Only BlockDocuments matching all criteria will be * returned */ export interface BlockDocuments { /** * Filter by `BlockDocument.id`. */ id?: BlockDocuments.ID | null; /** * Filter by `BlockDocument.block_type_id`. */ block_type_id?: BlockDocuments.BlockTypeID | null; /** * Filter by `BlockDocument.is_anonymous`. */ is_anonymous?: BlockDocuments.IsAnonymous | null; /** * Filter by `BlockDocument.name`. */ name?: BlockDocuments.Name | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; } export namespace BlockDocuments { /** * Filter by `BlockDocument.id`. */ export interface ID { /** * A list of block ids to include */ any_?: Array | null; } /** * Filter by `BlockDocument.block_type_id`. */ export interface BlockTypeID { /** * A list of block type ids to include */ any_?: Array | null; } /** * Filter by `BlockDocument.is_anonymous`. */ export interface IsAnonymous { /** * Filter block documents for only those that are or are not anonymous. */ eq_?: boolean | null; } /** * Filter by `BlockDocument.name`. */ export interface Name { /** * A list of block names to include */ any_?: Array | null; /** * A string to match block names against. This can include SQL wildcard characters * like `%` and `_`. */ like_?: string | null; } } /** * Filter BlockSchemas */ export interface BlockSchemas { /** * Filter by BlockSchema.id */ id?: BlockSchemas.ID | null; /** * Filter by `BlockSchema.capabilities` */ block_capabilities?: BlockSchemas.BlockCapabilities | null; /** * Filter by `BlockSchema.block_type_id`. */ block_type_id?: BlockSchemas.BlockTypeID | null; /** * Operator for combining filter criteria. Defaults to 'and\_'. */ operator?: 'and_' | 'or_'; /** * Filter by `BlockSchema.capabilities` */ version?: BlockSchemas.Version | null; } export namespace BlockSchemas { /** * Filter by BlockSchema.id */ export interface ID { /** * A list of IDs to include */ any_?: Array | null; } /** * Filter by `BlockSchema.capabilities` */ export interface BlockCapabilities { /** * A list of block capabilities. Block entities will be returned only if an * associated block schema has a superset of the defined capabilities. */ all_?: Array | null; } /** * Filter by `BlockSchema.block_type_id`. */ export interface BlockTypeID { /** * A list of block type ids to include */ any_?: Array | null; } /** * Filter by `BlockSchema.capabilities` */ export interface Version { /** * A list of block schema versions. */ any_?: Array | null; } } /** * Filter BlockTypes */ export interface BlockTypes { /** * Filter by `BlockType.name` */ name?: BlockTypes.Name | null; /** * Filter by `BlockType.slug` */ slug?: BlockTypes.Slug | null; } export namespace BlockTypes { /** * Filter by `BlockType.name` */ export interface Name { /** * A case-insensitive partial match. For example, passing 'marvin' will match * 'marvin', 'sad-Marvin', and 'marvin-robot'. */ like_?: string | null; } /** * Filter by `BlockType.slug` */ export interface Slug { /** * A list of slugs to match */ any_?: Array | null; } } } export namespace BlockDocuments { export import BlockDocumentCountResponse = BlockDocumentsAPI.BlockDocumentCountResponse; export import BlockDocumentFilterResponse = BlockDocumentsAPI.BlockDocumentFilterResponse; export import BlockDocumentCreateParams = BlockDocumentsAPI.BlockDocumentCreateParams; export import BlockDocumentRetrieveParams = BlockDocumentsAPI.BlockDocumentRetrieveParams; export import BlockDocumentUpdateParams = BlockDocumentsAPI.BlockDocumentUpdateParams; export import BlockDocumentDeleteParams = BlockDocumentsAPI.BlockDocumentDeleteParams; export import BlockDocumentCountParams = BlockDocumentsAPI.BlockDocumentCountParams; export import BlockDocumentFilterParams = BlockDocumentsAPI.BlockDocumentFilterParams; }