Skip to content

Commit

Permalink
Final Changes
Browse files Browse the repository at this point in the history
Signed-off-by: Partik SIngh <[email protected]>
  • Loading branch information
partik03 committed Aug 28, 2023
1 parent b097c86 commit 88dcb88
Show file tree
Hide file tree
Showing 48 changed files with 4,413 additions and 4,042 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const ncProviders = nodeCloud.getProviders(options);
| | Peering/Dedicated Interconnect | Direct Connect | Cloud Interconnect\* | ExpressRoute\* | - | Express Connect\* | - | - |
| | DNS | Route53 | Google Domains, Cloud DNS | Azure DNS | DO DNS | Alibaba Cloud DNS\* | Domains | OCI DNS |
| Databases | RDBMS | RDS, Amazon Aurora*, Amazon Redshift* | Cloud SQL\*, Cloud Spanner | SQL Database, Azure Database for MySQL*, Azure Database for PostgreSQL* | Managed Databases(PostgreSQL\* and MySQL) | ApsaraDB (MySQL, MariaDB TX, SQL Server, PostgreSQL) | Database(Postgres and Myssql) | OCI Mysql |
| | NoSQL: key-value | DynamoDB | Cloud Firestore, Cloud Bigtable\* | Table Storage | Managed Databases(Redis)\* | ApsaraDB for Redis\* | - | OCI MOngoDb |
| | NoSQL: key-value | DynamoDB | Cloud Firestore, Cloud Bigtable\* | Table Storage | Managed Databases(Redis)\* | ApsaraDB for Redis\* | - | OCI MongoDb |
| | NoSQL: indexed | Amazon SimpleDB\* | Cloud Firestore | Cosmos DB | - | ApsaraDB for MongoDB\* | - | - |
| Security/ Authorization | Identity Access Management | AWS IAM | Cloud IAM\* | Azure Active Directory*, Azure Role Based Access Control* | - | Resource Access Management\* | - | - |
| Management | Key Management | AWS-KMS | - | - | Do-Keys | - | Monitoring | OCI KeyManagement |
Expand Down
1 change: 0 additions & 1 deletion examples/database/linode-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function createDatabase() {
type: 'g6-dedicated-2',
engine: 'mysql/8.0.30',
replication_type: 'semi_synch',

};

// create database
Expand Down
20 changes: 19 additions & 1 deletion generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,30 @@ Linode:

## Code parsers

This is the simplest part of the code generation tool. The SDK files are read from the relevant SDKs as specified in the `node-cloud.yml` file. Afterwards, it is converted to an **Abstract Syntax Tree**. Finally, the class declaration Node of that **Abstract Syntax Tree** is returned in case of SDKs which are class based,for SDKs like Linode which are function based we collect the FirstStatement nodes in an array which represent the exported arrow function declaration. This retured Node is another **Abstract Syntax Tree** since a class declaration itself is another **Abstract Syntax Tree**.
This is the simplest part of the code generation tool. The SDK files are read from the relevant SDKs as specified in the `node-cloud.yml` file. Afterwards, it is converted to an **Abstract Syntax Tree**. Finally, the class declaration Node of that **Abstract Syntax Tree** is returned in case of SDKs which are class based, for SDKs like Linode which are function based we collect the FirstStatement nodes in an array which represent the exported arrow function declaration. This retured Node is another **Abstract Syntax Tree** since a class declaration itself is another **Abstract Syntax Tree**.

## Data extraction functions

These functions are located in the generators of the each cloud providers. Each data extration function has a unique logic depending on the **Abstract Syntax Tree** of a SDK class. The goal here is to extract all the data required to generate the new JavaScript class. At the end it is retured as `classData`. The data extration function collects imports, clients, method parameters, types of parameters, method return types and package names. Additionally, class relationships are identified in the Google Cloud data extraction function for the Google Cloud class based transformer.

For Linode Cloud Provider in some function the function parameters had two nested parameters so to solve this problem and take both the parameters into consideration the below code has been implemented.

```
if (param.name.elements) {
const parameter: param = {
name:
'{' +
param.name.elements[0].name.text +
',' +
param.name.elements[1].name.text +
'}',
optional: param.questionToken ? true : false,
type: SyntaxKind[param.type.kind],
typeName: null,
};
```
In the above code we have looked for sub elements in a function parameter and printed both of them in braces.

