/** Example of deleting the ACL entry for an entity on a bucket. */ // [TARGET deleteAcl(String, Entity)] // [VARIABLE "my_unique_bucket"] public boolean deleteBucketAcl(String bucketName) { // [START deleteBucketAcl] boolean deleted = storage.deleteAcl(bucketName, User.ofAllAuthenticatedUsers()); if (deleted) { // the acl entry was deleted } else { // the acl entry was not found } // [END deleteBucketAcl] return deleted; }
/** * Deletes the ACL entry for the specified entity on this bucket. * * <p>Example of deleting the ACL entry for an entity. * * <pre>{@code * boolean deleted = bucket.deleteAcl(User.ofAllAuthenticatedUsers()); * if (deleted) { * // the acl entry was deleted * } else { * // the acl entry was not found * } * }</pre> * * @return {@code true} if the ACL was deleted, {@code false} if it was not found * @throws StorageException upon failure */ public boolean deleteAcl(Entity entity) { return storage.deleteAcl(getName(), entity); }
/** * Deletes the ACL entry for the specified entity on this blob. * * <p>Example of deleting the ACL entry for an entity. * * <pre>{@code * boolean deleted = blob.deleteAcl(User.ofAllAuthenticatedUsers()); * if (deleted) { * // the acl entry was deleted * } else { * // the acl entry was not found * } * }</pre> * * @return {@code true} if the ACL was deleted, {@code false} if it was not found * @throws StorageException upon failure */ public boolean deleteAcl(Entity entity) { return storage.deleteAcl(getBlobId(), entity); }
/** Example of deleting the ACL entry for an entity on a blob. */ // [TARGET deleteAcl(BlobId, Entity)] // [VARIABLE "my_unique_bucket"] // [VARIABLE "my_blob_name"] // [VARIABLE 42] public boolean deleteBlobAcl(String bucketName, String blobName, long blobGeneration) { // [START deleteBlobAcl] BlobId blobId = BlobId.of(bucketName, blobName, blobGeneration); boolean deleted = storage.deleteAcl(blobId, User.ofAllAuthenticatedUsers()); if (deleted) { // the acl entry was deleted } else { // the acl entry was not found } // [END deleteBlobAcl] return deleted; }
@Test public void testDeleteBucketAcl() { EasyMock.expect( storageRpcMock.deleteAcl( BUCKET_NAME1, "allAuthenticatedUsers", new HashMap<StorageRpc.Option, Object>())) .andReturn(true); EasyMock.replay(storageRpcMock); initializeService(); assertTrue(storage.deleteAcl(BUCKET_NAME1, User.ofAllAuthenticatedUsers())); }
@Test public void testDeleteBlobAcl() { BlobId blobId = BlobId.of(BUCKET_NAME1, BLOB_NAME1, 42L); EasyMock.expect( storageRpcMock.deleteAcl(BUCKET_NAME1, BLOB_NAME1, 42L, "allAuthenticatedUsers")) .andReturn(true); EasyMock.replay(storageRpcMock); initializeService(); assertTrue(storage.deleteAcl(blobId, User.ofAllAuthenticatedUsers())); }
@Test public void testDeleteAcl() throws Exception { initializeExpectedBucket(4); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.deleteAcl(BUCKET_INFO.getName(), User.ofAllAuthenticatedUsers())) .andReturn(true); replay(storage); initializeBucket(); assertTrue(bucket.deleteAcl(User.ofAllAuthenticatedUsers())); }
@Test public void testDeleteAcl() throws Exception { initializeExpectedBlob(1); expect(storage.getOptions()).andReturn(mockOptions); expect(storage.deleteAcl(BLOB_INFO.getBlobId(), User.ofAllAuthenticatedUsers())) .andReturn(true); replay(storage); initializeBlob(); assertTrue(blob.deleteAcl(User.ofAllAuthenticatedUsers())); }
private void testBucketAclRequesterPays(boolean requesterPays) { if (requesterPays) { Bucket remoteBucket = storage.get(BUCKET, Storage.BucketGetOption.fields(BucketField.ID)); assertNull(remoteBucket.requesterPays()); remoteBucket = remoteBucket.toBuilder().setRequesterPays(true).build(); Bucket updatedBucket = storage.update(remoteBucket); assertTrue(updatedBucket.requesterPays()); } String projectId = remoteStorageHelper.getOptions().getProjectId(); Storage.BucketSourceOption[] bucketOptions = requesterPays ? new Storage.BucketSourceOption[] {Storage.BucketSourceOption.userProject(projectId)} : new Storage.BucketSourceOption[] {}; assertNull(storage.getAcl(BUCKET, User.ofAllAuthenticatedUsers(), bucketOptions)); assertFalse(storage.deleteAcl(BUCKET, User.ofAllAuthenticatedUsers(), bucketOptions)); Acl acl = Acl.of(User.ofAllAuthenticatedUsers(), Role.READER); assertNotNull(storage.createAcl(BUCKET, acl, bucketOptions)); Acl updatedAcl = storage.updateAcl(BUCKET, acl.toBuilder().setRole(Role.WRITER).build(), bucketOptions); assertEquals(Role.WRITER, updatedAcl.getRole()); Set<Acl> acls = new HashSet<>(); acls.addAll(storage.listAcls(BUCKET, bucketOptions)); assertTrue(acls.contains(updatedAcl)); assertTrue(storage.deleteAcl(BUCKET, User.ofAllAuthenticatedUsers(), bucketOptions)); assertNull(storage.getAcl(BUCKET, User.ofAllAuthenticatedUsers(), bucketOptions)); }
Set<Acl> acls = new HashSet<>(storage.listAcls(blobId)); assertTrue(acls.contains(updatedAcl)); assertTrue(storage.deleteAcl(blobId, User.ofAllAuthenticatedUsers())); assertNull(storage.getAcl(blobId, User.ofAllAuthenticatedUsers())); assertFalse(storage.deleteAcl(otherBlobId, User.ofAllAuthenticatedUsers())); fail("Expected an 'Invalid argument' exception"); } catch (StorageException e) {
/** * Deletes the ACL entry for the specified entity on this bucket. * * <p>Example of deleting the ACL entry for an entity. * * <pre>{@code * boolean deleted = bucket.deleteAcl(User.ofAllAuthenticatedUsers()); * if (deleted) { * // the acl entry was deleted * } else { * // the acl entry was not found * } * }</pre> * * @return {@code true} if the ACL was deleted, {@code false} if it was not found * @throws StorageException upon failure */ public boolean deleteAcl(Entity entity) { return storage.deleteAcl(getName(), entity); }
/** * Deletes the ACL entry for the specified entity on this blob. * * <p>Example of deleting the ACL entry for an entity. * * <pre>{@code * boolean deleted = blob.deleteAcl(User.ofAllAuthenticatedUsers()); * if (deleted) { * // the acl entry was deleted * } else { * // the acl entry was not found * } * }</pre> * * @return {@code true} if the ACL was deleted, {@code false} if it was not found * @throws StorageException upon failure */ public boolean deleteAcl(Entity entity) { return storage.deleteAcl(getBlobId(), entity); }