// 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 BlockTypesAPI from './block-types'; import * as BlockDocumentsAPI from './block-documents'; import * as SlugAPI from './slug/slug'; export class BlockTypes extends APIResource { slug: SlugAPI.Slug = new SlugAPI.Slug(this._client); blockDocuments: BlockDocumentsAPI.BlockDocuments = new BlockDocumentsAPI.BlockDocuments(this._client); /** * Create a new block type */ create(params: BlockTypeCreateParams, options?: Core.RequestOptions): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/block_types/', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Get a block type by ID. */ retrieve( id: string, params?: BlockTypeRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; retrieve( id: string, params: BlockTypeRetrieveParams | 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_types/${id}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Update a block type. */ update(id: string, params: BlockTypeUpdateParams, options?: Core.RequestOptions): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.patch(`/api/block_types/${id}`, { body, ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete Block Type */ delete(id: string, params?: BlockTypeDeleteParams, options?: Core.RequestOptions): Core.APIPromise; delete(id: string, options?: Core.RequestOptions): Core.APIPromise; delete( id: string, params: BlockTypeDeleteParams | 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_types/${id}`, { ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Gets all block types. Optionally limit return with limit and offset. */ filter( params?: BlockTypeFilterParams, options?: Core.RequestOptions, ): Core.APIPromise; filter(options?: Core.RequestOptions): Core.APIPromise; filter( params: BlockTypeFilterParams | 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_types/filter', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Install System Block Types */ installSystemBlockTypes( params?: BlockTypeInstallSystemBlockTypesParams, options?: Core.RequestOptions, ): Core.APIPromise; installSystemBlockTypes(options?: Core.RequestOptions): Core.APIPromise; installSystemBlockTypes( params: BlockTypeInstallSystemBlockTypesParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.installSystemBlockTypes({}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion } = params; return this._client.post('/api/block_types/install_system_block_types', { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } /** * An ORM representation of a block type */ export interface BlockType { /** * A block type's name */ name: string; /** * A block type's slug */ slug: string; id?: string; /** * A code snippet demonstrating use of the corresponding block */ code_example?: string | null; created?: string | null; /** * A short blurb about the corresponding block's intended use */ description?: string | null; /** * Web URL for the block type's documentation */ documentation_url?: string | null; /** * Protected block types cannot be modified via API. */ is_protected?: boolean; /** * Web URL for the block type's logo */ logo_url?: string | null; updated?: string | null; } export type BlockTypeFilterResponse = Array; export type BlockTypeInstallSystemBlockTypesResponse = unknown; export interface BlockTypeCreateParams { /** * Body param: A block type's name */ name: string; /** * Body param: A block type's slug */ slug: string; /** * Body param: A code snippet demonstrating use of the corresponding block */ code_example?: string | null; /** * Body param: A short blurb about the corresponding block's intended use */ description?: string | null; /** * Body param: Web URL for the block type's documentation */ documentation_url?: string | null; /** * Body param: Web URL for the block type's logo */ logo_url?: string | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface BlockTypeRetrieveParams { 'x-prefect-api-version'?: string; } export interface BlockTypeUpdateParams { /** * Body param: */ code_example?: string | null; /** * Body param: */ description?: string | null; /** * Body param: */ documentation_url?: string | null; /** * Body param: */ logo_url?: string | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface BlockTypeDeleteParams { 'x-prefect-api-version'?: string; } export interface BlockTypeFilterParams { /** * Body param: Filter BlockSchemas */ block_schemas?: BlockTypeFilterParams.BlockSchemas | null; /** * Body param: Filter BlockTypes */ block_types?: BlockTypeFilterParams.BlockTypes | 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 BlockTypeFilterParams { /** * 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 BlockTypeInstallSystemBlockTypesParams { 'x-prefect-api-version'?: string; } export namespace BlockTypes { export import BlockType = BlockTypesAPI.BlockType; export import BlockTypeFilterResponse = BlockTypesAPI.BlockTypeFilterResponse; export import BlockTypeInstallSystemBlockTypesResponse = BlockTypesAPI.BlockTypeInstallSystemBlockTypesResponse; export import BlockTypeCreateParams = BlockTypesAPI.BlockTypeCreateParams; export import BlockTypeRetrieveParams = BlockTypesAPI.BlockTypeRetrieveParams; export import BlockTypeUpdateParams = BlockTypesAPI.BlockTypeUpdateParams; export import BlockTypeDeleteParams = BlockTypesAPI.BlockTypeDeleteParams; export import BlockTypeFilterParams = BlockTypesAPI.BlockTypeFilterParams; export import BlockTypeInstallSystemBlockTypesParams = BlockTypesAPI.BlockTypeInstallSystemBlockTypesParams; export import Slug = SlugAPI.Slug; export import SlugRetrieveParams = SlugAPI.SlugRetrieveParams; export import BlockDocuments = BlockDocumentsAPI.BlockDocuments; export import BlockDocumentRetrieveParams = BlockDocumentsAPI.BlockDocumentRetrieveParams; }