22# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
33# SPDX-License-Identifier: MIT
44
5- from .v1_response import Project , ProjectsResponse , Message , ProjectOptionsV1 , KeysResponse , Key , KeyOptionsV1 , CreateKeyResponse , MembersResponse , ScopesResponse , ScopeOptionsV1 , InvitesResponse , InviteOptionsV1 , UsageRequestsResponse , UsageRequestOptionsV1 , UsageRequest , UsageSummaryOptionsV1 , UsageSummaryResponse , UsageFieldsResponse , UsageFieldsOptionsV1 , BalancesResponse , Balance
5+ from .v1_response import Project , ProjectsResponse , Message , ProjectOptionsV1 , KeysResponse , KeyResponse , KeyOptionsV1 , Key , MembersResponse , ScopesResponse , ScopeOptionsV1 , InvitesResponse , InviteOptionsV1 , UsageRequestsResponse , UsageRequestOptionsV1 , UsageRequest , UsageSummaryOptionsV1 , UsageSummaryResponse , UsageFieldsResponse , UsageFieldsOptionsV1 , BalancesResponse , Balance
66
77from ..abstract_client import AbstractRestfulClient
88
@@ -29,99 +29,127 @@ class ManageClientV1(AbstractRestfulClient):
2929 Raises:
3030 DeepgramApiError: Raised for known API errors.
3131 DeepgramUnknownApiError: Raised for unknown API errors.
32- DeepgramUnknownError: Raised for unexpected errors not specific to the API.
3332 Exception: For any other unexpected exceptions.
3433 """
3534 def __init__ (self , url , headers ):
3635 self .url = url
3736 self .headers = headers
3837 self .endpoint = "v1/projects"
3938 super ().__init__ (url , headers )
40-
41- async def get_projects (self ) -> ProjectsResponse :
39+
40+ # projects
41+ async def list_projects (self ):
42+ return self .get_projects ()
43+ async def get_projects (self ):
4244 url = f"{ self .url } /{ self .endpoint } "
43- return await self .get (url )
45+ return ProjectsResponse . from_json ( await self .get (url ) )
4446
45- async def get_project (self , project_id : str ) -> Project :
47+ async def get_project (self , project_id : str ):
4648 url = f"{ self .url } /{ self .endpoint } /{ project_id } "
47- return await self .get (url )
49+ return Project . from_json ( await self .get (url ) )
4850
49- async def update_project (self , project_id : str , options : ProjectOptionsV1 ) -> Message :
51+ async def update_project_option (self , project_id : str , options : ProjectOptionsV1 ):
52+ url = f"{ self .url } /{ self .endpoint } /{ project_id } "
53+ return Message .from_json (await self .patch (url , json = options ))
54+ async def update_project (self , project_id : str , name = "" ):
5055 url = f"{ self .url } /{ self .endpoint } /{ project_id } "
51- return await self .patch (url , json = options )
56+ options : ProjectOptionsV1 = {
57+ "name" : name ,
58+ }
59+ return Message .from_json (await self .patch (url , json = options ))
5260
5361 async def delete_project (self , project_id : str ) -> None :
5462 url = f"{ self .url } /{ self .endpoint } /{ project_id } "
55- return await self .delete (url )
63+ return Message . from_json ( await self .delete (url ) )
5664
57- async def get_project_keys (self , project_id : str ) -> KeysResponse :
65+ # keys
66+ async def list_keys (self , project_id : str ):
67+ return self .get_keys (project_id )
68+ async def get_keys (self , project_id : str ):
5869 url = f"{ self .url } /{ self .endpoint } /{ project_id } /keys"
59- return await self .get (url )
70+ result = await self .get (url )
71+ return KeysResponse .from_json (result )
6072
61- async def get_project_key (self , project_id : str , key_id : str ) -> Key :
73+ async def get_key (self , project_id : str , key_id : str ):
6274 url = f"{ self .url } /{ self .endpoint } /{ project_id } /keys/{ key_id } "
63- return await self .get (url )
75+ return KeyResponse . from_json ( await self .get (url ) )
6476
65- async def create_project_key (self , project_id : str , options : KeyOptionsV1 ) -> CreateKeyResponse :
77+ async def create_key (self , project_id : str , options : KeyOptionsV1 ):
6678 url = f"{ self .url } /{ self .endpoint } /{ project_id } /keys"
67- return await self .post (url , json = options )
79+ return Key . from_json ( await self .post (url , json = options ) )
6880
69- async def delete_project_key (self , project_id : str , key_id : str ) -> None :
81+ async def delete_key (self , project_id : str , key_id : str ) -> None :
7082 url = f"{ self .url } /{ self .endpoint } /{ project_id } /keys/{ key_id } "
71- return await self .delete (url )
83+ return Message . from_json ( await self .delete (url ) )
7284
73- async def get_project_members (self , project_id : str ) -> MembersResponse :
85+ # members
86+ async def get_members (self , project_id : str ):
7487 url = f"{ self .url } /{ self .endpoint } /{ project_id } /members"
75- return await self .get (url )
88+ return MembersResponse . from_json ( await self .get (url ) )
7689
77- async def remove_project_member (self , project_id : str , member_id : str ) -> None :
90+ async def remove_member (self , project_id : str , member_id : str ) -> None :
7891 url = f"{ self .url } /{ self .endpoint } /{ project_id } /members/{ member_id } "
79- return await self .delete (url )
92+ return Message . from_json ( await self .delete (url ) )
8093
81- async def get_project_member_scopes (self , project_id : str , member_id : str ) -> ScopesResponse :
94+ # scopes
95+ async def get_member_scopes (self , project_id : str , member_id : str ):
8296 url = f"{ self .url } /{ self .endpoint } /{ project_id } /members/{ member_id } /scopes"
83- return await self .get (url )
97+ return ScopesResponse . from_json ( await self .get (url ) )
8498
85- async def update_project_member_scope (self , project_id : str , member_id : str , options : ScopeOptionsV1 ) -> Message :
99+ async def update_member_scope (self , project_id : str , member_id : str , options : ScopeOptionsV1 ):
86100 url = f"{ self .url } /{ self .endpoint } /{ project_id } /members/{ member_id } /scopes"
87- return await self .put (url , json = options )
101+ return Message . from_json ( await self .put (url , json = options ) )
88102
89- async def get_project_invites (self , project_id : str ) -> InvitesResponse :
103+ # invites
104+ async def list_invites (self , project_id : str ):
105+ return self .get_invites (project_id )
106+ async def get_invites (self , project_id : str ):
90107 url = f"{ self .url } /{ self .endpoint } /{ project_id } /invites"
91- return await self .get (url )
108+ return InvitesResponse . from_json ( await self .get (url ) )
92109
93- async def send_project_invite (self , project_id : str , options : InviteOptionsV1 ) -> Message :
110+ async def send_invite_options (self , project_id : str , options : InviteOptionsV1 ):
111+ url = f"{ self .url } /{ self .endpoint } /{ project_id } /invites"
112+ return Message .from_json (await self .post (url , json = options ))
113+ async def send_invite (self , project_id : str , email : str , scope = "member" ):
94114 url = f"{ self .url } /{ self .endpoint } /{ project_id } /invites"
95- return await self .post (url , json = options )
115+ options : InviteOptionsV1 = {
116+ "email" : email ,
117+ "scope" : scope ,
118+ }
119+ return Message .from_json (await self .post (url , json = options ))
96120
97- async def delete_project_invite (self , project_id : str , email : str ) -> Message :
121+ async def delete_invite (self , project_id : str , email : str ):
98122 url = f"{ self .url } /{ self .endpoint } /{ project_id } /invites/{ email } "
99- return await self .delete (url )
123+ return Message . from_json ( await self .delete (url ) )
100124
101- async def leave_project (self , project_id : str ) -> Message :
125+ async def leave_project (self , project_id : str ):
102126 url = f"{ self .url } /{ self .endpoint } /{ project_id } /leave"
103- return await self .delete (url )
127+ return Message . from_json ( await self .delete (url ) )
104128
105- async def get_project_usage_requests (self , project_id : str , options : UsageRequestOptionsV1 ) -> UsageRequestsResponse :
129+ # usage
130+ async def get_usage_requests (self , project_id : str , options : UsageRequestOptionsV1 ):
106131 url = f"{ self .url } /{ self .endpoint } /{ project_id } /requests"
107- return await self .get (url , options )
132+ return UsageRequestsResponse . from_json ( await self .get (url , options ) )
108133
109- async def get_project_usage_request (self , project_id : str , request_id : str ) -> UsageRequest :
134+ async def get_usage_request (self , project_id : str , request_id : str ):
110135 url = f"{ self .url } /{ self .endpoint } /{ project_id } /requests/{ request_id } "
111- return await self .get (url )
136+ return UsageRequest . from_json ( await self .get (url ) )
112137
113- async def get_project_usage_summary (self , project_id : str , options : UsageSummaryOptionsV1 ) -> UsageSummaryResponse :
138+ async def get_usage_summary (self , project_id : str , options : UsageSummaryOptionsV1 ):
114139 url = f"{ self .url } /{ self .endpoint } /{ project_id } /usage"
115- return await self .get (url , options )
140+ return UsageSummaryResponse . from_json ( await self .get (url , options ) )
116141
117- async def get_project_usage_fields (self , project_id : str , options : UsageFieldsOptionsV1 ) -> UsageFieldsResponse :
142+ async def get_usage_fields (self , project_id : str , options : UsageFieldsOptionsV1 ):
118143 url = f"{ self .url } /{ self .endpoint } /{ project_id } /usage/fields"
119- return await self .get (url , options )
144+ return UsageFieldsResponse . from_json ( await self .get (url , options ) )
120145
121- async def get_project_balances (self , project_id : str ) -> BalancesResponse :
146+ # balances
147+ async def list_balances (self , project_id : str ):
148+ return self .get_balances (project_id )
149+ async def get_balances (self , project_id : str ):
122150 url = f"{ self .url } /{ self .endpoint } /{ project_id } /balances"
123- return await self .get (url )
151+ return BalancesResponse . from_json ( await self .get (url ) )
124152
125- async def get_project_balance (self , project_id : str , balance_id : str ) -> Balance :
153+ async def get_balance (self , project_id : str , balance_id : str ):
126154 url = f"{ self .url } /{ self .endpoint } /{ project_id } /balances/{ balance_id } "
127- return await self .get (url )
155+ return Balance . from_json ( await self .get (url ) )
0 commit comments