@rockcarver/frodo-cli 2.0.0-51 → 2.0.0-53
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/CHANGELOG.md +42 -1
- package/esm/app.js +7 -2
- package/esm/app.js.map +1 -1
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js +3 -6
- package/esm/cli/admin/admin-add-autoid-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +46 -51
- package/esm/cli/admin/admin-create-oauth2-client-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +1 -1
- package/esm/cli/admin/admin-federation-export.js.map +1 -1
- package/esm/cli/admin/admin-federation-import.js +1 -1
- package/esm/cli/admin/admin-federation-import.js.map +1 -1
- package/esm/cli/admin/admin-federation-list.js +1 -1
- package/esm/cli/admin/admin-federation-list.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +4 -6
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js +4 -6
- package/esm/cli/admin/admin-hide-generic-extension-attributes.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +4 -9
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +4 -9
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +3 -9
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/admin/admin-remove-static-user-mapping.js +3 -6
- package/esm/cli/admin/admin-remove-static-user-mapping.js.map +1 -1
- package/esm/cli/admin/admin-repair-org-model.js +4 -6
- package/esm/cli/admin/admin-repair-org-model.js.map +1 -1
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +4 -6
- package/esm/cli/admin/admin-revoke-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-show-generic-extension-attributes.js +4 -6
- package/esm/cli/admin/admin-show-generic-extension-attributes.js.map +1 -1
- package/esm/cli/agent/agent-delete.js +8 -21
- package/esm/cli/agent/agent-delete.js.map +1 -1
- package/esm/cli/agent/agent-export.js +6 -3
- package/esm/cli/agent/agent-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-delete.js +7 -20
- package/esm/cli/agent/agent-gateway-delete.js.map +1 -1
- package/esm/cli/agent/agent-gateway-export.js +6 -3
- package/esm/cli/agent/agent-gateway-export.js.map +1 -1
- package/esm/cli/agent/agent-gateway-import.js +8 -4
- package/esm/cli/agent/agent-gateway-import.js.map +1 -1
- package/esm/cli/agent/agent-gateway-list.js +2 -1
- package/esm/cli/agent/agent-gateway-list.js.map +1 -1
- package/esm/cli/agent/agent-import.js +8 -4
- package/esm/cli/agent/agent-import.js.map +1 -1
- package/esm/cli/agent/agent-java-delete.js +7 -20
- package/esm/cli/agent/agent-java-delete.js.map +1 -1
- package/esm/cli/agent/agent-java-export.js +6 -3
- package/esm/cli/agent/agent-java-export.js.map +1 -1
- package/esm/cli/agent/agent-java-import.js +8 -4
- package/esm/cli/agent/agent-java-import.js.map +1 -1
- package/esm/cli/agent/agent-java-list.js +2 -1
- package/esm/cli/agent/agent-java-list.js.map +1 -1
- package/esm/cli/agent/agent-list.js +2 -1
- package/esm/cli/agent/agent-list.js.map +1 -1
- package/esm/cli/agent/agent-web-delete.js +7 -20
- package/esm/cli/agent/agent-web-delete.js.map +1 -1
- package/esm/cli/agent/agent-web-export.js +6 -3
- package/esm/cli/agent/agent-web-export.js.map +1 -1
- package/esm/cli/agent/agent-web-import.js +8 -4
- package/esm/cli/agent/agent-web-import.js.map +1 -1
- package/esm/cli/agent/agent-web-list.js +2 -1
- package/esm/cli/agent/agent-web-list.js.map +1 -1
- package/esm/cli/app/app-delete.js +4 -4
- package/esm/cli/app/app-delete.js.map +1 -1
- package/esm/cli/app/app-export.js +6 -6
- package/esm/cli/app/app-export.js.map +1 -1
- package/esm/cli/app/app-import.js +8 -8
- package/esm/cli/app/app-import.js.map +1 -1
- package/esm/cli/app/app-list.js +2 -1
- package/esm/cli/app/app-list.js.map +1 -1
- package/esm/cli/conn/conn-delete.js +7 -1
- package/esm/cli/conn/conn-delete.js.map +1 -1
- package/esm/cli/conn/conn-save.js +9 -9
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/email/email-template-export.js +6 -3
- package/esm/cli/email/email-template-export.js.map +1 -1
- package/esm/cli/email/email-template-import.js +8 -4
- package/esm/cli/email/email-template-import.js.map +1 -1
- package/esm/cli/email/email-template-list.js +2 -1
- package/esm/cli/email/email-template-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-create.js +1 -1
- package/esm/cli/esv/esv-secret-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-delete.js +1 -1
- package/esm/cli/esv/esv-secret-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-describe.js +1 -1
- package/esm/cli/esv/esv-secret-describe.js.map +1 -1
- package/esm/cli/esv/esv-secret-export.js +1 -1
- package/esm/cli/esv/esv-secret-export.js.map +1 -1
- package/esm/cli/esv/esv-secret-list.js +1 -1
- package/esm/cli/esv/esv-secret-list.js.map +1 -1
- package/esm/cli/esv/esv-secret-set.js +1 -1
- package/esm/cli/esv/esv-secret-set.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js +1 -1
- package/esm/cli/esv/esv-secret-version-activate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-create.js +1 -1
- package/esm/cli/esv/esv-secret-version-create.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js +1 -1
- package/esm/cli/esv/esv-secret-version-deactivate.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js +1 -1
- package/esm/cli/esv/esv-secret-version-delete.js.map +1 -1
- package/esm/cli/esv/esv-secret-version-list.js +1 -1
- package/esm/cli/esv/esv-secret-version-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-create.js +1 -1
- package/esm/cli/esv/esv-variable-create.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +1 -1
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-describe.js +1 -1
- package/esm/cli/esv/esv-variable-describe.js.map +1 -1
- package/esm/cli/esv/esv-variable-export.js +1 -1
- package/esm/cli/esv/esv-variable-export.js.map +1 -1
- package/esm/cli/esv/esv-variable-list.js +1 -1
- package/esm/cli/esv/esv-variable-list.js.map +1 -1
- package/esm/cli/esv/esv-variable-set.js +1 -1
- package/esm/cli/esv/esv-variable-set.js.map +1 -1
- package/esm/cli/idm/idm-count.js +2 -1
- package/esm/cli/idm/idm-count.js.map +1 -1
- package/esm/cli/idm/idm-export.js +6 -3
- package/esm/cli/idm/idm-export.js.map +1 -1
- package/esm/cli/idm/idm-import.js +8 -4
- package/esm/cli/idm/idm-import.js.map +1 -1
- package/esm/cli/idm/idm-list.js +2 -1
- package/esm/cli/idm/idm-list.js.map +1 -1
- package/esm/cli/idp/idp-export.js +6 -3
- package/esm/cli/idp/idp-export.js.map +1 -1
- package/esm/cli/idp/idp-import.js +8 -4
- package/esm/cli/idp/idp-import.js.map +1 -1
- package/esm/cli/idp/idp-list.js +2 -1
- package/esm/cli/idp/idp-list.js.map +1 -1
- package/esm/cli/journey/journey-delete.js +6 -7
- package/esm/cli/journey/journey-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +15 -9
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-export.js +6 -3
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/cli/journey/journey-import.js +8 -4
- package/esm/cli/journey/journey-import.js.map +1 -1
- package/esm/cli/journey/journey-list.js +2 -1
- package/esm/cli/journey/journey-list.js.map +1 -1
- package/esm/cli/journey/journey-prune.js +3 -2
- package/esm/cli/journey/journey-prune.js.map +1 -1
- package/esm/cli/log/log-fetch.js +6 -2
- package/esm/cli/log/log-fetch.js.map +1 -1
- package/esm/cli/log/log-list.js +12 -3
- package/esm/cli/log/log-list.js.map +1 -1
- package/esm/cli/log/log-tail.js +6 -2
- package/esm/cli/log/log-tail.js.map +1 -1
- package/esm/cli/oauth/oauth-client-export.js +6 -6
- package/esm/cli/oauth/oauth-client-export.js.map +1 -1
- package/esm/cli/oauth/oauth-client-import.js +8 -8
- package/esm/cli/oauth/oauth-client-import.js.map +1 -1
- package/esm/cli/oauth/oauth-client-list.js +2 -1
- package/esm/cli/oauth/oauth-client-list.js.map +1 -1
- package/esm/cli/saml/saml-describe.js +2 -1
- package/esm/cli/saml/saml-describe.js.map +1 -1
- package/esm/cli/saml/saml-export.js +6 -3
- package/esm/cli/saml/saml-export.js.map +1 -1
- package/esm/cli/saml/saml-import.js +8 -4
- package/esm/cli/saml/saml-import.js.map +1 -1
- package/esm/cli/saml/saml-list.js +2 -1
- package/esm/cli/saml/saml-list.js.map +1 -1
- package/esm/cli/saml/saml-metadata-export.js +10 -2
- package/esm/cli/saml/saml-metadata-export.js.map +1 -1
- package/esm/cli/script/script-delete.js +10 -4
- package/esm/cli/script/script-delete.js.map +1 -1
- package/esm/cli/script/script-export.js +9 -13
- package/esm/cli/script/script-export.js.map +1 -1
- package/esm/cli/script/script-import.js +19 -14
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/cli/service/service-delete.js +4 -2
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +6 -3
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +8 -4
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +2 -1
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/cli/shell/shell.js +2 -4
- package/esm/cli/shell/shell.js.map +1 -1
- package/esm/cli/theme/theme-delete.js +7 -4
- package/esm/cli/theme/theme-delete.js.map +1 -1
- package/esm/cli/theme/theme-export.js +8 -4
- package/esm/cli/theme/theme-export.js.map +1 -1
- package/esm/cli/theme/theme-import.js +10 -5
- package/esm/cli/theme/theme-import.js.map +1 -1
- package/esm/cli/theme/theme-list.js +2 -1
- package/esm/cli/theme/theme-list.js.map +1 -1
- package/esm/ops/AdminOps.js +790 -3
- package/esm/ops/AdminOps.js.map +1 -1
- package/esm/ops/AgentOps.js +638 -305
- package/esm/ops/AgentOps.js.map +1 -1
- package/esm/ops/ApplicationOps.js +91 -79
- package/esm/ops/ApplicationOps.js.map +1 -1
- package/esm/ops/AuthenticateOps.js +4 -9
- package/esm/ops/AuthenticateOps.js.map +1 -1
- package/esm/ops/AuthenticationSettingsOps.js +22 -23
- package/esm/ops/AuthenticationSettingsOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +52 -55
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/ConfigOps.js +100 -84
- package/esm/ops/ConfigOps.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +15 -8
- package/esm/ops/ConnectionProfileOps.js.map +1 -1
- package/esm/ops/EmailTemplateOps.js +64 -47
- package/esm/ops/EmailTemplateOps.js.map +1 -1
- package/esm/ops/IdmOps.js +149 -117
- package/esm/ops/IdmOps.js.map +1 -1
- package/esm/ops/IdpOps.js +76 -46
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/JourneyOps.js +333 -238
- package/esm/ops/JourneyOps.js.map +1 -1
- package/esm/ops/LogOps.js +15 -23
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +43 -36
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +104 -108
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +72 -78
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +84 -99
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +132 -88
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/ScriptOps.js +90 -80
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +125 -87
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/ThemeOps.js +170 -139
- package/esm/ops/ThemeOps.js.map +1 -1
- package/esm/ops/{AdminFederationOps.js → cloud/AdminFederationOps.js} +10 -16
- package/esm/ops/cloud/AdminFederationOps.js.map +1 -0
- package/esm/ops/{SecretsOps.js → cloud/SecretsOps.js} +123 -129
- package/esm/ops/cloud/SecretsOps.js.map +1 -0
- package/esm/ops/{VariablesOps.js → cloud/VariablesOps.js} +48 -52
- package/esm/ops/cloud/VariablesOps.js.map +1 -0
- package/esm/ops/templates/OAuth2ClientTemplate.json +270 -0
- package/esm/ops/templates/OAuth2TrustedJwtIssuerTemplate.json +38 -0
- package/esm/ops/templates/OrgModelUserAttributesTemplate.json +149 -0
- package/esm/ops/templates/autoaccess/IPAddresses.json +202 -0
- package/esm/ops/templates/autoaccess/UserAgents.json +35 -0
- package/esm/ops/templates/autoaccess/Usernames.json +203 -0
- package/esm/ops/templates/cloud/GenericExtensionAttributesTemplate.json +392 -0
- package/esm/ops/templates/cloud/managed.json +4119 -0
- package/esm/ops/utils/OpsUtils.js.map +1 -1
- package/esm/utils/Console.js +31 -0
- package/esm/utils/Console.js.map +1 -1
- package/package.json +10 -6
- package/esm/ops/AdminFederationOps.js.map +0 -1
- package/esm/ops/SecretsOps.js.map +0 -1
- package/esm/ops/VariablesOps.js.map +0 -1
package/esm/ops/AgentOps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
1
|
+
import { frodo, FrodoError, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { createProgressIndicator, createTable, debugMessage, printMessage, stopProgressIndicator } from '../utils/Console';
|
|
3
|
+
import { createProgressIndicator, createTable, debugMessage, printError, printMessage, stopProgressIndicator } from '../utils/Console';
|
|
4
4
|
const {
|
|
5
5
|
getRealmName,
|
|
6
6
|
getTypedFilename,
|
|
@@ -40,6 +40,7 @@ const agentTypeToFileIdMap = {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* List agents
|
|
43
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
43
44
|
*/
|
|
44
45
|
export async function listAgents(long = false) {
|
|
45
46
|
try {
|
|
@@ -67,14 +68,16 @@ export async function listAgents(long = false) {
|
|
|
67
68
|
printMessage(`${agent._id}`, 'data');
|
|
68
69
|
});
|
|
69
70
|
}
|
|
71
|
+
return true;
|
|
70
72
|
} catch (error) {
|
|
71
|
-
|
|
72
|
-
printMessage(error.stack, 'error');
|
|
73
|
+
printError(error, `Error listing agents`);
|
|
73
74
|
}
|
|
75
|
+
return false;
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
/**
|
|
77
79
|
* List identity gateway agents
|
|
80
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
78
81
|
*/
|
|
79
82
|
export async function listIdentityGatewayAgents(long = false) {
|
|
80
83
|
try {
|
|
@@ -90,14 +93,16 @@ export async function listIdentityGatewayAgents(long = false) {
|
|
|
90
93
|
printMessage(`${agent._id}`, 'data');
|
|
91
94
|
});
|
|
92
95
|
}
|
|
96
|
+
return true;
|
|
93
97
|
} catch (error) {
|
|
94
|
-
|
|
95
|
-
printMessage(error.stack, 'error');
|
|
98
|
+
printError(error, `Error listing gateway agents`);
|
|
96
99
|
}
|
|
100
|
+
return false;
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
104
|
* List java agents
|
|
105
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
101
106
|
*/
|
|
102
107
|
export async function listJavaAgents(long = false) {
|
|
103
108
|
try {
|
|
@@ -113,14 +118,16 @@ export async function listJavaAgents(long = false) {
|
|
|
113
118
|
printMessage(`${agent._id}`, 'data');
|
|
114
119
|
});
|
|
115
120
|
}
|
|
121
|
+
return true;
|
|
116
122
|
} catch (error) {
|
|
117
|
-
|
|
118
|
-
printMessage(error.stack, 'error');
|
|
123
|
+
printError(error, `Error listing java agents`);
|
|
119
124
|
}
|
|
125
|
+
return false;
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
/**
|
|
123
129
|
* List web agents
|
|
130
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
124
131
|
*/
|
|
125
132
|
export async function listWebAgents(long = false) {
|
|
126
133
|
try {
|
|
@@ -136,66 +143,95 @@ export async function listWebAgents(long = false) {
|
|
|
136
143
|
printMessage(`${agent._id}`, 'data');
|
|
137
144
|
});
|
|
138
145
|
}
|
|
146
|
+
return true;
|
|
139
147
|
} catch (error) {
|
|
140
|
-
|
|
141
|
-
printMessage(error.stack, 'error');
|
|
148
|
+
printError(error, `Error listing web agents`);
|
|
142
149
|
}
|
|
150
|
+
return false;
|
|
143
151
|
}
|
|
144
152
|
|
|
145
153
|
/**
|
|
146
154
|
* Export all agents to file
|
|
147
155
|
* @param {string} file file name
|
|
148
156
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
157
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
149
158
|
*/
|
|
150
159
|
export async function exportAgentsToFile(file, includeMeta = true) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
160
|
+
try {
|
|
161
|
+
const exportData = await exportAgents();
|
|
162
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, 'agent');
|
|
163
|
+
if (file) {
|
|
164
|
+
fileName = file;
|
|
165
|
+
}
|
|
166
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
167
|
+
return true;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
printError(error, `Error exporting agents to file`);
|
|
155
170
|
}
|
|
156
|
-
|
|
171
|
+
return false;
|
|
157
172
|
}
|
|
158
173
|
|
|
159
174
|
/**
|
|
160
175
|
* Export all identity gateway agents to file
|
|
161
176
|
* @param {string} file file name
|
|
162
177
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
178
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
163
179
|
*/
|
|
164
180
|
export async function exportIdentityGatewayAgentsToFile(file, includeMeta = true) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
181
|
+
try {
|
|
182
|
+
const exportData = await exportIdentityGatewayAgents();
|
|
183
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['IdentityGatewayAgent']);
|
|
184
|
+
if (file) {
|
|
185
|
+
fileName = file;
|
|
186
|
+
}
|
|
187
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
188
|
+
return true;
|
|
189
|
+
} catch (error) {
|
|
190
|
+
printError(error, `Error exporting identity gateway agents to file`);
|
|
169
191
|
}
|
|
170
|
-
|
|
192
|
+
return false;
|
|
171
193
|
}
|
|
172
194
|
|
|
173
195
|
/**
|
|
174
196
|
* Export all java agents to file
|
|
175
197
|
* @param {string} file file name
|
|
176
198
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
199
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
177
200
|
*/
|
|
178
201
|
export async function exportJavaAgentsToFile(file, includeMeta = true) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
202
|
+
try {
|
|
203
|
+
const exportData = await exportJavaAgents();
|
|
204
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['J2EEAgent']);
|
|
205
|
+
if (file) {
|
|
206
|
+
fileName = file;
|
|
207
|
+
}
|
|
208
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
209
|
+
return true;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
printError(error, `Error exporting java agents to file`);
|
|
183
212
|
}
|
|
184
|
-
|
|
213
|
+
return false;
|
|
185
214
|
}
|
|
186
215
|
|
|
187
216
|
/**
|
|
188
217
|
* Export all web agents to file
|
|
189
218
|
* @param {string} file file name
|
|
190
219
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
220
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
191
221
|
*/
|
|
192
222
|
export async function exportWebAgentsToFile(file, includeMeta = true) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
223
|
+
try {
|
|
224
|
+
const exportData = await exportWebAgents();
|
|
225
|
+
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.getRealm()))}Agents`, agentTypeToFileIdMap['WebAgent']);
|
|
226
|
+
if (file) {
|
|
227
|
+
fileName = file;
|
|
228
|
+
}
|
|
229
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
230
|
+
return true;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
printError(error, `Error exporting web agents to file`);
|
|
197
233
|
}
|
|
198
|
-
|
|
234
|
+
return false;
|
|
199
235
|
}
|
|
200
236
|
|
|
201
237
|
/**
|
|
@@ -203,14 +239,21 @@ export async function exportWebAgentsToFile(file, includeMeta = true) {
|
|
|
203
239
|
* @param {string} agentId agent id
|
|
204
240
|
* @param {string} file file name
|
|
205
241
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
242
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
206
243
|
*/
|
|
207
244
|
export async function exportAgentToFile(agentId, file, includeMeta = true) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
245
|
+
try {
|
|
246
|
+
const exportData = await exportAgent(agentId);
|
|
247
|
+
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
248
|
+
if (file) {
|
|
249
|
+
fileName = file;
|
|
250
|
+
}
|
|
251
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
252
|
+
return true;
|
|
253
|
+
} catch (error) {
|
|
254
|
+
printError(error, `Error exporting agent ${agentId} to file`);
|
|
212
255
|
}
|
|
213
|
-
|
|
256
|
+
return false;
|
|
214
257
|
}
|
|
215
258
|
|
|
216
259
|
/**
|
|
@@ -218,14 +261,21 @@ export async function exportAgentToFile(agentId, file, includeMeta = true) {
|
|
|
218
261
|
* @param {string} agentId agent id
|
|
219
262
|
* @param {string} file file name
|
|
220
263
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
264
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
221
265
|
*/
|
|
222
266
|
export async function exportIdentityGatewayAgentToFile(agentId, file, includeMeta = true) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
267
|
+
try {
|
|
268
|
+
const exportData = await exportIdentityGatewayAgent(agentId);
|
|
269
|
+
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
270
|
+
if (file) {
|
|
271
|
+
fileName = file;
|
|
272
|
+
}
|
|
273
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
274
|
+
return true;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
printError(error, `Error exporting identity gateway agent ${agentId} to file`);
|
|
227
277
|
}
|
|
228
|
-
|
|
278
|
+
return false;
|
|
229
279
|
}
|
|
230
280
|
|
|
231
281
|
/**
|
|
@@ -233,14 +283,21 @@ export async function exportIdentityGatewayAgentToFile(agentId, file, includeMet
|
|
|
233
283
|
* @param {string} agentId agent id
|
|
234
284
|
* @param {string} file file name
|
|
235
285
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
286
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
236
287
|
*/
|
|
237
288
|
export async function exportJavaAgentToFile(agentId, file, includeMeta = true) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
289
|
+
try {
|
|
290
|
+
const exportData = await exportJavaAgent(agentId);
|
|
291
|
+
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
292
|
+
if (file) {
|
|
293
|
+
fileName = file;
|
|
294
|
+
}
|
|
295
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
296
|
+
return true;
|
|
297
|
+
} catch (error) {
|
|
298
|
+
printError(error, `Error exporting java agent ${agentId} to file`);
|
|
242
299
|
}
|
|
243
|
-
|
|
300
|
+
return false;
|
|
244
301
|
}
|
|
245
302
|
|
|
246
303
|
/**
|
|
@@ -248,85 +305,121 @@ export async function exportJavaAgentToFile(agentId, file, includeMeta = true) {
|
|
|
248
305
|
* @param {string} agentId agent id
|
|
249
306
|
* @param {string} file file name
|
|
250
307
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
308
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
251
309
|
*/
|
|
252
310
|
export async function exportWebAgentToFile(agentId, file, includeMeta = true) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
311
|
+
try {
|
|
312
|
+
const exportData = await exportWebAgent(agentId);
|
|
313
|
+
let fileName = getTypedFilename(agentId, agentTypeToFileIdMap[exportData.agents[agentId]._type._id]);
|
|
314
|
+
if (file) {
|
|
315
|
+
fileName = file;
|
|
316
|
+
}
|
|
317
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
318
|
+
return true;
|
|
319
|
+
} catch (error) {
|
|
320
|
+
printError(error, `Error exporting web agent ${agentId} to file`);
|
|
257
321
|
}
|
|
258
|
-
|
|
322
|
+
return false;
|
|
259
323
|
}
|
|
260
324
|
|
|
261
325
|
/**
|
|
262
326
|
* Export all agents to separate files
|
|
263
327
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
328
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
264
329
|
*/
|
|
265
330
|
export async function exportAgentsToFiles(includeMeta = true) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
331
|
+
try {
|
|
332
|
+
const agents = await readAgents();
|
|
333
|
+
debugMessage(`exportAgentsToFiles: ${agents.length} agents`);
|
|
334
|
+
for (const agent of agents) {
|
|
335
|
+
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
336
|
+
const filePath = getFilePath(fileName, true);
|
|
337
|
+
const exportData = createAgentExportTemplate();
|
|
338
|
+
exportData.agents[agent._id] = agent;
|
|
339
|
+
debugMessage(`exportAgentsToFiles: exporting ${agent._id} to ${filePath}`);
|
|
340
|
+
saveJsonToFile(exportData, filePath, includeMeta);
|
|
341
|
+
}
|
|
342
|
+
debugMessage(`exportAgentsToFiles: done.`);
|
|
343
|
+
return true;
|
|
344
|
+
} catch (error) {
|
|
345
|
+
printError(error, `Error exporting agents to files`);
|
|
275
346
|
}
|
|
276
|
-
|
|
347
|
+
return false;
|
|
277
348
|
}
|
|
278
349
|
|
|
279
350
|
/**
|
|
280
351
|
* Export all identity gateway agents to separate files
|
|
281
352
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
353
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
282
354
|
*/
|
|
283
355
|
export async function exportIdentityGatewayAgentsToFiles(includeMeta = true) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
356
|
+
try {
|
|
357
|
+
const agents = await readIdentityGatewayAgents();
|
|
358
|
+
for (const agent of agents) {
|
|
359
|
+
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
360
|
+
const exportData = createAgentExportTemplate();
|
|
361
|
+
exportData.agents[agent._id] = agent;
|
|
362
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
363
|
+
}
|
|
364
|
+
return true;
|
|
365
|
+
} catch (error) {
|
|
366
|
+
printError(error, `Error exporting identity gateway agents to files`);
|
|
290
367
|
}
|
|
368
|
+
return false;
|
|
291
369
|
}
|
|
292
370
|
|
|
293
371
|
/**
|
|
294
372
|
* Export all java agents to separate files
|
|
295
373
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
374
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
296
375
|
*/
|
|
297
376
|
export async function exportJavaAgentsToFiles(includeMeta = true) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
377
|
+
try {
|
|
378
|
+
const agents = await readJavaAgents();
|
|
379
|
+
for (const agent of agents) {
|
|
380
|
+
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
381
|
+
const exportData = createAgentExportTemplate();
|
|
382
|
+
exportData.agents[agent._id] = agent;
|
|
383
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
384
|
+
}
|
|
385
|
+
return true;
|
|
386
|
+
} catch (error) {
|
|
387
|
+
printError(error, `Error exporting java agents to files`);
|
|
304
388
|
}
|
|
389
|
+
return false;
|
|
305
390
|
}
|
|
306
391
|
|
|
307
392
|
/**
|
|
308
393
|
* Export all web agents to separate files
|
|
309
394
|
* @param {boolean} includeMeta true to include metadata, false otherwise. Default: true
|
|
395
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
310
396
|
*/
|
|
311
397
|
export async function exportWebAgentsToFiles(includeMeta = true) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
398
|
+
try {
|
|
399
|
+
const agents = await readWebAgents();
|
|
400
|
+
for (const agent of agents) {
|
|
401
|
+
const fileName = getTypedFilename(agent._id, agentTypeToFileIdMap[agent._type._id]);
|
|
402
|
+
const exportData = createAgentExportTemplate();
|
|
403
|
+
exportData.agents[agent._id] = agent;
|
|
404
|
+
saveJsonToFile(exportData, getFilePath(fileName, true), includeMeta);
|
|
405
|
+
}
|
|
406
|
+
return true;
|
|
407
|
+
} catch (error) {
|
|
408
|
+
printError(error, `Error exporting web agents to files`);
|
|
318
409
|
}
|
|
410
|
+
return false;
|
|
319
411
|
}
|
|
320
412
|
|
|
321
413
|
/**
|
|
322
414
|
* Import an agent from file
|
|
323
415
|
* @param {string} agentId agent id/name
|
|
324
416
|
* @param {string} file import file name
|
|
417
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
325
418
|
*/
|
|
326
419
|
export async function importAgentFromFile(agentId, file) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
420
|
+
try {
|
|
421
|
+
const verbose = state.getVerbose();
|
|
422
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
330
423
|
const importData = JSON.parse(data);
|
|
331
424
|
// check if this is a file with multiple agents and get agent by id
|
|
332
425
|
if (importData.agents && importData.agents[agentId]) {
|
|
@@ -344,89 +437,33 @@ export async function importAgentFromFile(agentId, file) {
|
|
|
344
437
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
345
438
|
await importAgent(agentId, importData);
|
|
346
439
|
stopProgressIndicator(spinnerId, `Imported ${agentId}.`, 'success');
|
|
347
|
-
|
|
440
|
+
return true;
|
|
441
|
+
} catch (error) {
|
|
348
442
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
349
|
-
stopProgressIndicator(spinnerId,
|
|
443
|
+
stopProgressIndicator(spinnerId, `Error importing agent ${agentId}`, 'fail');
|
|
444
|
+
printError(error, `Error importing agent ${agentId}`);
|
|
350
445
|
}
|
|
351
446
|
} else {
|
|
352
447
|
spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
353
448
|
stopProgressIndicator(spinnerId, `${agentId} not found!`, 'fail');
|
|
354
449
|
}
|
|
355
|
-
})
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Import first agent from file
|
|
360
|
-
* @param {string} file import file name
|
|
361
|
-
*/
|
|
362
|
-
export async function importFirstAgentFromFile(file) {
|
|
363
|
-
const verbose = state.getVerbose();
|
|
364
|
-
fs.readFile(getFilePath(file), 'utf8', async (err, data) => {
|
|
365
|
-
if (err) throw err;
|
|
366
|
-
const importData = JSON.parse(data);
|
|
367
|
-
let spinnerId;
|
|
368
|
-
if (Object.keys(importData.agents).length > 0) {
|
|
369
|
-
for (const agent of Object.values(importData.agents)) {
|
|
370
|
-
if (!verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
371
|
-
try {
|
|
372
|
-
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
373
|
-
await importAgent(agent['_id'], importData);
|
|
374
|
-
stopProgressIndicator(spinnerId, `Imported ${agent['_id']}.`, 'success');
|
|
375
|
-
} catch (importError) {
|
|
376
|
-
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
377
|
-
stopProgressIndicator(spinnerId, `${importError}`, 'fail');
|
|
378
|
-
}
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
} else {
|
|
382
|
-
spinnerId = createProgressIndicator('indeterminate', 0, `Importing...`);
|
|
383
|
-
stopProgressIndicator(spinnerId, `No agents found!`, 'fail');
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Import agents from file
|
|
390
|
-
* @param {String} file file name
|
|
391
|
-
*/
|
|
392
|
-
export async function importAgentsFromFile(file) {
|
|
393
|
-
debugMessage(`importAgentsFromFile: start`);
|
|
394
|
-
const filePath = getFilePath(file);
|
|
395
|
-
fs.readFile(filePath, 'utf8', async (err, data) => {
|
|
396
|
-
if (err) throw err;
|
|
397
|
-
debugMessage(`importAgentsFromFile: importing ${filePath}`);
|
|
398
|
-
const importData = JSON.parse(data);
|
|
399
|
-
try {
|
|
400
|
-
await importAgents(importData);
|
|
401
|
-
} catch (error) {
|
|
402
|
-
printMessage(`${error.message}`, 'error');
|
|
403
|
-
printMessage(error.response.status, 'error');
|
|
404
|
-
}
|
|
405
|
-
debugMessage(`importAgentsFromFile: end`);
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Import all agents from separate files
|
|
411
|
-
*/
|
|
412
|
-
export async function importAgentsFromFiles() {
|
|
413
|
-
const names = fs.readdirSync(getWorkingDirectory());
|
|
414
|
-
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.agent.json'));
|
|
415
|
-
for (const file of agentFiles) {
|
|
416
|
-
await importAgentsFromFile(file);
|
|
450
|
+
} catch (error) {
|
|
451
|
+
printError(error, `Error importing agent ${agentId} from file`);
|
|
417
452
|
}
|
|
453
|
+
return false;
|
|
418
454
|
}
|
|
419
455
|
|
|
420
456
|
/**
|
|
421
457
|
* Import an identity gateway agent from file
|
|
422
458
|
* @param {string} agentId agent id/name
|
|
423
459
|
* @param {string} file import file name
|
|
460
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
424
461
|
*/
|
|
425
462
|
export async function importIdentityGatewayAgentFromFile(agentId, file) {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
463
|
+
try {
|
|
464
|
+
debugMessage(`cli.AgentOps.importIdentityGatewayAgentFromFile: start`);
|
|
465
|
+
const verbose = state.getVerbose();
|
|
466
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
430
467
|
const importData = JSON.parse(data);
|
|
431
468
|
// check if this is a file with multiple agents and get agent by id
|
|
432
469
|
if (importData.agents && importData.agents[agentId]) {
|
|
@@ -444,92 +481,77 @@ export async function importIdentityGatewayAgentFromFile(agentId, file) {
|
|
|
444
481
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
445
482
|
await importIdentityGatewayAgent(agentId, importData);
|
|
446
483
|
stopProgressIndicator(spinnerId, `Imported ${agentId}.`, 'success');
|
|
447
|
-
|
|
448
|
-
|
|
484
|
+
return true;
|
|
485
|
+
} catch (error) {
|
|
486
|
+
stopProgressIndicator(spinnerId, `Error importing identity gateway agent ${agentId}`, 'fail');
|
|
487
|
+
printError(error, `Error importing identity gateway agent ${agentId}`);
|
|
449
488
|
}
|
|
450
489
|
} else {
|
|
451
490
|
spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
452
491
|
stopProgressIndicator(spinnerId, `${agentId} not found!`, 'fail');
|
|
453
492
|
}
|
|
454
493
|
debugMessage(`cli.AgentOps.importIdentityGatewayAgentFromFile: end`);
|
|
455
|
-
})
|
|
494
|
+
} catch (error) {
|
|
495
|
+
printError(error, `Error importing identity gateway agent ${agentId} from file`);
|
|
496
|
+
}
|
|
497
|
+
return false;
|
|
456
498
|
}
|
|
457
499
|
|
|
458
500
|
/**
|
|
459
|
-
* Import
|
|
501
|
+
* Import an java agent from file
|
|
502
|
+
* @param {string} agentId agent id/name
|
|
460
503
|
* @param {string} file import file name
|
|
504
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
461
505
|
*/
|
|
462
|
-
export async function
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
506
|
+
export async function importJavaAgentFromFile(agentId, file) {
|
|
507
|
+
try {
|
|
508
|
+
debugMessage(`cli.AgentOps.importJavaAgentFromFile: start`);
|
|
509
|
+
const verbose = state.getVerbose();
|
|
510
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
467
511
|
const importData = JSON.parse(data);
|
|
512
|
+
// check if this is a file with multiple agents and get agent by id
|
|
513
|
+
if (importData.agents && importData.agents[agentId]) {
|
|
514
|
+
const agent = importData.agents[agentId];
|
|
515
|
+
importData.agents = {};
|
|
516
|
+
importData.agents[agentId] = agent;
|
|
517
|
+
} else if (importData.agents) {
|
|
518
|
+
importData.agents = null;
|
|
519
|
+
}
|
|
520
|
+
// if an agentId was specified, only import the matching agent
|
|
468
521
|
let spinnerId;
|
|
469
|
-
if (
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
return;
|
|
522
|
+
if (importData.agents) {
|
|
523
|
+
if (!verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
524
|
+
try {
|
|
525
|
+
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
526
|
+
await importJavaAgent(agentId, importData);
|
|
527
|
+
stopProgressIndicator(spinnerId, `Imported ${agentId}.`, 'success');
|
|
528
|
+
return true;
|
|
529
|
+
} catch (error) {
|
|
530
|
+
stopProgressIndicator(spinnerId, `Error importing java agent ${agentId}`, 'fail');
|
|
531
|
+
printError(error, `Error importing java agent ${agentId}`);
|
|
480
532
|
}
|
|
481
533
|
} else {
|
|
482
|
-
spinnerId = createProgressIndicator('indeterminate', 0, `Importing...`);
|
|
483
|
-
stopProgressIndicator(spinnerId,
|
|
484
|
-
}
|
|
485
|
-
debugMessage(`cli.AgentOps.importFirstIdentityGatewayAgentFromFile: end`);
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Import identity gateway agents from file
|
|
491
|
-
* @param {String} file file name
|
|
492
|
-
*/
|
|
493
|
-
export async function importIdentityGatewayAgentsFromFile(file) {
|
|
494
|
-
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFile: start`);
|
|
495
|
-
const filePath = getFilePath(file);
|
|
496
|
-
fs.readFile(filePath, 'utf8', async (err, data) => {
|
|
497
|
-
if (err) throw err;
|
|
498
|
-
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFile: importing ${filePath}`);
|
|
499
|
-
const importData = JSON.parse(data);
|
|
500
|
-
try {
|
|
501
|
-
await importIdentityGatewayAgents(importData);
|
|
502
|
-
} catch (error) {
|
|
503
|
-
printMessage(`${error.message}`, 'error');
|
|
504
|
-
printMessage(error.response.status, 'error');
|
|
534
|
+
spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
535
|
+
stopProgressIndicator(spinnerId, `${agentId} not found!`, 'fail');
|
|
505
536
|
}
|
|
506
|
-
debugMessage(`cli.AgentOps.
|
|
507
|
-
})
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Import all identity gateway agents from separate files
|
|
512
|
-
*/
|
|
513
|
-
export async function importIdentityGatewayAgentsFromFiles() {
|
|
514
|
-
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFiles: start`);
|
|
515
|
-
const names = fs.readdirSync(getWorkingDirectory());
|
|
516
|
-
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.agent.json'));
|
|
517
|
-
for (const file of agentFiles) {
|
|
518
|
-
await importIdentityGatewayAgentsFromFile(file);
|
|
537
|
+
debugMessage(`cli.AgentOps.importJavaAgentFromFile: end`);
|
|
538
|
+
} catch (error) {
|
|
539
|
+
printError(error, `Error importing java agent ${agentId} from file`);
|
|
519
540
|
}
|
|
520
|
-
|
|
541
|
+
return false;
|
|
521
542
|
}
|
|
522
543
|
|
|
523
544
|
/**
|
|
524
|
-
* Import an
|
|
545
|
+
* Import an web agent from file
|
|
525
546
|
* @param {string} agentId agent id/name
|
|
526
547
|
* @param {string} file import file name
|
|
548
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
527
549
|
*/
|
|
528
|
-
export async function
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
export async function importWebAgentFromFile(agentId, file) {
|
|
551
|
+
try {
|
|
552
|
+
debugMessage(`cli.AgentOps.importWebAgentFromFile: start`);
|
|
553
|
+
const verbose = state.getVerbose();
|
|
554
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
533
555
|
const importData = JSON.parse(data);
|
|
534
556
|
// check if this is a file with multiple agents and get agent by id
|
|
535
557
|
if (importData.agents && importData.agents[agentId]) {
|
|
@@ -545,28 +567,33 @@ export async function importJavaAgentFromFile(agentId, file) {
|
|
|
545
567
|
if (!verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
546
568
|
try {
|
|
547
569
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
548
|
-
await
|
|
570
|
+
await importWebAgent(agentId, importData);
|
|
549
571
|
stopProgressIndicator(spinnerId, `Imported ${agentId}.`, 'success');
|
|
550
|
-
|
|
551
|
-
|
|
572
|
+
return true;
|
|
573
|
+
} catch (error) {
|
|
574
|
+
stopProgressIndicator(spinnerId, `Error importing web agent ${agentId}`, 'fail');
|
|
575
|
+
printError(error, `Error importing web agent ${agentId}`);
|
|
552
576
|
}
|
|
553
577
|
} else {
|
|
554
578
|
spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agentId}...`);
|
|
555
579
|
stopProgressIndicator(spinnerId, `${agentId} not found!`, 'fail');
|
|
556
580
|
}
|
|
557
|
-
debugMessage(`cli.AgentOps.
|
|
558
|
-
})
|
|
581
|
+
debugMessage(`cli.AgentOps.importWebAgentFromFile: end`);
|
|
582
|
+
} catch (error) {
|
|
583
|
+
printError(error, `Error importing web agent ${agentId} from file`);
|
|
584
|
+
}
|
|
585
|
+
return false;
|
|
559
586
|
}
|
|
560
587
|
|
|
561
588
|
/**
|
|
562
|
-
* Import first
|
|
589
|
+
* Import first agent from file
|
|
563
590
|
* @param {string} file import file name
|
|
591
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
564
592
|
*/
|
|
565
|
-
export async function
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
if (err) throw err;
|
|
593
|
+
export async function importFirstAgentFromFile(file) {
|
|
594
|
+
try {
|
|
595
|
+
const verbose = state.getVerbose();
|
|
596
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
570
597
|
const importData = JSON.parse(data);
|
|
571
598
|
let spinnerId;
|
|
572
599
|
if (Object.keys(importData.agents).length > 0) {
|
|
@@ -574,10 +601,13 @@ export async function importFirstJavaAgentFromFile(file) {
|
|
|
574
601
|
if (!verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
575
602
|
try {
|
|
576
603
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
577
|
-
await
|
|
604
|
+
await importAgent(agent['_id'], importData);
|
|
578
605
|
stopProgressIndicator(spinnerId, `Imported ${agent['_id']}.`, 'success');
|
|
579
|
-
|
|
580
|
-
|
|
606
|
+
return true;
|
|
607
|
+
} catch (error) {
|
|
608
|
+
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
609
|
+
stopProgressIndicator(spinnerId, `${error}`, 'fail');
|
|
610
|
+
printError(error, `Error importing first agent`);
|
|
581
611
|
}
|
|
582
612
|
return;
|
|
583
613
|
}
|
|
@@ -585,91 +615,94 @@ export async function importFirstJavaAgentFromFile(file) {
|
|
|
585
615
|
spinnerId = createProgressIndicator('indeterminate', 0, `Importing...`);
|
|
586
616
|
stopProgressIndicator(spinnerId, `No agents found!`, 'fail');
|
|
587
617
|
}
|
|
588
|
-
|
|
589
|
-
|
|
618
|
+
} catch (error) {
|
|
619
|
+
printError(error, `Error importing first agent from file`);
|
|
620
|
+
}
|
|
621
|
+
return false;
|
|
590
622
|
}
|
|
591
623
|
|
|
592
624
|
/**
|
|
593
|
-
* Import
|
|
594
|
-
* @param {
|
|
625
|
+
* Import first identity gateway agent from file
|
|
626
|
+
* @param {string} file import file name
|
|
627
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
595
628
|
*/
|
|
596
|
-
export async function
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
debugMessage(`cli.AgentOps.importJavaAgentsFromFile: importing ${filePath}`);
|
|
629
|
+
export async function importFirstIdentityGatewayAgentFromFile(file) {
|
|
630
|
+
try {
|
|
631
|
+
debugMessage(`cli.AgentOps.importFirstIdentityGatewayAgentFromFile: start`);
|
|
632
|
+
const verbose = state.getVerbose();
|
|
633
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
602
634
|
const importData = JSON.parse(data);
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
635
|
+
let spinnerId;
|
|
636
|
+
if (Object.keys(importData.agents).length > 0) {
|
|
637
|
+
for (const agent of Object.values(importData.agents)) {
|
|
638
|
+
if (!verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
639
|
+
try {
|
|
640
|
+
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
641
|
+
await importIdentityGatewayAgent(agent['_id'], importData);
|
|
642
|
+
stopProgressIndicator(spinnerId, `Imported ${agent['_id']}.`, 'success');
|
|
643
|
+
return true;
|
|
644
|
+
} catch (error) {
|
|
645
|
+
stopProgressIndicator(spinnerId, `${error}`, 'fail');
|
|
646
|
+
printError(error, `Error importing first identity gateway agent from file`);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
} else {
|
|
650
|
+
spinnerId = createProgressIndicator('indeterminate', 0, `Importing...`);
|
|
651
|
+
stopProgressIndicator(spinnerId, `No agents found!`, 'fail');
|
|
608
652
|
}
|
|
609
|
-
debugMessage(`cli.AgentOps.
|
|
610
|
-
})
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* Import all java agents from separate files
|
|
615
|
-
*/
|
|
616
|
-
export async function importJavaAgentsFromFiles() {
|
|
617
|
-
debugMessage(`cli.AgentOps.importJavaAgentsFromFiles: start`);
|
|
618
|
-
const names = fs.readdirSync(getWorkingDirectory());
|
|
619
|
-
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.agent.json'));
|
|
620
|
-
for (const file of agentFiles) {
|
|
621
|
-
await importJavaAgentsFromFile(file);
|
|
653
|
+
debugMessage(`cli.AgentOps.importFirstIdentityGatewayAgentFromFile: end`);
|
|
654
|
+
} catch (error) {
|
|
655
|
+
printError(error, `Error importing first identity gateway agent from file`);
|
|
622
656
|
}
|
|
623
|
-
|
|
657
|
+
return false;
|
|
624
658
|
}
|
|
625
659
|
|
|
626
660
|
/**
|
|
627
|
-
* Import
|
|
628
|
-
* @param {string} agentId agent id/name
|
|
661
|
+
* Import first java agent from file
|
|
629
662
|
* @param {string} file import file name
|
|
663
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
630
664
|
*/
|
|
631
|
-
export async function
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
665
|
+
export async function importFirstJavaAgentFromFile(file) {
|
|
666
|
+
try {
|
|
667
|
+
debugMessage(`cli.AgentOps.importFirstJavaAgentFromFile: start`);
|
|
668
|
+
const verbose = state.getVerbose();
|
|
669
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
636
670
|
const importData = JSON.parse(data);
|
|
637
|
-
// check if this is a file with multiple agents and get agent by id
|
|
638
|
-
if (importData.agents && importData.agents[agentId]) {
|
|
639
|
-
const agent = importData.agents[agentId];
|
|
640
|
-
importData.agents = {};
|
|
641
|
-
importData.agents[agentId] = agent;
|
|
642
|
-
} else if (importData.agents) {
|
|
643
|
-
importData.agents = null;
|
|
644
|
-
}
|
|
645
|
-
// if an agentId was specified, only import the matching agent
|
|
646
671
|
let spinnerId;
|
|
647
|
-
if (importData.agents) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
672
|
+
if (Object.keys(importData.agents).length > 0) {
|
|
673
|
+
for (const agent of Object.values(importData.agents)) {
|
|
674
|
+
if (!verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
675
|
+
try {
|
|
676
|
+
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
677
|
+
await importJavaAgent(agent['_id'], importData);
|
|
678
|
+
stopProgressIndicator(spinnerId, `Imported ${agent['_id']}.`, 'success');
|
|
679
|
+
return true;
|
|
680
|
+
} catch (importError) {
|
|
681
|
+
stopProgressIndicator(spinnerId, `${importError}`, 'fail');
|
|
682
|
+
}
|
|
683
|
+
return;
|
|
655
684
|
}
|
|
656
685
|
} else {
|
|
657
|
-
spinnerId = createProgressIndicator('indeterminate', 0, `Importing
|
|
658
|
-
stopProgressIndicator(spinnerId,
|
|
686
|
+
spinnerId = createProgressIndicator('indeterminate', 0, `Importing...`);
|
|
687
|
+
stopProgressIndicator(spinnerId, `No agents found!`, 'fail');
|
|
659
688
|
}
|
|
660
|
-
debugMessage(`cli.AgentOps.
|
|
661
|
-
})
|
|
689
|
+
debugMessage(`cli.AgentOps.importFirstJavaAgentFromFile: end`);
|
|
690
|
+
} catch (error) {
|
|
691
|
+
printError(error, `Error importing first java agent from file`);
|
|
692
|
+
}
|
|
693
|
+
return false;
|
|
662
694
|
}
|
|
663
695
|
|
|
664
696
|
/**
|
|
665
697
|
* Import web gateway agent from file
|
|
666
698
|
* @param {string} file import file name
|
|
699
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
667
700
|
*/
|
|
668
701
|
export async function importFirstWebAgentFromFile(file) {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
702
|
+
try {
|
|
703
|
+
debugMessage(`cli.AgentOps.importFirstWebAgentFromFile: start`);
|
|
704
|
+
const verbose = state.getVerbose();
|
|
705
|
+
const data = fs.readFileSync(getFilePath(file), 'utf8');
|
|
673
706
|
const importData = JSON.parse(data);
|
|
674
707
|
let spinnerId;
|
|
675
708
|
if (Object.keys(importData.agents).length > 0) {
|
|
@@ -679,6 +712,7 @@ export async function importFirstWebAgentFromFile(file) {
|
|
|
679
712
|
if (verbose) spinnerId = createProgressIndicator('indeterminate', 0, `Importing ${agent['_id']}...`);
|
|
680
713
|
await importWebAgent(agent['_id'], importData);
|
|
681
714
|
stopProgressIndicator(spinnerId, `Imported ${agent['_id']}.`, 'success');
|
|
715
|
+
return true;
|
|
682
716
|
} catch (importError) {
|
|
683
717
|
stopProgressIndicator(spinnerId, `caught it here ${importError}`, 'fail');
|
|
684
718
|
}
|
|
@@ -689,40 +723,339 @@ export async function importFirstWebAgentFromFile(file) {
|
|
|
689
723
|
stopProgressIndicator(spinnerId, `No agents found!`, 'fail');
|
|
690
724
|
}
|
|
691
725
|
debugMessage(`cli.AgentOps.importFirstWebAgentFromFile: end`);
|
|
692
|
-
})
|
|
726
|
+
} catch (error) {
|
|
727
|
+
printError(error, `Error importing first java agent from file`);
|
|
728
|
+
}
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Import agents from file
|
|
734
|
+
* @param {String} file file name
|
|
735
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
736
|
+
*/
|
|
737
|
+
export async function importAgentsFromFile(file) {
|
|
738
|
+
try {
|
|
739
|
+
debugMessage(`importAgentsFromFile: start`);
|
|
740
|
+
const filePath = getFilePath(file);
|
|
741
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
742
|
+
debugMessage(`importAgentsFromFile: importing ${filePath}`);
|
|
743
|
+
const importData = JSON.parse(data);
|
|
744
|
+
await importAgents(importData);
|
|
745
|
+
debugMessage(`importAgentsFromFile: end`);
|
|
746
|
+
return true;
|
|
747
|
+
} catch (error) {
|
|
748
|
+
printError(error, `Error importing agents from file`);
|
|
749
|
+
}
|
|
750
|
+
return false;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Import identity gateway agents from file
|
|
755
|
+
* @param {String} file file name
|
|
756
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
757
|
+
*/
|
|
758
|
+
export async function importIdentityGatewayAgentsFromFile(file) {
|
|
759
|
+
try {
|
|
760
|
+
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFile: start`);
|
|
761
|
+
const filePath = getFilePath(file);
|
|
762
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
763
|
+
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFile: importing ${filePath}`);
|
|
764
|
+
const importData = JSON.parse(data);
|
|
765
|
+
await importIdentityGatewayAgents(importData);
|
|
766
|
+
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFile: end`);
|
|
767
|
+
return true;
|
|
768
|
+
} catch (error) {
|
|
769
|
+
printError(error, `Error importing identity gateway agents from file`);
|
|
770
|
+
}
|
|
771
|
+
return false;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Import java agents from file
|
|
776
|
+
* @param {String} file file name
|
|
777
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
778
|
+
*/
|
|
779
|
+
export async function importJavaAgentsFromFile(file) {
|
|
780
|
+
try {
|
|
781
|
+
debugMessage(`cli.AgentOps.importJavaAgentsFromFile: start`);
|
|
782
|
+
const filePath = getFilePath(file);
|
|
783
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
784
|
+
debugMessage(`cli.AgentOps.importJavaAgentsFromFile: importing ${filePath}`);
|
|
785
|
+
const importData = JSON.parse(data);
|
|
786
|
+
await importJavaAgents(importData);
|
|
787
|
+
debugMessage(`cli.AgentOps.importJavaAgentsFromFile: end`);
|
|
788
|
+
return true;
|
|
789
|
+
} catch (error) {
|
|
790
|
+
printError(error, `Error importing java agents from file`);
|
|
791
|
+
}
|
|
792
|
+
return false;
|
|
693
793
|
}
|
|
694
794
|
|
|
695
795
|
/**
|
|
696
796
|
* Import web agents from file
|
|
697
797
|
* @param {String} file file name
|
|
798
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
698
799
|
*/
|
|
699
800
|
export async function importWebAgentsFromFile(file) {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
801
|
+
try {
|
|
802
|
+
debugMessage(`cli.AgentOps.importWebAgentsFromFile: start`);
|
|
803
|
+
const filePath = getFilePath(file);
|
|
804
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
704
805
|
debugMessage(`cli.AgentOps.importWebAgentsFromFile: importing ${filePath}`);
|
|
705
806
|
const importData = JSON.parse(data);
|
|
706
|
-
|
|
707
|
-
await importWebAgents(importData);
|
|
708
|
-
} catch (error) {
|
|
709
|
-
printMessage(`${error.message}`, 'error');
|
|
710
|
-
printMessage(error.response.status, 'error');
|
|
711
|
-
}
|
|
807
|
+
await importWebAgents(importData);
|
|
712
808
|
debugMessage(`cli.AgentOps.importWebAgentsFromFile: end`);
|
|
713
|
-
|
|
809
|
+
return true;
|
|
810
|
+
} catch (error) {
|
|
811
|
+
printError(error, `Error importing web agents from file`);
|
|
812
|
+
}
|
|
813
|
+
return false;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Import all agents from separate files
|
|
818
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
819
|
+
*/
|
|
820
|
+
export async function importAgentsFromFiles() {
|
|
821
|
+
const errors = [];
|
|
822
|
+
try {
|
|
823
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
824
|
+
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.agent.json'));
|
|
825
|
+
for (const file of agentFiles) {
|
|
826
|
+
try {
|
|
827
|
+
await importAgentsFromFile(file);
|
|
828
|
+
} catch (error) {
|
|
829
|
+
errors.push(new FrodoError(`Error importing agents from ${file}`, error));
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (errors.length > 0) {
|
|
833
|
+
throw new FrodoError(`One or more errors importing agents`, errors);
|
|
834
|
+
}
|
|
835
|
+
return true;
|
|
836
|
+
} catch (error) {
|
|
837
|
+
if (errors.length > 0) {
|
|
838
|
+
printError(error);
|
|
839
|
+
} else {
|
|
840
|
+
printError(error, `Error importing agents from files`);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return false;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Import all identity gateway agents from separate files
|
|
848
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
849
|
+
*/
|
|
850
|
+
export async function importIdentityGatewayAgentsFromFiles() {
|
|
851
|
+
const errors = [];
|
|
852
|
+
try {
|
|
853
|
+
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFiles: start`);
|
|
854
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
855
|
+
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.agent.json'));
|
|
856
|
+
for (const file of agentFiles) {
|
|
857
|
+
try {
|
|
858
|
+
await importIdentityGatewayAgentsFromFile(file);
|
|
859
|
+
} catch (error) {
|
|
860
|
+
errors.push(new FrodoError(`Error importing identity gateway agents from ${file}`, error));
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
if (errors.length > 0) {
|
|
864
|
+
throw new FrodoError(`One or more errors importing identity gateway agents`, errors);
|
|
865
|
+
}
|
|
866
|
+
debugMessage(`cli.AgentOps.importIdentityGatewayAgentsFromFiles: end`);
|
|
867
|
+
return true;
|
|
868
|
+
} catch (error) {
|
|
869
|
+
if (errors.length > 0) {
|
|
870
|
+
printError(error);
|
|
871
|
+
} else {
|
|
872
|
+
printError(error, `Error importing identity gateway agents from files`);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Import all java agents from separate files
|
|
880
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
881
|
+
*/
|
|
882
|
+
export async function importJavaAgentsFromFiles() {
|
|
883
|
+
const errors = [];
|
|
884
|
+
try {
|
|
885
|
+
debugMessage(`cli.AgentOps.importJavaAgentsFromFiles: start`);
|
|
886
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
887
|
+
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.agent.json'));
|
|
888
|
+
for (const file of agentFiles) {
|
|
889
|
+
try {
|
|
890
|
+
await importJavaAgentsFromFile(file);
|
|
891
|
+
} catch (error) {
|
|
892
|
+
errors.push(new FrodoError(`Error importing java agents from ${file}`, error));
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
if (errors.length > 0) {
|
|
896
|
+
throw new FrodoError(`One or more errors importing java agents`, errors);
|
|
897
|
+
}
|
|
898
|
+
debugMessage(`cli.AgentOps.importJavaAgentsFromFiles: end`);
|
|
899
|
+
return true;
|
|
900
|
+
} catch (error) {
|
|
901
|
+
if (errors.length > 0) {
|
|
902
|
+
printError(error);
|
|
903
|
+
} else {
|
|
904
|
+
printError(error, `Error importing java agents from files`);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
return false;
|
|
714
908
|
}
|
|
715
909
|
|
|
716
910
|
/**
|
|
717
911
|
* Import all web agents from separate files
|
|
912
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
718
913
|
*/
|
|
719
914
|
export async function importWebAgentsFromFiles() {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
915
|
+
const errors = [];
|
|
916
|
+
try {
|
|
917
|
+
debugMessage(`cli.AgentOps.importWebAgentsFromFiles: start`);
|
|
918
|
+
const names = fs.readdirSync(getWorkingDirectory());
|
|
919
|
+
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.agent.json'));
|
|
920
|
+
for (const file of agentFiles) {
|
|
921
|
+
try {
|
|
922
|
+
await importWebAgentsFromFile(file);
|
|
923
|
+
} catch (error) {
|
|
924
|
+
errors.push(new FrodoError(`Error importing web agents from ${file}`, error));
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
if (errors.length > 0) {
|
|
928
|
+
throw new FrodoError(`One or more errors importing web agents`, errors);
|
|
929
|
+
}
|
|
930
|
+
debugMessage(`cli.AgentOps.importWebAgentsFromFiles: end`);
|
|
931
|
+
return true;
|
|
932
|
+
} catch (error) {
|
|
933
|
+
if (errors.length > 0) {
|
|
934
|
+
printError(error);
|
|
935
|
+
} else {
|
|
936
|
+
printError(error, `Error importing web agents from files`);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
return false;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Delete agent
|
|
944
|
+
* @param {string} agentId agent id/name
|
|
945
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
946
|
+
*/
|
|
947
|
+
export async function deleteAgent(agentId) {
|
|
948
|
+
try {
|
|
949
|
+
await frodo.agent.deleteAgent(agentId);
|
|
950
|
+
return true;
|
|
951
|
+
} catch (error) {
|
|
952
|
+
printError(error);
|
|
953
|
+
}
|
|
954
|
+
return false;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Delete identity gateway agent
|
|
959
|
+
* @param {string} agentId agent id/name
|
|
960
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
961
|
+
*/
|
|
962
|
+
export async function deleteIdentityGatewayAgent(agentId) {
|
|
963
|
+
try {
|
|
964
|
+
await frodo.agent.deleteIdentityGatewayAgent(agentId);
|
|
965
|
+
return true;
|
|
966
|
+
} catch (error) {
|
|
967
|
+
printError(error);
|
|
968
|
+
}
|
|
969
|
+
return false;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Delete java agent
|
|
974
|
+
* @param {string} agentId agent id/name
|
|
975
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
976
|
+
*/
|
|
977
|
+
export async function deleteJavaAgent(agentId) {
|
|
978
|
+
try {
|
|
979
|
+
await frodo.agent.deleteJavaAgent(agentId);
|
|
980
|
+
return true;
|
|
981
|
+
} catch (error) {
|
|
982
|
+
printError(error);
|
|
983
|
+
}
|
|
984
|
+
return false;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* Delete web agent
|
|
989
|
+
* @param {string} agentId agent id/name
|
|
990
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
991
|
+
*/
|
|
992
|
+
export async function deleteWebAgent(agentId) {
|
|
993
|
+
try {
|
|
994
|
+
await frodo.agent.deleteWebAgent(agentId);
|
|
995
|
+
return true;
|
|
996
|
+
} catch (error) {
|
|
997
|
+
printError(error);
|
|
998
|
+
}
|
|
999
|
+
return false;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Delete agents
|
|
1004
|
+
* @param {string} agentId agent id/name
|
|
1005
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
1006
|
+
*/
|
|
1007
|
+
export async function deleteAgents() {
|
|
1008
|
+
try {
|
|
1009
|
+
await frodo.agent.deleteAgents();
|
|
1010
|
+
return true;
|
|
1011
|
+
} catch (error) {
|
|
1012
|
+
printError(error);
|
|
1013
|
+
}
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Delete identity gateway agents
|
|
1019
|
+
* @param {string} agentId agent id/name
|
|
1020
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
1021
|
+
*/
|
|
1022
|
+
export async function deleteIdentityGatewayAgents() {
|
|
1023
|
+
try {
|
|
1024
|
+
await frodo.agent.deleteIdentityGatewayAgents();
|
|
1025
|
+
return true;
|
|
1026
|
+
} catch (error) {
|
|
1027
|
+
printError(error);
|
|
1028
|
+
}
|
|
1029
|
+
return false;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Delete java agents
|
|
1034
|
+
* @param {string} agentId agent id/name
|
|
1035
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
1036
|
+
*/
|
|
1037
|
+
export async function deleteJavaAgents() {
|
|
1038
|
+
try {
|
|
1039
|
+
await frodo.agent.deleteJavaAgents();
|
|
1040
|
+
return true;
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
printError(error);
|
|
1043
|
+
}
|
|
1044
|
+
return false;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Delete web agents
|
|
1049
|
+
* @param {string} agentId agent id/name
|
|
1050
|
+
* @returns {Promise<boolean>} true if successful, false otherwise
|
|
1051
|
+
*/
|
|
1052
|
+
export async function deleteWebAgents() {
|
|
1053
|
+
try {
|
|
1054
|
+
await frodo.agent.deleteWebAgents();
|
|
1055
|
+
return true;
|
|
1056
|
+
} catch (error) {
|
|
1057
|
+
printError(error);
|
|
725
1058
|
}
|
|
726
|
-
|
|
1059
|
+
return false;
|
|
727
1060
|
}
|
|
728
1061
|
//# sourceMappingURL=AgentOps.js.map
|