Skip to content

Commit

Permalink
added support for "include_totals" to Organizations.all_organization_…
Browse files Browse the repository at this point in the history
…member_roles
  • Loading branch information
jpayton-cx committed Dec 17, 2024
1 parent 49b8be4 commit 62557b9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
11 changes: 10 additions & 1 deletion auth0/management/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ def all_organization_member_roles(
user_id: str,
page: int | None = None,
per_page: int | None = None,
include_totals: bool = False,
) -> list[dict[str, Any]]:
"""Retrieves a list of all the roles from the given organization member.
Expand All @@ -343,9 +344,17 @@ def all_organization_member_roles(
per_page (int, optional): The amount of entries per page. When not set,
the default value is up to the server.
include_totals (bool, optional): True if the query summary is
to be included in the result, False otherwise. Defaults to False.
See: https://auth0.com/docs/api/management/v2#!/Organizations/get_organization_member_roles
"""
params = {"page": page, "per_page": per_page}
params = {
"page": page,
"per_page": per_page,
"include_totals": str(include_totals).lower()
}

return self.client.get(
self._url(id, "members", user_id, "roles"), params=params
)
Expand Down
22 changes: 19 additions & 3 deletions auth0/test/management/test_organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,34 @@ def test_all_organization_member_roles(self, mock_rc):
"https://domain/api/v2/organizations/test-org/members/test-user/roles",
args[0],
)
self.assertEqual(kwargs["params"], {"page": None, "per_page": None})
self.assertEqual(
kwargs["params"],
{
"page": None,
"per_page": None,
"include_totals": "false",
},
)

# Specific pagination
c.all_organization_member_roles("test-org", "test-user", page=7, per_page=25)
c.all_organization_member_roles(
"test-org", "test-user", page=7, per_page=25, include_totals=True
)

args, kwargs = mock_instance.get.call_args

self.assertEqual(
"https://domain/api/v2/organizations/test-org/members/test-user/roles",
args[0],
)
self.assertEqual(kwargs["params"], {"page": 7, "per_page": 25})
self.assertEqual(
kwargs["params"],
{
"page": 7,
"per_page": 25,
"include_totals": "true",
},
)

@mock.patch("auth0.management.organizations.RestClient")
def test_create_organization_member_roles(self, mock_rc):
Expand Down

0 comments on commit 62557b9

Please sign in to comment.