MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

storage/removeBucketDefaultOwner.js:25–60  ·  view source on GitHub ↗

* This application demonstrates how to perform basic operations on bucket and * file Access Control Lists with the Google Cloud Storage API. * * For more information, see the README.md under /storage and the documentation * at https://cloud.google.com/storage/docs.

(bucketName = 'my-bucket', userEmail = 'jdobry@google.com')

Source from the content-addressed store, hash-verified

23 */
24
25function main(bucketName = 'my-bucket', userEmail = 'jdobry@google.com') {
26 // [START storage_remove_bucket_default_owner]
27 /**
28 * TODO(developer): Uncomment the following lines before running the sample.
29 */
30 // The ID of your GCS bucket
31 // const bucketName = 'your-unique-bucket-name';
32
33 // The email address of the user to remove
34 // const userEmail = 'user-email-to-remove';
35
36 // Imports the Google Cloud client library
37 const {Storage} = require('@google-cloud/storage');
38
39 // Creates a client
40 const storage = new Storage();
41
42 async function removeBucketDefaultOwner() {
43 try {
44 // Removes the user from the access control list of the bucket. You can use
45 // deleteAllUsers(), deleteDomain(), deleteProject(), deleteGroup(), and
46 // deleteAllAuthenticatedUsers() to remove access for different types of entities.
47 await storage.bucket(bucketName).acl.default.owners.deleteUser(userEmail);
48
49 console.log(`Removed user ${userEmail} from bucket ${bucketName}.`);
50 } catch (error) {
51 console.error(
52 'Error executing remove bucket default owner ACL:',
53 error.message || error
54 );
55 }
56 }
57
58 removeBucketDefaultOwner();
59 // [END storage_remove_bucket_default_owner]
60}
61
62main(...process.argv.slice(2));

Callers 1

Calls 1

removeBucketDefaultOwnerFunction · 0.85

Tested by

no test coverage detected