Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 823e58f

Browse files
authored
[SDK-4656] Add fields to all_organization_members (auth0#537)
### Changes Add `fields` and `include_fields` option to `all_organization_members` ### References fixes auth0#534 https://auth0.com/docs/api/management/v2/organizations/get-members
2 parents 32a8cc8 + be23eb0 commit 823e58f

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

auth0/management/organizations.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,14 @@ def all_organization_members(
246246
include_totals: bool = True,
247247
from_param: str | None = None,
248248
take: int | None = None,
249+
fields: list[str] | None = None,
250+
include_fields: bool = True,
249251
):
250252
"""Retrieves a list of all the organization members.
251253
254+
Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member.
255+
To use this parameter, you must include the `read:organization_member_roles scope` in the token.
256+
252257
Args:
253258
id (str): the ID of the organization.
254259
@@ -267,7 +272,14 @@ def all_organization_members(
267272
take (int, optional): The total amount of entries to retrieve when
268273
using the from parameter. When not set, the default value is up to the server.
269274
270-
See: https://auth0.com/docs/api/management/v2#!/Organizations/get_members
275+
fields (list of str, optional): A list of fields to include or
276+
exclude from the result (depending on include_fields). If fields is left blank,
277+
all fields (except roles) are returned.
278+
279+
include_fields (bool, optional): True if the fields specified are
280+
to be included in the result, False otherwise. Defaults to True.
281+
282+
See: https://auth0.com/docs/api/management/v2/organizations/get-members
271283
"""
272284

273285
params = {
@@ -276,6 +288,8 @@ def all_organization_members(
276288
"include_totals": str(include_totals).lower(),
277289
"from": from_param,
278290
"take": take,
291+
"fields": fields and ",".join(fields) or None,
292+
"include_fields": str(include_fields).lower(),
279293
}
280294

281295
return self.client.get(self._url(id, "members"), params=params)

auth0/test/management/test_organizations.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ def test_all_organization_members(self, mock_rc):
232232
"include_totals": "true",
233233
"from": None,
234234
"take": None,
235+
"fields": None,
236+
"include_fields": "true",
235237
},
236238
)
237239

@@ -253,6 +255,8 @@ def test_all_organization_members(self, mock_rc):
253255
"include_totals": "false",
254256
"from": None,
255257
"take": None,
258+
"fields": None,
259+
"include_fields": "true",
256260
},
257261
)
258262

@@ -272,6 +276,29 @@ def test_all_organization_members(self, mock_rc):
272276
"page": None,
273277
"per_page": None,
274278
"include_totals": "true",
279+
"fields": None,
280+
"include_fields": "true",
281+
},
282+
)
283+
284+
# With fields
285+
c.all_organization_members("test-org", fields=["a,b"], include_fields=False)
286+
287+
args, kwargs = mock_instance.get.call_args
288+
289+
self.assertEqual(
290+
"https://domain/api/v2/organizations/test-org/members", args[0]
291+
)
292+
self.assertEqual(
293+
kwargs["params"],
294+
{
295+
"page": None,
296+
"per_page": None,
297+
"include_totals": "true",
298+
"from": None,
299+
"take": None,
300+
"fields": "a,b",
301+
"include_fields": "false",
275302
},
276303
)
277304

0 commit comments

Comments
 (0)