import { CogniteExternalId, CogniteInternalId, Limit } from '@cognite/sdk-core'; import { DateRange, ExternalIdPrefix, Metadata } from '../../types'; /** * Status of the function. * - Queued: Initial state when the function is created. * - Deploying: The function is being deployed. * - Ready: The function is ready and can be called. * - Failed: The function deployment failed. */ export type FunctionStatus = 'Queued' | 'Deploying' | 'Ready' | 'Failed'; /** * Runtime for the function. For example, runtime "py312" translates to the latest version of the Python 3.12 series. */ export type FunctionRuntime = 'py310' | 'py311' | 'py312'; /** * Activation status of Functions. * - inactive: Functions have not been activated for the project. * - requested: Activation has been requested. * - activated: Functions have been activated and are ready to use. */ export type FunctionsActivationStatus = 'inactive' | 'requested' | 'activated'; /** * Error that occurred during function build. */ export interface FunctionBuildError { /** * Error message. */ message?: string; /** * Error trace. */ trace?: string; } interface ExternalCogniteFunction { /** * Name of the function. */ name: string; /** * External ID of the function. */ externalId?: CogniteExternalId; /** * File ID of the function source code. */ fileId: CogniteInternalId; /** * Owner of the function. Typically used to know who created it. */ owner?: string; /** * Description of the function. */ description?: string; /** * Custom metadata for the function. */ metadata?: Metadata; /** * Secrets are returned scrambled if set. */ secrets?: Record; /** * Relative path from the root folder to the file containing the handle function. */ functionPath?: string; /** * Environment variables for the function. */ envVars?: Record; /** * Number of CPU cores per function. */ cpu?: number; /** * Memory per function measured in GB. */ memory?: number; /** * The runtime of the function. */ runtime?: FunctionRuntime; } /** * A function in Cognite Functions. */ export interface CogniteFunction extends ExternalCogniteFunction { /** * A server-generated ID for the function. */ id: CogniteInternalId; /** * The time the function was created in CDF. */ createdTime: Date; /** * Status of the function. */ status: FunctionStatus; /** * The complete specification of the function runtime with major, minor and patch version numbers. */ runtimeVersion?: string; /** * Error that occurred during function build. */ error?: FunctionBuildError; /** * The last time the function was called. Not present if the function has never been called. */ lastCalled?: Date; } /** * Item type for creating a new function. */ export interface ExternalCogniteFunctionItem extends ExternalCogniteFunction { /** * Specify a different python package index. */ indexUrl?: string; /** * Extra package index URLs to use when building the function. */ extraIndexUrls?: string[]; } /** * Filter for listing functions. */ export interface FunctionFilterProps { /** * Filter by function name. */ name?: string; /** * Filter by function owner. */ owner?: string; /** * Filter by file ID. */ fileId?: CogniteInternalId; /** * Filter by function status. */ status?: FunctionStatus; /** * Filter by external ID prefix. */ externalIdPrefix?: ExternalIdPrefix; /** * Filter by created time. */ createdTime?: DateRange; /** * Filter by metadata. */ metadata?: Metadata; } /** * Filter request for listing functions. */ export interface FunctionFilter { filter?: FunctionFilterProps; } /** * List scope for listing functions with filter and limit. */ export interface FunctionListScope extends FunctionFilter, Limit { } /** * Range for CPU or memory limits. */ export interface FunctionsLimitsRange { /** * Minimum value. */ min: number; /** * Maximum value. */ max: number; /** * Default value. */ default: number; } /** * Service limits for Cognite Functions. */ export interface FunctionsLimits { /** * Timeout of each function call in minutes. */ timeoutMinutes: number; /** * CPU cores range and default. */ cpuCores: FunctionsLimitsRange; /** * Memory in GB range and default. */ memoryGb: FunctionsLimitsRange; /** * Available runtimes. */ runtimes: string[]; /** * Maximum response size of function calls in MB. */ responseSizeMb: number; } /** * Activation status response for Cognite Functions. */ export interface FunctionsActivationResponse { /** * Signifies whether Cognite Functions have been requested or activated for the project. */ status: FunctionsActivationStatus; } export {};