Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for "include_totals" to all_organization_member_roles #635

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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