Skip to content

Commit

Permalink
API: user_project falls back to project (#208)
Browse files Browse the repository at this point in the history
* API: user_project falls back to project

Closes #207
  • Loading branch information
TomAugspurger authored Dec 2, 2019
1 parent 55b9b25 commit 61b2f66
Show file tree
Hide file tree
Showing 61 changed files with 6,456 additions and 6,511 deletions.
5 changes: 3 additions & 2 deletions gcsfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class GCSFileSystem(fsspec.AbstractFileSystem):
Parameters
----------
project : string
project_id to work under. Note that this is not the same as, but ofter
project_id to work under. Note that this is not the same as, but often
very similar to, the project name.
This is required in order
to list all the buckets you have access to within a project and to
Expand Down Expand Up @@ -278,6 +278,7 @@ class GCSFileSystem(fsspec.AbstractFileSystem):
user_project : string
project_id to use for requester-pays buckets. This is included as
the ``userProject`` parameter in requests made to Google Cloud Storage.
If not provided, this falls back to ``project`` when that is specified.
"""

scopes = {"read_only", "read_write", "full_control"}
Expand Down Expand Up @@ -307,7 +308,7 @@ def __init__(
if block_size is not None:
self.default_block_size = block_size
self.project = project
self.user_project = user_project
self.user_project = user_project or project
self.access = access
self.scope = "https://www.googleapis.com/auth/devstorage." + access
self.consistency = consistency
Expand Down
98 changes: 49 additions & 49 deletions gcsfs/tests/recordings/test_array.yaml

Large diffs are not rendered by default.

177 changes: 89 additions & 88 deletions gcsfs/tests/recordings/test_attrs.yaml

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions gcsfs/tests/recordings/test_bad_open.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interactions:
response:
body:
string: !!binary |
H4sIAAsv5V0C/yWNQQoCMQwAv7LkLO2C4GGPfqSEGrvFuilJ1lbEv2v1OgwzL8AYSTUY32iDZYLe
H4sIAI5B5V0C/yWNQQoCMQwAv7LkLO2C4GGPfqSEGrvFuilJ1lbEv2v1OgwzL8AYSTUY32iDZYLe
OxwmoF6zkIY84PE0z1+mkSsNZzWrunjfWnOJORXCmtVFvnvcbfUXeqixYCJ33UsJkTcTLqP7+wR7
/kNnQiGB9we3u8nlhwAAAA==
headers:
Expand Down Expand Up @@ -58,7 +58,7 @@ interactions:
Content-Type:
- application/json
method: POST
uri: https://www.googleapis.com/storage/v1/b/?predefinedAcl=publicReadWrite&predefinedDefaultObjectAcl=authenticatedread&project=test_project
uri: https://www.googleapis.com/storage/v1/b/?predefinedAcl=publicReadWrite&predefinedDefaultObjectAcl=authenticatedread&project=test_project&userProject=test_project
response:
body:
string: "{\n \"error\": {\n \"errors\": [\n {\n \"domain\": \"global\",\n
Expand Down Expand Up @@ -88,7 +88,7 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/?delimiter=%2F
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/?delimiter=%2F&userProject=test_project
response:
body:
string: "{\n \"kind\": \"storage#objects\"\n}\n"
Expand Down Expand Up @@ -117,7 +117,7 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://www.googleapis.com/storage/v1/b/?project=test_project
uri: https://www.googleapis.com/storage/v1/b/?project=test_project&userProject=test_project
response:
body:
string: "{\n \"kind\": \"storage#buckets\",\n \"items\": [\n {\n \"kind\":
Expand Down Expand Up @@ -228,18 +228,18 @@ interactions:
Content-Type:
- multipart/mixed; boundary="===============7330845974216740156=="
method: POST
uri: https://www.googleapis.com/batch
uri: https://www.googleapis.com/batch?userProject=test_project
response:
body:
string: !!binary |
H4sIAAAAAAAAANPVTUosSc6IN4yMrypxKS9zTvGMd3R08y5yNfP2qyjW1eXlAgArFqEDIwAAAA==
H4sIAAAAAAAAANPVTUosSc6Iz873yqoKjDQyLnCMd3T0ySnPSUpMKg7V1eXlAgCTDo/3IwAAAA==
headers:
Cache-Control:
- private, max-age=0
Content-Encoding:
- gzip
Content-Type:
- multipart/mixed; boundary=batch_1Y_ztDwvCdI_AAFKrE6KNxs
- multipart/mixed; boundary=batch_koJjzQY23pA_AALlwlbabsU
Server:
- GSE
Transfer-Encoding:
Expand Down Expand Up @@ -268,7 +268,7 @@ interactions:
Content-Length:
- '0'
method: DELETE
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fa
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fa?userProject=test_project
response:
body:
string: "{\n \"error\": {\n \"code\": 404,\n \"message\": \"No such object:
Expand Down Expand Up @@ -304,7 +304,7 @@ interactions:
Content-Length:
- '0'
method: DELETE
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fb
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fb?userProject=test_project
response:
body:
string: "{\n \"error\": {\n \"code\": 404,\n \"message\": \"No such object:
Expand Down Expand Up @@ -340,7 +340,7 @@ interactions:
Content-Length:
- '0'
method: DELETE
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fc
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fc?userProject=test_project
response:
body:
string: "{\n \"error\": {\n \"code\": 404,\n \"message\": \"No such object:
Expand Down Expand Up @@ -376,7 +376,7 @@ interactions:
Content-Length:
- '0'
method: DELETE
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fd
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/tmp%2Ftest%2Fd?userProject=test_project
response:
body:
string: "{\n \"error\": {\n \"code\": 404,\n \"message\": \"No such object:
Expand Down Expand Up @@ -410,7 +410,7 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://www.googleapis.com/storage/v1/b/?project=test_project
uri: https://www.googleapis.com/storage/v1/b/?project=test_project&userProject=test_project
response:
body:
string: "{\n \"kind\": \"storage#buckets\",\n \"items\": [\n {\n \"kind\":
Expand Down Expand Up @@ -515,7 +515,7 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://www.googleapis.com/storage/v1/b/?project=test_project
uri: https://www.googleapis.com/storage/v1/b/?project=test_project&userProject=test_project
response:
body:
string: "{\n \"kind\": \"storage#buckets\",\n \"items\": [\n {\n \"kind\":
Expand Down Expand Up @@ -620,15 +620,15 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/?delimiter=%2F
uri: https://www.googleapis.com/storage/v1/b/gcsfs-testing/o/?delimiter=%2F&userProject=test_project
response:
body:
string: "{\n \"kind\": \"storage#objects\"\n}\n"
string: "{\n \"kind\": \"storage#objects\"\n}\n"
headers:
Cache-Control:
- private, max-age=0, must-revalidate, no-transform
Content-Length:
- '31'
- '32'
Content-Type:
- application/json; charset=UTF-8
Server:
Expand All @@ -649,7 +649,7 @@ interactions:
Connection:
- keep-alive
method: GET
uri: https://www.googleapis.com/storage/v1/b/?project=test_project
uri: https://www.googleapis.com/storage/v1/b/?project=test_project&userProject=test_project
response:
body:
string: "{\n \"kind\": \"storage#buckets\",\n \"items\": [\n {\n \"kind\":
Expand Down
Loading

0 comments on commit 61b2f66

Please sign in to comment.