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

Commit c35f2c5

Browse files
committed
fix: undprecate entity factory helpers
Closes #100
1 parent 85e14e3 commit c35f2c5

2 files changed

Lines changed: 6 additions & 75 deletions

File tree

‎google/api_core/iam.py‎

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
_ASSIGNMENT_DEPRECATED_MSG = """\
7575
Assigning to '{}' is deprecated. Use the `policy.bindings` property to modify bindings instead."""
7676

77-
_FACTORY_DEPRECATED_MSG = """\
78-
Factory method {0} is deprecated. Replace with '{0}'."""
79-
8077
_DICT_ACCESS_MSG = """\
8178
Dict access is not supported on policies with version > 1 or with conditional bindings."""
8279

@@ -316,12 +313,7 @@ def user(email):
316313
317314
Returns:
318315
str: A member string corresponding to the given user.
319-
320-
DEPRECATED: set the role `user:{email}` in the binding instead.
321316
"""
322-
warnings.warn(
323-
_FACTORY_DEPRECATED_MSG.format("user:{email}"), DeprecationWarning,
324-
)
325317
return "user:%s" % (email,)
326318

327319
@staticmethod
@@ -334,12 +326,7 @@ def service_account(email):
334326
Returns:
335327
str: A member string corresponding to the given service account.
336328
337-
DEPRECATED: set the role `serviceAccount:{email}` in the binding instead.
338329
"""
339-
warnings.warn(
340-
_FACTORY_DEPRECATED_MSG.format("serviceAccount:{email}"),
341-
DeprecationWarning,
342-
)
343330
return "serviceAccount:%s" % (email,)
344331

345332
@staticmethod
@@ -351,12 +338,7 @@ def group(email):
351338
352339
Returns:
353340
str: A member string corresponding to the given group.
354-
355-
DEPRECATED: set the role `group:{email}` in the binding instead.
356341
"""
357-
warnings.warn(
358-
_FACTORY_DEPRECATED_MSG.format("group:{email}"), DeprecationWarning,
359-
)
360342
return "group:%s" % (email,)
361343

362344
@staticmethod
@@ -368,12 +350,7 @@ def domain(domain):
368350
369351
Returns:
370352
str: A member string corresponding to the given domain.
371-
372-
DEPRECATED: set the role `domain:{email}` in the binding instead.
373353
"""
374-
warnings.warn(
375-
_FACTORY_DEPRECATED_MSG.format("domain:{email}"), DeprecationWarning,
376-
)
377354
return "domain:%s" % (domain,)
378355

379356
@staticmethod
@@ -382,12 +359,7 @@ def all_users():
382359
383360
Returns:
384361
str: A member string representing all users.
385-
386-
DEPRECATED: set the role `allUsers` in the binding instead.
387362
"""
388-
warnings.warn(
389-
_FACTORY_DEPRECATED_MSG.format("allUsers"), DeprecationWarning,
390-
)
391363
return "allUsers"
392364

393365
@staticmethod
@@ -396,12 +368,7 @@ def authenticated_users():
396368
397369
Returns:
398370
str: A member string representing all authenticated users.
399-
400-
DEPRECATED: set the role `allAuthenticatedUsers` in the binding instead.
401371
"""
402-
warnings.warn(
403-
_FACTORY_DEPRECATED_MSG.format("allAuthenticatedUsers"), DeprecationWarning,
404-
)
405372
return "allAuthenticatedUsers"
406373

407374
@classmethod

‎tests/unit/test_iam.py‎

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -219,72 +219,36 @@ def test_viewers_setter(self):
219219
assert policy[VIEWER_ROLE] == expected
220220

221221
def test_user(self):
222-
import warnings
223-
224222
EMAIL = "phred@example.com"
225223
MEMBER = "user:%s" % (EMAIL,)
226224
policy = self._make_one()
227-
with warnings.catch_warnings(record=True) as warned:
228-
assert policy.user(EMAIL) == MEMBER
229-
230-
(warning,) = warned
231-
assert warning.category is DeprecationWarning
225+
assert policy.user(EMAIL) == MEMBER
232226

233227
def test_service_account(self):
234-
import warnings
235-
236228
EMAIL = "phred@example.com"
237229
MEMBER = "serviceAccount:%s" % (EMAIL,)
238230
policy = self._make_one()
239-
with warnings.catch_warnings(record=True) as warned:
240-
assert policy.service_account(EMAIL) == MEMBER
241-
242-
(warning,) = warned
243-
assert warning.category is DeprecationWarning
231+
assert policy.service_account(EMAIL) == MEMBER
244232

245233
def test_group(self):
246-
import warnings
247-
248234
EMAIL = "phred@example.com"
249235
MEMBER = "group:%s" % (EMAIL,)
250236
policy = self._make_one()
251-
with warnings.catch_warnings(record=True) as warned:
252-
assert policy.group(EMAIL) == MEMBER
253-
254-
(warning,) = warned
255-
assert warning.category is DeprecationWarning
237+
assert policy.group(EMAIL) == MEMBER
256238

257239
def test_domain(self):
258-
import warnings
259-
260240
DOMAIN = "example.com"
261241
MEMBER = "domain:%s" % (DOMAIN,)
262242
policy = self._make_one()
263-
with warnings.catch_warnings(record=True) as warned:
264-
assert policy.domain(DOMAIN) == MEMBER
265-
266-
(warning,) = warned
267-
assert warning.category is DeprecationWarning
243+
assert policy.domain(DOMAIN) == MEMBER
268244

269245
def test_all_users(self):
270-
import warnings
271-
272246
policy = self._make_one()
273-
with warnings.catch_warnings(record=True) as warned:
274-
assert policy.all_users() == "allUsers"
275-
276-
(warning,) = warned
277-
assert warning.category is DeprecationWarning
247+
assert policy.all_users() == "allUsers"
278248

279249
def test_authenticated_users(self):
280-
import warnings
281-
282250
policy = self._make_one()
283-
with warnings.catch_warnings(record=True) as warned:
284-
assert policy.authenticated_users() == "allAuthenticatedUsers"
285-
286-
(warning,) = warned
287-
assert warning.category is DeprecationWarning
251+
assert policy.authenticated_users() == "allAuthenticatedUsers"
288252

289253
def test_from_api_repr_only_etag(self):
290254
empty = frozenset()

0 commit comments

Comments
 (0)