or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.mdparsing.mdrequests.mdservices.md
tile.json

services.mddocs/

Elyra API Services

High-level service methods for interacting with Elyra's schema and metadata APIs. The FrontendServices class provides CRUD operations for metadata management and schema retrieval with caching, built on top of the RequestHandler for consistent error handling.

import { FrontendServices } from "@elyra/application";
import { Dialog } from '@jupyterlab/apputils';

Capabilities

Frontend Services Class

Service class for accessing the Elyra API with high-level methods for common operations.

/**
 * A service class for accessing the elyra api.
 */
class FrontendServices {
  /**
   * Displays a dialog for error cases during metadata calls.
   * @param namespace - The metadata namespace that was being accessed when the error occurred
   * @returns A promise that resolves with whether the dialog was accepted.
   */
  static noMetadataError(namespace: string): Promise<Dialog.IResult<any>>;
  
  /**
   * Service function for making GET calls to the elyra metadata API.
   * @param namespace - The metadata namespace being accessed
   * @returns A promise that resolves with the requested metadata or an error dialog result
   */
  static getMetadata(namespace: string): Promise<any>;
  
  /**
   * Service function for making POST calls to the elyra metadata API.
   * @param namespace - The metadata namespace being accessed
   * @param requestBody - The body of the request
   * @returns A promise that resolves with the newly created metadata or an error dialog result
   */
  static postMetadata(namespace: string, requestBody: any): Promise<any>;
  
  /**
   * Service function for making PUT calls to the elyra metadata API.
   * @param namespace - The metadata namespace being accessed
   * @param name - The metadata name being updated
   * @param requestBody - The body of the request
   * @returns A promise that resolves with the updated metadata or an error dialog result
   */
  static putMetadata(namespace: string, name: string, requestBody: any): Promise<any>;
  
  /**
   * Service function for making DELETE calls to the elyra metadata API.
   * @param namespace - The metadata namespace being accessed
   * @param name - The metadata name being deleted
   * @returns A promise that resolves void or an error dialog result
   */
  static deleteMetadata(namespace: string, name: string): Promise<any>;
  
  /**
   * Service function for making GET calls to the elyra schema API.
   * @param namespace - The schema namespace being requested
   * @returns A promise that resolves with the requested schemas or an error dialog result
   */
  static getSchema(namespace: string): Promise<any>;
  
  /**
   * Service function for making GET calls to the elyra schema API.
   * @returns A promise that resolves with all available schemas or an error dialog result
   */
  static getAllSchema(): Promise<any>;
}

Metadata Operations

CRUD operations for managing Elyra metadata instances.

Get Metadata

Retrieve metadata instances from a specific namespace.

/**
 * Service function for making GET calls to the elyra metadata API.
 * @param namespace - The metadata namespace being accessed
 * @returns Promise resolving with the requested metadata or an error dialog result
 */
static getMetadata(namespace: string): Promise<any>;

Usage Examples:

import { FrontendServices } from "@elyra/application";

// Get all code snippets
const codeSnippets = await FrontendServices.getMetadata('code-snippets');

// Get runtime images
const runtimeImages = await FrontendServices.getMetadata('runtime-images');

Create Metadata

Create new metadata instances in a specific namespace.

/**
 * Service function for making POST calls to the elyra metadata API.
 * @param namespace - The metadata namespace being accessed
 * @param requestBody - The body of the request
 * @returns Promise resolving with the newly created metadata or an error dialog result
 */
static postMetadata(namespace: string, requestBody: any): Promise<any>;

Usage Examples:

import { FrontendServices } from "@elyra/application";

const newCodeSnippet = {
  schema_name: 'code-snippet',
  display_name: 'My Python Helper',
  name: 'python-helper',
  metadata: {
    language: 'Python',
    code: ['import pandas as pd', 'import numpy as np']
  }
};

const created = await FrontendServices.postMetadata(
  'code-snippets',
  JSON.stringify(newCodeSnippet)
);

Update Metadata

Update existing metadata instances.

