def _SetAclGsutilApi(self, url, gsutil_api):
    try:
      if url.IsBucket():
        if self.def_acl:
          if self.canned:
            gsutil_api.PatchBucket(
                url.bucket_name, apitools_messages.Bucket(),
                canned_def_acl=self.acl_arg, provider=url.scheme, fields=['id'])
          else:
            def_obj_acl = AclTranslation.JsonToMessage(
                self.acl_arg, apitools_messages.ObjectAccessControl)
            if not def_obj_acl:
              # Use a sentinel value to indicate a private (no entries) default
              # object ACL.
              def_obj_acl.append(PRIVATE_DEFAULT_OBJ_ACL)
            bucket_metadata = apitools_messages.Bucket(
                defaultObjectAcl=def_obj_acl)
            gsutil_api.PatchBucket(url.bucket_name, bucket_metadata,
                                   provider=url.scheme, fields=['id'])
        else:
          if self.canned:
            gsutil_api.PatchBucket(
                url.bucket_name, apitools_messages.Bucket(),
                canned_acl=self.acl_arg, provider=url.scheme, fields=['id'])
          else:
            bucket_acl = AclTranslation.JsonToMessage(
                self.acl_arg, apitools_messages.BucketAccessControl)
            bucket_metadata = apitools_messages.Bucket(acl=bucket_acl)
            gsutil_api.PatchBucket(url.bucket_name, bucket_metadata,
                                   provider=url.scheme, fields=['id'])
      else:  # url.IsObject()
        if self.canned:
          gsutil_api.PatchObjectMetadata(
              url.bucket_name, url.object_name, apitools_messages.Object(),
              provider=url.scheme, generation=url.generation,
              canned_acl=self.acl_arg)
        else:
          object_acl = AclTranslation.JsonToMessage(
              self.acl_arg, apitools_messages.ObjectAccessControl)
          object_metadata = apitools_messages.Object(acl=object_acl)
          gsutil_api.PatchObjectMetadata(url.bucket_name, url.object_name,
                                         object_metadata, provider=url.scheme,
                                         generation=url.generation)
    except ArgumentException, e:
      raise
    except ServiceException, e:
      if self.continue_on_error:
        self.everything_set_okay = False
        self.logger.error(e)
      else:
        raise
NOTE: This method uses the old-style request parameters
dataset/ETHPy150Open GoogleCloudPlatform/gsutil/gslib/command.py/Command._SetAclGsutilApi--crossover with--dataset/ETHPy150Open darcyliu/storyboard/boto/ec2/connection.py/EC2Connection.revoke_security_group_deprecated