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

blob.acl.save_predefined() only works for private #1659

Closed
pdknsk opened this issue Mar 25, 2016 · 5 comments
Closed

blob.acl.save_predefined() only works for private #1659

pdknsk opened this issue Mar 25, 2016 · 5 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API.

Comments

@pdknsk
Copy link

pdknsk commented Mar 25, 2016

From the documentation.

Must be one of the keys in _PREDEFINED_ACLS

    _PREDEFINED_ACLS = frozenset([
        "private",
        "project-private",
        "public-read",
        "public-read-write",
        "authenticated-read",
        "bucket-owner-read",
        "bucket-owner-full-control",
    ])

Let's try.

>>> blob.acl.save_predefined('public-read')
...
gcloud.exceptions.BadRequest: 400 Invalid string value: 'public-read'. Allowed values: [authenticatedread, bucketownerfullcontrol, bucketownerread, private, projectprivate, publicread]
>>> blob.acl.save_predefined('publicread')
...
ValueError: Invalid predefined ACL: publicread

Coincidentally, the tests only try private.

@pdknsk
Copy link
Author

pdknsk commented Mar 26, 2016

I have confirmed that editing _PREDEFINED_ACLS to use the suggested values makes it work. The bug is that it uses the XML API names rather than the JSON API names. I think both should be valid in gcloud-python, as gsutil uses the former.

PS. public-read-write only applies to buckets, so isn't listed in the allowed values.

@tseaver
Copy link
Contributor

tseaver commented Mar 26, 2016

Thanks for investigating! Can you confirm my reading: we have the bug, because the values enumerated in gcloud.storage.acl are the XML API spellings, which aren't valid for use against the JSON API?

Begging the question, of course, of why the two APIs use different spelings for those constants. :(

@pdknsk
Copy link
Author

pdknsk commented Mar 26, 2016

Yes, that's the bug. I think both should be valid in gcloud-python though, as the XML API names are more commonly mentioned in docs and otherwise. And gsutil uses those names too, as mentioned. They could be easily mapped to each other.

@tseaver
Copy link
Contributor

tseaver commented Mar 26, 2016

Can you point me to the docs for the JSON predefined ACL constants? The ones I worked from weren't obviously tied to the XML API.

@tseaver
Copy link
Contributor

tseaver commented Mar 26, 2016

Oh, never mind: I see that the first column is the JSON spellings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API.
Projects
None yet
Development

No branches or pull requests

3 participants