fabric-ias
Version:
Node.JS Service for Microsoft Fabric supporting infrastructure as code
47 lines (44 loc) • 1.61 kB
JavaScript
;
const Base = require("./base");
const Environment = require("./environment");
const Git = require("./git");
/**
* @class Workspace
* @classdesc
* Represents a Microsoft Fabric Workspace.
* Provides access to workspace environments and Git integration.
* Extends the Base class for authentication and API request handling.
*
* @extends Base
*
* @property {string} id - The workspace ID.
* @property {string} endpoint - The API endpoint for the workspace.
* @property {Git} Git - Instance for managing Git integration.
* @property {Array<Environement>} _environments - Cached environment instances.
*/
class Workspace extends Base {
/**
* Constructs a Workspace instance for a given workspace ID.
* @param {AzOauth} OAuthHandler - OAuth handler for authentication.
* @param {string} workspace_id - The workspace ID.
*/
constructor(OAuthHandler, handler, workspace_id) {
super(OAuthHandler, handler);
this.id = workspace_id || '';
this.endpoint = `${this.endpoint}/workspaces/${this.id}`;
this.Git = new Git(OAuthHandler, handler, this.id);
this._environments = [];
}
/**
* Returns an Environement instance for the specified environment key.
* Caches instances for reuse.
*
* @param {string} key - The environment ID.
* @returns {Environement} The environment instance.
*/
environment(key) {
if (this._environments[key] == undefined) this._environments[key] = new Environment(this.OAuth, this.ErrorHandler, this.id, key);
return this._environments[key];
}
}
module.exports = Workspace;