Debian Codegraph @

src/auth0/management/users/organizations/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.list_user_organizations_offset_paginated_response_content import (
9 ListUserOrganizationsOffsetPaginatedResponseContent,
10 )
11 from ...types.organization import Organization
12 from .raw_client import AsyncRawOrganizationsClient, RawOrganizationsClient
13
14
15 class OrganizationsClient:
16 def __init__(self, *, client_wrapper: SyncClientWrapper):
17 self._raw_client = RawOrganizationsClient(client_wrapper=client_wrapper)
18
19 @property
20 def with_raw_response(self) -> RawOrganizationsClient:
21 """
22 Retrieves a raw implementation of this client that returns raw responses.
23
24 Returns
25 -------
26 RawOrganizationsClient
27 """
28 return self._raw_client
29
30 def list(
31 self,
32 id: str,
33 *,
34 page: typing.Optional[int] = 0,
35 per_page: typing.Optional[int] = 50,
36 include_totals: typing.Optional[bool] = True,
37 request_options: typing.Optional[RequestOptions] = None,
38 ) -> SyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent]:
39 """
40 Retrieve list of the specified user's current Organization memberships. User must be specified by user ID. For more information, review [Auth0 Organizations](https://auth0.com/docs/manage-users/organizations).
41
42 Parameters
43 ----------
44 id : str
45 ID of the user to retrieve the organizations for.
46
47 page : typing.Optional[int]
48 Page index of the results to return. First page is 0.
49
50 per_page : typing.Optional[int]
51 Number of results per page. Defaults to 50.
52
53 include_totals : typing.Optional[bool]
54 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
55
56 request_options : typing.Optional[RequestOptions]
57 Request-specific configuration.
58
59 Returns
60 -------
61 SyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent]
62 Organizations successfully retrieved.
63
64 Examples
65 --------
66 from auth0 import Auth0
67
68 client = Auth0(
69 token="YOUR_TOKEN",
70 )
71 response = client.users.organizations.list(
72 id="id",
73 page=1,
74 per_page=1,
75 include_totals=True,
76 )
77 for item in response:
78 yield item
79 # alternatively, you can paginate page-by-page
80 for page in response.iter_pages():
81 yield page
82 """
83 return self._raw_client.list(
84 id, page=page, per_page=per_page, include_totals=include_totals, request_options=request_options
85 )
86
87
88 class AsyncOrganizationsClient:
89 def __init__(self, *, client_wrapper: AsyncClientWrapper):
90 self._raw_client = AsyncRawOrganizationsClient(client_wrapper=client_wrapper)
91
92 @property
93 def with_raw_response(self) -> AsyncRawOrganizationsClient:
94 """
95 Retrieves a raw implementation of this client that returns raw responses.
96
97 Returns
98 -------
99 AsyncRawOrganizationsClient
100 """
101 return self._raw_client
102
103 async def list(
104 self,
105 id: str,
106 *,
107 page: typing.Optional[int] = 0,
108 per_page: typing.Optional[int] = 50,
109 include_totals: typing.Optional[bool] = True,
110 request_options: typing.Optional[RequestOptions] = None,
111 ) -> AsyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent]:
112 """
113 Retrieve list of the specified user's current Organization memberships. User must be specified by user ID. For more information, review [Auth0 Organizations](https://auth0.com/docs/manage-users/organizations).
114
115 Parameters
116 ----------
117 id : str
118 ID of the user to retrieve the organizations for.
119
120 page : typing.Optional[int]
121 Page index of the results to return. First page is 0.
122
123 per_page : typing.Optional[int]
124 Number of results per page. Defaults to 50.
125
126 include_totals : typing.Optional[bool]
127 Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
128
129 request_options : typing.Optional[RequestOptions]
130 Request-specific configuration.
131
132 Returns
133 -------
134 AsyncPager[Organization, ListUserOrganizationsOffsetPaginatedResponseContent]
135 Organizations successfully retrieved.
136
137 Examples
138 --------
139 import asyncio
140
141 from auth0 import AsyncAuth0
142
143 client = AsyncAuth0(
144 token="YOUR_TOKEN",
145 )
146
147
148 async def main() -> None:
149 response = await client.users.organizations.list(
150 id="id",
151 page=1,
152 per_page=1,
153 include_totals=True,
154 )
155 async for item in response:
156 yield item
157
158 # alternatively, you can paginate page-by-page
159 async for page in response.iter_pages():
160 yield page
161
162
163 asyncio.run(main())
164 """
165 return await self._raw_client.list(
166 id, page=page, per_page=per_page, include_totals=include_totals, request_options=request_options
167 )