GSoC 2020: Completing the Transformers for Google Cloud plugin

This article covers the second phase of the Node Cloud GCP plugin class generation

Rajitha Warusavitarana
Leopards Lab
3 min readJul 24, 2020

--

Welcome to another article of the Node Cloud project. In the previous article, I explained the JavaScript class generation process using Google Cloud client based SDKs. In this article, I will be explaining the second stage of it which is generating code using the Google Cloud class-based SDKs. If you haven’t read my previous article it’s highly recommended to read it as this is a continuation of it.

The class-based transformer and generator works a bit different compared to the other transformers and generators. It parses all the files in the SDK to extract data wherein other SDKs only the relevant files are parsed. This is because we need to identify the class connections, in a more detailed manner “has-a” relationships need to be identified properly as it will be needed when generating the JavaScript classes.

E.g.-

In order to call the “create” function, it should be accessed through a Zone object which can be obtained from a DNS object. Because of that, the transformer should know which object contains the relevant function and how to obtain the required objects.

Generated code for the GCP plugin:

For the class-based SDKs there is a minor change in the node-cloud.yml to record the main class of an SDK. For the above scenario, it’s the DNS class.

The below diagram visualizes the JavaScript class generation process of the class-based Google Cloud SDKs,

After completing the transformer some functions were tested in the Google Cloud environment. Along with that, while working with the class-based transformer, I was able to identify a bug in the “@google-cloud/dns” NPM package. Which is my first contribution to Google APIs :)

With the completion of this transformer, the code generation process for AWS, Azure and Google Cloud is now completed :). Currently, I am writing unit tests for the code generation component.

So that’s pretty much it for this article. Stay tuned to read more updates about the Node Cloud project.

Good Bye…

--

--