UNPKG

fabric-ias

Version:

Node.JS Service for Microsoft Fabric supporting infrastructure as code

42 lines (39 loc) 1.34 kB
"use strict"; const AzOauth = require("./azoauth"); const Workspace = require("./workspace"); /** * @class FabricIASService * @classdesc * Entry point for interacting with the Microsoft Fabric IAS API. * Manages authentication and provides access to workspaces. * * @property {AzOauth} OAuth - The OAuth handler instance. * @property {string} endpoint - The base API endpoint. * @property {Object} options - Additional options for API requests. * @property {Array<Workspace>} _workspaces - Cached workspace instances. */ class FabricIASService { /** * Constructs a FabricIASService instance. * @param {Object} options - Options for OAuth authentication. */ constructor(options, handler = null) { this.OAuth = new AzOauth(options); this.handler = handler; this.endpoint = `https://api.fabric.microsoft.com/v1`; this.options = {}; this._workspaces = []; } /** * Returns a Workspace instance for the specified workspace key. * Caches instances for reuse. * * @param {string} key - The workspace ID. * @returns {Workspace} The workspace instance. */ workspace(key) { if (this._workspaces[key] == undefined) this._workspaces[key] = new Workspace(this.OAuth, this.handler, key); return this._workspaces[key]; } } module.exports = FabricIASService;