@axway/axway-central-cli 3.10.0-rc.6 → 3.11.0-rc.0

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.
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": "1.0",
3
+ "project": "Amplify - APIC CLI",
4
+ "repo_url": "https://git.ecd.axway.org/apigov/apicentral-cli",
5
+ "security_guide": "https://docs.axway.com/bundle/axway_resources/page/amplify_api_management_platform_security_white_paper.html",
6
+ "requirements": {
7
+ "fortify": false,
8
+ "irius-risk": false,
9
+ "pentest": false,
10
+ "twistlock": false,
11
+ "blackduck": true,
12
+ "third-party-policy-violation": false,
13
+ "appspider": false,
14
+ "insightvm": false
15
+ },
16
+ "suppressions": [
17
+ ]
18
+ }
@@ -34,6 +34,7 @@ var softwareAGWebMethodsAgent = _interopRequireWildcard(require("./softwareAGWeb
34
34
  var traceableAgent = _interopRequireWildcard(require("./traceableAgents"));
35
35
  var platform = _interopRequireWildcard(require("./platform"));
36
36
  var backstageAgent = _interopRequireWildcard(require("./backstageAgents"));
37
+ var sapApiPortalAgent = _interopRequireWildcard(require("./sapApiPortalAgents"));
37
38
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
38
39
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
39
40
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -59,7 +60,8 @@ const agentInstallFlows = {
59
60
  [_types.GatewayTypes.IBMAPICONNECT]: ibmAPIConnectAgent.IBMAPIConnectInstallMethods,
60
61
  [_types.GatewayTypes.SOFTWAREAGWEBMETHODS]: softwareAGWebMethodsAgent.SoftwareAGWebMethodsInstallMethods,
61
62
  [_types.GatewayTypes.TRACEABLE]: traceableAgent.TraceableInstallMethods,
62
- [_types.GatewayTypes.BACKSTAGE]: backstageAgent.BackstageInstallMethods
63
+ [_types.GatewayTypes.BACKSTAGE]: backstageAgent.BackstageInstallMethods,
64
+ [_types.GatewayTypes.SAPAPIPORTAL]: sapApiPortalAgent.SAPAPIPortalInstallMethods
63
65
  };
64
66
  const saasAgentInstallFlows = {
65
67
  [_types.SaaSGatewayTypes.AWS_GATEWAY]: awsSaaSAgents.AWSSaaSInstallMethods,
@@ -20,6 +20,7 @@ const {
20
20
  } = (0, _snooplogg.default)('central: install: agents: aws');
21
21
  const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_DA}`;
22
22
  const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.AWS_TA}`;
23
+ const STAGE_TAG_NAME_LENGTH = 127;
23
24
 
24
25
  // DeploymentTypes - ways the agents may be deployed with an AWS APIGW setup
25
26
  let DeploymentTypes = exports.DeploymentTypes = /*#__PURE__*/function (DeploymentTypes) {
@@ -66,6 +67,7 @@ const AWSPrompts = exports.AWSPrompts = {
66
67
  CONFIG_BUCKET_EXISTS: 'Does this bucket already exist on AWS, or will you create beforehand?',
67
68
  CONFIG_SERVICE: 'Do you want to setup config service?',
68
69
  DA_LOG_GROUP: 'Enter the log group name the discovery agent will log to',
70
+ STAGE_TAG_NAME: 'Enter the name of the tag on AWS API Gateway Stage that holds mapped stage on Amplify Central',
69
71
  DA_QUEUE: 'Enter the discovery queue name',
70
72
  DEPLOYMENT: 'Select the type of deployment you wish to configure',
71
73
  EC2_TYPE: 'Select the EC2 instance type',
@@ -276,6 +278,13 @@ const gatewayConnectivity = async installConfig => {
276
278
  awsAgentValues.logGroup = apiGWTrafficLogGroupName;
277
279
  awsAgentValues.cloudFormationConfig.APIGWTrafficLogGroupName = apiGWTrafficLogGroupName;
278
280
 
281
+ // StageTagName
282
+ const stageTagName = await (0, _basicPrompts.askInput)({
283
+ msg: AWSPrompts.STAGE_TAG_NAME,
284
+ validate: (0, _basicPrompts.validateInputLength)(STAGE_TAG_NAME_LENGTH, "Maximum length of 'stage tag name' is 127")
285
+ });
286
+ awsAgentValues.stageTagName = stageTagName;
287
+
279
288
  // FullTransactionLogging
280
289
  const fullTransactionLogging = (await (0, _basicPrompts.askList)({
281
290
  msg: AWSPrompts.FULL_TRANSACTION_LOGGING,
@@ -21,6 +21,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
21
21
  const {
22
22
  log
23
23
  } = (0, _snooplogg.default)('central: install: agents: saas');
24
+ const STAGE_TAG_NAME_LENGTH = 127;
24
25
  class DataplaneConfig {
25
26
  constructor(type) {
26
27
  _defineProperty(this, "type", void 0);
@@ -108,6 +109,7 @@ class SaasAWSAgentValues extends SaasAgentValues {
108
109
  _defineProperty(this, "externalID", void 0);
109
110
  _defineProperty(this, "accessLogARN", void 0);
110
111
  _defineProperty(this, "fullTransactionLogging", void 0);
112
+ _defineProperty(this, "stageTagName", void 0);
111
113
  this.authType = AWSAuthType.ASSUME;
112
114
  this.accessKey = '';
113
115
  this.secretKey = '';
@@ -116,6 +118,7 @@ class SaasAWSAgentValues extends SaasAgentValues {
116
118
  this.externalID = '';
117
119
  this.accessLogARN = '';
118
120
  this.fullTransactionLogging = false;
121
+ this.stageTagName = '';
119
122
  }
120
123
  getAccessData() {
121
124
  let data = JSON.stringify({
@@ -150,6 +153,7 @@ const SaasPrompts = {
150
153
  ASSUME_ROLE: 'Enter the Role ARN that the agent will Assume',
151
154
  EXTERNAL_ID: 'Enter the External ID the Assume Role expects',
152
155
  ACCESS_LOG_ARN: 'Enter the ARN for the Access Log that the Discovery will add and the Traceability will use',
156
+ STAGE_TAG_NAME: 'Enter the name of the tag on AWS API Gateway Stage that holds mapped stage on Amplify Central',
153
157
  FULL_TRANSACTION_LOGGING: 'Do you want to enable Full Transaction Logging? Please note that CloudWatch costs would increase when Full Transaction Logging is enabled',
154
158
  DA_FREQUENCY: 'How often should the discovery run, leave blank for integrating in CI/CD process',
155
159
  DA_FILTER: 'Please enter the filter conditions for discovery of API Services based on tags',
@@ -335,6 +339,10 @@ const gatewayConnectivity = async installConfig => {
335
339
  // AWS connection details
336
340
  hostedAgentValues = new SaasAWSAgentValues();
337
341
  hostedAgentValues = await askForAWSCredentials(hostedAgentValues);
342
+ hostedAgentValues.stageTagName = await (0, _basicPrompts.askInput)({
343
+ msg: SaasPrompts.STAGE_TAG_NAME,
344
+ validate: (0, _basicPrompts.validateInputLength)(STAGE_TAG_NAME_LENGTH, "Maximum length of 'stage tag name' is 127")
345
+ });
338
346
  if (installConfig.switches.isTaEnabled) {
339
347
  console.log(_chalk.default.gray('\nThe access log ARN is a cloud watch log group amazon resource name'));
340
348
  hostedAgentValues.accessLogARN = await (0, _basicPrompts.askInput)({
@@ -403,12 +411,59 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
403
411
  */
404
412
  console.log('\n');
405
413
  let awsAgentValues = installConfig.gatewayConfig;
406
-
414
+ let resourceFuncsForCleanup = [];
415
+ let referencedIDPs = [];
416
+ let providedIDPs = installConfig.idpConfig[0];
417
+ let providedIDPAuths = installConfig.idpConfig[1];
418
+ // create Identity Provider resource
419
+ try {
420
+ for (let i = 0; i < providedIDPs.length; i++) {
421
+ let idpResource = await helpers.createNewIDPResource(apiServerClient, defsManager, providedIDPs[i]);
422
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpResource === null || idpResource === void 0 ? void 0 : idpResource.name, 'IdentityProvider', 'idp');
423
+ resourceFuncsForCleanup.push(cleanupFunc);
424
+ referencedIDPs.push({
425
+ name: idpResource === null || idpResource === void 0 ? void 0 : idpResource.name
426
+ });
427
+ log(idpResource);
428
+ let encryptedAccessData = await createEncryptedAccessData(providedIDPAuths[i], idpResource);
429
+ providedIDPAuths[i].setAccessData(encryptedAccessData);
430
+ let idpSecResource = await helpers.createNewIDPSecretResource(apiServerClient, defsManager, providedIDPAuths[i], idpResource);
431
+ let anotherCleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, idpSecResource === null || idpSecResource === void 0 ? void 0 : idpSecResource.name, 'IdentityProviderSecret', 'idpsec', idpResource === null || idpResource === void 0 ? void 0 : idpResource.name);
432
+ resourceFuncsForCleanup.push(anotherCleanupFunc);
433
+ }
434
+ } catch (error) {
435
+ log(error);
436
+ console.log(_chalk.default.redBright('rolling back installation. Could not create the Identity Provider resources'));
437
+ await cleanResources(resourceFuncsForCleanup);
438
+ return;
439
+ }
440
+ let refIDPsSubResources = {
441
+ references: {
442
+ identityProviders: referencedIDPs
443
+ }
444
+ };
407
445
  // create the environment, if necessary
408
- installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.isNew ? await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
409
- axwayManaged: installConfig.centralConfig.axwayManaged,
410
- production: installConfig.centralConfig.production
411
- }) : installConfig.centralConfig.ampcEnvInfo.name;
446
+ if (installConfig.centralConfig.ampcEnvInfo.isNew) {
447
+ installConfig.centralConfig.environment = await helpers.createByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', {
448
+ axwayManaged: installConfig.centralConfig.axwayManaged,
449
+ production: installConfig.centralConfig.production
450
+ }, '', refIDPsSubResources);
451
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
452
+ resourceFuncsForCleanup.push(cleanupFunc);
453
+ } else {
454
+ // if the env exists, we simply update the references with the newly created IDPs, while preserving the existing IDP references
455
+ // In the case of any failure during the whole process, we return everything back to how it was before.
456
+ installConfig.centralConfig.environment = installConfig.centralConfig.ampcEnvInfo.name;
457
+ refIDPsSubResources.references.identityProviders.push(...installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders);
458
+ await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', refIDPsSubResources);
459
+ let oldIDPRef = {
460
+ references: {
461
+ identityProviders: installConfig.centralConfig.ampcEnvInfo.referencedIdentityProviders
462
+ }
463
+ };
464
+ let cleanupFunc = async () => await helpers.updateSubResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env', '', oldIDPRef);
465
+ resourceFuncsForCleanup.push(cleanupFunc);
466
+ }
412
467
  if (installConfig.gatewayType === _types.GatewayTypes.AWS_GATEWAY) {
413
468
  if (installConfig.switches.isTaEnabled) {
414
469
  awsAgentValues.dataplaneConfig = new AWSDataplaneConfig(awsAgentValues.accessLogARN, awsAgentValues.fullTransactionLogging);
@@ -418,18 +473,25 @@ const completeInstall = async (installConfig, apiServerClient, defsManager) => {
418
473
  }
419
474
 
420
475
  // create the data plane resource
421
- let dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
476
+ let dataplaneRes;
477
+ try {
478
+ dataplaneRes = await helpers.createNewDataPlaneResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], awsAgentValues.dataplaneConfig);
479
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
480
+ resourceFuncsForCleanup.push(cleanupFunc);
481
+ } catch (error) {
482
+ console.log(_chalk.default.redBright('rolling back installation. Please check the configuration data before re-running install'));
483
+ await cleanResources(resourceFuncsForCleanup);
484
+ return;
485
+ }
422
486
 
423
487
  // create data plane secret resource
424
488
  try {
425
- await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
489
+ let dataplaneSecretRes = await helpers.createNewDataPlaneSecretResource(apiServerClient, defsManager, installConfig.centralConfig.environment, _types.GatewayTypeToDataPlane[installConfig.gatewayType], dataplaneRes.name, await createEncryptedAccessData(awsAgentValues, dataplaneRes));
490
+ let cleanupFunc = async () => await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneSecretRes === null || dataplaneSecretRes === void 0 ? void 0 : dataplaneSecretRes.name, 'DataplaneSecret', 'dps', installConfig.centralConfig.environment);
491
+ resourceFuncsForCleanup.push(cleanupFunc);
426
492
  } catch (error) {
427
493
  console.log(_chalk.default.redBright('rolling back installation. Please check the credential data before re-running install'));
428
- if (installConfig.centralConfig.ampcEnvInfo.isNew) {
429
- await helpers.deleteByResourceType(apiServerClient, defsManager, installConfig.centralConfig.ampcEnvInfo.name, 'Environment', 'env');
430
- } else {
431
- await helpers.deleteByResourceType(apiServerClient, defsManager, dataplaneRes.name, 'Dataplane', 'dp', installConfig.centralConfig.environment);
432
- }
494
+ await cleanResources(resourceFuncsForCleanup);
433
495
  return;
434
496
  }
435
497
 
@@ -450,6 +512,7 @@ const AWSSaaSInstallMethods = exports.AWSSaaSInstallMethods = {
450
512
  GetBundleType: askBundleType,
451
513
  GetDeploymentType: askConfigType,
452
514
  AskGatewayQuestions: gatewayConnectivity,
515
+ AddIDP: true,
453
516
  FinalizeGatewayInstall: completeInstall,
454
517
  ConfigFiles: [],
455
518
  AgentNameMap: {
@@ -466,4 +529,12 @@ const testables = exports.testables = {
466
529
  AWSAuthType,
467
530
  SaasPrompts,
468
531
  ConfigFiles
532
+ };
533
+ // These are useful because there are multiple resources created in a specific order and in case of failure, this goes through
534
+ // everything that was created and deletes it one by one. It deletes the resources in opposite order because resources added
535
+ // at the beginning might be referred by resources added afterwards
536
+ const cleanResources = async cleanupFuncs => {
537
+ for (let i = cleanupFuncs.length - 1; i >= 0; i--) {
538
+ await cleanupFuncs[i]();
539
+ }
469
540
  };
@@ -259,7 +259,8 @@ const agentsDocsUrl = exports.agentsDocsUrl = {
259
259
  IBMAPICONNECT: '',
260
260
  SOFTWAREAGWEBMETHODS: '',
261
261
  TRACEABLE: '',
262
- BACKSTAGE: ''
262
+ BACKSTAGE: '',
263
+ SAPAPIPORTAL: ''
263
264
  };
264
265
 
265
266
  // export * from './updaters';
@@ -37,7 +37,8 @@ const AWSRegexPatterns = exports.AWSRegexPatterns = {
37
37
 
38
38
  // APIGEEXRegexPatterns - regex patters to validate user inputs
39
39
  const APIGEEXRegexPatterns = exports.APIGEEXRegexPatterns = {
40
- APIGEEX_REGEXP_PROJECT_ID: '^[a-z][a-z0-9-]{4,28}[a-z0-9]$'
40
+ APIGEEX_REGEXP_PROJECT_ID: '^[a-z][a-z0-9-]{4,28}[a-z0-9]$',
41
+ APIGEEX_REGEXP_EMAIL_ADDRESS: '^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$'
41
42
  };
42
43
 
43
44
  // AzureRegexPatterns - regex patters to validate user inputs
@@ -17,6 +17,7 @@ class AWSAgentValues {
17
17
  _defineProperty(this, "accessKey", void 0);
18
18
  _defineProperty(this, "secretKey", void 0);
19
19
  _defineProperty(this, "logGroup", void 0);
20
+ _defineProperty(this, "stageTagName", void 0);
20
21
  _defineProperty(this, "fullTransactionLogging", void 0);
21
22
  _defineProperty(this, "region", void 0);
22
23
  _defineProperty(this, "apigwAgentConfigZipFile", void 0);
@@ -36,6 +37,7 @@ class AWSAgentValues {
36
37
  this.accessKey = awsDeployment === 'Other' ? '**Insert Access Key**' : '';
37
38
  this.secretKey = awsDeployment === 'Other' ? '**Insert Secret Key**' : '';
38
39
  this.logGroup = '';
40
+ this.stageTagName = '';
39
41
  this.fullTransactionLogging = false;
40
42
  this.region = '';
41
43
  this.apigwAgentConfigZipFile = '';
@@ -107,6 +109,7 @@ AWS_AUTH_ACCESSKEY={{accessKey}}
107
109
  AWS_AUTH_SECRETKEY={{secretKey}}
108
110
  {{/if}}
109
111
  AWS_LOGGROUP={{logGroup}}
112
+ AWS_STAGETAGNAME={{stageTagName}}
110
113
 
111
114
  # Amplify Central configs
112
115
  CENTRAL_AGENTNAME={{centralConfig.daAgentName}}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sapAPIPortalTAEnvVarTemplate = exports.sapAPIPortalDAEnvVarTemplate = exports.SAPApiPortalAgentValues = void 0;
7
+ var _types = require("../../../../common/types");
8
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
10
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ /**
12
+ * @description Parameters to provide to the SAP API Portal handlebars templates.
13
+ */
14
+ class SAPApiPortalAgentValues {
15
+ constructor() {
16
+ _defineProperty(this, "authTokenURL", void 0);
17
+ _defineProperty(this, "authAPIPortalBaseURL", void 0);
18
+ _defineProperty(this, "authAPIPortalClientID", void 0);
19
+ _defineProperty(this, "authAPIPortalClientSecret", void 0);
20
+ _defineProperty(this, "authDevPortalBaseURL", void 0);
21
+ _defineProperty(this, "authDevPortalClientID", void 0);
22
+ _defineProperty(this, "authDevPortalClientSecret", void 0);
23
+ _defineProperty(this, "developerEmail", void 0);
24
+ _defineProperty(this, "specCreateUnstructuredAPI", void 0);
25
+ _defineProperty(this, "centralConfig", void 0);
26
+ _defineProperty(this, "traceabilityConfig", void 0);
27
+ this.authTokenURL = '';
28
+ this.authAPIPortalBaseURL = '';
29
+ this.authAPIPortalClientID = '';
30
+ this.authAPIPortalClientSecret = '';
31
+ this.authDevPortalBaseURL = '';
32
+ this.authDevPortalClientID = '';
33
+ this.authDevPortalClientSecret = '';
34
+ this.developerEmail = '';
35
+ this.specCreateUnstructuredAPI = false;
36
+ this.centralConfig = new _types.CentralAgentConfig();
37
+ this.traceabilityConfig = new _types.TraceabilityConfig();
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @description Generates the SAP API Portal DA env vars file.
43
+ */
44
+ exports.SAPApiPortalAgentValues = SAPApiPortalAgentValues;
45
+ const sapAPIPortalDAEnvVarTemplate = () => {
46
+ return `# SAP API Portal configs
47
+ SAP_AUTH_TOKENURL={{authTokenURL}}
48
+ SAP_AUTH_APIPORTAL_BASEURL={{authAPIPortalBaseURL}}
49
+ SAP_AUTH_APIPORTAL_CLIENTID={{authAPIPortalClientID}}
50
+ SAP_AUTH_APIPORTAL_CLIENTSECRET={{authAPIPortalClientSecret}}
51
+ SAP_AUTH_DEVPORTAL_BASEURL={{authDevPortalBaseURL}}
52
+ SAP_AUTH_DEVPORTAL_CLIENTID={{authDevPortalClientID}}
53
+ SAP_AUTH_DEVPORTAL_CLIENTSECRET={{authDevPortalClientSecret}}
54
+ SAP_DEVELOPEREMAIL={{developerEmail}}
55
+ SAP_SPEC_CREATEUNSTRUCTUREDAPI={{specCreateUnstructuredAPI}}
56
+
57
+ # Amplify Central configs
58
+ CENTRAL_AGENTNAME={{centralConfig.daAgentName}}
59
+ CENTRAL_AUTH_CLIENTID={{centralConfig.dosaAccount.clientId}}
60
+ CENTRAL_AUTH_PRIVATEKEY={{centralConfig.dosaAccount.templatePrivateKey}}
61
+ CENTRAL_AUTH_PUBLICKEY={{centralConfig.dosaAccount.templatePublicKey}}
62
+ CENTRAL_ENVIRONMENT={{centralConfig.environment}}
63
+ CENTRAL_ORGANIZATIONID={{centralConfig.orgId}}
64
+ CENTRAL_TEAM={{centralConfig.ampcTeamName}}
65
+ CENTRAL_REGION={{centralConfig.region}}
66
+
67
+ # Logging configs
68
+ # Define the logging level: info, debug, error
69
+ LOG_LEVEL=info
70
+ # Specify where to send the log: stdout, file, both
71
+ LOG_OUTPUT=stdout
72
+ # Define where the log files are written
73
+ LOG_FILE_PATH=logs
74
+ `;
75
+ };
76
+
77
+ /**
78
+ * @description Generates the SAP API Portal TA env vars file.
79
+ */
80
+ exports.sapAPIPortalDAEnvVarTemplate = sapAPIPortalDAEnvVarTemplate;
81
+ const sapAPIPortalTAEnvVarTemplate = () => {
82
+ return `# SAP API Portal configs
83
+ SAP_AUTH_TOKENURL={{authTokenURL}}
84
+ SAP_AUTH_APIPORTAL_BASEURL={{authAPIPortalBaseURL}}
85
+ SAP_AUTH_APIPORTAL_CLIENTID={{authAPIPortalClientID}}
86
+ SAP_AUTH_APIPORTAL_CLIENTSECRET={{authAPIPortalClientSecret}}
87
+
88
+ # Amplify Central configs
89
+ {{#if traceabilityConfig.usageReportingOffline}}
90
+ CENTRAL_USAGEREPORTING_OFFLINE={{traceabilityConfig.usageReportingOffline}}
91
+ CENTRAL_ENVIRONMENTID={{centralConfig.environmentId}}
92
+ CENTRAL_AGENTNAME={{centralConfig.taAgentName}}
93
+ {{else}}
94
+ CENTRAL_AGENTNAME={{centralConfig.taAgentName}}
95
+ CENTRAL_AUTH_CLIENTID={{centralConfig.dosaAccount.clientId}}
96
+ CENTRAL_AUTH_PRIVATEKEY={{centralConfig.dosaAccount.templatePrivateKey}}
97
+ CENTRAL_AUTH_PUBLICKEY={{centralConfig.dosaAccount.templatePublicKey}}
98
+ CENTRAL_ENVIRONMENT={{centralConfig.environment}}
99
+ CENTRAL_ORGANIZATIONID={{centralConfig.orgId}}
100
+ CENTRAL_TEAM={{centralConfig.ampcTeamName}}
101
+ CENTRAL_REGION={{centralConfig.region}}
102
+
103
+ {{#compare . traceabilityConfig.protocol "https"}}
104
+ TRACEABILITY_PROTOCOL={{traceabilityConfig.protocol}}
105
+ {{/compare}}
106
+ TRACEABILITY_SAMPLING_PERCENTAGE={{traceabilityConfig.samplingPercentage}}
107
+ {{/if}}
108
+
109
+ # Logging configs
110
+ # Define the logging level: info, debug, error
111
+ LOG_LEVEL=info
112
+ # Specify where to send the log: stdout, file, both
113
+ LOG_OUTPUT=stdout
114
+ # Define where the log files are written
115
+ LOG_FILE_PATH=logs
116
+ `;
117
+ };
118
+ exports.sapAPIPortalTAEnvVarTemplate = sapAPIPortalTAEnvVarTemplate;
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.testables = exports.gatewayConnectivity = exports.defaultLogFiles = exports.completeInstall = exports.askConfigType = exports.askBundleType = exports.SAPAPIPortalInstallMethods = exports.ConfigFiles = void 0;
7
+ var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _snooplogg = _interopRequireDefault(require("snooplogg"));
9
+ var _basicPrompts = require("../../common/basicPrompts");
10
+ var _types = require("../../common/types");
11
+ var _utils = require("../../common/utils");
12
+ var helpers = _interopRequireWildcard(require("./helpers"));
13
+ var _sapApiPortalTemplates = require("./helpers/templates/sapApiPortalTemplates");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ // @ts-ignore
18
+ const {
19
+ log
20
+ } = (0, _snooplogg.default)('central: install: agents: SAP API Portal');
21
+ const daImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.SAPAPIPORTAL_DA}`;
22
+ const taImage = `${_types.PublicDockerRepoBaseUrl}${_types.BasePaths.DockerAgentPublicRepo}/${_types.AgentNames.SAPAPIPORTAL_TA}`;
23
+ const defaultLogFiles = exports.defaultLogFiles = '/group-*_instance-*.log';
24
+
25
+ // ConfigFiles - all the config file that are used in the setup
26
+ const ConfigFiles = exports.ConfigFiles = {
27
+ DAEnvVars: `${helpers.configFiles.DA_ENV_VARS}`,
28
+ TAEnvVars: `${helpers.configFiles.TA_ENV_VARS}`,
29
+ SAPAPIPortalDABinaryFile: 'discovery_agent',
30
+ SAPAPIPortalDAYaml: 'discovery_agent.yml',
31
+ SAPAPIPortalTABinaryFile: 'traceability_agent',
32
+ SAPAPIPortalTAYaml: 'traceability_agent.yml'
33
+ };
34
+
35
+ // SAPAPIPortalPrompts - prompts for user inputs
36
+ const SAPAPIPortalPrompts = {
37
+ configTypeMsg: 'Select the mode of installation',
38
+ enterAuthTokenURL: 'Enter the token URL used for agent authentication to SAP',
39
+ enterAuthAPIPortalBaseURL: 'Enter the SAP API Portal baseURL',
40
+ enterAuthAPIPortalClientID: 'Enter the SAP API Portal ClientID',
41
+ enterAuthAPIPortalClientSecret: 'Enter the SAP API Portal ClientSecret',
42
+ enterAuthDevPortalBaseURL: 'Enter the SAP Dev Portal baseURL',
43
+ enterAuthDevPortalClientID: 'Enter the SAP Dev Portal ClientID',
44
+ enterAuthDevPortalClientSecret: 'Enter the SAP Dev Portal ClientSecret',
45
+ enterDeveloperEmail: 'Enter the SAP developer email',
46
+ selectSpecCreateUnstructuredAPI: 'Select whether to create unstructured APIs for invalid/unknown API specs'
47
+ };
48
+ const askBundleType = async () => {
49
+ return await (0, _basicPrompts.askList)({
50
+ msg: helpers.agentMessages.selectAgentType,
51
+ choices: [_types.BundleType.ALL_AGENTS, _types.BundleType.DISCOVERY, _types.BundleType.TRACEABILITY]
52
+ });
53
+ };
54
+ exports.askBundleType = askBundleType;
55
+ const askConfigType = async () => {
56
+ return _types.AgentConfigTypes.DOCKERIZED;
57
+ };
58
+
59
+ //
60
+ // Questions for the configuration of IBM API Connect agents
61
+ //
62
+ exports.askConfigType = askConfigType;
63
+ const askAuthTokenURL = async () => await (0, _basicPrompts.askInput)({
64
+ msg: SAPAPIPortalPrompts.enterAuthTokenURL
65
+ });
66
+ const askAuthAPIPortalBaseURL = async () => await (0, _basicPrompts.askInput)({
67
+ msg: SAPAPIPortalPrompts.enterAuthAPIPortalBaseURL
68
+ });
69
+ const askAuthAPIPortalClientID = async () => await (0, _basicPrompts.askInput)({
70
+ msg: SAPAPIPortalPrompts.enterAuthAPIPortalClientID
71
+ });
72
+ const askAuthAPIPortalClientSecret = async () => await (0, _basicPrompts.askInput)({
73
+ msg: SAPAPIPortalPrompts.enterAuthAPIPortalClientSecret
74
+ });
75
+ const askAuthDevPortalBaseURL = async () => await (0, _basicPrompts.askInput)({
76
+ msg: SAPAPIPortalPrompts.enterAuthDevPortalBaseURL
77
+ });
78
+ const askAuthDevPortalClientID = async () => await (0, _basicPrompts.askInput)({
79
+ msg: SAPAPIPortalPrompts.enterAuthDevPortalClientID
80
+ });
81
+ const askAuthDevPortalClientSecret = async () => await (0, _basicPrompts.askInput)({
82
+ msg: SAPAPIPortalPrompts.enterAuthDevPortalClientSecret
83
+ });
84
+ const askDeveloperEmail = async () => await (0, _basicPrompts.askInput)({
85
+ msg: SAPAPIPortalPrompts.enterDeveloperEmail
86
+ });
87
+ const askSpecCreateUnstructuredAPI = async () => (await (0, _basicPrompts.askList)({
88
+ msg: SAPAPIPortalPrompts.selectSpecCreateUnstructuredAPI,
89
+ default: _types.YesNo.No,
90
+ choices: _types.YesNoChoices
91
+ })) === _types.YesNo.Yes;
92
+ const gatewayConnectivity = async installConfig => {
93
+ const agentValues = new _sapApiPortalTemplates.SAPApiPortalAgentValues();
94
+ console.log('\nCONNECTION TO IBM API Connect:');
95
+ console.log(_chalk.default.gray(`The discovery agent needs to connect to the IBM API Connect Gateway to discover API's for publishing to Amplify.\nThe traceability agent needs to connect to IBM API Connect for collecting APIs transactions. These will be forwarded to the Business Insights.\n`));
96
+ await askCommonPrompts(agentValues);
97
+
98
+ // SAP API Portal Discovery Agent Prompts
99
+ if (installConfig.switches.isDaEnabled) {
100
+ console.log(_chalk.default.gray(`\nDiscovery Agent Configuration\n`));
101
+ await askDiscoveryPrompts(agentValues);
102
+ }
103
+ return agentValues;
104
+ };
105
+ exports.gatewayConnectivity = gatewayConnectivity;
106
+ const generateSuccessHelpMsg = installConfig => {
107
+ if (installConfig.centralConfig.ampcDosaInfo.isNew && !installConfig.switches.isHelmInstall) {
108
+ console.log(_chalk.default.yellow('\nPlease make sure to copy the "private_key.pem" and "public_key.pem" files for the existing service account you selected.'));
109
+ }
110
+ dockerSuccessMsg(installConfig);
111
+ console.log(_chalk.default.gray(`\nAdditional information about agent features can be found here:\n${helpers.agentsDocsUrl.SAPAPIPORTAL}`));
112
+ };
113
+ const dockerSuccessMsg = installConfig => {
114
+ let dockerInfo;
115
+ const runDaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
116
+ const runDaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.DA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
117
+ const runTaLinuxMsg = `docker run -it --env-file ${helpers.pwd}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwd}:/keys ${helpers.eolChar}`;
118
+ const runTaWinMsg = `docker run -it --env-file ${helpers.pwdWin}/${helpers.configFiles.TA_ENV_VARS} -v ${helpers.pwdWin}:/keys ${helpers.eolCharWin}`;
119
+ const startDaLinuxMsg = `\nStart the Discovery Agent on a Linux based machine`;
120
+ const startDaWinMsg = `\nStart the Discovery Agent on a Windows machine`;
121
+ const startTaLinuxMsg = `\nStart the Traceability Agent on a Linux based machine`;
122
+ const startTaWinMsg = `\nStart the Traceability Agent on a Windows machine`;
123
+ if (installConfig.switches.isDaEnabled && installConfig.switches.isTaEnabled) {
124
+ dockerInfo = `To utilize the agents, pull the latest Docker images and run them using the appropriate supplied environment files, (${helpers.configFiles.DA_ENV_VARS} & ${helpers.configFiles.TA_ENV_VARS}):`;
125
+ } else if (installConfig.switches.isDaEnabled) {
126
+ dockerInfo = `To utilize the discovery agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.DA_ENV_VARS}):`;
127
+ } else {
128
+ dockerInfo = `To utilize the traceability agent, pull the latest Docker image and run it using the supplied environment file, (${helpers.configFiles.TA_ENV_VARS}):`;
129
+ }
130
+ console.log(_chalk.default.whiteBright(dockerInfo), '\n');
131
+ if (installConfig.switches.isDaEnabled) {
132
+ const daImageVersion = `${daImage}:${installConfig.daVersion}`;
133
+ console.log(_chalk.default.white('Pull the latest image of the Discovery Agent:'));
134
+ console.log(_chalk.default.cyan(`docker pull ${daImageVersion}`));
135
+ console.log(_chalk.default.white(_utils.isWindows ? startDaWinMsg : startDaLinuxMsg));
136
+ console.log(_chalk.default.cyan(_utils.isWindows ? runDaWinMsg : runDaLinuxMsg));
137
+ console.log('\t', _chalk.default.cyan(`-v /data ${daImageVersion}`), '\n');
138
+ }
139
+ if (installConfig.switches.isTaEnabled) {
140
+ const taImageVersion = `${taImage}:${installConfig.taVersion}`;
141
+ console.log(_chalk.default.white('Pull the latest image of the Traceability Agent:'));
142
+ console.log(_chalk.default.cyan(`docker pull ${taImageVersion}`));
143
+ console.log(_chalk.default.white(_utils.isWindows ? startTaWinMsg : startTaLinuxMsg));
144
+ console.log(_chalk.default.cyan(_utils.isWindows ? runTaWinMsg : runTaLinuxMsg));
145
+ console.log('\t', _chalk.default.cyan(`-v /data ${taImageVersion}`), '\n');
146
+ }
147
+ };
148
+ async function askCommonPrompts(agentValues) {
149
+ agentValues.authTokenURL = await askAuthTokenURL();
150
+ agentValues.authAPIPortalBaseURL = await askAuthAPIPortalBaseURL();
151
+ agentValues.authAPIPortalClientID = await askAuthAPIPortalClientID();
152
+ agentValues.authAPIPortalClientSecret = await askAuthAPIPortalClientSecret();
153
+ }
154
+
155
+ // IBM API Connect DA prompts
156
+ async function askDiscoveryPrompts(agentValues) {
157
+ agentValues.authDevPortalBaseURL = await askAuthDevPortalBaseURL();
158
+ agentValues.authDevPortalClientID = await askAuthDevPortalClientID();
159
+ agentValues.authDevPortalClientSecret = await askAuthDevPortalClientSecret();
160
+ agentValues.developerEmail = await askDeveloperEmail();
161
+ agentValues.specCreateUnstructuredAPI = await askSpecCreateUnstructuredAPI();
162
+ }
163
+ const completeInstall = async installConfig => {
164
+ /**
165
+ * Create agent resources
166
+ */
167
+ const agentValues = installConfig.gatewayConfig;
168
+
169
+ // Add final settings to SAP API Portal agentValues
170
+ agentValues.centralConfig = installConfig.centralConfig;
171
+ agentValues.traceabilityConfig = installConfig.traceabilityConfig;
172
+ console.log('Generating the configuration file(s)...');
173
+ if (installConfig.switches.isDaEnabled) {
174
+ (0, _utils.writeTemplates)(ConfigFiles.DAEnvVars, agentValues, _sapApiPortalTemplates.sapAPIPortalDAEnvVarTemplate);
175
+ }
176
+ if (installConfig.switches.isTaEnabled) {
177
+ (0, _utils.writeTemplates)(ConfigFiles.TAEnvVars, agentValues, _sapApiPortalTemplates.sapAPIPortalTAEnvVarTemplate);
178
+ }
179
+ console.log('Configuration file(s) have been successfully created.\n');
180
+ generateSuccessHelpMsg(installConfig);
181
+ };
182
+ exports.completeInstall = completeInstall;
183
+ const SAPAPIPortalInstallMethods = exports.SAPAPIPortalInstallMethods = {
184
+ GetBundleType: askBundleType,
185
+ GetDeploymentType: askConfigType,
186
+ AskGatewayQuestions: gatewayConnectivity,
187
+ FinalizeGatewayInstall: completeInstall,
188
+ ConfigFiles: Object.values(ConfigFiles),
189
+ AgentNameMap: {
190
+ [_types.AgentTypes.da]: _types.AgentNames.SAPAPIPORTAL_DA,
191
+ [_types.AgentTypes.ta]: _types.AgentNames.SAPAPIPORTAL_TA
192
+ },
193
+ GatewayDisplay: _types.GatewayTypes.SAPAPIPORTAL
194
+ };
195
+ const testables = exports.testables = {
196
+ SAPAPIPortalPrompts,
197
+ ConfigFiles,
198
+ defaultLogFiles
199
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.verifyApigeeXCredentialFile = exports.validateValueRange = exports.validateValidRegex = exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = exports.MAX_FILE_SIZE = void 0;
6
+ exports.verifyApigeeXCredentialFile = exports.validateValueRange = exports.validateValidRegex = exports.validateRegex = exports.validateNonEmptyInput = exports.validateInputLength = exports.validateInputIsNew = exports.runValidations = exports.filterEmptyNumberInput = exports.askUsernameAndPassword = exports.askList = exports.askInputValidation = exports.askInput = exports.MAX_FILE_SIZE = void 0;
7
7
  var _inquirer = _interopRequireDefault(require("inquirer"));
8
8
  var _fsExtra = require("fs-extra");
9
9
  var _path = require("path");
@@ -30,6 +30,10 @@ const validateRegex = (regexp, message) => input => {
30
30
  return input.toString().match(regexp) ? true : message;
31
31
  };
32
32
  exports.validateRegex = validateRegex;
33
+ const validateInputLength = (length, message) => input => {
34
+ return input.toString().length <= length ? true : message;
35
+ };
36
+ exports.validateInputLength = validateInputLength;
33
37
  const MAX_FILE_SIZE = exports.MAX_FILE_SIZE = process.env.NODE_ENV === 'test' ? 1e5 : 20 * 1024 * 1024;
34
38
  const verifyApigeeXCredentialFile = () => input => {
35
39
  let stats;
@@ -237,9 +237,11 @@ let AgentNames = exports.AgentNames = /*#__PURE__*/function (AgentNames) {
237
237
  AgentNames["IBMAPICONNECT_DA"] = "ibm-apiconnect-discovery-agent";
238
238
  AgentNames["IBMAPICONNECT_TA"] = "ibm-apiconnect-traceability-agent";
239
239
  AgentNames["TRACEABLE_TA"] = "traceable-agent";
240
- AgentNames["SOFTWAREAGWEBMETHODS_DA"] = "software-ag-web-methods-discovery-agent";
241
- AgentNames["SOFTWAREAGWEBMETHODS_TA"] = "software-ag-web-methods-traceability-agent";
240
+ AgentNames["SOFTWAREAGWEBMETHODS_DA"] = "software-ag-webmethods-discovery-agent";
241
+ AgentNames["SOFTWAREAGWEBMETHODS_TA"] = "software-ag-webmethods-traceability-agent";
242
242
  AgentNames["BACKSTAGE_DA"] = "backstage-discovery-agent";
243
+ AgentNames["SAPAPIPORTAL_DA"] = "sap-discovery-agent";
244
+ AgentNames["SAPAPIPORTAL_TA"] = "sap-traceability-agent";
243
245
  return AgentNames;
244
246
  }({});
245
247
  let GatewayTypes = exports.GatewayTypes = /*#__PURE__*/function (GatewayTypes) {
@@ -257,6 +259,7 @@ let GatewayTypes = exports.GatewayTypes = /*#__PURE__*/function (GatewayTypes) {
257
259
  GatewayTypes["SOFTWAREAGWEBMETHODS"] = "Software AG WebMethods";
258
260
  GatewayTypes["TRACEABLE"] = "Traceable";
259
261
  GatewayTypes["BACKSTAGE"] = "Backstage";
262
+ GatewayTypes["SAPAPIPORTAL"] = "SAP API Portal";
260
263
  return GatewayTypes;
261
264
  }({});
262
265
  let SaaSGatewayTypes = exports.SaaSGatewayTypes = /*#__PURE__*/function (SaaSGatewayTypes) {
@@ -282,6 +285,7 @@ let DataPlaneNames = exports.DataPlaneNames = /*#__PURE__*/function (DataPlaneNa
282
285
  DataPlaneNames["TRACEABLE"] = "Traceable";
283
286
  DataPlaneNames["MULESOFT"] = "Mulesoft";
284
287
  DataPlaneNames["BACKSTAGE"] = "Backstage";
288
+ DataPlaneNames["SAPAPIPORTAL"] = "SAP API Portal";
285
289
  DataPlaneNames["OTHER"] = "Unidentified";
286
290
  return DataPlaneNames;
287
291
  }({});
@@ -301,7 +305,8 @@ const GatewayTypeToDataPlane = exports.GatewayTypeToDataPlane = {
301
305
  [GatewayTypes.GRAYLOG]: DataPlaneNames.GRAYLOG,
302
306
  [GatewayTypes.IBMAPICONNECT]: DataPlaneNames.IBMAPICONNECT,
303
307
  [GatewayTypes.TRACEABLE]: DataPlaneNames.TRACEABLE,
304
- [GatewayTypes.BACKSTAGE]: DataPlaneNames.BACKSTAGE
308
+ [GatewayTypes.BACKSTAGE]: DataPlaneNames.BACKSTAGE,
309
+ [GatewayTypes.SAPAPIPORTAL]: DataPlaneNames.SAPAPIPORTAL
305
310
  };
306
311
  let AgentResourceKind = exports.AgentResourceKind = /*#__PURE__*/function (AgentResourceKind) {
307
312
  AgentResourceKind["da"] = "DiscoveryAgent";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axway/axway-central-cli",
3
- "version": "3.10.0-rc.6",
3
+ "version": "3.11.0-rc.0",
4
4
  "description": "Manage APIs, services and publish to the Amplify Marketplace",
5
5
  "homepage": "https://platform.axway.com",
6
6
  "author": {