import { HttpClient } from '@angular/common/http'; import { InjectionToken } from '@angular/core'; import { MtnaLogger } from '@mtna/lib-ui'; import { ExternalRdsAppConfig } from '../models/index'; export interface RdsApiConfig { configPath: string; } export declare const RDS_API_CONFIG: InjectionToken; /** * Service that acts as a central hub for all RDS interactions. * All other RDS services rely on this services for the api url, selected catalog id, and selected data product id. * * This service can be used in one of two ways. * 1. Use the optional RDS_API_CONFIG to inject a path for a json config file. Be sure to load the config file in the `APP_INITIALIZER`. * 2. Don't provide the RDS_API_CONFIG and manually set the api url, and optionally default catalog and data product IDs * * @author Will Davis */ export declare class RdsApiService { protected http: HttpClient; protected logger: MtnaLogger; /** API url for the RDS instance */ apiUrl: string; /** Selected Catalog ID */ catalogId: string; /** Seleted Data Product ID */ dataProductId: string; /** Object read from config JSON file */ private config; /** Path to the config JSON file */ private configPath; /** * Creates an instance of RdsApiService. * @param http HttpClient * @param rdsApiConfig optional configuration that tells where to load the config file */ constructor(http: HttpClient, rdsApiConfig: RdsApiConfig, logger: MtnaLogger); /** * Called by all other services for http calls requiring the api url */ getApiUrl(): string; setApiUrl(url: string): void; /** * Use to get the data found in the second file (config file) */ getConfig(key: K): ExternalRdsAppConfig[K]; /** * Returns the id of the selected catalog. Throws error if * the id has not been set. */ getCatalogId(): string; /** * Checks if the catalog id has been set. */ isCatalogIdSet(): boolean; /** * Sets the catalogId using the selected catalog. */ setCatalogId(id: string): void; /** * Returns the id of the selected data product. Throws error if * the id has not been set. */ getDataProductId(): string; /** * Checks if the data product id has been set. */ isDataProductIdSet(): boolean; /** * Set the dataProductId using the selected data product. */ setDataProductId(id: string): void; /** * Load a config file located at the path provided in `RDS_API_CONFIG`. * This should be done in the angular `APP_INITIALIZER` * * @example * * function initConfig(config: RdsApiService) { * return () => config.loadConfigFile(); * } * * // AppModule providers * providers: [ * { * provide: APP_INITIALIZER, * useFactory: initConfig, * deps: [RdsApiService], * multi: true * } * ], */ loadConfigFile(): Promise; /** * Read the config file and set the api url and any defaults */ private _initializeConfigurations; }