Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Add command - Object Storage Bucket Access Modify
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiran committed Oct 28, 2021
1 parent 9be4371 commit f33a31b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

import { Command } from 'commander';
import bucketAccessModify from '../src/commands/bucket-access-modify.js';
import bucketCreate from '../src/commands/bucket-create.js';
import bucketList from '../src/commands/bucket-list.js';
import bucketRemove from '../src/commands/bucket-remove.js';
Expand All @@ -18,10 +19,13 @@ cli
.helpOption(false);

cli.addCommand(setToken);

cli.addCommand(bucketList);
cli.addCommand(bucketView);
cli.addCommand(bucketCreate);
cli.addCommand(bucketRemove);
cli.addCommand(bucketAccessModify);

cli.addCommand(objectList);

cli.parse(process.argv);
26 changes: 26 additions & 0 deletions src/buckets.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,35 @@ const getOne = async (label, cluster) => {
return console.log(response);
};

const updateAccess = async ({ label, cluster, acl, cors }) => {
if (acl === undefined && cors === undefined) {
console.log('You must provide either ACL or CORS setting.');
return;
}

const params = {};

if (acl) {
params['acl'] = acl;
}

if (cors) {
params['cors_enabled'] = cors === 'true';
}

const response = await makeRequest(
'POST',
`${baseUrl}/${cluster}/${label}/access`,
params
);

return console.log(response);
};

export default {
create,
remove,
getAll,
getOne,
updateAccess,
};
19 changes: 19 additions & 0 deletions src/commands/bucket-access-modify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Object Storage Bucket Access Modify

import { Command } from 'commander';
import buckets from '../buckets.js';

const program = new Command('bucket-access-modify');

program
.requiredOption('--label <label>', 'The bucket name.')
.requiredOption(
'--cluster <cluster>',
'The ID of the cluster this bucket exists in.'
)
.option('--acl <acl>', 'The ACL of the bucket.')
.option('--cors <cors>', 'Enable/Disable CORS.')
.description('Allows changing basic CORS and ACL settings.')
.action(buckets.updateAccess);

export default program;

0 comments on commit f33a31b

Please sign in to comment.