/** * (C) Copyright IBM Corp. 2025-2026. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import type { UserOptions } from 'ibm-cloud-sdk-core'; import { BaseService } from 'ibm-cloud-sdk-core'; import type { Stream } from "../lib/common.mjs"; import type { CreateStreamParameters, DeleteParameters, GetParameters, HttpsAgentMap, PostParameters, PutParameters, Response, Certificates, TokenAuthenticationOptions } from "./types/base.mjs"; import type { ContextIdentifiers } from "../types/common.mjs"; /** * WatsonxBaseService class extends BaseService and provides common functionalities for Watsonx * services. * * @category BaseService */ export declare class WatsonxBaseService extends BaseService { /** @ignore */ static DEFAULT_SERVICE_URL: string; /** @ignore */ static DEFAULT_SERVICE_NAME: string; static PLATFORM_URLS_MAP: Record; /** The version date for the API of the form `YYYY-MM-DD`. */ version: string; /** URL required for dataplatform endpoints */ wxServiceUrl: string; /** URL required for watsonx inference endpoints */ serviceUrl: string; httpsAgentMap: HttpsAgentMap; projectId?: string; spaceId?: string; /** * Constructs an instance of WatsonxBaseService with passed in options and external configuration. * * @category Constructor * @param {UserOptions} [options] - The parameters to send to the service. * @param {string} [options.version] - The version date for the API of the form `YYYY-MM-DD` * @param {string} [options.serviceUrl] - The base URL for the service * @param {string} [options.serviceName] - The name of the service to configure * @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate * requests to the service * @param {Certificates['caCert']} [options.caCert] - Certificate configuration for HTTPS * connections * @param {string} [options.projectId] - The project ID to use for API requests * @param {string} [options.spaceId] - The space ID to use for API requests */ constructor(options?: UserOptions & Certificates & TokenAuthenticationOptions); /** * Resolves projectId and spaceId with fallback to instance values. * * This method implements a priority-based resolution strategy: * * 1. If both instance values (this.projectId/this.spaceId) AND parameter values exist, parameter * values take absolute precedence and instance values are ignored * 2. Otherwise, parameter values are used if provided, falling back to instance values * * This ensures that explicitly passed parameters always override instance configuration when both * are present, preventing unintended mixing of project and space contexts. * * @private * @param {Object} params - Object containing optional projectId and spaceId * @param {string} [params.projectId] - The project ID to use for the request * @param {string} [params.spaceId] - The space ID to use for the request * @returns {Object} Resolved projectId and spaceId values * @returns {string | undefined} Return.projectId - The resolved project ID (from params or * instance) * @returns {string | undefined} Return.spaceId - The resolved space ID (from params or instance) */ protected resolveContextId(params: { projectId?: string; spaceId?: string; }): { projectId?: string; spaceId?: string; }; } /** * APIBaseService class extends WatsonxBaseService and provides common API request functionalities. * * @category APIBaseService */ export declare class APIBaseService extends WatsonxBaseService { /** * Forms container ID headers based on project ID or space ID. * * This method creates the appropriate IBM-specific headers for identifying the container (project * or space) that the API request should operate within. It prioritizes parameters passed in the * request over instance-level defaults. * * @param {ContextIdentifiers} [params={}] - Container identifiers (projectId or spaceId). Default * is `{}` * @returns {{ 'X-IBM-PROJECT-ID': string } | { 'X-IBM-SPACE-ID': string } | {}} An object * containing either the project ID header, space ID header, or an empty object if neither is * provided * @protected */ protected _formContainerIdHeaders(params?: ContextIdentifiers, requireContainerId?: boolean): { 'X-IBM-PROJECT-ID': string; } | { 'X-IBM-SPACE-ID': string; } | {}; /** * Appends additional data to request headers. * * This utility method merges override headers with existing headers in the parameters object, * ensuring that custom headers are properly combined without losing existing header data. * * @template T - The type of parameters, constrained to request parameter types with container * identifiers * @param {T} params - The request parameters containing existing headers * @param {Record} overrides - Additional headers to merge into the request * @returns {T} A new parameters object with merged headers * @protected */ protected appendDataToHeaders(params: T, overrides: Record): T; /** * Performs a POST request to the specified URL. * * @template T * @param {PostParameters} params - The parameters for the POST request. * @param {string} params.url - The parameters for the POST request. * @param {Record} [params.body] - Body parameters to be passed to an endpoint * @param {Record} [params.query] - Query parameters to be passed with url. * @param {Record} [params.path] - Path parameters to be used to create url. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers. * @param {AbortSignal} [params.signal] - Signal from AbortController * @returns {Promise>} - A promise that resolves to the response from the POST * request. */ _post(params: PostParameters): Promise>; /** * Performs a GET request to the specified URL. * * @template T * @param {GetParameters} params - The parameters for the GET request. * @param {string} [params.url] - The parameters for the GET request. * @param {Record} [params.query] - Query parameters to be passed with url. * @param {Record} [params.path] - Path parameters to be used to create url. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers. * @param {AbortSignal} [params.signal] - Signal from AbortController * @returns {Promise>} - A promise that resolves to the response from the GET request. */ _get(params: GetParameters): Promise>; /** * Performs a DELETE request to the specified URL. * * @template T * @param {DeleteParameters} params - The parameters for the DELETE request. * @param {string} params.url - The parameters for the DELETE request. * @param {Record} [params.body] - Body parameters to be passed to an endpoint * @param {Record} [params.query] - Query parameters to be passed with url. * @param {Record} [params.path] - Path parameters to be used to create url. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers. * @param {AbortSignal} [params.signal] - Signal from AbortController * @returns {Promise>} - A promise that resolves to the response from the DELETE * request. */ _delete(params: DeleteParameters): Promise>; /** * Performs a PUT request to the specified URL. * * @template T * @param {PutParameters} params - The parameters for the PUT request. * @param {string} params.url - The parameters for the PUT request. * @param {Record} [params.body] - Body parameters to be passed to an endpoint * @param {Record} [params.query] - Query parameters to be passed with url. * @param {Record} [params.path] - Path parameters to be used to create url. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers. * @param {AbortSignal} [params.signal] - Signal from AbortController * @returns {Promise>} - A promise that resolves to the response from the PUT request. */ _put(params: PutParameters): Promise>; /** * Performs a POST request to the specified URL and returns a stream. * * @template T * @param {CreateStreamParameters} params - The parameters for the POST request. * @param {string} params.url - The parameters for the POST request. * @param {Record} [params.body] - Body parameters to be passed to an endpoint * @param {Record} [params.query] - Query parameters to be passed with url. * @param {Record} [params.path] - Path parameters to be used to create url. * @param {Record} [params.returnObject] - Flag that indicates return type. Set * 'true' to return objects, 'false' to return SSE * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers. * @param {AbortSignal} [params.signal] - Signal from AbortController * @returns {Promise>} - A promise that resolves to a stream from the POST * request. */ _postStream(params: CreateStreamParameters): Promise>; } //# sourceMappingURL=base.d.mts.map