* GET Service - Get list of buckets owned by user * @param {AuthInfo} authInfo - Instance of AuthInfo class with requester's info * @param {object} request - normalized request object * @param {object} log - Werelogs logger * @param {function} callback - callback * @return {undefined}
(authInfo, request, log, callback)
| 52 | * @return {undefined} |
| 53 | */ |
| 54 | function serviceGet(authInfo, request, log, callback) { |
| 55 | log.debug('processing request', { method: 'serviceGet' }); |
| 56 | |
| 57 | if (authInfo.isRequesterPublicUser()) { |
| 58 | log.debug('operation not available for public user'); |
| 59 | monitoring.promMetrics( |
| 60 | 'GET', request.bucketName, 403, 'getService'); |
| 61 | return callback(errors.AccessDenied); |
| 62 | } |
| 63 | const xml = []; |
| 64 | const canonicalId = authInfo.getCanonicalID(); |
| 65 | xml.push( |
| 66 | '<?xml version="1.0" encoding="UTF-8"?>', |
| 67 | '<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/' + |
| 68 | '2006-03-01/">', |
| 69 | '<Owner>', |
| 70 | `<ID>${canonicalId}</ID>`, |
| 71 | `<DisplayName>${authInfo.getAccountDisplayName()}` + |
| 72 | '</DisplayName>', |
| 73 | '</Owner>', |
| 74 | '<Buckets>' |
| 75 | ); |
| 76 | return services.getService(authInfo, request, log, constants.splitter, |
| 77 | (err, userBuckets, splitter) => { |
| 78 | if (err) { |
| 79 | monitoring.promMetrics( |
| 80 | 'GET', userBuckets, err.code, 'getService'); |
| 81 | return callback(err); |
| 82 | } |
| 83 | // TODO push metric for serviceGet |
| 84 | // pushMetric('getService', log, { |
| 85 | // bucket: bucketName, |
| 86 | // }); |
| 87 | monitoring.promMetrics('GET', userBuckets, '200', 'getService'); |
| 88 | return callback(null, generateXml(xml, canonicalId, userBuckets, |
| 89 | splitter)); |
| 90 | }); |
| 91 | } |
| 92 | |
| 93 | module.exports = serviceGet; |
no test coverage detected