SAP-BTP-Spielwiese/app1/node_modules/@sap/audit-logging/lib/v1/audit-log.js

74 lines
2.7 KiB
JavaScript
Raw Normal View History

'use strict';
var currentTransport = require('../transports/current-transport');
var ConfigurationChangeMessage = require('./ConfigurationChangeMessage');
var DataModificationMessage = require('./DataModificationMessage');
var DataAccessMessage = require('./DataAccessMessage');
var SecurityEventMessage = require('./SecurityEventMessage');
var format = require('util').format;
var utils = require('../utils');
module.exports = function auditlog(credentials, securityContext) {
const routeExtension = credentials.user && credentials.password ? 'v1/' : 'oauth2/v1/';
var transport = currentTransport(credentials, { url: `/audit-log/${routeExtension}` }, securityContext);
return {
/**
* @deprecated API v1 will be deprecated by March 2023.
* We strongly recommend that you switch to API v2 as soon as possible.
*/
configurationChange: function (objectID) {
utils.validate.notEmptyString(objectID, 'Object ID');
return new ConfigurationChangeMessage({ 'object_id': objectID }, transport);
},
/**
* @deprecated API v1 will be deprecated by March 2023.
* We strongly recommend that you switch to API v2 as soon as possible.
*/
updateConfigurationChange: function (configurationChangeId, state) {
return {
log: function (callback) {
transport.updateConfigurationChange(configurationChangeId, state, callback);
}
};
},
/**
* @deprecated API v1 will be deprecated by March 2023.
* We strongly recommend that you switch to API v2 as soon as possible.
*/
updateDataModification: function (dataModificationId, state) {
return {
log: function (callback) {
transport.updateDataModification(dataModificationId, state, callback);
}
};
},
/**
* @deprecated API v1 will be deprecated by March 2023.
* We strongly recommend that you switch to API v2 as soon as possible.
*/
read: function (objectID) {
utils.validate.notEmptyString(objectID, 'Object ID');
return new DataAccessMessage({ 'object_id': objectID }, transport);
},
/**
* @deprecated API v1 will be deprecated by March 2023.
* We strongly recommend that you switch to API v2 as soon as possible.
*/
update: function (objectID) {
utils.validate.notEmptyString(objectID, 'Object ID');
return new DataModificationMessage({ 'object_id': objectID }, transport);
},
/**
* @deprecated API v1 will be deprecated by March 2023.
* We strongly recommend that you switch to API v2 as soon as possible.
*/
securityMessage: function () {
utils.validate.provided(arguments[0], 'An argument');
return new SecurityEventMessage({ data: format.apply(null, arguments) }, transport);
}
};
};