MCPcopy Index your code
hub / github.com/scality/cloudserver / bucketPutNotification

Function bucketPutNotification

lib/api/bucketPutNotification.js:19–58  ·  view source on GitHub ↗

* Bucket Put Notification - Create or update bucket notification configuration * @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info * @param {object} request - http request object * @param {object} log - Werelogs logger * @param {function} callback - callback to server

(authInfo, request, log, callback)

Source from the content-addressed store, hash-verified

17 */
18
19function bucketPutNotification(authInfo, request, log, callback) {
20 log.debug('processing request', { method: 'bucketPutNotification' });
21
22 const { bucketName } = request;
23 const metadataValParams = {
24 authInfo,
25 bucketName,
26 requestType: request.apiMethods || 'bucketPutNotification',
27 request,
28 };
29
30 return async.waterfall([
31 next => parseXML(request.post, log, next),
32 (parsedXml, next) => {
33 const notificationConfig = getNotificationConfiguration(parsedXml);
34 const notifConfig = notificationConfig.error ? undefined : notificationConfig;
35 process.nextTick(() => next(notificationConfig.error, notifConfig));
36 },
37 (notifConfig, next) => standardMetadataValidateBucket(metadataValParams, request.actionImplicitDenies, log,
38 (err, bucket) => next(err, bucket, notifConfig)),
39 (bucket, notifConfig, next) => {
40 bucket.setNotificationConfiguration(notifConfig);
41 metadata.updateBucket(bucket.getName(), bucket, log,
42 err => next(err, bucket));
43 },
44 ], (err, bucket) => {
45 const corsHeaders = collectCorsHeaders(request.headers.origin,
46 request.method, bucket);
47 if (err) {
48 log.trace('error processing request', { error: err,
49 method: 'bucketPutNotification' });
50 return callback(err, corsHeaders);
51 }
52 pushMetric('putBucketNotification', log, {
53 authInfo,
54 bucket: bucketName,
55 });
56 return callback(null, corsHeaders);
57 });
58}
59
60module.exports = bucketPutNotification;

Callers 3

objectDelete.jsFile · 0.85

Calls 7

parseXMLFunction · 0.85
collectCorsHeadersFunction · 0.85
pushMetricFunction · 0.85
debugMethod · 0.80
traceMethod · 0.80

Tested by

no test coverage detected