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

Function updateMetadata

tests/functional/backbeat/utils.js:9–55  ·  view source on GitHub ↗
(params, toUpdate, cb)

Source from the content-addressed store, hash-verified

7// This approach is preferred over directly updating the metadata in MongoDB,
8// as it allows the tests to be compatible with S3C metadata.
9function updateMetadata(params, toUpdate, cb) {
10 const { bucket, objectKey, versionId, authCredentials } = params;
11 const { dataStoreName } = toUpdate;
12 const options = {
13 authCredentials,
14 hostname: ipAddress,
15 port: 8000,
16 method: 'GET',
17 path: `/_/backbeat/metadata/${bucket}/${objectKey}`,
18 jsonResponse: true,
19 };
20 if (versionId) {
21 options.queryObj = { versionId };
22 }
23 return makeRequest(options, (err, data) => {
24 if (err) {
25 return cb(err);
26 }
27 let parsedBody;
28 try {
29 parsedBody = JSON.parse(data.body);
30 } catch (err) {
31 return cb(err);
32 }
33 const { result, error } = ObjectMD.createFromBlob(parsedBody.Body);
34 if (error) {
35 return cb(error);
36 }
37
38 if (dataStoreName) {
39 result.setDataStoreName(dataStoreName);
40 }
41 const options = {
42 authCredentials,
43 hostname: ipAddress,
44 port: 8000,
45 method: 'PUT',
46 path: `/_/backbeat/metadata/${bucket}/${objectKey}`,
47 requestBody: result.getSerialized(),
48 jsonResponse: true,
49 };
50 if (versionId) {
51 options.queryObj = { versionId };
52 }
53 return makeRequest(options, err => cb(err));
54 });
55}
56
57/** makeBackbeatRequest - utility function to generate a request going
58 * through backbeat route

Callers 1

Calls 1

makeRequestFunction · 0.50

Tested by

no test coverage detected