FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: undeprecate entity factory helpers by tseaver · Pull Request #101 · googleapis/python-api-core · GitHub

This repository was archived by the owner on Feb 23, 2026. It is now read-only.
/ python-api-core Public archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
33 changes: 0 additions & 33 deletions google/api_core/iam.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@
_ASSIGNMENT_DEPRECATED_MSG = """\
Assigning to '{}' is deprecated. Use the `policy.bindings` property to modify bindings instead."""

_FACTORY_DEPRECATED_MSG = """\
Factory method {0} is deprecated. Replace with '{0}'."""

_DICT_ACCESS_MSG = """\
Dict access is not supported on policies with version > 1 or with conditional bindings."""

Expand Down Expand Up @@ -316,12 +313,7 @@ def user(email):

Returns:
str: A member string corresponding to the given user.

DEPRECATED: set the role `user:{email}` in the binding instead.
"""
warnings.warn(
_FACTORY_DEPRECATED_MSG.format("user:{email}"), DeprecationWarning,
)
return "user:%s" % (email,)

@staticmethod
Expand All @@ -334,12 +326,7 @@ def service_account(email):
Returns:
str: A member string corresponding to the given service account.

DEPRECATED: set the role `serviceAccount:{email}` in the binding instead.
"""
warnings.warn(
_FACTORY_DEPRECATED_MSG.format("serviceAccount:{email}"),
DeprecationWarning,
)
return "serviceAccount:%s" % (email,)

@staticmethod
Expand All @@ -351,12 +338,7 @@ def group(email):

Returns:
str: A member string corresponding to the given group.

DEPRECATED: set the role `group:{email}` in the binding instead.
"""
warnings.warn(
_FACTORY_DEPRECATED_MSG.format("group:{email}"), DeprecationWarning,
)
return "group:%s" % (email,)

@staticmethod
Expand All @@ -368,12 +350,7 @@ def domain(domain):

Returns:
str: A member string corresponding to the given domain.

DEPRECATED: set the role `domain:{email}` in the binding instead.
"""
warnings.warn(
_FACTORY_DEPRECATED_MSG.format("domain:{email}"), DeprecationWarning,
)
return "domain:%s" % (domain,)

@staticmethod
Expand All @@ -382,12 +359,7 @@ def all_users():

Returns:
str: A member string representing all users.

DEPRECATED: set the role `allUsers` in the binding instead.
"""
warnings.warn(
_FACTORY_DEPRECATED_MSG.format("allUsers"), DeprecationWarning,
)
return "allUsers"

@staticmethod
Expand All @@ -396,12 +368,7 @@ def authenticated_users():

Returns:
str: A member string representing all authenticated users.

DEPRECATED: set the role `allAuthenticatedUsers` in the binding instead.
"""
warnings.warn(
_FACTORY_DEPRECATED_MSG.format("allAuthenticatedUsers"), DeprecationWarning,
)
return "allAuthenticatedUsers"

@classmethod
Expand Down
48 changes: 6 additions & 42 deletions tests/unit/test_iam.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -219,72 +219,36 @@ def test_viewers_setter(self):
assert policy[VIEWER_ROLE] == expected

def test_user(self):
import warnings

EMAIL = "phred@example.com"
MEMBER = "user:%s" % (EMAIL,)
policy = self._make_one()
with warnings.catch_warnings(record=True) as warned:
assert policy.user(EMAIL) == MEMBER

(warning,) = warned
assert warning.category is DeprecationWarning
assert policy.user(EMAIL) == MEMBER

def test_service_account(self):
import warnings

EMAIL = "phred@example.com"
MEMBER = "serviceAccount:%s" % (EMAIL,)
policy = self._make_one()
with warnings.catch_warnings(record=True) as warned:
assert policy.service_account(EMAIL) == MEMBER

(warning,) = warned
assert warning.category is DeprecationWarning
assert policy.service_account(EMAIL) == MEMBER

def test_group(self):
import warnings

EMAIL = "phred@example.com"
MEMBER = "group:%s" % (EMAIL,)
policy = self._make_one()
with warnings.catch_warnings(record=True) as warned:
assert policy.group(EMAIL) == MEMBER

(warning,) = warned
assert warning.category is DeprecationWarning
assert policy.group(EMAIL) == MEMBER

def test_domain(self):
import warnings

DOMAIN = "example.com"
MEMBER = "domain:%s" % (DOMAIN,)
policy = self._make_one()
with warnings.catch_warnings(record=True) as warned:
assert policy.domain(DOMAIN) == MEMBER

(warning,) = warned
assert warning.category is DeprecationWarning
assert policy.domain(DOMAIN) == MEMBER

def test_all_users(self):
import warnings

policy = self._make_one()
with warnings.catch_warnings(record=True) as warned:
assert policy.all_users() == "allUsers"

(warning,) = warned
assert warning.category is DeprecationWarning
assert policy.all_users() == "allUsers"

def test_authenticated_users(self):
import warnings

policy = self._make_one()
with warnings.catch_warnings(record=True) as warned:
assert policy.authenticated_users() == "allAuthenticatedUsers"

(warning,) = warned
assert warning.category is DeprecationWarning
assert policy.authenticated_users() == "allAuthenticatedUsers"

def test_from_api_repr_only_etag(self):
empty = frozenset()
Expand Down

Back | FazBrowse Home | New Git URL