Debian Codegraph @

src/auth0/management/users/groups/client.py

raw symbols SCIP
1 # This file was auto-generated by Fern from our API Definition.
2
3 import typing
4
5 from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6 from ...core.pagination import AsyncPager, SyncPager
7 from ...core.request_options import RequestOptions
8 from ...types.get_user_groups_paginated_response_content import GetUserGroupsPaginatedResponseContent
9 from ...types.user_groups_response_schema import UserGroupsResponseSchema
10 from .raw_client import AsyncRawGroupsClient, RawGroupsClient
11
12
13 class GroupsClient:
14 def __init__(self, *, client_wrapper: SyncClientWrapper):
15 self._raw_client = RawGroupsClient(client_wrapper=client_wrapper)
16
17 @property
18 def with_raw_response(self) -> RawGroupsClient:
19 """
20 Retrieves a raw implementation of this client that returns raw responses.
21
22 Returns
23 -------
24 RawGroupsClient
25 """
26 return self._raw_client
27
28 def get(
29 self,
30 id: str,
31 *,
32 fields: typing.Optional[str] = None,
33 include_fields: typing.Optional[bool] = None,
34 from_: typing.Optional[str] = None,
35 take: typing.Optional[int] = 50,
36 request_options: typing.Optional[RequestOptions] = None,
37 ) -> SyncPager[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent]:
38 """
39 List all groups to which this user belongs.
40
41 Parameters
42 ----------
43 id : str
44 ID of the user to list groups for.
45
46 fields : typing.Optional[str]
47 A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields
48
49 include_fields : typing.Optional[bool]
50 Whether specified fields are to be included (true) or excluded (false).
51
52 from_ : typing.Optional[str]
53 Optional Id from which to start selection.
54
55 take : typing.Optional[int]
56 Number of results per page. Defaults to 50.
57
58 request_options : typing.Optional[RequestOptions]
59 Request-specific configuration.
60
61 Returns
62 -------
63 SyncPager[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent]
64 Groups successfully retrieved.
65
66 Examples
67 --------
68 from auth0 import Auth0
69
70 client = Auth0(
71 token="YOUR_TOKEN",
72 )
73 response = client.users.groups.get(
74 id="id",
75 fields="fields",
76 include_fields=True,
77 from_="from",
78 take=1,
79 )
80 for item in response:
81 yield item
82 # alternatively, you can paginate page-by-page
83 for page in response.iter_pages():
84 yield page
85 """
86 return self._raw_client.get(
87 id, fields=fields, include_fields=include_fields, from_=from_, take=take, request_options=request_options
88 )
89
90
91 class AsyncGroupsClient:
92 def __init__(self, *, client_wrapper: AsyncClientWrapper):
93 self._raw_client = AsyncRawGroupsClient(client_wrapper=client_wrapper)
94
95 @property
96 def with_raw_response(self) -> AsyncRawGroupsClient:
97 """
98 Retrieves a raw implementation of this client that returns raw responses.
99
100 Returns
101 -------
102 AsyncRawGroupsClient
103 """
104 return self._raw_client
105
106 async def get(
107 self,
108 id: str,
109 *,
110 fields: typing.Optional[str] = None,
111 include_fields: typing.Optional[bool] = None,
112 from_: typing.Optional[str] = None,
113 take: typing.Optional[int] = 50,
114 request_options: typing.Optional[RequestOptions] = None,
115 ) -> AsyncPager[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent]:
116 """
117 List all groups to which this user belongs.
118
119 Parameters
120 ----------
121 id : str
122 ID of the user to list groups for.
123
124 fields : typing.Optional[str]
125 A comma separated list of fields to include or exclude (depending on include_fields) from the result, empty to retrieve all fields
126
127 include_fields : typing.Optional[bool]
128 Whether specified fields are to be included (true) or excluded (false).
129
130 from_ : typing.Optional[str]
131 Optional Id from which to start selection.
132
133 take : typing.Optional[int]
134 Number of results per page. Defaults to 50.
135
136 request_options : typing.Optional[RequestOptions]
137 Request-specific configuration.
138
139 Returns
140 -------
141 AsyncPager[UserGroupsResponseSchema, GetUserGroupsPaginatedResponseContent]
142 Groups successfully retrieved.
143
144 Examples
145 --------
146 import asyncio
147
148 from auth0 import AsyncAuth0
149
150 client = AsyncAuth0(
151 token="YOUR_TOKEN",
152 )
153
154
155 async def main() -> None:
156 response = await client.users.groups.get(
157 id="id",
158 fields="fields",
159 include_fields=True,
160 from_="from",
161 take=1,
162 )
163 async for item in response:
164 yield item
165
166 # alternatively, you can paginate page-by-page
167 async for page in response.iter_pages():
168 yield page
169
170
171 asyncio.run(main())
172 """
173 return await self._raw_client.get(
174 id, fields=fields, include_fields=include_fields, from_=from_, take=take, request_options=request_options
175 )