22
33from __future__ import annotations
44
5+ from typing import Type , Optional , cast
6+
57import httpx
68
79from ...._types import NOT_GIVEN , Body , Query , Headers , NotGiven
10+ from ...._utils import maybe_transform , async_maybe_transform
811from ...._compat import cached_property
912from ...._resource import SyncAPIResource , AsyncAPIResource
1013from ...._response import (
1316 async_to_raw_response_wrapper ,
1417 async_to_streamed_response_wrapper ,
1518)
19+ from ...._wrappers import ResultWrapper
1620from ....pagination import SyncSinglePage , AsyncSinglePage
1721from ...._base_client import AsyncPaginator , make_request_options
22+ from ....types .accounts .tokens import permission_group_get_params , permission_group_list_params
1823from ....types .accounts .tokens .permission_group_get_response import PermissionGroupGetResponse
1924from ....types .accounts .tokens .permission_group_list_response import PermissionGroupListResponse
2025
@@ -45,6 +50,8 @@ def list(
4550 self ,
4651 * ,
4752 account_id : str ,
53+ name : str | NotGiven = NOT_GIVEN ,
54+ scope : str | NotGiven = NOT_GIVEN ,
4855 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
4956 # The extra values given here take precedence over values defined on the client or passed to this method.
5057 extra_headers : Headers | None = None ,
@@ -58,6 +65,10 @@ def list(
5865 Args:
5966 account_id: Account identifier tag.
6067
68+ name: Filter by the name of the permission group. The value must be URL-encoded.
69+
70+ scope: Filter by the scope of the permission group. The value must be URL-encoded.
71+
6172 extra_headers: Send extra headers
6273
6374 extra_query: Add additional query parameters to the request
@@ -72,7 +83,17 @@ def list(
7283 f"/accounts/{ account_id } /tokens/permission_groups" ,
7384 page = SyncSinglePage [PermissionGroupListResponse ],
7485 options = make_request_options (
75- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
86+ extra_headers = extra_headers ,
87+ extra_query = extra_query ,
88+ extra_body = extra_body ,
89+ timeout = timeout ,
90+ query = maybe_transform (
91+ {
92+ "name" : name ,
93+ "scope" : scope ,
94+ },
95+ permission_group_list_params .PermissionGroupListParams ,
96+ ),
7697 ),
7798 model = PermissionGroupListResponse ,
7899 )
@@ -81,19 +102,25 @@ def get(
81102 self ,
82103 * ,
83104 account_id : str ,
105+ name : str | NotGiven = NOT_GIVEN ,
106+ scope : str | NotGiven = NOT_GIVEN ,
84107 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
85108 # The extra values given here take precedence over values defined on the client or passed to this method.
86109 extra_headers : Headers | None = None ,
87110 extra_query : Query | None = None ,
88111 extra_body : Body | None = None ,
89112 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
90- ) -> SyncSinglePage [PermissionGroupGetResponse ]:
113+ ) -> Optional [PermissionGroupGetResponse ]:
91114 """
92115 Find all available permission groups for Account Owned API Tokens
93116
94117 Args:
95118 account_id: Account identifier tag.
96119
120+ name: Filter by the name of the permission group. The value must be URL-encoded.
121+
122+ scope: Filter by the scope of the permission group. The value must be URL-encoded.
123+
97124 extra_headers: Send extra headers
98125
99126 extra_query: Add additional query parameters to the request
@@ -104,13 +131,23 @@ def get(
104131 """
105132 if not account_id :
106133 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
107- return self ._get_api_list (
134+ return self ._get (
108135 f"/accounts/{ account_id } /tokens/permission_groups" ,
109- page = SyncSinglePage [PermissionGroupGetResponse ],
110136 options = make_request_options (
111- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
137+ extra_headers = extra_headers ,
138+ extra_query = extra_query ,
139+ extra_body = extra_body ,
140+ timeout = timeout ,
141+ query = maybe_transform (
142+ {
143+ "name" : name ,
144+ "scope" : scope ,
145+ },
146+ permission_group_get_params .PermissionGroupGetParams ,
147+ ),
148+ post_parser = ResultWrapper [Optional [PermissionGroupGetResponse ]]._unwrapper ,
112149 ),
113- model = PermissionGroupGetResponse ,
150+ cast_to = cast ( Type [ Optional [ PermissionGroupGetResponse ]], ResultWrapper [ PermissionGroupGetResponse ]) ,
114151 )
115152
116153
@@ -138,6 +175,8 @@ def list(
138175 self ,
139176 * ,
140177 account_id : str ,
178+ name : str | NotGiven = NOT_GIVEN ,
179+ scope : str | NotGiven = NOT_GIVEN ,
141180 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
142181 # The extra values given here take precedence over values defined on the client or passed to this method.
143182 extra_headers : Headers | None = None ,
@@ -151,6 +190,10 @@ def list(
151190 Args:
152191 account_id: Account identifier tag.
153192
193+ name: Filter by the name of the permission group. The value must be URL-encoded.
194+
195+ scope: Filter by the scope of the permission group. The value must be URL-encoded.
196+
154197 extra_headers: Send extra headers
155198
156199 extra_query: Add additional query parameters to the request
@@ -165,28 +208,44 @@ def list(
165208 f"/accounts/{ account_id } /tokens/permission_groups" ,
166209 page = AsyncSinglePage [PermissionGroupListResponse ],
167210 options = make_request_options (
168- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
211+ extra_headers = extra_headers ,
212+ extra_query = extra_query ,
213+ extra_body = extra_body ,
214+ timeout = timeout ,
215+ query = maybe_transform (
216+ {
217+ "name" : name ,
218+ "scope" : scope ,
219+ },
220+ permission_group_list_params .PermissionGroupListParams ,
221+ ),
169222 ),
170223 model = PermissionGroupListResponse ,
171224 )
172225
173- def get (
226+ async def get (
174227 self ,
175228 * ,
176229 account_id : str ,
230+ name : str | NotGiven = NOT_GIVEN ,
231+ scope : str | NotGiven = NOT_GIVEN ,
177232 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
178233 # The extra values given here take precedence over values defined on the client or passed to this method.
179234 extra_headers : Headers | None = None ,
180235 extra_query : Query | None = None ,
181236 extra_body : Body | None = None ,
182237 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
183- ) -> AsyncPaginator [PermissionGroupGetResponse , AsyncSinglePage [ PermissionGroupGetResponse ] ]:
238+ ) -> Optional [PermissionGroupGetResponse ]:
184239 """
185240 Find all available permission groups for Account Owned API Tokens
186241
187242 Args:
188243 account_id: Account identifier tag.
189244
245+ name: Filter by the name of the permission group. The value must be URL-encoded.
246+
247+ scope: Filter by the scope of the permission group. The value must be URL-encoded.
248+
190249 extra_headers: Send extra headers
191250
192251 extra_query: Add additional query parameters to the request
@@ -197,13 +256,23 @@ def get(
197256 """
198257 if not account_id :
199258 raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
200- return self ._get_api_list (
259+ return await self ._get (
201260 f"/accounts/{ account_id } /tokens/permission_groups" ,
202- page = AsyncSinglePage [PermissionGroupGetResponse ],
203261 options = make_request_options (
204- extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
262+ extra_headers = extra_headers ,
263+ extra_query = extra_query ,
264+ extra_body = extra_body ,
265+ timeout = timeout ,
266+ query = await async_maybe_transform (
267+ {
268+ "name" : name ,
269+ "scope" : scope ,
270+ },
271+ permission_group_get_params .PermissionGroupGetParams ,
272+ ),
273+ post_parser = ResultWrapper [Optional [PermissionGroupGetResponse ]]._unwrapper ,
205274 ),
206- model = PermissionGroupGetResponse ,
275+ cast_to = cast ( Type [ Optional [ PermissionGroupGetResponse ]], ResultWrapper [ PermissionGroupGetResponse ]) ,
207276 )
208277
209278
0 commit comments