11from __future__ import annotations
22
3- from typing import Dict , List , Optional
3+ from typing import List
44
5+ from conductor .asyncio_client .adapters import ApiClient
56from conductor .asyncio_client .adapters .models .authorization_request_adapter import (
67 AuthorizationRequestAdapter as AuthorizationRequest ,
78)
1112from conductor .asyncio_client .adapters .models .extended_conductor_application_adapter import (
1213 ExtendedConductorApplicationAdapter as ExtendedConductorApplication ,
1314)
14- from conductor .asyncio_client .adapters .models .tag_adapter import TagAdapter as Tag
15+ from conductor .asyncio_client .adapters .models .granted_access_adapter import (
16+ GrantedAccessAdapter as GrantedAccess ,
17+ )
1518from conductor .asyncio_client .adapters .models .group_adapter import GroupAdapter as Group
19+ from conductor .asyncio_client .adapters .models .tag_adapter import TagAdapter as Tag
20+ from conductor .asyncio_client .adapters .models .target_ref_adapter import (
21+ TargetRefAdapter as TargetRef ,
22+ )
1623from conductor .asyncio_client .adapters .models .upsert_group_request_adapter import (
1724 UpsertGroupRequestAdapter as UpsertGroupRequest ,
1825)
1926from conductor .asyncio_client .adapters .models .upsert_user_request_adapter import (
2027 UpsertUserRequestAdapter as UpsertUserRequest ,
2128)
22- from conductor .asyncio_client .adapters import ApiClient
2329from conductor .asyncio_client .configuration .configuration import Configuration
2430from conductor .asyncio_client .orkes .orkes_base_client import OrkesBaseClient
25- from conductor .asyncio_client .adapters .models .create_or_update_application_request_adapter import (
26- CreateOrUpdateApplicationRequestAdapter ,
27- )
2831from conductor .client .orkes .models .access_key import AccessKey
29- from conductor .client .orkes .models .access_type import AccessType
30- from conductor .asyncio_client .adapters .models .subject_ref_adapter import (
31- SubjectRefAdapter as SubjectRef ,
32- )
33- from conductor .asyncio_client .adapters .models .target_ref_adapter import (
34- TargetRefAdapter as TargetRef ,
35- )
36- from conductor .asyncio_client .adapters .models .granted_access_adapter import (
37- GrantedAccessAdapter as GrantedAccess ,
38- )
3932
4033
4134class OrkesAuthorizationClient (OrkesBaseClient ):
@@ -47,17 +40,13 @@ async def create_user(
4740 self , user_id : str , upsert_user_request : UpsertUserRequest
4841 ) -> ConductorUser :
4942 """Create a new user"""
50- return await self .user_api .upsert_user (
51- id = user_id , upsert_user_request = upsert_user_request
52- )
43+ return await self .user_api .upsert_user (id = user_id , upsert_user_request = upsert_user_request )
5344
5445 async def update_user (
5546 self , user_id : str , upsert_user_request : UpsertUserRequest
5647 ) -> ConductorUser :
5748 """Update an existing user"""
58- return await self .user_api .upsert_user (
59- id = user_id , upsert_user_request = upsert_user_request
60- )
49+ return await self .user_api .upsert_user (id = user_id , upsert_user_request = upsert_user_request )
6150
6251 async def get_user (self , user_id : str ) -> ConductorUser :
6352 """Get user by ID"""
@@ -93,9 +82,7 @@ async def update_application(
9382 )
9483 return ExtendedConductorApplication .from_dict (app )
9584
96- async def get_application (
97- self , application_id : str
98- ) -> ExtendedConductorApplication :
85+ async def get_application (self , application_id : str ) -> ExtendedConductorApplication :
9986 """Get application by ID"""
10087 app = await self .application_api .get_application (id = application_id )
10188 return ExtendedConductorApplication .from_dict (app )
@@ -109,17 +96,13 @@ async def list_applications(self) -> List[ExtendedConductorApplication]:
10996 return await self .application_api .list_applications ()
11097
11198 # Group Operations
112- async def create_group (
113- self , group_id : str , upsert_group_request : UpsertGroupRequest
114- ) -> Group :
99+ async def create_group (self , group_id : str , upsert_group_request : UpsertGroupRequest ) -> Group :
115100 """Create a new group"""
116101 return await self .group_api .upsert_group (
117102 id = group_id , upsert_group_request = upsert_group_request
118103 )
119104
120- async def update_group (
121- self , group_id : str , upsert_group_request : UpsertGroupRequest
122- ) -> Group :
105+ async def update_group (self , group_id : str , upsert_group_request : UpsertGroupRequest ) -> Group :
123106 """Update an existing group"""
124107 group = await self .group_api .upsert_group (
125108 id = group_id , upsert_group_request = upsert_group_request
@@ -142,25 +125,17 @@ async def list_groups(self) -> List[Group]:
142125 # Group User Management Operations
143126 async def add_user_to_group (self , group_id : str , user_id : str ) -> object :
144127 """Add a user to a group"""
145- return await self .group_api .add_user_to_group (
146- group_id = group_id , user_id = user_id
147- )
128+ return await self .group_api .add_user_to_group (group_id = group_id , user_id = user_id )
148129
149130 async def remove_user_from_group (self , group_id : str , user_id : str ) -> object :
150131 """Remove a user from a group"""
151- return await self .group_api .remove_user_from_group (
152- group_id = group_id , user_id = user_id
153- )
132+ return await self .group_api .remove_user_from_group (group_id = group_id , user_id = user_id )
154133
155134 async def add_users_to_group (self , group_id : str , user_ids : List [str ]) -> object :
156135 """Add multiple users to a group"""
157- return await self .group_api .add_users_to_group (
158- group_id = group_id , request_body = user_ids
159- )
136+ return await self .group_api .add_users_to_group (group_id = group_id , request_body = user_ids )
160137
161- async def remove_users_from_group (
162- self , group_id : str , user_ids : List [str ]
163- ) -> object :
138+ async def remove_users_from_group (self , group_id : str , user_ids : List [str ]) -> object :
164139 """Remove multiple users from a group"""
165140 return await self .group_api .remove_users_from_group (
166141 group_id = group_id , request_body = user_ids
@@ -171,27 +146,21 @@ async def get_users_in_group(self, group_id: str) -> object:
171146 return await self .group_api .get_users_in_group (id = group_id )
172147
173148 # Permission Operations (Only available operations)
174- async def grant_permissions (
175- self , authorization_request : AuthorizationRequest
176- ) -> object :
149+ async def grant_permissions (self , authorization_request : AuthorizationRequest ) -> object :
177150 """Grant permissions to users or groups"""
178151 return await self .authorization_api .grant_permissions (
179152 authorization_request = authorization_request
180153 )
181154
182- async def remove_permissions (
183- self , authorization_request : AuthorizationRequest
184- ) -> object :
155+ async def remove_permissions (self , authorization_request : AuthorizationRequest ) -> object :
185156 """Remove permissions from users or groups"""
186157 return await self .authorization_api .remove_permissions (
187158 authorization_request = authorization_request
188159 )
189160
190161 async def get_permissions (self , entity_type : str , entity_id : str ) -> object :
191162 """Get permissions for a specific entity (user, group, or application)"""
192- return await self .authorization_api .get_permissions (
193- type = entity_type , id = entity_id
194- )
163+ return await self .authorization_api .get_permissions (type = entity_type , id = entity_id )
195164
196165 async def get_group_permissions (self , group_id : str ) -> object :
197166 """Get permissions granted to a group"""
@@ -205,9 +174,7 @@ async def upsert_user(
205174 user = await self .create_user (user_id , upsert_user_request )
206175 return ConductorUser .from_dict (user )
207176
208- async def upsert_group (
209- self , group_id : str , upsert_group_request : UpsertGroupRequest
210- ) -> Group :
177+ async def upsert_group (self , group_id : str , upsert_group_request : UpsertGroupRequest ) -> Group :
211178 """Alias for create_group/update_group"""
212179 group = await self .create_group (group_id , upsert_group_request )
213180 return Group .from_dict (group )
@@ -219,7 +186,7 @@ async def get_application_tags(self, application_id: str) -> List[Tag]:
219186 return await self .application_api .get_tags_for_application (application_id )
220187
221188 async def delete_application_tags (self , tags : List [Tag ], application_id : str ):
222- await self .application_api .delete_tag_for_application (tags , application_id )
189+ await self .application_api .delete_tag_for_application (application_id , tags )
223190
224191 async def create_access_key (self , application_id : str ) -> AccessKey :
225192 key_obj = await self .application_api .create_access_key (application_id )
@@ -233,12 +200,8 @@ async def get_access_keys(self, application_id: str) -> List[AccessKey]:
233200
234201 return access_keys
235202
236- async def toggle_access_key_status (
237- self , application_id : str , key_id : str
238- ) -> AccessKey :
239- key_obj = await self .application_api .toggle_access_key_status (
240- application_id , key_id
241- )
203+ async def toggle_access_key_status (self , application_id : str , key_id : str ) -> AccessKey :
204+ key_obj = await self .application_api .toggle_access_key_status (application_id , key_id )
242205 return key_obj
243206
244207 async def delete_access_key (self , application_id : str , key_id : str ):
@@ -248,13 +211,9 @@ async def add_role_to_application_user(self, application_id: str, role: str):
248211 await self .application_api .add_role_to_application_user (application_id , role )
249212
250213 async def remove_role_from_application_user (self , application_id : str , role : str ):
251- await self .application_api .remove_role_from_application_user (
252- application_id , role
253- )
214+ await self .application_api .remove_role_from_application_user (application_id , role )
254215
255- async def get_granted_permissions_for_group (
256- self , group_id : str
257- ) -> List [GrantedAccess ]:
216+ async def get_granted_permissions_for_group (self , group_id : str ) -> List [GrantedAccess ]:
258217 granted_access_obj = await self .group_api .get_granted_permissions1 (group_id )
259218 granted_permissions = []
260219 for ga in granted_access_obj .granted_access :
@@ -263,13 +222,19 @@ async def get_granted_permissions_for_group(
263222 granted_permissions .append (GrantedAccess (target = target , access = access ))
264223 return granted_permissions
265224
266- async def get_granted_permissions_for_user (
267- self , user_id : str
268- ) -> List [GrantedAccess ]:
225+ async def get_granted_permissions_for_user (self , user_id : str ) -> List [GrantedAccess ]:
269226 granted_access_obj = await self .user_api .get_granted_permissions (user_id )
270227 granted_permissions = []
271228 for ga in granted_access_obj ["grantedAccess" ]:
272229 target = TargetRef (type = ga ["target" ]["type" ], id = ga ["target" ]["id" ])
273230 access = ga ["access" ]
274231 granted_permissions .append (GrantedAccess (target = target , access = access ))
275232 return granted_permissions
233+
234+ async def get_app_by_access_key_id (
235+ self , access_key_id : str , * args , ** kwargs
236+ ) -> ExtendedConductorApplication :
237+ application_access_key_obj = await self .application_api .get_app_by_access_key_id (
238+ access_key_id = access_key_id , * args , ** kwargs
239+ )
240+ return ExtendedConductorApplication .from_dict (application_access_key_obj )
0 commit comments