// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as DeploymentsAPI from './deployments'; import { DeploymentCreateParams, DeploymentListLogsParams, DeploymentListLogsResponse, DeploymentListResponse, DeploymentRetrieveParams, Deployments, FunctionDeployment, } from './deployments'; import * as ExecutionsAPI from './executions'; import { ExecutionCreateParams, ExecutionListLogsParams, ExecutionListLogsResponse, ExecutionListParams, ExecutionRetrieveParams, Executions, FunctionExecution, FunctionExecutionsPageCursorURL, } from './executions'; import { APIPromise } from '../../core/api-promise'; import { PageCursorURL, PagePromise } from '../../core/pagination'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; /** * Functions defined by the company */ export class Functions extends APIResource { deployments: DeploymentsAPI.Deployments = new DeploymentsAPI.Deployments(this._client); executions: ExecutionsAPI.Executions = new ExecutionsAPI.Executions(this._client); /** * A list of functions. * * - Requires: `API Tier 2` * - Sortable fields: `id`, `created_at`, `updated_at` */ list( query: FunctionListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/functions/', PageCursorURL, { query, ...options }); } /** * Create a new function. */ create(body: FunctionCreateParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.post('/functions/', { body, ...options }); } /** * Retrieve a specific function. */ retrieve(functionAPIName: string, options?: RequestOptions): APIPromise { return this._client.get(path`/functions/${functionAPIName}/`, options); } /** * Update a function */ update( functionAPIName: string, body: FunctionUpdateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.patch(path`/functions/${functionAPIName}/`, { body, ...options }); } /** * Create a new function dev bundle. */ createDevBundle( functionAPIName: string, body?: FunctionCreateDevBundleParams | null | undefined, options?: RequestOptions, ): APIPromise { return this._client.post(path`/functions/${functionAPIName}/dev_bundles/`, { body, ...options }); } } export type FunctionsPageCursorURL = PageCursorURL; export interface Function { /** * Identifier field */ id: string; /** * Record creation date */ created_at: string; /** * Record update date */ updated_at: string; /** * The API name of the function */ api_name?: string; /** * The current draft of code for the function */ code_draft?: string; /** * The dependencies of the function */ dependencies?: unknown; /** * The function description */ description?: string; /** * Whether this function runs asynchronously */ is_async?: boolean; /** * The function name */ name?: string; } export interface FunctionCreateDevBundleResponse { /** * The bundle contents as a base64 encoded zip */ contents?: string; } export interface FunctionListParams { order_by?: string; } export interface FunctionCreateParams { /** * The API name of the function */ api_name?: string; /** * The current draft of code for the function */ code_draft?: string; /** * The dependencies of the function */ dependencies?: unknown; /** * The function description */ description?: string; /** * Whether this function runs asynchronously */ is_async?: boolean; /** * The function name */ name?: string; } export interface FunctionUpdateParams { /** * The current draft of code for the function */ code_draft?: string; /** * The dependencies of the function */ dependencies?: unknown; /** * The function description */ description?: string; /** * The function name */ name?: string; } export interface FunctionCreateDevBundleParams {} Functions.Deployments = Deployments; Functions.Executions = Executions; export declare namespace Functions { export { type Function as Function, type FunctionCreateDevBundleResponse as FunctionCreateDevBundleResponse, type FunctionsPageCursorURL as FunctionsPageCursorURL, type FunctionListParams as FunctionListParams, type FunctionCreateParams as FunctionCreateParams, type FunctionUpdateParams as FunctionUpdateParams, type FunctionCreateDevBundleParams as FunctionCreateDevBundleParams, }; export { Deployments as Deployments, type FunctionDeployment as FunctionDeployment, type DeploymentListResponse as DeploymentListResponse, type DeploymentListLogsResponse as DeploymentListLogsResponse, type DeploymentCreateParams as DeploymentCreateParams, type DeploymentRetrieveParams as DeploymentRetrieveParams, type DeploymentListLogsParams as DeploymentListLogsParams, }; export { Executions as Executions, type FunctionExecution as FunctionExecution, type ExecutionListLogsResponse as ExecutionListLogsResponse, type FunctionExecutionsPageCursorURL as FunctionExecutionsPageCursorURL, type ExecutionListParams as ExecutionListParams, type ExecutionCreateParams as ExecutionCreateParams, type ExecutionRetrieveParams as ExecutionRetrieveParams, type ExecutionListLogsParams as ExecutionListLogsParams, }; }