GSoC 2020: Finally! Automated code generation for Node Cloud Azure plugin

Rajitha Warusavitarana
Leopards Lab
Published in
2 min readJun 16, 2020

--

In the previous article, I explained about the enhancements carried out in the code generator created for the AWS SDK and the bug fix related to the import of the Node Cloud configuration file. I also mentioned that I was thoroughly studying the structure of the Microsoft Azure SDKs to automatically generate JavaScript classes in the Node Cloud Azure plugin. So finally last Sunday I completed the class generation process for the Node Cloud Azure plugin. In this article, I will explain how data is extracted from the Azure SDKs and how JavaScript classes are generated using the extracted data.

First, we need to list down all the services and functions of each cloud provider in a YAML file (node-cloud.yml). Here is an example which is created to automatically generate JavaScript classes for Node Cloud Azure plugin.

The above example contains a few functions related to the Azure container service which is taken from the Azure container service SDK . You might wonder why Typescript definition files are listed along with the SDK functions. In order to explain that we need to dig into the structure of Azure arm SDKs.

Structure of an Azure arm SDK

As shown in the above image, every Azure resource manager SDK contains type definition files in the path ‘esm/operations’. These type definition files contain information about the classes and functions of the SDK. The relevant type definition files are parsed using the Typescript parser. After going through the parsed source files all the necessary data (parameters, return types, client information and class information) are extracted. Using the extracted data node cloud plugin classes are generated. The below diagram explains this process in a detailed manner.

So that’s pretty much it for this week. See you again in another article with more updates of Node Cloud project.

Good Bye…

--

--