@contiva/sap-integration-suite-client
Version:
SAP Cloud Platform Integration API Client
123 lines (122 loc) • 6.2 kB
TypeScript
/**
* SAP Log Files Client
*
* This file contains a client class for interacting with the
* Log Files API of SAP Cloud Integration, used for accessing
* system logs (HTTP, trace).
*
* @module sap-integration-suite-client/log-files
*/
import { Api as LogFilesApi, ComSapHciApiLogFile, ComSapHciApiLogFileArchive } from '../types/sap.LogFiles';
/**
* SAP Log Files Client
*
* Provides simplified access to the Log Files API (HTTP/Trace logs).
*/
export declare class LogFilesClient {
private api;
private normalizer;
/**
* Creates a new LogFilesClient
*
* @param {LogFilesApi<unknown>} api - The underlying API instance
*/
constructor(api: LogFilesApi<unknown>);
/**
* Retrieves a list of available log file archives.
*
* @returns {Promise<ComSapHciApiLogFileArchive[]>} Promise resolving to a list of archive descriptions.
*
* @example
* const archives = await client.getLogFileArchives();
*/
getLogFileArchives(): Promise<ComSapHciApiLogFileArchive[]>;
/**
* Retrieves metadata for a collection of log files based on scope and type.
* Use `downloadLogFileArchiveCollection` to get the actual content as a ZIP file.
*
* @param {('all' | 'latest')} scope - The scope of logs ('all' or 'latest').
* @param {('http' | 'trace')} logFileType - The type of logs ('http' or 'trace').
* @param {string} [modifiedAfter] - Optional ISO timestamp (yyyy-MM-dd'T'HH:mm:ss'Z') to filter logs modified after this time.
* @returns {Promise<ComSapHciApiLogFileArchive[]>} Promise resolving to a list of archive metadata.
*
* @example
* const latestHttpArchives = await client.getLogFileArchiveCollection('latest', 'http');
* const traceArchivesAfterDate = await client.getLogFileArchiveCollection('all', 'trace', '2023-10-26T10:00:00Z');
*/
getLogFileArchiveCollection(scope: 'all' | 'latest', logFileType: 'http' | 'trace', modifiedAfter?: string): Promise<ComSapHciApiLogFileArchive[]>;
/**
* Downloads a collection of log files as a ZIP archive.
*
* The return type `File` is primarily relevant for browser environments. In Node.js,
* the response needs to be handled differently (e.g., as a Stream or Buffer).
*
* @param {('all' | 'latest')} scope - The scope of logs ('all' or 'latest').
* @param {('http' | 'trace')} logFileType - The type of logs ('http' or 'trace').
* @param {string} [modifiedAfter] - Optional ISO timestamp (yyyy-MM-dd'T'HH:mm:ss'Z') to filter logs modified after this time.
* @returns {Promise<File>} Promise resolving to the downloaded ZIP file (in browser context).
*
* @example
* // In Browser:
* try {
* const zipFile = await client.downloadLogFileArchiveCollection('latest', 'http');
* // ... (code to handle the downloaded file)
* } catch (error) {
* console.error('Download failed:', error);
* }
*/
downloadLogFileArchiveCollection(scope: 'all' | 'latest', logFileType: 'http' | 'trace', modifiedAfter?: string): Promise<File>;
/**
* Retrieves a list of individual log files based on specified criteria.
*
* @param {object} [options] Optional parameters for filtering, pagination, sorting, and selection.
* @param {number} [options.top] Maximum number of files to retrieve.
* @param {number} [options.skip] Number of files to skip.
* @param {string} [options.filter] OData filter string (e.g., "LogFileType eq 'http' and NodeScope eq 'worker'").
* @param {('Name' | 'Name desc' | 'Application' | 'Application desc' | 'LastModified' | 'LastModified desc' | 'ContentType' | 'ContentType desc' | 'LogFileType' | 'LogFileType desc' | 'NodeScope' | 'NodeScope desc')[]} [options.orderby] Sorting order.
* @param {('Name' | 'Application' | 'LastModified' | 'ContentType' | 'LogFileType' | 'NodeScope')[]} [options.select] Properties to select.
* @returns {Promise<ComSapHciApiLogFile[]>} Promise resolving to a list of log files.
*
* @example
* const httpLogs = await client.getLogFiles({ filter: "LogFileType eq 'http'" });
*/
getLogFiles(options?: {
top?: number;
skip?: number;
filter?: string;
orderby?: ('Name' | 'Name desc' | 'Application' | 'Application desc' | 'LastModified' | 'LastModified desc' | 'ContentType' | 'ContentType desc' | 'LogFileType' | 'LogFileType desc' | 'NodeScope' | 'NodeScope desc')[];
select?: ('Name' | 'Application' | 'LastModified' | 'ContentType' | 'LogFileType' | 'NodeScope')[];
}): Promise<ComSapHciApiLogFile[]>;
/**
* Retrieves metadata for a specific log file by its name and application.
* Use `downloadLogFile` to get the actual content.
*
* @param {string} name The name of the log file.
* @param {string} application The application associated with the log file.
* @returns {Promise<ComSapHciApiLogFile | undefined>} Promise resolving to the log file metadata or undefined if not found.
*
* @example
* const logFileInfo = await client.getLogFileByNameAndApp('server.log', 'com.sap.it.rt.application.http.provider');
*/
getLogFileByNameAndApp(name: string, application: string): Promise<ComSapHciApiLogFile | undefined>;
/**
* Downloads a specific log file by its name and application.
*
* The return type `File` is primarily relevant for browser environments. In Node.js,
* the response needs to be handled differently (e.g., as a Stream or Buffer).
*
* @param {string} name The name of the log file.
* @param {string} application The application associated with the log file.
* @returns {Promise<File>} Promise resolving to the downloaded file (in browser context).
*
* @example
* // In Browser:
* try {
* const logFile = await client.downloadLogFile('server.log', 'com.sap.it.rt.application.http.provider');
* // ... (code to handle the downloaded file)
* } catch (error) {
* console.error('Download failed:', error);
* }
*/
downloadLogFile(name: string, application: string): Promise<File>;
}