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

Function bucketDeleteRateLimit

lib/api/bucketDeleteRateLimit.js:18–62  ·  view source on GitHub ↗

* bucketDeleteRateLimit - Delete the bucket rate limit 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 * @retur

(authInfo, request, log, callback)

Source from the content-addressed store, hash-verified

16 * @return {undefined}
17 */
18function bucketDeleteRateLimit(authInfo, request, log, callback) {
19 log.debug('processing request', { method: 'bucketDeleteRateLimit' });
20
21 if (!isRateLimitServiceUser(authInfo)) {
22 return callback(errors.AccessDenied);
23 }
24
25 const { bucketName, headers, method } = request;
26 const metadataValParams = {
27 authInfo,
28 bucketName,
29 requestType: request.apiMethods || 'bucketDeleteRateLimit',
30 request,
31 };
32 return standardMetadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => {
33 const corsHeaders = collectCorsHeaders(headers.origin, method, bucket);
34 if (err) {
35 log.debug('error processing request', {
36 error: err,
37 method: 'bucketDeleteRateLimit',
38 });
39 return callback(err, corsHeaders);
40 }
41 if (!bucket.getRateLimitConfiguration()) {
42 log.trace('no existing bucket rate limit configuration', {
43 method: 'bucketDeleteRateLimit',
44 });
45 // TODO: implement Utapi metric support
46 return callback(null, corsHeaders);
47 }
48 log.trace('deleting bucket rate limit configuration in metadata');
49 bucket.setRateLimitConfiguration(undefined);
50 return metadata.updateBucket(bucketName, bucket, log, err => {
51 if (err) {
52 return callback(err, corsHeaders);
53 }
54 // Invalidate cache and remove token bucket
55 cache.deleteCachedConfig(cache.namespace.bucket, bucketName);
56 removeTokenBucket('bucket', bucketName, 'rps');
57 log.debug('invalidated rate limit cache and token bucket for bucket', { bucketName });
58 // TODO: implement Utapi metric support
59 return callback(null, corsHeaders);
60 });
61 });
62}
63
64module.exports = bucketDeleteRateLimit;

Callers 1

Calls 6

isRateLimitServiceUserFunction · 0.85
collectCorsHeadersFunction · 0.85
removeTokenBucketFunction · 0.85
debugMethod · 0.80
traceMethod · 0.80

Tested by

no test coverage detected