Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit 44eeeb4

Browse files
committed
refactor: rename 'Client._get_path' -> '_get_resource'
For parity with forthcoming '_put_resource', '_patch_resource', '_post_resource', and '_delete_resource' methods. Toward #38.
1 parent 58df886 commit 44eeeb4

File tree

14 files changed

+171
-171
lines changed

14 files changed

+171
-171
lines changed

google/cloud/storage/_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def reload(
215215
if_metageneration_match=if_metageneration_match,
216216
if_metageneration_not_match=if_metageneration_not_match,
217217
)
218-
api_response = client._get_path(
218+
api_response = client._get_resource(
219219
self.path,
220220
query_params=query_params,
221221
headers=self._encryption_headers(),

google/cloud/storage/acl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
466466

467467
self.entities.clear()
468468

469-
found = client._get_path(
469+
found = client._get_resource(
470470
path, query_params=query_params, timeout=timeout, retry=retry,
471471
)
472472
self.loaded = True

google/cloud/storage/blob.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def exists(
704704
try:
705705
# We intentionally pass `_target_object=None` since fields=name
706706
# would limit the local properties.
707-
client._get_path(
707+
client._get_resource(
708708
self.path,
709709
query_params=query_params,
710710
timeout=timeout,
@@ -2828,7 +2828,7 @@ def get_iam_policy(
28282828
if requested_policy_version is not None:
28292829
query_params["optionsRequestedPolicyVersion"] = requested_policy_version
28302830

2831-
info = client._get_path(
2831+
info = client._get_resource(
28322832
"%s/iam" % (self.path,),
28332833
query_params=query_params,
28342834
timeout=timeout,
@@ -2968,7 +2968,7 @@ def test_iam_permissions(
29682968
query_params["userProject"] = self.user_project
29692969

29702970
path = "%s/iam/testPermissions" % (self.path,)
2971-
resp = client._get_path(
2971+
resp = client._get_resource(
29722972
path,
29732973
query_params=query_params,
29742974
timeout=timeout,

google/cloud/storage/bucket.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ def exists(
786786
try:
787787
# We intentionally pass `_target_object=None` since fields=name
788788
# would limit the local properties.
789-
client._get_path(
789+
client._get_resource(
790790
self.path,
791791
query_params=query_params,
792792
timeout=timeout,
@@ -2881,7 +2881,7 @@ def get_iam_policy(
28812881
if requested_policy_version is not None:
28822882
query_params["optionsRequestedPolicyVersion"] = requested_policy_version
28832883

2884-
info = client._get_path(
2884+
info = client._get_resource(
28852885
"%s/iam" % (self.path,),
28862886
query_params=query_params,
28872887
timeout=timeout,
@@ -3006,7 +3006,7 @@ def test_iam_permissions(
30063006
query_params["userProject"] = self.user_project
30073007

30083008
path = "%s/iam/testPermissions" % (self.path,)
3009-
resp = client._get_path(
3009+
resp = client._get_resource(
30103010
path,
30113011
query_params=query_params,
30123012
timeout=timeout,

google/cloud/storage/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def get_service_account_email(
286286
project = self.project
287287

288288
path = "/projects/%s/serviceAccount" % (project,)
289-
api_response = self._get_path(path, timeout=timeout, retry=retry)
289+
api_response = self._get_resource(path, timeout=timeout, retry=retry)
290290
return api_response["email_address"]
291291

292292
def bucket(self, bucket_name, user_project=None):
@@ -320,7 +320,7 @@ def batch(self):
320320
"""
321321
return Batch(client=self)
322322

323-
def _get_path(
323+
def _get_resource(
324324
self,
325325
path,
326326
query_params=None,

google/cloud/storage/hmac_key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def exists(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
222222
if self.user_project is not None:
223223
qs_params["userProject"] = self.user_project
224224

225-
self._client._get_path(
225+
self._client._get_resource(
226226
self.path, query_params=qs_params, timeout=timeout, retry=retry,
227227
)
228228
except NotFound:
@@ -262,7 +262,7 @@ def reload(self, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
262262
if self.user_project is not None:
263263
qs_params["userProject"] = self.user_project
264264

265-
self._properties = self._client._get_path(
265+
self._properties = self._client._get_resource(
266266
self.path, query_params=qs_params, timeout=timeout, retry=retry,
267267
)
268268

google/cloud/storage/notification.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def exists(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
323323
query_params["userProject"] = self.bucket.user_project
324324

325325
try:
326-
client._get_path(
326+
client._get_resource(
327327
self.path, query_params=query_params, timeout=timeout, retry=retry,
328328
)
329329
except NotFound:
@@ -377,7 +377,7 @@ def reload(self, client=None, timeout=_DEFAULT_TIMEOUT, retry=DEFAULT_RETRY):
377377
if self.bucket.user_project is not None:
378378
query_params["userProject"] = self.bucket.user_project
379379

380-
response = client._get_path(
380+
response = client._get_resource(
381381
self.path, query_params=query_params, timeout=timeout, retry=retry,
382382
)
383383
self._set_properties(response)

tests/unit/test__helpers.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ def test__query_params_w_user_project(self):
112112
def test_reload_w_defaults(self):
113113
path = "/path"
114114
response = {"foo": "Foo"}
115-
client = mock.Mock(spec=["_get_path"])
116-
client._get_path.return_value = response
115+
client = mock.Mock(spec=["_get_resource"])
116+
client._get_resource.return_value = response
117117
derived = self._derivedClass(path)()
118118
# Make sure changes is not a set instance before calling reload
119119
# (which will clear / replace it with an empty set), checked below.
@@ -127,7 +127,7 @@ def test_reload_w_defaults(self):
127127

128128
expected_query_params = {"projection": "noAcl"}
129129
expected_headers = {} # no encryption headers by default
130-
client._get_path.assert_called_once_with(
130+
client._get_resource.assert_called_once_with(
131131
path,
132132
query_params=expected_query_params,
133133
headers=expected_headers,
@@ -142,8 +142,8 @@ def test_reload_w_generation_match_w_timeout(self):
142142
path = "/path"
143143
timeout = 42
144144
response = {"foo": "Foo"}
145-
client = mock.Mock(spec=["_get_path"])
146-
client._get_path.return_value = response
145+
client = mock.Mock(spec=["_get_resource"])
146+
client._get_resource.return_value = response
147147
derived = self._derivedClass(path)()
148148
# Make sure changes is not a set instance before calling reload
149149
# (which will clear / replace it with an empty set), checked below.
@@ -165,7 +165,7 @@ def test_reload_w_generation_match_w_timeout(self):
165165
"ifMetagenerationMatch": metageneration_number,
166166
}
167167
expected_headers = {} # no encryption headers by default
168-
client._get_path.assert_called_once_with(
168+
client._get_resource.assert_called_once_with(
169169
path,
170170
query_params=expected_query_params,
171171
headers=expected_headers,
@@ -179,8 +179,8 @@ def test_reload_w_user_project_w_retry(self):
179179
path = "/path"
180180
retry = mock.Mock(spec=[])
181181
response = {"foo": "Foo"}
182-
client = mock.Mock(spec=["_get_path"])
183-
client._get_path.return_value = response
182+
client = mock.Mock(spec=["_get_resource"])
183+
client._get_resource.return_value = response
184184
derived = self._derivedClass(path, user_project)()
185185
# Make sure changes is not a set instance before calling reload
186186
# (which will clear / replace it with an empty set), checked below.
@@ -197,7 +197,7 @@ def test_reload_w_user_project_w_retry(self):
197197
"userProject": user_project,
198198
}
199199
expected_headers = {} # no encryption headers by default
200-
client._get_path.assert_called_once_with(
200+
client._get_resource.assert_called_once_with(
201201
path,
202202
query_params=expected_query_params,
203203
headers=expected_headers,
@@ -210,8 +210,8 @@ def test_reload_w_projection_w_explicit_client_w_enc_header(self):
210210
path = "/path"
211211
response = {"foo": "Foo"}
212212
encryption_headers = {"bar": "Bar"}
213-
client = mock.Mock(spec=["_get_path"])
214-
client._get_path.return_value = response
213+
client = mock.Mock(spec=["_get_resource"])
214+
client._get_resource.return_value = response
215215
derived = self._derivedClass(path)()
216216
# Make sure changes is not a set instance before calling reload
217217
# (which will clear / replace it with an empty set), checked below.
@@ -224,7 +224,7 @@ def test_reload_w_projection_w_explicit_client_w_enc_header(self):
224224
self.assertEqual(derived._changes, set())
225225

226226
expected_query_params = {"projection": "full"}
227-
client._get_path.assert_called_once_with(
227+
client._get_resource.assert_called_once_with(
228228
path,
229229
query_params=expected_query_params,
230230
headers=encryption_headers,

tests/unit/test_acl.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,15 @@ class Derived(self._get_target_class()):
546546
acl.reload_path = reload_path
547547
acl.loaded = True
548548
acl.entity("allUsers", role)
549-
client = acl.client = mock.Mock(spec=["_get_path"])
550-
client._get_path.return_value = api_response
549+
client = acl.client = mock.Mock(spec=["_get_resource"])
550+
client._get_resource.return_value = api_response
551551

552552
acl.reload()
553553

554554
self.assertEqual(list(acl), [])
555555

556556
expected_query_params = {}
557-
client._get_path.assert_called_once_with(
557+
client._get_resource.assert_called_once_with(
558558
reload_path,
559559
query_params=expected_query_params,
560560
timeout=self._get_default_timeout(),
@@ -571,16 +571,16 @@ def test_reload_w_empty_result_w_timeout_w_retry_w_explicit_client(self):
571571
acl.reload_path = reload_path
572572
acl.loaded = True
573573
acl.entity("allUsers", role)
574-
client = mock.Mock(spec=["_get_path"])
575-
client._get_path.return_value = api_response
574+
client = mock.Mock(spec=["_get_resource"])
575+
client._get_resource.return_value = api_response
576576

577577
acl.reload(client=client, timeout=timeout, retry=retry)
578578

579579
self.assertTrue(acl.loaded)
580580
self.assertEqual(list(acl), [])
581581

582582
expected_query_params = {}
583-
client._get_path.assert_called_once_with(
583+
client._get_resource.assert_called_once_with(
584584
reload_path,
585585
query_params=expected_query_params,
586586
timeout=timeout,
@@ -596,16 +596,16 @@ def test_reload_w_nonempty_result_w_user_project(self):
596596
acl.reload_path = reload_path
597597
acl.loaded = True
598598
acl.user_project = user_project
599-
client = mock.Mock(spec=["_get_path"])
600-
client._get_path.return_value = api_response
599+
client = mock.Mock(spec=["_get_resource"])
600+
client._get_resource.return_value = api_response
601601

602602
acl.reload(client=client)
603603

604604
self.assertTrue(acl.loaded)
605605
self.assertEqual(list(acl), [{"entity": "allUsers", "role": role}])
606606

607607
expected_query_params = {"userProject": user_project}
608-
client._get_path.assert_called_once_with(
608+
client._get_resource.assert_called_once_with(
609609
reload_path,
610610
query_params=expected_query_params,
611611
timeout=self._get_default_timeout(),

0 commit comments

Comments
 (0)