@adobe/aio-cli-plugin-api-mesh 5.4.2 → 5.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/api-mesh/__tests__/get.test.js +136 -51
- package/src/commands/api-mesh/get.js +37 -41
- package/src/commands/api-mesh/source/install.js +1 -1
- package/src/commands/api-mesh/status.js +1 -1
- package/src/lib/smsClient.js +29 -10
- package/src/utils.js +7 -0
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.4.2","commands":{"api-mesh":{"id":"api-mesh","description":"Create, run, test, and deploy API Mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{},"args":[]},"api-mesh:create":{"id":"api-mesh:create","description":"Create a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:delete":{"id":"api-mesh:delete","description":"Delete the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:describe":{"id":"api-mesh:describe","description":"Get details of a mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:get":{"id":"api-mesh:get","description":"Get the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[{"name":"file"}]},"api-mesh:init":{"id":"api-mesh:init","description":"This command will create a workspace where you can organise your API mesh configuration and other files","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[{"description":"API mesh workspace init","command":"aio api-mesh init commerce-mesh"},{"description":"API mesh workspace init with flags","command":"aio api-mesh init commerce-mesh --path ./mesh_projects/test_mesh --git y --packageManager yarn"}],"flags":{"path":{"name":"path","type":"option","char":"p","default":"."},"packageManager":{"name":"packageManager","type":"option","char":"m","options":["npm","yarn"]},"git":{"name":"git","type":"option","char":"g","options":["y","n"]}},"args":[{"name":"projectName","description":"Project name","required":true}]},"api-mesh:log-get-bulk":{"id":"api-mesh:log-get-bulk","description":"Download all mesh logs for a selected time period.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"startTime":{"name":"startTime","type":"option","description":"Start time for the logs in UTC"},"endTime":{"name":"endTime","type":"option","description":"End time for the logs in UTC"},"filename":{"name":"filename","type":"option","description":"Path to the output file for logs","required":true},"past":{"name":"past","type":"option","description":"Past time window in minutes"}},"args":[]},"api-mesh:log-get":{"id":"api-mesh:log-get","description":"Get the Log of a given mesh by RayId","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"rayId","description":"Fetch a single log by rayID","required":true}]},"api-mesh:log-list":{"id":"api-mesh:log-list","description":"Get recent logs of requests made to the API Mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"filename":{"name":"filename","type":"option","description":"Name of CSV file to export the recent logs to"}},"args":[]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server","default":5000},"inspectPort":{"name":"inspectPort","type":"option","char":"i","description":"Port number for the local dev server inspector","default":9229},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file","description":"Mesh File"}]},"api-mesh:status":{"id":"api-mesh:status","description":"Get a mesh status with a given meshid.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:update":{"id":"api-mesh:update","description":"Update a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:cache:purge":{"id":"api-mesh:cache:purge","description":"Cache purge for a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"all":{"name":"all","type":"boolean","char":"a","description":"Purge all cache. CLI will purge all cache data.","required":true,"allowNo":false}},"args":[]},"api-mesh:config":{"id":"api-mesh:config","description":"The 'config' command includes the following options:\n- set: Set log forwarding details for a given mesh.\n- get: Retrieve log forwarding details for a given mesh.\n- delete: Delete log forwarding details for a given mesh.","usage":"api-mesh:config [COMMAND]","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{},"args":[]},"api-mesh:source:discover":{"id":"api-mesh:source:discover","description":"Return the list of avaliable sources","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm install action prompt. CLI will not check ask user to install source.","allowNo":false}},"args":[]},"api-mesh:source:get":{"id":"api-mesh:source:get","description":"Command returns the content of a specific source.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:get -s=<version>@<source_name>","$ aio api-mesh:source:get -s<source_name>","$ aio api-mesh:source:get -m"],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm print action prompt. CLI will not check ask user to print source.","allowNo":false},"source":{"name":"source","type":"option","char":"s","description":"Source name"},"multiple":{"name":"multiple","type":"boolean","char":"m","description":"Select multiple sources","allowNo":false}},"args":[]},"api-mesh:source:install":{"id":"api-mesh:source:install","description":"Command to install the source to your API mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:install <version>@<source_name>","$ aio api-mesh:source:install <source_name> -v <variable_name>=<variable_value>","$ aio api-mesh:source:install <source_name> -f <path_to_variables_file>"],"flags":{"source":{"name":"source","type":"option","char":"s","description":"Source name"},"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm override action prompt. CLI will not check ask user to override source.","allowNo":false},"variable":{"name":"variable","type":"option","char":"v","description":"Variables required for the source"},"variable-file":{"name":"variable-file","type":"option","char":"f","description":"Variables file path"},"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"source"}]},"api-mesh:config:delete:log-forwarding":{"id":"api-mesh:config:delete:log-forwarding","description":"Delete log forwarding details for a given mesh","usage":"api-mesh:config:delete:log-forwarding","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:config:set:log-forwarding":{"id":"api-mesh:config:set:log-forwarding","description":"Sets the log forwarding destination for API mesh. \n- Select a log forwarding destination - Choose from available options (for example, New Relic).\n- Enter the base URI - Provide the URI for the log forwarding service. Ensure it includes the protocol (for example, if the hosted region of the New Relic account is the U.S, the base URI could be 'https://log-api.newrelic.com/log/v1').\n- Enter the license key - Provide the INGEST-LICENSE API key type.","usage":"api-mesh:config:set:log-forwarding","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[]},"api-mesh:config:get:log-forwarding:errors":{"id":"api-mesh:config:get:log-forwarding:errors","description":"Get log forwarding errors for the mesh.","usage":"api-mesh:config:get:log-forwarding:errors","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"filename":{"name":"filename","type":"option","description":"Name of CSV file to export the recent logs to"}},"args":[]},"api-mesh:config:get:log-forwarding":{"id":"api-mesh:config:get:log-forwarding","description":"Get log forwarding details and error logs for a specified mesh.\n\n-The 'log-forwarding' command includes the following options:\n\n- api-mesh:config:get:log-forwarding : Retrieve log forwarding details for a given mesh.\n- api-mesh:config:get:log-forwarding:errors : Download log forwarding error logs for a selected time period.","usage":"api-mesh:config:get:log-forwarding","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[]}}}
|
|
1
|
+
{"version":"5.5.0-beta.1","commands":{"api-mesh":{"id":"api-mesh","description":"Create, run, test, and deploy API Mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{},"args":[]},"api-mesh:create":{"id":"api-mesh:create","description":"Create a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:delete":{"id":"api-mesh:delete","description":"Delete the config of a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:describe":{"id":"api-mesh:describe","description":"Get details of a mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:get":{"id":"api-mesh:get","description":"Get the config of a specified mesh. Use the --active flag to retrieve the last successfully deployed mesh config","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false},"active":{"name":"active","type":"boolean","char":"a","description":"Retrieve the last successfully deployed mesh config","allowNo":false}},"args":[{"name":"file"}]},"api-mesh:init":{"id":"api-mesh:init","description":"This command will create a workspace where you can organise your API mesh configuration and other files","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[{"description":"API mesh workspace init","command":"aio api-mesh init commerce-mesh"},{"description":"API mesh workspace init with flags","command":"aio api-mesh init commerce-mesh --path ./mesh_projects/test_mesh --git y --packageManager yarn"}],"flags":{"path":{"name":"path","type":"option","char":"p","default":"."},"packageManager":{"name":"packageManager","type":"option","char":"m","options":["npm","yarn"]},"git":{"name":"git","type":"option","char":"g","options":["y","n"]}},"args":[{"name":"projectName","description":"Project name","required":true}]},"api-mesh:log-get-bulk":{"id":"api-mesh:log-get-bulk","description":"Download all mesh logs for a selected time period.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"startTime":{"name":"startTime","type":"option","description":"Start time for the logs in UTC"},"endTime":{"name":"endTime","type":"option","description":"End time for the logs in UTC"},"filename":{"name":"filename","type":"option","description":"Path to the output file for logs","required":true},"past":{"name":"past","type":"option","description":"Past time window in minutes"}},"args":[]},"api-mesh:log-get":{"id":"api-mesh:log-get","description":"Get the Log of a given mesh by RayId","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"rayId","description":"Fetch a single log by rayID","required":true}]},"api-mesh:log-list":{"id":"api-mesh:log-list","description":"Get recent logs of requests made to the API Mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"filename":{"name":"filename","type":"option","description":"Name of CSV file to export the recent logs to"}},"args":[]},"api-mesh:run":{"id":"api-mesh:run","description":"Run a local development server that builds and compiles a mesh locally","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"Port number for the local dev server","default":5000},"inspectPort":{"name":"inspectPort","type":"option","char":"i","description":"Port number for the local dev server inspector","default":9229},"debug":{"name":"debug","type":"boolean","description":"Enable debugging mode","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"select":{"name":"select","type":"boolean","description":"Retrieve existing artifacts from the mesh","allowNo":false},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file","description":"Mesh File"}]},"api-mesh:status":{"id":"api-mesh:status","description":"Get a mesh status with a given meshid.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[]},"api-mesh:update":{"id":"api-mesh:update","description":"Update a mesh with the given config.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"env":{"name":"env","type":"option","char":"e","description":"Path to env file","default":".env"},"secrets":{"name":"secrets","type":"option","char":"s","description":"Path to secrets file","default":false}},"args":[{"name":"file"}]},"api-mesh:cache:purge":{"id":"api-mesh:cache:purge","description":"Cache purge for a given mesh","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"all":{"name":"all","type":"boolean","char":"a","description":"Purge all cache. CLI will purge all cache data.","required":true,"allowNo":false}},"args":[]},"api-mesh:config":{"id":"api-mesh:config","description":"The 'config' command includes the following options:\n- set: Set log forwarding details for a given mesh.\n- get: Retrieve log forwarding details for a given mesh.\n- delete: Delete log forwarding details for a given mesh.","usage":"api-mesh:config [COMMAND]","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{},"args":[]},"api-mesh:source:discover":{"id":"api-mesh:source:discover","description":"Return the list of avaliable sources","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm install action prompt. CLI will not check ask user to install source.","allowNo":false}},"args":[]},"api-mesh:source:get":{"id":"api-mesh:source:get","description":"Command returns the content of a specific source.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:get -s=<version>@<source_name>","$ aio api-mesh:source:get -s<source_name>","$ aio api-mesh:source:get -m"],"flags":{"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm print action prompt. CLI will not check ask user to print source.","allowNo":false},"source":{"name":"source","type":"option","char":"s","description":"Source name"},"multiple":{"name":"multiple","type":"boolean","char":"m","description":"Select multiple sources","allowNo":false}},"args":[]},"api-mesh:source:install":{"id":"api-mesh:source:install","description":"Command to install the source to your API mesh.","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"examples":["$ aio api-mesh:source:install <version>@<source_name>","$ aio api-mesh:source:install <source_name> -v <variable_name>=<variable_value>","$ aio api-mesh:source:install <source_name> -f <path_to_variables_file>"],"flags":{"source":{"name":"source","type":"option","char":"s","description":"Source name"},"confirm":{"name":"confirm","type":"boolean","char":"c","description":"Auto confirm override action prompt. CLI will not check ask user to override source.","allowNo":false},"variable":{"name":"variable","type":"option","char":"v","description":"Variables required for the source"},"variable-file":{"name":"variable-file","type":"option","char":"f","description":"Variables file path"},"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false}},"args":[{"name":"source"}]},"api-mesh:config:delete:log-forwarding":{"id":"api-mesh:config:delete:log-forwarding","description":"Delete log forwarding details for a given mesh","usage":"api-mesh:config:delete:log-forwarding","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false}},"args":[]},"api-mesh:config:set:log-forwarding":{"id":"api-mesh:config:set:log-forwarding","description":"Sets the log forwarding destination for API mesh. \n- Select a log forwarding destination - Choose from available options (for example, New Relic).\n- Enter the base URI - Provide the URI for the log forwarding service. Ensure it includes the protocol (for example, if the hosted region of the New Relic account is the U.S, the base URI could be 'https://log-api.newrelic.com/log/v1').\n- Enter the license key - Provide the INGEST-LICENSE API key type.","usage":"api-mesh:config:set:log-forwarding","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"autoConfirmAction":{"name":"autoConfirmAction","type":"boolean","char":"c","description":"Auto confirm action prompt. CLI will not check for user approval before executing the action.","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[]},"api-mesh:config:get:log-forwarding:errors":{"id":"api-mesh:config:get:log-forwarding:errors","description":"Get log forwarding errors for the mesh.","usage":"api-mesh:config:get:log-forwarding:errors","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"filename":{"name":"filename","type":"option","description":"Name of CSV file to export the recent logs to"}},"args":[]},"api-mesh:config:get:log-forwarding":{"id":"api-mesh:config:get:log-forwarding","description":"Get log forwarding details and error logs for a specified mesh.\n\n-The 'log-forwarding' command includes the following options:\n\n- api-mesh:config:get:log-forwarding : Retrieve log forwarding details for a given mesh.\n- api-mesh:config:get:log-forwarding:errors : Download log forwarding error logs for a selected time period.","usage":"api-mesh:config:get:log-forwarding","pluginName":"@adobe/aio-cli-plugin-api-mesh","pluginType":"core","aliases":[],"flags":{"ignoreCache":{"name":"ignoreCache","type":"boolean","char":"i","description":"Ignore cache and force manual org -> project -> workspace selection","allowNo":false},"json":{"name":"json","type":"boolean","description":"Output JSON","allowNo":false}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ const { writeFile } = require('fs/promises');
|
|
|
34
34
|
const { initSdk } = require('../../../helpers');
|
|
35
35
|
const GetCommand = require('../get');
|
|
36
36
|
const mockGetMeshConfig = require('../../__fixtures__/sample_mesh.json');
|
|
37
|
-
const {
|
|
37
|
+
const { getMesh } = require('../../../lib/smsClient');
|
|
38
38
|
|
|
39
39
|
let logSpy = null;
|
|
40
40
|
let errorLogSpy = null;
|
|
@@ -47,6 +47,7 @@ describe('get command tests', () => {
|
|
|
47
47
|
beforeEach(() => {
|
|
48
48
|
initSdk.mockResolvedValue({
|
|
49
49
|
imsOrgId: selectedOrg.id,
|
|
50
|
+
imsOrgCode: selectedOrg.code,
|
|
50
51
|
projectId: selectedProject.id,
|
|
51
52
|
workspaceId: selectedWorkspace.id,
|
|
52
53
|
workspaceName: selectedWorkspace.title,
|
|
@@ -59,7 +60,6 @@ describe('get command tests', () => {
|
|
|
59
60
|
|
|
60
61
|
writeFile.mockResolvedValue(true);
|
|
61
62
|
|
|
62
|
-
getMeshId.mockResolvedValue('dummy_meshId');
|
|
63
63
|
getMesh.mockResolvedValue({
|
|
64
64
|
meshId: 'dummy_meshId',
|
|
65
65
|
mesh: mockGetMeshConfig,
|
|
@@ -79,7 +79,9 @@ describe('get command tests', () => {
|
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
test('snapshot get command', () => {
|
|
82
|
-
expect(GetCommand.description).toMatchInlineSnapshot(
|
|
82
|
+
expect(GetCommand.description).toMatchInlineSnapshot(
|
|
83
|
+
`"Get the config of a specified mesh. Use the --active flag to retrieve the last successfully deployed mesh config"`,
|
|
84
|
+
);
|
|
83
85
|
expect(GetCommand.args).toMatchInlineSnapshot(`
|
|
84
86
|
[
|
|
85
87
|
{
|
|
@@ -89,6 +91,14 @@ describe('get command tests', () => {
|
|
|
89
91
|
`);
|
|
90
92
|
expect(GetCommand.flags).toMatchInlineSnapshot(`
|
|
91
93
|
{
|
|
94
|
+
"active": {
|
|
95
|
+
"allowNo": false,
|
|
96
|
+
"char": "a",
|
|
97
|
+
"default": false,
|
|
98
|
+
"description": "Retrieve the last successfully deployed mesh config",
|
|
99
|
+
"parse": [Function],
|
|
100
|
+
"type": "boolean",
|
|
101
|
+
},
|
|
92
102
|
"ignoreCache": {
|
|
93
103
|
"allowNo": false,
|
|
94
104
|
"char": "i",
|
|
@@ -109,52 +119,14 @@ describe('get command tests', () => {
|
|
|
109
119
|
expect(GetCommand.aliases).toMatchInlineSnapshot(`[]`);
|
|
110
120
|
});
|
|
111
121
|
|
|
112
|
-
test('should fail if mesh
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return runResult.catch(err => {
|
|
117
|
-
expect(err.message).toMatchInlineSnapshot(
|
|
118
|
-
`"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again."`,
|
|
119
|
-
);
|
|
120
|
-
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
121
|
-
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
122
|
-
[
|
|
123
|
-
[
|
|
124
|
-
"Unable to get mesh config. No mesh found for Org(1234) -> Project(5678) -> Workspace(123456789). Check the details and try again.",
|
|
125
|
-
],
|
|
126
|
-
]
|
|
127
|
-
`);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test('should fail if getMeshId failed', async () => {
|
|
132
|
-
getMeshId.mockRejectedValueOnce(new Error('getMeshId failed'));
|
|
133
|
-
const runResult = GetCommand.run();
|
|
134
|
-
|
|
135
|
-
return runResult.catch(err => {
|
|
136
|
-
expect(err.message).toMatchInlineSnapshot(
|
|
137
|
-
`"Unable to get mesh ID. Check the details and try again. RequestId: dummy_request_id"`,
|
|
138
|
-
);
|
|
139
|
-
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
140
|
-
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`
|
|
141
|
-
[
|
|
142
|
-
[
|
|
143
|
-
"Unable to get mesh ID. Check the details and try again. RequestId: dummy_request_id",
|
|
144
|
-
],
|
|
145
|
-
]
|
|
146
|
-
`);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test('should fail if mesh id is not found', async () => {
|
|
151
|
-
getMesh.mockResolvedValueOnce(null);
|
|
122
|
+
test('should fail if mesh is missing', async () => {
|
|
123
|
+
getMesh.mockRejectedValueOnce(new Error('MeshNotFound'));
|
|
124
|
+
await GetCommand.run();
|
|
152
125
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
126
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
127
|
+
expect(errorLogSpy.mock.calls[0][0]).toBe(
|
|
128
|
+
'Unable to get mesh config. No mesh found for Org(CODE1234@AdobeOrg) -> Project(5678) -> Workspace(123456789). Please check the details and try again.',
|
|
129
|
+
);
|
|
158
130
|
});
|
|
159
131
|
|
|
160
132
|
test('should fail if get mesh method failed', async () => {
|
|
@@ -183,9 +155,7 @@ describe('get command tests', () => {
|
|
|
183
155
|
`);
|
|
184
156
|
});
|
|
185
157
|
|
|
186
|
-
test('should pass if mesh
|
|
187
|
-
const meshId = 'dummy_meshId';
|
|
188
|
-
getMeshId.mockResolvedValueOnce(meshId);
|
|
158
|
+
test('should pass if mesh is found', async () => {
|
|
189
159
|
const runResult = await GetCommand.run();
|
|
190
160
|
|
|
191
161
|
expect(initSdk).toHaveBeenCalledWith({
|
|
@@ -402,4 +372,119 @@ describe('get command tests', () => {
|
|
|
402
372
|
`);
|
|
403
373
|
expect(errorLogSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
404
374
|
});
|
|
375
|
+
|
|
376
|
+
// Active flag test cases
|
|
377
|
+
test('should get last successfully deployed mesh config with --active flag', async () => {
|
|
378
|
+
getMesh.mockResolvedValueOnce({
|
|
379
|
+
meshId: 'dummy_meshId',
|
|
380
|
+
mesh: mockGetMeshConfig,
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
parseSpy.mockResolvedValueOnce({
|
|
384
|
+
args: {},
|
|
385
|
+
flags: {
|
|
386
|
+
ignoreCache: mockIgnoreCacheFlag,
|
|
387
|
+
active: true,
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const runResult = await GetCommand.run();
|
|
392
|
+
|
|
393
|
+
expect(getMesh).toHaveBeenCalledWith(
|
|
394
|
+
selectedOrg.code,
|
|
395
|
+
selectedProject.id,
|
|
396
|
+
selectedWorkspace.id,
|
|
397
|
+
selectedWorkspace.title,
|
|
398
|
+
true,
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
expect(runResult).toBeDefined();
|
|
402
|
+
expect(runResult.meshId).toBe('dummy_meshId');
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test('should get last successfully deployed mesh config with shorthand -a flag', async () => {
|
|
406
|
+
getMesh.mockResolvedValueOnce({
|
|
407
|
+
meshId: 'dummy_meshId',
|
|
408
|
+
mesh: mockGetMeshConfig,
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
parseSpy.mockResolvedValueOnce({
|
|
412
|
+
args: {},
|
|
413
|
+
flags: {
|
|
414
|
+
ignoreCache: mockIgnoreCacheFlag,
|
|
415
|
+
active: true, // -a flag also sets active to true
|
|
416
|
+
},
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
const runResult = await GetCommand.run();
|
|
420
|
+
|
|
421
|
+
expect(getMesh).toHaveBeenCalledWith(
|
|
422
|
+
selectedOrg.code,
|
|
423
|
+
selectedProject.id,
|
|
424
|
+
selectedWorkspace.id,
|
|
425
|
+
selectedWorkspace.title,
|
|
426
|
+
true,
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
expect(runResult).toBeDefined();
|
|
430
|
+
expect(runResult.meshId).toBe('dummy_meshId');
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
test('should handle NoActiveDeploymentFound error when using --active flag', async () => {
|
|
434
|
+
getMesh.mockRejectedValueOnce(new Error('NoActiveDeploymentFound'));
|
|
435
|
+
|
|
436
|
+
parseSpy.mockResolvedValueOnce({
|
|
437
|
+
args: {},
|
|
438
|
+
flags: {
|
|
439
|
+
ignoreCache: mockIgnoreCacheFlag,
|
|
440
|
+
active: true,
|
|
441
|
+
},
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const runResult = GetCommand.run();
|
|
445
|
+
|
|
446
|
+
await expect(runResult).rejects.toEqual(
|
|
447
|
+
new Error(
|
|
448
|
+
'No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: dummy_request_id',
|
|
449
|
+
),
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
453
|
+
expect(errorLogSpy.mock.calls[0][0]).toBe(
|
|
454
|
+
'No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: dummy_request_id',
|
|
455
|
+
);
|
|
456
|
+
expect(getMesh).toHaveBeenCalledWith(
|
|
457
|
+
selectedOrg.code,
|
|
458
|
+
selectedProject.id,
|
|
459
|
+
selectedWorkspace.id,
|
|
460
|
+
selectedWorkspace.title,
|
|
461
|
+
true,
|
|
462
|
+
);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
test('should handle mesh not found when using --active flag', async () => {
|
|
466
|
+
getMesh.mockRejectedValueOnce(new Error('MeshNotFound'));
|
|
467
|
+
|
|
468
|
+
parseSpy.mockResolvedValueOnce({
|
|
469
|
+
args: {},
|
|
470
|
+
flags: {
|
|
471
|
+
ignoreCache: mockIgnoreCacheFlag,
|
|
472
|
+
active: true,
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
await GetCommand.run();
|
|
477
|
+
|
|
478
|
+
expect(logSpy.mock.calls).toMatchInlineSnapshot(`[]`);
|
|
479
|
+
expect(errorLogSpy.mock.calls[0][0]).toBe(
|
|
480
|
+
'Unable to get mesh config. No mesh found for Org(CODE1234@AdobeOrg) -> Project(5678) -> Workspace(123456789). Please check the details and try again.',
|
|
481
|
+
);
|
|
482
|
+
expect(getMesh).toHaveBeenCalledWith(
|
|
483
|
+
selectedOrg.code,
|
|
484
|
+
selectedProject.id,
|
|
485
|
+
selectedWorkspace.id,
|
|
486
|
+
selectedWorkspace.title,
|
|
487
|
+
true,
|
|
488
|
+
);
|
|
489
|
+
});
|
|
405
490
|
});
|
|
@@ -14,8 +14,8 @@ const { writeFile } = require('fs/promises');
|
|
|
14
14
|
|
|
15
15
|
const logger = require('../../classes/logger');
|
|
16
16
|
const { initSdk } = require('../../helpers');
|
|
17
|
-
const { ignoreCacheFlag, jsonFlag } = require('../../utils');
|
|
18
|
-
const {
|
|
17
|
+
const { ignoreCacheFlag, jsonFlag, activeFlag } = require('../../utils');
|
|
18
|
+
const { getMesh } = require('../../lib/smsClient');
|
|
19
19
|
const { buildMeshUrl } = require('../../urlBuilder');
|
|
20
20
|
|
|
21
21
|
require('dotenv').config();
|
|
@@ -24,6 +24,7 @@ class GetCommand extends Command {
|
|
|
24
24
|
static flags = {
|
|
25
25
|
ignoreCache: ignoreCacheFlag,
|
|
26
26
|
json: jsonFlag,
|
|
27
|
+
active: activeFlag,
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
static enableJsonFlag = true;
|
|
@@ -35,67 +36,62 @@ class GetCommand extends Command {
|
|
|
35
36
|
|
|
36
37
|
const ignoreCache = await flags.ignoreCache;
|
|
37
38
|
const json = await flags.json;
|
|
39
|
+
const active = await flags.active;
|
|
38
40
|
|
|
39
41
|
const { imsOrgId, imsOrgCode, projectId, workspaceId, workspaceName } = await initSdk({
|
|
40
42
|
ignoreCache,
|
|
41
43
|
verbose: !json,
|
|
42
44
|
});
|
|
43
45
|
|
|
44
|
-
let meshId = null;
|
|
45
|
-
|
|
46
46
|
try {
|
|
47
|
-
|
|
48
|
-
} catch (err) {
|
|
49
|
-
this.error(
|
|
50
|
-
`Unable to get mesh ID. Check the details and try again. RequestId: ${global.requestId}`,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
47
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, active);
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName, meshId);
|
|
49
|
+
if (mesh) {
|
|
50
|
+
this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2));
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
this.log('Successfully retrieved mesh %s', JSON.stringify(mesh, null, 2));
|
|
52
|
+
const meshUrl = buildMeshUrl(mesh.meshId, workspaceName);
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
if (args.file) {
|
|
55
|
+
try {
|
|
56
|
+
const { meshConfig } = mesh;
|
|
57
|
+
await writeFile(args.file, JSON.stringify({ meshConfig }, null, 2));
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
await writeFile(args.file, JSON.stringify({ meshConfig }, null, 2));
|
|
59
|
+
this.log('Successfully wrote mesh to file %s', args.file);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
this.log('Unable to write mesh to file %s', args.file);
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
} catch (error) {
|
|
70
|
-
this.log('Unable to write mesh to file %s', args.file);
|
|
71
|
-
|
|
72
|
-
logger.error(error);
|
|
73
|
-
}
|
|
63
|
+
logger.error(error);
|
|
74
64
|
}
|
|
75
|
-
|
|
76
|
-
return { ...mesh, meshUrl, imsOrgId, projectId, workspaceId, workspaceName };
|
|
77
|
-
} else {
|
|
78
|
-
logger.error(
|
|
79
|
-
`Unable to get mesh with the ID ${meshId}. Check the mesh ID and try again. RequestId: ${global.requestId}`,
|
|
80
|
-
{ exit: false },
|
|
81
|
-
);
|
|
82
65
|
}
|
|
83
|
-
} catch (error) {
|
|
84
|
-
this.log(error.message);
|
|
85
66
|
|
|
67
|
+
return { ...mesh, meshUrl, imsOrgId, projectId, workspaceId, workspaceName };
|
|
68
|
+
} else {
|
|
69
|
+
this.error(
|
|
70
|
+
`Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
|
|
71
|
+
{ exit: false },
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (error.message === 'MeshNotFound') {
|
|
76
|
+
this.error(
|
|
77
|
+
`Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
|
|
78
|
+
{ exit: false },
|
|
79
|
+
);
|
|
80
|
+
} else if (error.message === 'NoActiveDeploymentFound') {
|
|
81
|
+
this.error(
|
|
82
|
+
`No active deployment found for mesh. Check the details and try again or try without the --active flag. RequestId: ${global.requestId}`,
|
|
83
|
+
);
|
|
84
|
+
} else {
|
|
85
|
+
this.log(error.message);
|
|
86
86
|
this.error(
|
|
87
87
|
`Unable to get mesh. Check the details and try again. If the error persists please contact support. RequestId: ${global.requestId}`,
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
|
-
} else {
|
|
91
|
-
this.error(
|
|
92
|
-
`Unable to get mesh config. No mesh found for Org(${imsOrgCode}) -> Project(${projectId}) -> Workspace(${workspaceId}). Please check the details and try again.`,
|
|
93
|
-
{ exit: false },
|
|
94
|
-
);
|
|
95
90
|
}
|
|
96
91
|
}
|
|
97
92
|
}
|
|
98
93
|
|
|
99
|
-
GetCommand.description =
|
|
94
|
+
GetCommand.description =
|
|
95
|
+
'Get the config of a specified mesh. Use the --active flag to retrieve the last successfully deployed mesh config';
|
|
100
96
|
|
|
101
97
|
module.exports = GetCommand;
|
|
@@ -140,7 +140,7 @@ class InstallCommand extends Command {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
try {
|
|
143
|
-
const mesh = await getMesh(imsOrgCode, projectId, workspaceId,
|
|
143
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
144
144
|
|
|
145
145
|
if (!mesh) {
|
|
146
146
|
this.error(
|
|
@@ -41,7 +41,7 @@ class StatusCommand extends Command {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
try {
|
|
44
|
-
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName
|
|
44
|
+
const mesh = await getMesh(imsOrgCode, projectId, workspaceId, workspaceName);
|
|
45
45
|
this.log(''.padEnd(102, '*'));
|
|
46
46
|
await this.displayMeshStatus(mesh, imsOrgCode, projectId, workspaceId);
|
|
47
47
|
this.log(''.padEnd(102, '*'));
|
package/src/lib/smsClient.js
CHANGED
|
@@ -142,11 +142,27 @@ const listLogs = async (organizationCode, projectId, workspaceId, meshId, fileNa
|
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Retrieves mesh configuration from the Schema Management Service.
|
|
147
|
+
*
|
|
148
|
+
* @param {string} organizationId - The organization ID
|
|
149
|
+
* @param {string} projectId - The project ID
|
|
150
|
+
* @param {string} workspaceId - The workspace ID
|
|
151
|
+
* @param {string} workspaceName - The workspace name
|
|
152
|
+
* @param {boolean} active - Whether to retrieve the last successful deployed mesh configuration.
|
|
153
|
+
* @returns {Promise<Object|null>} The mesh configuration object, or null if mesh not found
|
|
154
|
+
* @throws {Error} Throws 'NoActiveDeploymentFound' when active=true but no successful deployment exists
|
|
155
|
+
* @throws {Error} Throws generic error for other API failures
|
|
156
|
+
*/
|
|
157
|
+
const getMesh = async (organizationId, projectId, workspaceId, workspaceName, active) => {
|
|
146
158
|
const { accessToken } = await getDevConsoleConfig();
|
|
159
|
+
|
|
160
|
+
const url = `${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/mesh`;
|
|
161
|
+
const params = active ? { active } : undefined;
|
|
162
|
+
|
|
147
163
|
const config = {
|
|
148
164
|
method: 'get',
|
|
149
|
-
url:
|
|
165
|
+
url: url,
|
|
150
166
|
headers: {
|
|
151
167
|
...global?.metadataHeaders,
|
|
152
168
|
'Authorization': `Bearer ${accessToken}`,
|
|
@@ -154,12 +170,10 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me
|
|
|
154
170
|
'workspaceName': workspaceName,
|
|
155
171
|
'x-api-key': SMS_API_KEY,
|
|
156
172
|
},
|
|
173
|
+
params: params,
|
|
157
174
|
};
|
|
158
175
|
|
|
159
|
-
logger.info(
|
|
160
|
-
'Initiating GET %s',
|
|
161
|
-
`${SMS_BASE_URL}/organizations/${organizationId}/projects/${projectId}/workspaces/${workspaceId}/meshes/${meshId}`,
|
|
162
|
-
);
|
|
176
|
+
logger.info('Initiating GET %s', url);
|
|
163
177
|
|
|
164
178
|
try {
|
|
165
179
|
const response = await axios(config);
|
|
@@ -186,10 +200,15 @@ const getMesh = async (organizationId, projectId, workspaceId, workspaceName, me
|
|
|
186
200
|
logger.info('Response from GET %s', error.response.status);
|
|
187
201
|
|
|
188
202
|
if (error.response.status === 404) {
|
|
189
|
-
//
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
203
|
+
// Check if no active deployment found
|
|
204
|
+
if (active && error.response.data?.message?.includes('No active deployment found')) {
|
|
205
|
+
logger.error('No active deployment found for mesh');
|
|
206
|
+
throw new Error('NoActiveDeploymentFound');
|
|
207
|
+
} else {
|
|
208
|
+
// General mesh not found case
|
|
209
|
+
logger.error('Mesh not found');
|
|
210
|
+
throw new Error('MeshNotFound');
|
|
211
|
+
}
|
|
193
212
|
} else if (error.response && error.response.data) {
|
|
194
213
|
// The request was made and the server responded with an unsupported status code
|
|
195
214
|
logger.error(
|
package/src/utils.js
CHANGED
|
@@ -70,6 +70,12 @@ const inspectPortNoFlag = Flags.integer({
|
|
|
70
70
|
default: 9229,
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
+
const activeFlag = Flags.boolean({
|
|
74
|
+
char: 'a',
|
|
75
|
+
description: 'Retrieve the last successfully deployed mesh config',
|
|
76
|
+
default: false,
|
|
77
|
+
});
|
|
78
|
+
|
|
73
79
|
const debugFlag = Flags.boolean({
|
|
74
80
|
description: 'Enable debugging mode',
|
|
75
81
|
default: false,
|
|
@@ -815,6 +821,7 @@ module.exports = {
|
|
|
815
821
|
getAppRootDir,
|
|
816
822
|
portNoFlag,
|
|
817
823
|
inspectPortNoFlag,
|
|
824
|
+
activeFlag,
|
|
818
825
|
debugFlag,
|
|
819
826
|
selectFlag,
|
|
820
827
|
secretsFlag,
|