Skip to content

Commit b4fb361

Browse files
shungangcsg01123119
and
csg01123119
authored
feat: bucket options support set headers (#1306)
* feat: support list buckets headers * feat: support list buckets headers * feat: support list buckets headers * feat: support list buckets headers * fix: error detail from header * feat: support list buckets headers * feat: support list buckets headers --------- Co-authored-by: csg01123119 <[email protected]>
1 parent 6bde1c2 commit b4fb361

6 files changed

+201
-3
lines changed

lib/bucket.js

+1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ proto._bucketRequestParams = function _bucketRequestParams(method, bucket, subre
330330
method,
331331
bucket,
332332
subres,
333+
headers: options && options.headers,
333334
additionalHeaders: options && options.additionalHeaders,
334335
timeout: options && options.timeout,
335336
ctx: options && options.ctx

package-lock.json

+168-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"node": ">=8"
7070
},
7171
"devDependencies": {
72+
"@alicloud/openapi-client": "^0.4.10",
73+
"@alicloud/resourcemanager20200331": "^2.3.0",
74+
"@alicloud/tea-util": "^1.4.9",
7275
"@babel/core": "^7.11.6",
7376
"@babel/plugin-transform-regenerator": "^7.10.4",
7477
"@babel/plugin-transform-runtime": "^7.11.5",
@@ -153,7 +156,7 @@
153156
"sdk-base": "^2.0.1",
154157
"stream-http": "2.8.2",
155158
"stream-wormhole": "^1.0.4",
156-
"urllib": "2.42.0",
159+
"urllib": "^2.44.0",
157160
"utility": "^1.18.0",
158161
"xml2js": "^0.6.2"
159162
},

test/node/bucket.test.js

+28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
const assert = require('assert');
23
const utils = require('./utils');
34
const oss = require('../..');
45
const ms = require('humanize-ms');
6+
const { default: ResourceManager, ListResourceGroupsRequest } = require('@alicloud/resourcemanager20200331');
7+
const { Config: OpenConfig } = require('@alicloud/openapi-client');
8+
const { RuntimeOptions } = require('@alicloud/tea-util');
9+
510
const { oss: config, metaSyncTime, timeout } = require('../config');
611

712
describe('test/bucket.test.js', () => {
@@ -265,6 +270,29 @@ describe('test/bucket.test.js', () => {
265270
}
266271
});
267272

273+
it('should list buckets by group id', async () => {
274+
const { accessKeyId, accessKeySecret } = config;
275+
const openConfig = new OpenConfig({
276+
accessKeyId,
277+
accessKeySecret
278+
});
279+
openConfig.endpoint = `resourcemanager.aliyuncs.com`;
280+
const client = new ResourceManager(openConfig);
281+
const runtime = new RuntimeOptions({});
282+
const {
283+
body: {
284+
resourceGroups: { resourceGroup }
285+
}
286+
} = await client.listResourceGroupsWithOptions(new ListResourceGroupsRequest({}), runtime);
287+
assert(resourceGroup.length > 1);
288+
const { id: defaultId } = resourceGroup.find(re => re.name.indexOf('default') > -1);
289+
const { buckets } = await store.listBuckets({}, { headers: { 'x-oss-resource-group-id': defaultId } });
290+
assert(buckets.some(b => b.name === bucket));
291+
const { id } = resourceGroup.find(re => re.name.indexOf('default') === -1);
292+
const { buckets: list } = await store.listBuckets({}, { headers: { 'x-oss-resource-group-id': id } });
293+
assert(list === null || !list.some(b => b.name === bucket));
294+
});
295+
268296
after(async () => {
269297
await Promise.all(
270298
Array(2)
Loading
22.8 KB
Loading

0 commit comments

Comments
 (0)