(authInfo, request, log, callback)
| 8 | const METRICS_ACTION = 'deleteBucketWebsite'; |
| 9 | |
| 10 | function bucketDeleteWebsite(authInfo, request, log, callback) { |
| 11 | const bucketName = request.bucketName; |
| 12 | const metadataValParams = { |
| 13 | authInfo, |
| 14 | bucketName, |
| 15 | requestType: REQUEST_TYPE, |
| 16 | request, |
| 17 | }; |
| 18 | |
| 19 | return standardMetadataValidateBucket(metadataValParams, request.actionImplicitDenies, log, (err, bucket) => { |
| 20 | const corsHeaders = collectCorsHeaders(request.headers.origin, request.method, bucket); |
| 21 | if (err) { |
| 22 | monitoring.promMetrics('DELETE', bucketName, err.code, REQUEST_TYPE); |
| 23 | if (err?.is?.AccessDenied) { |
| 24 | return callback(err, corsHeaders); |
| 25 | } |
| 26 | return callback(err); |
| 27 | } |
| 28 | |
| 29 | const websiteConfig = bucket.getWebsiteConfiguration(); |
| 30 | if (!websiteConfig) { |
| 31 | log.trace('no existing website configuration', { method: REQUEST_TYPE }); |
| 32 | pushMetric(METRICS_ACTION, log, { authInfo, bucket: bucketName }); |
| 33 | return callback(null, corsHeaders); |
| 34 | } |
| 35 | |
| 36 | log.trace('deleting website configuration in metadata'); |
| 37 | bucket.setWebsiteConfiguration(null); |
| 38 | return metadata.updateBucket(bucketName, bucket, log, err => { |
| 39 | if (err) { |
| 40 | monitoring.promMetrics('DELETE', bucketName, err.code, METRICS_ACTION); |
| 41 | return callback(err, corsHeaders); |
| 42 | } |
| 43 | pushMetric(METRICS_ACTION, log, { authInfo, bucket: bucketName }); |
| 44 | monitoring.promMetrics('DELETE', bucketName, '200', METRICS_ACTION); |
| 45 | return callback(null, corsHeaders); |
| 46 | }); |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | module.exports = bucketDeleteWebsite; |
no test coverage detected