Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage ACL invalid argument #1906

Closed
daspecster opened this issue Jun 25, 2016 · 2 comments
Closed

Storage ACL invalid argument #1906

daspecster opened this issue Jun 25, 2016 · 2 comments
Assignees
Labels
api: logging Issues related to the Cloud Logging API. api: storage Issues related to the Cloud Storage API. type: question Request for information or clarification. Not an issue.

Comments

@daspecster
Copy link
Contributor

Let me know if I'm doing this wrong but for the docs PR #1905 I'm trying to grant cloud-logs@google.com owner permissions on a bucket but it throws an InvalidArgument HTTP 400 error when I try to save it.

from gcloud import storage
client = storage.Client()
bucket = client.get_bucket('my-bucket-name')
acl = bucket.acl
acl.user('cloud-logs@google.com').grant_owner()
acl.save()

Traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "gcloud/storage/acl.py", line 464, in save
    self._save(acl, None, client)
  File "gcloud/storage/acl.py", line 440, in _save
    query_params=query_params)
  File "gcloud/connection.py", line 344, in api_request
    error_info=method + ' ' + url)
gcloud.exceptions.BadRequest: 400 Invalid argument. (PATCH https://www.googleapis.com/storage/v1/b/ferrous-arena-my-test-bucket?projection=full)

Did I do it wrong somehow?

I'm looking into the API call deeper to find out, but I wanted to make sure I didn't miss a step.

@tseaver
Copy link
Contributor

tseaver commented Jun 26, 2016

@daspecster Have a look at the system_tests/logging_.py example:

    def _init_storage_bucket(self):
        from gcloud import storage
        BUCKET_URI = 'storage.googleapis.com/%s' % (BUCKET_NAME,)

        # Create the destination bucket, and set up the ACL to allow
        # Cloud Logging to write into it.
        storage_client = storage.Client()
        bucket = storage_client.create_bucket(BUCKET_NAME)
        self.to_delete.append(bucket)
        bucket.acl.reload()
        logs_group = bucket.acl.group('cloud-logs@google.com')
        logs_group.grant_owner()
        bucket.acl.add_entity(logs_group)
        bucket.acl.save()

        return BUCKET_URI

Maybe you need to fetch the ACL (via acl.reload()) before updating and saving it?

@tseaver tseaver added type: question Request for information or clarification. Not an issue. api: storage Issues related to the Cloud Storage API. api: logging Issues related to the Cloud Logging API. labels Jun 26, 2016
@daspecster
Copy link
Contributor Author

Thanks @tseaver! This works...

from gcloud import storage
client = storage.Client()
bucket = client.get_bucket('my-bucket-name')
bucket.acl.reload()
logs_group = bucket.acl.group('cloud-logs@google.com')
logs_group.grant_owner()
bucket.acl.add_entity(logs_group)
bucket.acl.save()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the Cloud Logging API. api: storage Issues related to the Cloud Storage API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants