UNPKG

fabric-ias

Version:

Node.JS Service for Microsoft Fabric supporting infrastructure as code

120 lines (95 loc) 4.46 kB
<a id="readme-top"></a> <!-- PROJECT LOGO --> <br /> <div align="center"> <h2 align="center">Fabric-IAS</h2> <p align="center"> Node.JS Module for providing Infrastructure as Code to Microsoft Fabric <br /> <!-- <a href="https://github.com/fullsteam-corp-dataeng/npm-pkg-fabric-ias/README.md"><strong>Explore the docs »</strong></a> --> </p> </div> <!-- TABLE OF CONTENTS --> <details> <summary>Table of Contents</summary> - [About Fabric-IAS](#about-fabric-ias) - [Built With](#built-with) - [Getting Started](#getting-started) - [Implement the Service](#implement-the-service) - [Authenticate the Service](#authenticate-the-service) - [Elements](#elements) - [Workspace](#workspace) - [Collections](#collections) - [GIT](#git) - [setConnection](#setconnection) - [status](#status) - [update](#update) </details> <!-- ABOUT Fabric-IAS --> # About Fabric-IAS This node.js module hosts several SPN based API calls useful for controling the Microsoft Fabric Service ### Built With * ![NodeJS][NodeJS] * ![Microsoft-Azure][Microsoft-Azure] * ![GitHub-Actions][GitHub-Actions] ## Getting Started Utilization of this module is as simple as downloading from NPM ```console npm install fabric-ias ``` ### Implement the Service ```js const FabricIASService = require('fabric-ias'); // @param {string} options.tenant - Azure tenant ID. // @param {string} options.client - Client application ID. // @param {string} options.secret - Client secret. const service = new FabricIASService({tenant: tenant_id, client: client_id, secret: client_secret}); ``` ### Authenticate the Service Once the service has been instantiated, you need only call the authorization method of the embedded SPN based OAUTH. ```js await service.OAuth.authorization(); ``` <p align="right">(<a href="#readme-top">back to top</a>)</p> # Elements Fabric-IAS takes a true OOP approach to the Microsoft Fabric Service. Once the service is established, referencing the various components of Fabric are just properties, collections, and methods. ## Workspace **Workspace** is the entrypoint for accessing workspaces from the service ```js const myWorkspace = service.Workspace('db341d98-315d-46cc-9f47-eb68d53256cc') //in all subsequant calls you can reuse service.workspace(GUID) or myWorkspace ``` If this workspace has already been referenced within your code it will return the existing item from the collection, otherwise it instantiates a Workspace object ### Collections Each Workspace object contains a **git** object or interacting with the workspace's code versioning, and an **Environment** collection ### GIT #### setConnection Implemented to assign an already existing Fabric Managed Connection for Github/AZ Devops and assign to the workspace ```js await myWorkspace.git.setConnection('62529ee1-9821-4345-94be-ef31e0088253'); // alternatively use await service.Workspace(WORKSPACE GUID).setConnection(CONNECTION GUID) ``` #### status Implemented to obtain the state of GIT in the workspace and determine if changes are pending. This is required before running an update in order to extract the commit head. This is captured in the background. ```js const status = await myWorkspace.git.status(); ``` #### update Implemented to request and update from git using the head obtained from the status call. This call returns an operation object which can subsequantly be used to Poll the status until the longrunning job completes. ```js const operation = await myWorkspace.git.update(); if(operation){ await operation.pollStatus(function(status, progress){ //Will request an update on the operation in 20 second intervals //Only performs up to 90 requests (30 minutes) //Fires this callback with the status and progress percent //Exits once Status is successful or failed }); } ``` <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> [Microsoft-Azure]: https://custom-icon-badges.demolab.com/badge/Microsoft%20Azure-0089D6?logo=msazure&logoColor=white [GitHub-Actions]: https://img.shields.io/badge/GitHub_Actions-2088FF?logo=github-actions&logoColor=white [NodeJS]: https://img.shields.io/badge/Node.js-6DA55F?logo=node.js&logoColor=white