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

Function bucketGetLifecycle

lib/api/bucketGetLifecycle.js:18–57  ·  view source on GitHub ↗

* bucketGetLifecycle - Get the bucket lifecycle 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 * @return {unde

(authInfo, request, log, callback)

Source from the content-addressed store, hash-verified

16 * @return {undefined}
17 */
18function bucketGetLifecycle(authInfo, request, log, callback) {
19 log.debug('processing request', { method: 'bucketGetLifecycle' });
20 const { bucketName, headers, method } = request;
21 const metadataValParams = {
22 authInfo,
23 bucketName,
24 requestType: request.apiMethods || 'bucketGetLifecycle',
25 request,
26 };
27 return standardMetadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
28 const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
29 if (err) {
30 log.debug('error processing request', {
31 error: err,
32 method: 'bucketGetLifecycle',
33 });
34 monitoring.promMetrics(
35 'GET', bucketName, err.code, 'getBucketLifecycle');
36 return callback(err, null, corsHeaders);
37 }
38 const lifecycleConfig = bucket.getLifecycleConfiguration();
39 if (!lifecycleConfig) {
40 log.debug('error processing request', {
41 error: errors.NoSuchLifecycleConfiguration,
42 method: 'bucketGetLifecycle',
43 });
44 monitoring.promMetrics(
45 'GET', bucketName, 404, 'getBucketLifecycle');
46 return callback(errors.NoSuchLifecycleConfiguration, null,
47 corsHeaders);
48 }
49 const xml = LifecycleConfiguration.getConfigXml(lifecycleConfig);
50 pushMetric('getBucketLifecycle', log, {
51 authInfo,
52 bucket: bucketName,
53 });
54 monitoring.promMetrics('GET', bucketName, '200', 'getBucketLifecycle');
55 return callback(null, xml, corsHeaders);
56 });
57}
58
59module.exports = bucketGetLifecycle;

Callers 1

Calls 4

collectCorsHeadersFunction · 0.85
pushMetricFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected