Skip to content

Commit

Permalink
feat: bucket options support set headers (#1306)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
shungang and csg01123119 authored Aug 1, 2024
1 parent 6bde1c2 commit b4fb361
Show file tree
Hide file tree
Showing 6 changed files with 201 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ proto._bucketRequestParams = function _bucketRequestParams(method, bucket, subre
method,
bucket,
subres,
headers: options && options.headers,
additionalHeaders: options && options.additionalHeaders,
timeout: options && options.timeout,
ctx: options && options.ctx
Expand Down
170 changes: 168 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
"node": ">=8"
},
"devDependencies": {
"@alicloud/openapi-client": "^0.4.10",
"@alicloud/resourcemanager20200331": "^2.3.0",
"@alicloud/tea-util": "^1.4.9",
"@babel/core": "^7.11.6",
"@babel/plugin-transform-regenerator": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.11.5",
Expand Down Expand Up @@ -153,7 +156,7 @@
"sdk-base": "^2.0.1",
"stream-http": "2.8.2",
"stream-wormhole": "^1.0.4",
"urllib": "2.42.0",
"urllib": "^2.44.0",
"utility": "^1.18.0",
"xml2js": "^0.6.2"
},
Expand Down
28 changes: 28 additions & 0 deletions test/node/bucket.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/* eslint-disable @typescript-eslint/no-require-imports */
const assert = require('assert');
const utils = require('./utils');
const oss = require('../..');
const ms = require('humanize-ms');
const { default: ResourceManager, ListResourceGroupsRequest } = require('@alicloud/resourcemanager20200331');
const { Config: OpenConfig } = require('@alicloud/openapi-client');
const { RuntimeOptions } = require('@alicloud/tea-util');

const { oss: config, metaSyncTime, timeout } = require('../config');

describe('test/bucket.test.js', () => {
Expand Down Expand Up @@ -265,6 +270,29 @@ describe('test/bucket.test.js', () => {
}
});

it('should list buckets by group id', async () => {
const { accessKeyId, accessKeySecret } = config;
const openConfig = new OpenConfig({
accessKeyId,
accessKeySecret
});
openConfig.endpoint = `resourcemanager.aliyuncs.com`;
const client = new ResourceManager(openConfig);
const runtime = new RuntimeOptions({});
const {
body: {
resourceGroups: { resourceGroup }
}
} = await client.listResourceGroupsWithOptions(new ListResourceGroupsRequest({}), runtime);
assert(resourceGroup.length > 1);
const { id: defaultId } = resourceGroup.find(re => re.name.indexOf('default') > -1);
const { buckets } = await store.listBuckets({}, { headers: { 'x-oss-resource-group-id': defaultId } });
assert(buckets.some(b => b.name === bucket));
const { id } = resourceGroup.find(re => re.name.indexOf('default') === -1);
const { buckets: list } = await store.listBuckets({}, { headers: { 'x-oss-resource-group-id': id } });
assert(list === null || !list.some(b => b.name === bucket));
});

after(async () => {
await Promise.all(
Array(2)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/node/fixtures/nodejs-processed-w200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b4fb361

Please sign in to comment.