#NEWLINE# @ Retry ( ServiceException , tries = 3 , timeout_secs = 1 ) #NEWLINE# def ApplyAclChanges( self , url ) : #NEWLINE# #INDENT# 'Applies the changes in self.changes to the provided URL.' #NEWLINE# bucket = self . gsutil_api . GetBucket ( url . bucket_name , provider = url . scheme , fields = [ 'defaultObjectAcl' , 'metageneration' ] ) #NEWLINE# current_acl = bucket . defaultObjectAcl #NEWLINE# modification_count = 0 #NEWLINE# for change in self . changes : #NEWLINE# #INDENT# modification_count += change . Execute ( url , current_acl , 'defacl' , self . logger ) #NEWLINE# #UNINDENT# if ( modification_count == 0 ) : #NEWLINE# #INDENT# self . logger . info ( 'No changes to %s' , url ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( not current_acl ) : #NEWLINE# #INDENT# current_acl . append ( PRIVATE_DEFAULT_OBJ_ACL ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# preconditions = Preconditions ( meta_gen_match = bucket . metageneration ) #NEWLINE# bucket_metadata = apitools_messages . Bucket ( defaultObjectAcl = current_acl ) #NEWLINE# self . gsutil_api . PatchBucket ( url . bucket_name , bucket_metadata , preconditions = preconditions , provider = url . scheme , fields = [ 'id' ] ) #NEWLINE# #UNINDENT# except BadRequestException as e : #NEWLINE# #INDENT# raise CommandException ( ( 'Received bad request from server: %s' % str ( e ) ) ) #NEWLINE# #UNINDENT# except AccessDeniedException : #NEWLINE# #INDENT# self . _WarnServiceAccounts ( ) #NEWLINE# raise CommandException ( ( 'Failed to set acl for %s. Please ensure you have OWNER-role access to this resource.' % url ) ) #NEWLINE# #UNINDENT# self . logger . info ( 'Updated default ACL on %s' , preconditions )