/**
 * Service function for making PUT calls to the elyra metadata API.
 * @param namespace - The metadata namespace being accessed
 * @param name - The metadata name being updated
 * @param requestBody - The body of the request
 * @returns Promise resolving with the updated metadata or an error dialog result
 */
static putMetadata(namespace: string, name: string, requestBody: any): Promise<any>;

Usage Examples:

import { FrontendServices } from "@elyra/application";

const updatedCodeSnippet = {
  schema_name: 'code-snippet',
  display_name: 'Updated Python Helper',
  name: 'python-helper',
  metadata: {
    language: 'Python',
    code: ['import pandas as pd', 'import numpy as np', 'import matplotlib.pyplot as plt']
  }
};

const updated = await FrontendServices.putMetadata(
  'code-snippets',
  'python-helper',
  JSON.stringify(updatedCodeSnippet)
);

Delete Metadata

Remove metadata instances from a namespace.

/**
 * Service function for making DELETE calls to the elyra metadata API.
 * @param namespace - The metadata namespace being accessed
 * @param name - The metadata name being deleted
 * @returns Promise resolving void or an error dialog result
 */
static deleteMetadata(namespace: string, name: string): Promise<any>;

Usage Examples:

import { FrontendServices } from "@elyra/application";

// Delete a specific code snippet
await FrontendServices.deleteMetadata('code-snippets', 'python-helper');

Schema Operations

Operations for retrieving Elyra schema definitions with caching.

Get Schema

Retrieve schema definition for a specific namespace with automatic caching.

/**
 * Service function for making GET calls to the elyra schema API.
 * @param namespace - The schema namespace being requested
 * @returns Promise resolving with the requested schemas or an error dialog result
 */
static getSchema(namespace: string): Promise<any>;

Usage Examples:

import { FrontendServices } from "@elyra/application";

// Get code snippet schema (cached after first call)
const codeSnippetSchema = await FrontendServices.getSchema('code-snippets');

// Get runtime image schema
const runtimeImageSchema = await FrontendServices.getSchema('runtime-images');

Get All Schemas

Retrieve all available schemas from all namespaces.

/**
 * Service function for making GET calls to the elyra schema API.
 * @returns Promise resolving with all available schemas or an error dialog result
 */
static getAllSchema(): Promise<any>;

Usage Examples:

import { FrontendServices } from "@elyra/application";

// Get all schemas
const allSchemas = await FrontendServices.getAllSchema();

// Filter schemas by name
const schemaNames = allSchemas.map((schema: any) => schema.name);
console.log('Available schemas:', schemaNames);

Error Handling

Display specialized error dialogs for metadata operations.

/**
 * Displays a dialog for error cases during metadata calls.
 * @param namespace - The metadata namespace that was being accessed when the error occurred
 * @returns Promise resolving with whether the dialog was accepted
 */
static noMetadataError(namespace: string): Promise<Dialog.IResult<any>>;

Usage Examples:

import { FrontendServices } from "@elyra/application";

// Show error when no metadata is configured
try {
  const metadata = await FrontendServices.getMetadata('custom-namespace');
  if (!metadata || metadata.length === 0) {
    await FrontendServices.noMetadataError('custom-namespace');
  }
} catch (error) {
  await FrontendServices.noMetadataError('custom-namespace');
}

API Endpoints

FrontendServices uses these base endpoints defined as constants:

  • Metadata API: elyra/metadata/ (ELYRA_METADATA_API_ENDPOINT) - For CRUD operations on metadata instances
  • Schema API: elyra/schema/ (ELYRA_SCHEMA_API_ENDPOINT) - For retrieving schema definitions
  • Namespace API: elyra/namespace - For listing available namespaces

These endpoints are relative to the JupyterLab server base URL and are automatically joined by the RequestHandler's ServerConnection utilities.

Caching

The schema retrieval methods implement automatic caching:

  • First call to getSchema(namespace) fetches from server and caches the result
  • Subsequent calls return deep copies of cached data
  • Cache is maintained per namespace for the lifetime of the session