// 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 BlockSchemasAPI from './block-schemas'; import * as ChecksumAPI from './checksum'; import * as BlockTypesAPI from '../block-types/block-types'; export class BlockSchemas extends APIResource { checksum: ChecksumAPI.Checksum = new ChecksumAPI.Checksum(this._client); /** * Create Block Schema */ create(params: BlockSchemaCreateParams, options?: Core.RequestOptions): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/block_schemas/', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Get a block schema by id. */ retrieve( id: string, params?: BlockSchemaRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; retrieve( id: string, params: BlockSchemaRetrieveParams | 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/block_schemas/${id}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete a block schema by id. */ delete(id: string, params?: BlockSchemaDeleteParams, options?: Core.RequestOptions): Core.APIPromise; delete(id: string, options?: Core.RequestOptions): Core.APIPromise; delete( id: string, params: BlockSchemaDeleteParams | 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_schemas/${id}`, { ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Read all block schemas, optionally filtered by type */ filter( params?: BlockSchemaFilterParams, options?: Core.RequestOptions, ): Core.APIPromise; filter(options?: Core.RequestOptions): Core.APIPromise; filter( params: BlockSchemaFilterParams | 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_schemas/filter', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } /** * An ORM representation of a block schema. */ export interface BlockSchema { /** * A block type ID */ block_type_id: string | null; /** * The block schema's unique checksum */ checksum: string; id?: string; /** * An ORM representation of a block type */ block_type?: BlockTypesAPI.BlockType | null; /** * A list of Block capabilities */ capabilities?: Array; created?: string | null; /** * The block schema's field schema */ fields?: unknown; updated?: string | null; /** * Human readable identifier for the block schema */ version?: string; } export type BlockSchemaFilterResponse = Array; export interface BlockSchemaCreateParams { /** * Body param: A block type ID */ block_type_id: string; /** * Body param: A list of Block capabilities */ capabilities?: Array; /** * Body param: The block schema's field schema */ fields?: unknown; /** * Body param: Human readable identifier for the block schema */ version?: string; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface BlockSchemaRetrieveParams { 'x-prefect-api-version'?: string; } export interface BlockSchemaDeleteParams { 'x-prefect-api-version'?: string; } export interface BlockSchemaFilterParams { /** * Body param: Filter BlockSchemas */ block_schemas?: BlockSchemaFilterParams.BlockSchemas | null; /** * 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 BlockSchemaFilterParams { /** * 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; } } } export namespace BlockSchemas { export import BlockSchema = BlockSchemasAPI.BlockSchema; export import BlockSchemaFilterResponse = BlockSchemasAPI.BlockSchemaFilterResponse; export import BlockSchemaCreateParams = BlockSchemasAPI.BlockSchemaCreateParams; export import BlockSchemaRetrieveParams = BlockSchemasAPI.BlockSchemaRetrieveParams; export import BlockSchemaDeleteParams = BlockSchemasAPI.BlockSchemaDeleteParams; export import BlockSchemaFilterParams = BlockSchemasAPI.BlockSchemaFilterParams; export import Checksum = ChecksumAPI.Checksum; export import ChecksumRetrieveParams = ChecksumAPI.ChecksumRetrieveParams; }