diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6704566 --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/README.md b/README.md index 126ad95..82d12ad 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,44 @@ -# azureGatewayDiscovery -Demo days code for azure gateway discovery +# Azure Gateway Batch Import +Demo days code for azure gateway discovery. For addition deatails on this setup, please reach out to James DeLuca for Azure Gaateway configuration and Gabe Ortiz for Code logic. -##Notion Documentaiton Link +## Functionality +Batch import all APIs listed in Azure API Gateway into the RapidAPI Enterprise Hub + +## Installation +Run the following command +``` npm i ``` + +## Setup .env File + +Add local .env file with the following variables +``` +# Team ID for the Governance Team you have created in Rapid ENT tenent +OWNER_ID= +# REST URL of Platform API in ENT tenent +REST_URL= +# REST HOST of Platform API in ENT tenent +REST_HOST= +# REST API KEY for Platform API in ENT tenent +REST_KEY= +# URL of GQL Platform API in ENT tenent +GQL_URL= +# HOST of GQL Platform API in ENT tenent +GQL_HOST= +# Personal API Key used for GQL Platform API in ENT tenent +GQL_RAPID_IDENTITY_KEY= +# Team API Key used for GQL Platform API in ENT tenent +GQL_RAPID_KEY= +# Name of the Azure Gateway to export APIs from +AZURE_SERVICE_GATEWAY= +# Resource group used for Azure Gateway +AZURE_RESOURCE_GROUP= +# Subscription ID for Azure Gateway +AZURE_SUBSCRIPTION_ID= +# Access key for Azure Gateway +AZURE_SHARED_ACCESS_KEY= +``` + +## Notion Documentaiton Link https://www.notion.so/rapidapi/Azure-Gateway-API-Discovery-02f33835a547403284dc28a5aa7b6328 diff --git a/azureAPIGatewayIngest.js b/azureAPIGatewayIngest.js index 84cdc9f..3ec0445 100644 --- a/azureAPIGatewayIngest.js +++ b/azureAPIGatewayIngest.js @@ -1,4 +1,7 @@ const axios = require("axios") +const FormData = require('form-data'); + +require('dotenv').config(); var data = "" var json = "" @@ -10,33 +13,32 @@ const apiSpecs = {} const apiListings = {} //RapiAPI Rest PAPI Settings -const OWNERID = ''; // Team Number for the Governance Team you will create -const RESTURL = '' // Rest PAPI URL -const RESTHOST = '' // Rest PAPI Host -const RESTKEY = '' // Rest PAPI Key +const OWNERID = process.env.OWNER_ID; // Team Number for the Governance Team you will create +const RESTURL = process.env.REST_URL; // Rest PAPI URL +const RESTHOST = process.env.REST_HOST; // Rest PAPI Host +const RESTKEY = process.env.REST_KEY; // Rest PAPI Key //Rapid GraphQL PAPI Settings -const GQLHOST = '' // GQL PAPI Host -const GQLURL = '' // GQL PAPI URL -const GQLRAPIDIDENTITYKEY = '' // GQL Personel PAPI Key -const GQLRAPIDKEY = '' // GQL Team PAPI Key +const GQLHOST = process.env.GQL_HOST; // GQL PAPI Host +const GQLURL = process.env.GQL_URL; // GQL PAPI URL +const GQLRAPIDIDENTITYKEY = process.env.GQL_RAPID_IDENTITY_KEY; // GQL Personel PAPI Key +const GQLRAPIDKEY = process.env.GQL_RAPID_KEY; // GQL Team PAPI Key //Rapid API Listing via form data settings var FILENAME = ``; -const FormData = require('form-data'); //Azure Settings -const serviceGatway = '' // Set your Azure gateway name as defing -const azureGatewayName = serviceGatway.toLowerCase() -const serviceGatwayApi = serviceGatway+"/apis" -const azureBaseUrl = "https://" + azureGatewayName + ".management.azure-api.net" -const resourceGroup = '' // Set your Azure resource group +const serviceGatway = process.env.AZURE_SERVICE_GATEWAY; // Set your Azure gateway name as defing +const azureGatewayName = serviceGatway.toLowerCase(); +const serviceGatwayApi = serviceGatway+"/apis"; +const azureBaseUrl = "https://" + azureGatewayName + ".management.azure-api.net"; +const resourceGroup = proces.env.AZURE_RESOURCE_GROUP; // Set your Azure resource group const provider = "Microsoft.ApiManagement" const azureAPIversion = "2021-12-01-preview" //Azure Subscription Details -const subscription = '' // Set your Azure subscription id -const sharedAccessKey = '' // Set your Azure SharedAccess Signature +const subscription = process.env.AZURE_SUBSCRIPTION_ID // Set your Azure subscription id +const sharedAccessKey = process.env.AZURE_SHARED_ACCESS_KEY // Set your Azure SharedAccess Signature //Azure Gateway API Endpoints const azureAPISpecURL = `${azureBaseUrl}/subscriptions/${subscription}/resourceGroups/${resourceGroup}/providers/${provider}/service/${serviceGatway}/apis/`; @@ -254,4 +256,4 @@ async function walle() { } } -walle() \ No newline at end of file +walle()