## Transformers

This is the most important part of the code generator tool. Currently, there are four transformers. Two transformers for Google Cloud, and one each for AWS and Azure. All of the transformers runs three main transformations.
Expand Down
130 changes: 67 additions & 63 deletions generator/generatedClasses/Linode/compute/linode-computeInstance.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,72 @@
/*This is an auto generated class, please do not change.*/
/**
* Class to create a ComputeInstanceLinodeClass object
* @category Linode
*/
* Class to create a ComputeInstanceLinodeClass object
* @category Linode
*/
class Linode_ComputeInstance {
/**
*
* @param {module} linodeSdk Linode SDK
* @param {string} linodeToken Linode Token
*/
constructor(linodeSdk, linodeToken) {
this._linode = linodeSdk;
this._linodeToken = linodeToken;
this._linode.setToken(this._linodeToken);
}
/**
* Trigers the getLinodes function of ComputeInstanceLinodeClass
* @param {Params} params - Data required for getLinodes
* @param {Filter} filter - Data required for getLinodes
* @returns {Promise<getLinodesResponse>}
*/
list(params = undefined, filter = undefined) {
return new Promise((resolve, reject) => {
this._linode.getLinodes(params, filter)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
/**
* Trigers the createLinode function of ComputeInstanceLinodeClass
* @param {CreateLinodeRequest} data - Data required for createLinode
* @returns {Promise<createLinodeResponse>}
*/
create(data) {
return new Promise((resolve, reject) => {
this._linode.createLinode(data)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
/**
* Trigers the updateLinode function of ComputeInstanceLinodeClass
* @param {NumberKeyword} linodeId - Data required for updateLinode
* @param {DeepPartial} values - Data required for updateLinode
* @returns {Promise<updateLinodeResponse>}
*/
update(linodeId, values) {
return new Promise((resolve, reject) => {
this._linode.updateLinode(linodeId, values)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
/**
* Trigers the deleteLinode function of ComputeInstanceLinodeClass
* @param {NumberKeyword} linodeId - Data required for deleteLinode
* @returns {Promise<deleteLinodeResponse>}
*/
delete(linodeId) {
return new Promise((resolve, reject) => {
this._linode.deleteLinode(linodeId)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
/**
*
* @param {module} linodeSdk Linode SDK
* @param {string} linodeToken Linode Token
*/
constructor(linodeSdk, linodeToken) {
this._linode = linodeSdk;
this._linodeToken = linodeToken;
this._linode.setToken(this._linodeToken);
}
/**
* Trigers the getLinodes function of ComputeInstanceLinodeClass
* @param {Params} params - Data required for getLinodes
* @param {Filter} filter - Data required for getLinodes
* @returns {Promise<getLinodesResponse>}
*/
list(params = undefined, filter = undefined) {
return new Promise((resolve, reject) => {
this._linode
.getLinodes(params, filter)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
/**
* Trigers the createLinode function of ComputeInstanceLinodeClass
* @param {CreateLinodeRequest} data - Data required for createLinode
* @returns {Promise<createLinodeResponse>}
*/
create(data) {
return new Promise((resolve, reject) => {
this._linode
.createLinode(data)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
/**
* Trigers the updateLinode function of ComputeInstanceLinodeClass
* @param {NumberKeyword} linodeId - Data required for updateLinode
* @param {DeepPartial} values - Data required for updateLinode
* @returns {Promise<updateLinodeResponse>}
*/
update(linodeId, values) {
return new Promise((resolve, reject) => {
this._linode
.updateLinode(linodeId, values)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
/**
* Trigers the deleteLinode function of ComputeInstanceLinodeClass
* @param {NumberKeyword} linodeId - Data required for deleteLinode
* @returns {Promise<deleteLinodeResponse>}
*/
delete(linodeId) {
return new Promise((resolve, reject) => {
this._linode
.deleteLinode(linodeId)
.then(data => resolve(data))
.catch(err => reject(err));
});
}
}
module.exports = Linode_ComputeInstance;
Loading

0 comments on commit 88dcb88

Please sign in to comment.