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

Function bucketGetPolicy

lib/api/bucketGetPolicy.js:14–47  ·  view source on GitHub ↗

* bucketGetPolicy - Get the bucket policy * @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 {undefined}

(authInfo, request, log, callback)

Source from the content-addressed store, hash-verified

12 * @return {undefined}
13 */
14function bucketGetPolicy(authInfo, request, log, callback) {
15 log.debug('processing request', { method: 'bucketGetPolicy' });
16 const { bucketName, headers, method } = request;
17 const metadataValParams = {
18 authInfo,
19 bucketName,
20 requestType: request.apiMethods || 'bucketGetPolicy',
21 request,
22 };
23
24 return standardMetadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
25 const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
26 if (err) {
27 log.debug('error processing request', {
28 error: err,
29 method: 'bucketGetPolicy',
30 });
31 return callback(err, null, corsHeaders);
32 }
33 const bucketPolicy = bucket.getBucketPolicy();
34 if (!bucketPolicy) {
35 log.debug('error processing request', {
36 error: errors.NoSuchBucketPolicy,
37 method: 'bucketGetPolicy',
38 });
39 return callback(errors.NoSuchBucketPolicy, null,
40 corsHeaders);
41 }
42 // TODO: implement Utapi metric support
43 // bucketPolicy needs to be JSON stringified on return for proper
44 // parsing on return to caller function
45 return callback(null, JSON.stringify(bucketPolicy), corsHeaders);
46 });
47}
48
49module.exports = bucketGetPolicy;

Callers 1

bucketGetPolicy.jsFile · 0.85

Calls 3

collectCorsHeadersFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected