import { SeverityEnum } from '../enums/SeverityEnum'; import { SdkConfiguration } from './SdkConfiguration'; /** * SDK Base class for making API calls with logging and timeout functionality. * @module SdkBase */ export default class SdkBase { private logger; protected config: SdkConfiguration; /** * Creates an instance of SdkBase. * @param {SdkConfiguration} config - The SDK configuration. * @throws {Error} Throws an error if the config is null. */ constructor(config: SdkConfiguration); /** * Logs a message with a severity level. * @param {string} sev - The severity level (e.g., SeverityEnum.Debug, 'warn'). * @param {string} msg - The message to log. */ protected log(sev: SeverityEnum, msg: string): void; /** * Sends a PUT request to create an object at a given URL. * @param {string} url - The URL where the object is created. * @param {Object} obj - The object to be created. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @return {Promise} Resolves with the created object. * @throws {Error | ApiErrorResponse} Rejects if the URL or object is invalid or if the request fails. */ protected putCreate(url: string, obj: any, cancellationToken?: AbortController): Promise; /** * Checks if an object exists at a given URL using a HEAD request. * @param {string} url - The URL to check. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @return {Promise} Resolves to true if the object exists. * @throws {Error | ApiErrorResponse} Rejects if the URL is invalid or if the request fails. */ protected head(url: string, cancellationToken?: AbortController): Promise; /** * Retrieves an object from a given URL using a GET request. * @param {string} url - The URL of the object. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @param {Object} [headers] - Additional headers. * @param {boolean} [doNotDeserialize] - Optional flag to not deserialize the response. * @return {Promise} Resolves with the retrieved object. * @throws {Error} Rejects if the URL is invalid or if the request fails. */ protected get(url: string, cancellationToken?: AbortController, headers?: any, doNotDeserialize?: boolean): Promise; /** * Retrieves raw data from a given URL using a GET request. * @param {string} url - The URL of the object. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @return {Promise} Resolves with the retrieved data. * @throws {Error | ApiErrorResponse} Rejects if the URL is invalid or if the request fails. */ protected getDataInBytes(url: string, cancellationToken?: AbortController): Promise; /** * Retrieves a list of objects from a given URL using a GET request. * @param {string} url - The URL of the objects. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @param {Object} [headers] - Additional headers. * @return {Promise>} Resolves with the list of retrieved objects. * @throws {Error | ApiErrorResponse} Rejects if the URL is invalid or if the request fails. */ protected getMany(url: string, cancellationToken?: AbortController, headers?: any): Promise; /** * Sends a PUT request to update an object at a given URL. * @param {string} url - The URL where the object is created. * @param {Object} obj - The object to be created. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @return {Promise} Resolves with the created object. * @throws {Error | ApiErrorResponse} Rejects if the URL or object is invalid or if the request fails. */ protected putUpdate(url: string, obj: any, cancellationToken?: AbortController): Promise; /** * Sends a DELETE request to remove an object at a given URL. * @param {string} url - The URL of the object to delete. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @return {Promise} Resolves if the object is successfully deleted. * @throws {Error | ApiErrorResponse} Rejects if the URL is invalid or if the request fails. */ protected del(url: string, cancellationToken?: AbortController): Promise; /** * Submits data using a POST request to a given URL. * @param {string} url - The URL to post data to. * @param {Object|string} data - The data to send in the POST request. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @return {Promise} Resolves with the response data. * @throws {Error | ApiErrorResponse} Rejects if the URL or data is invalid or if the request fails. */ protected post(url: string, data: any, cancellationToken?: AbortController): Promise; /** * Sends a DELETE request to remove an object at a given URL. * @param {string} url - The URL of the object to delete. * @param {Object} obj - The object to be created. * @param {AbortController} [cancellationToken] - Optional cancellation token for cancelling the request. * @return {Promise} Resolves if the object is successfully deleted. * @throws {Error | ApiErrorResponse} Rejects if the URL is invalid, the object is not serializable, or if the request fails. */ protected deleteMany(url: string, obj: any, cancellationToken?: AbortController): Promise; /** * Submits a POST request. * @param {string} url - The URL to which the request is sent. * @param {Object} obj - The object to send in the POST request body. * @param {AbortController} [cancellationToken] - Optional cancellation token to cancel the request. * @returns {Promise} The response data parsed as an object of type Object, or null if unsuccessful. * @throws {Error | ApiErrorResponse} If the URL is invalid or the object cannot be serialized to JSON. */ protected postBatch(url: string, obj: any, cancellationToken?: AbortController): Promise; }