5050 RoleBindingList ,
5151 BulkRoleBindingUpdate ,
5252 RoleList ,
53+ OAuth2UpdateURI ,
54+ ServiceAccountList ,
55+ ServiceAccount ,
56+ ServiceAccountToken ,
57+ ServiceAccountTokenInfo ,
58+ ServiceAccountTokenList ,
5359)
5460from rapyuta_io_sdk_v2 .utils import handle_server_errors
5561
@@ -128,7 +134,7 @@ def login(
128134 token = self .get_auth_token (email , password )
129135 self .config .auth_token = token
130136
131- def logout (self , token : str | None = None ) -> dict [ str , Any ] :
137+ def logout (self , token : str | None = None ) -> None :
132138 """Expire the authentication token.
133139
134140 Args:
@@ -146,7 +152,6 @@ def logout(self, token: str | None = None) -> dict[str, Any]:
146152 },
147153 )
148154 handle_server_errors (result )
149- return result .json ()
150155
151156 def refresh_token (self , token : str | None = None , set_token : bool = True ) -> str :
152157 """Refresh the authentication token.
@@ -236,7 +241,7 @@ async def update_organization(
236241 headers = self .config .get_headers (
237242 with_project = False , organization_guid = organization_guid , ** kwargs
238243 ),
239- json = body .model_dump (),
244+ json = body .model_dump (by_alias = True ),
240245 )
241246 handle_server_errors (result )
242247 return Organization (** result .json ())
@@ -310,7 +315,7 @@ async def update_user(self, body: User | dict[str, Any], **kwargs) -> User:
310315 headers = self .config .get_headers (
311316 with_project = False , with_organization = False , ** kwargs
312317 ),
313- json = body .model_dump (),
318+ json = body .model_dump (by_alias = True ),
314319 )
315320 handle_server_errors (result )
316321 return User (** result .json ())
@@ -408,7 +413,7 @@ async def create_project(self, body: Project | dict[str, Any], **kwargs) -> Proj
408413 headers = self .config .get_headers (
409414 organization_guid = org_guid , with_project = False , ** kwargs
410415 ),
411- json = body .model_dump (),
416+ json = body .model_dump (by_alias = True ),
412417 )
413418 handle_server_errors (result )
414419 return Project (** result .json ())
@@ -431,7 +436,7 @@ async def update_project(
431436 result = await self .c .put (
432437 url = f"{ self .v2api_host } /v2/projects/{ project_guid } /" ,
433438 headers = self .config .get_headers (with_project = False , ** kwargs ),
434- json = body .model_dump (),
439+ json = body .model_dump (by_alias = True ),
435440 )
436441 handle_server_errors (result )
437442 return Project (** result .json ())
@@ -522,7 +527,7 @@ async def create_package(self, body: Package | dict[str, Any], **kwargs) -> Pack
522527 result = await self .c .post (
523528 url = f"{ self .v2api_host } /v2/packages/" ,
524529 headers = self .config .get_headers (** kwargs ),
525- json = body .model_dump (),
530+ json = body .model_dump (by_alias = True ),
526531 )
527532
528533 handle_server_errors (result )
@@ -645,7 +650,7 @@ async def create_deployment(
645650 result = await self .c .post (
646651 url = f"{ self .v2api_host } /v2/deployments/" ,
647652 headers = self .config .get_headers (** kwargs ),
648- json = body .model_dump (),
653+ json = body .model_dump (by_alias = True ),
649654 )
650655
651656 handle_server_errors (result )
@@ -692,7 +697,7 @@ async def update_deployment(
692697 result = await self .c .patch (
693698 url = f"{ self .v2api_host } /v2/deployments/{ name } /" ,
694699 headers = self .config .get_headers (** kwargs ),
695- json = body .model_dump (),
700+ json = body .model_dump (by_alias = True ),
696701 )
697702 handle_server_errors (result )
698703 return Deployment (** result .json ())
@@ -831,7 +836,7 @@ async def create_disk(self, body: Disk | dict[str, Any], **kwargs) -> Disk:
831836 result = await self .c .post (
832837 url = f"{ self .v2api_host } /v2/disks/" ,
833838 headers = self .config .get_headers (** kwargs ),
834- json = body .model_dump (),
839+ json = body .model_dump (by_alias = True ),
835840 )
836841 handle_server_errors (result )
837842 return Disk (** result .json ())
@@ -932,7 +937,7 @@ async def create_staticroute(
932937 result = await self .c .post (
933938 url = f"{ self .v2api_host } /v2/staticroutes/" ,
934939 headers = self .config .get_headers (** kwargs ),
935- json = body .model_dump (),
940+ json = body .model_dump (by_alias = True ),
936941 )
937942 handle_server_errors (result )
938943 return StaticRoute (** result .json ())
@@ -973,7 +978,7 @@ async def update_staticroute(
973978 result = await self .c .put (
974979 url = f"{ self .v2api_host } /v2/staticroutes/{ name } /" ,
975980 headers = self .config .get_headers (** kwargs ),
976- json = body .model_dump (),
981+ json = body .model_dump (by_alias = True ),
977982 )
978983 handle_server_errors (result )
979984 return StaticRoute (** result .json ())
@@ -1061,7 +1066,7 @@ async def create_network(self, body: Network | dict[str, Any], **kwargs) -> Netw
10611066 result = await self .c .post (
10621067 url = f"{ self .v2api_host } /v2/networks/" ,
10631068 headers = self .config .get_headers (** kwargs ),
1064- json = body .model_dump (),
1069+ json = body .model_dump (by_alias = True ),
10651070 )
10661071 handle_server_errors (result )
10671072 return Network (** result .json ())
@@ -1162,7 +1167,7 @@ async def create_secret(
11621167 result = await self .c .post (
11631168 url = f"{ self .v2api_host } /v2/secrets/" ,
11641169 headers = self .config .get_headers (** kwargs ),
1165- json = body .model_dump (),
1170+ json = body .model_dump (by_alias = True ),
11661171 )
11671172
11681173 handle_server_errors (result )
@@ -1204,7 +1209,7 @@ async def update_secret(
12041209 result = await self .c .put (
12051210 url = f"{ self .v2api_host } /v2/secrets/{ name } /" ,
12061211 headers = self .config .get_headers (** kwargs ),
1207- json = body .model_dump (),
1212+ json = body .model_dump (by_alias = True ),
12081213 )
12091214 handle_server_errors (result )
12101215 return Secret (** result .json ())
@@ -1321,21 +1326,21 @@ async def update_oauth2_client(
13211326 return result .json ()
13221327
13231328 async def update_oauth2_client_uris (
1324- self , client_id : str , uris : dict , ** kwargs
1329+ self , client_id : str , update : OAuth2UpdateURI , ** kwargs
13251330 ) -> dict [str , Any ]:
13261331 """Update OAuth2 client URIs.
13271332
13281333 Args:
13291334 client_id (str): OAuth2 client ID
1330- uris (dict ): URIs update payload
1335+ update (OAuth2UpdateURI ): URIs update payload
13311336
13321337 Returns:
13331338 OAuth2 client details as a dictionary.
13341339 """
13351340 result = await self .c .patch (
1336- url = f"{ self .v2api_host } /v2/oauth2clients /{ client_id } /uris/" ,
1341+ url = f"{ self .v2api_host } /v2/oauth2/clients /{ client_id } /uris/" ,
13371342 headers = self .config .get_headers (** kwargs ),
1338- json = uris ,
1343+ json = update . model_dump ( by_alias = True ) ,
13391344 )
13401345 handle_server_errors (result )
13411346 return result .json ()
@@ -1827,7 +1832,7 @@ async def create_instance(
18271832 result = await self .c .post (
18281833 url = f"{ self .v2api_host } /v2/managedservices/" ,
18291834 headers = self .config .get_headers (),
1830- json = body .model_dump (),
1835+ json = body .model_dump (by_alias = True ),
18311836 )
18321837
18331838 handle_server_errors (result )
@@ -1897,7 +1902,7 @@ async def create_instance_binding(
18971902 result = await self .c .post (
18981903 url = f"{ self .v2api_host } /v2/managedservices/{ instance_name } /bindings/" ,
18991904 headers = self .config .get_headers (),
1900- json = body .model_dump (),
1905+ json = body .model_dump (by_alias = True ),
19011906 )
19021907
19031908 handle_server_errors (result )
@@ -1987,7 +1992,7 @@ async def create_user_group(self, user_group: UserGroup, **kwargs) -> UserGroup:
19871992 result = await self .c .post (
19881993 url = f"{ self .v2api_host } /v2/usergroups/" ,
19891994 headers = self .config .get_headers (with_project = False , ** kwargs ),
1990- json = user_group .model_dump (),
1995+ json = user_group .model_dump (by_alias = True ),
19911996 )
19921997 handle_server_errors (result )
19931998
@@ -2002,7 +2007,7 @@ async def update_user_group(self, user_group: UserGroup, **kwargs) -> UserGroup:
20022007 group_guid = user_group .metadata .guid ,
20032008 ** kwargs ,
20042009 ),
2005- json = user_group .model_dump (),
2010+ json = user_group .model_dump (by_alias = True ),
20062011 )
20072012 handle_server_errors (result )
20082013
@@ -2060,7 +2065,7 @@ async def create_role(self, role: Role | dict, **kwargs) -> Role:
20602065 result = await self .c .post (
20612066 url = f"{ self .v2api_host } /v2/roles/" ,
20622067 headers = self .config .get_headers (with_project = False , ** kwargs ),
2063- json = role .model_dump (),
2068+ json = role .model_dump (by_alias = True ),
20642069 )
20652070 handle_server_errors (result )
20662071
@@ -2072,7 +2077,7 @@ async def update_role(self, role: Role, **kwargs) -> Role:
20722077 result = await self .c .put (
20732078 url = f"{ self .v2api_host } /v2/roles/{ role .metadata .name } /" ,
20742079 headers = self .config .get_headers (with_project = False , ** kwargs ),
2075- json = role .model_dump (),
2080+ json = role .model_dump (by_alias = True ),
20762081 )
20772082 handle_server_errors (result )
20782083
@@ -2151,11 +2156,160 @@ async def update_role_binding(
21512156 result = await self .c .put (
21522157 url = f"{ self .v2api_host } /v2/role-bindings/" ,
21532158 headers = self .config .get_headers (with_project = False , ** kwargs ),
2154- json = binding .model_dump (),
2159+ json = binding .model_dump (by_alias = True ),
21552160 )
21562161 handle_server_errors (result )
21572162
21582163 try :
21592164 return RoleBinding (** result .json ())
21602165 except Exception :
21612166 return result .json ()
2167+
2168+ # -------------------ServiceAccount-------------------
2169+
2170+ async def list_service_accounts (
2171+ self ,
2172+ cont : int = 0 ,
2173+ limit : int = 50 ,
2174+ label_selector : list [str ] | None = None ,
2175+ name : str | None = None ,
2176+ regions : list [str ] | None = None ,
2177+ ** kwargs ,
2178+ ) -> ServiceAccountList :
2179+ parameters : dict [str , Any ] = {
2180+ "continue" : cont ,
2181+ "limit" : limit ,
2182+ }
2183+ if label_selector :
2184+ parameters ["labelSelector" ] = label_selector
2185+ if name :
2186+ parameters ["name" ] = name
2187+ if regions :
2188+ parameters ["regions" ] = regions
2189+
2190+ result = await self .c .get (
2191+ url = f"{ self .v2api_host } /v2/serviceaccounts/" ,
2192+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2193+ params = parameters ,
2194+ )
2195+
2196+ handle_server_errors (result )
2197+
2198+ return ServiceAccountList (** result .json ())
2199+
2200+ async def get_service_account (
2201+ self ,
2202+ name : str ,
2203+ ** kwargs ,
2204+ ) -> ServiceAccount :
2205+ result = await self .c .get (
2206+ url = f"{ self .v2api_host } /v2/serviceaccounts/{ name } /" ,
2207+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2208+ )
2209+
2210+ handle_server_errors (result )
2211+ return ServiceAccount (** result .json ())
2212+
2213+ async def create_service_account (
2214+ self ,
2215+ service_account : ServiceAccount | dict ,
2216+ ** kwargs ,
2217+ ) -> ServiceAccount :
2218+ if isinstance (service_account , dict ):
2219+ service_account = ServiceAccount .model_validate (service_account )
2220+ result = await self .c .post (
2221+ url = f"{ self .v2api_host } /v2/serviceaccounts/" ,
2222+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2223+ json = service_account .model_dump (by_alias = True ),
2224+ )
2225+
2226+ handle_server_errors (result )
2227+ return ServiceAccount (** result .json ())
2228+
2229+ async def update_service_account (
2230+ self ,
2231+ service_account : ServiceAccount | dict ,
2232+ name : str | None ,
2233+ ** kwargs ,
2234+ ) -> ServiceAccount :
2235+ if isinstance (service_account , dict ):
2236+ service_account = ServiceAccount .model_validate (service_account )
2237+ if not name :
2238+ name = service_account .metadata .name
2239+ result = await self .c .put (
2240+ url = f"{ self .v2api_host } /v2/serviceaccounts/{ name } /" ,
2241+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2242+ json = service_account .model_dump (by_alias = True ),
2243+ )
2244+
2245+ handle_server_errors (result )
2246+ return ServiceAccount (** result .json ())
2247+
2248+ async def delete_service_account (
2249+ self ,
2250+ name : str ,
2251+ ** kwargs ,
2252+ ) -> None :
2253+ result = await self .c .delete (
2254+ url = f"{ self .v2api_host } /v2/serviceaccounts/{ name } /" ,
2255+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2256+ )
2257+
2258+ handle_server_errors (result )
2259+ return None
2260+
2261+ async def list_service_account_tokens (
2262+ self , name : str , cont : int = 0 , limit : int = 50 , ** kwargs
2263+ ) -> ServiceAccountTokenList :
2264+ result = await self .c .get (
2265+ url = f"{ self .v2api_host } /v2/serviceaccounts/{ name } /token/" ,
2266+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2267+ )
2268+
2269+ handle_server_errors (result )
2270+
2271+ return ServiceAccountTokenList (** result .json ())
2272+
2273+ async def create_service_account_token (
2274+ self , name : str , expiry_at : ServiceAccountToken | dict , ** kwargs
2275+ ) -> ServiceAccountTokenInfo :
2276+ if isinstance (expiry_at , dict ):
2277+ expiry_at = ServiceAccountToken .model_validate (expiry_at )
2278+
2279+ result = await self .c .post (
2280+ url = f"{ self .v2api_host } /v2/serviceaccounts/{ name } /token/" ,
2281+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2282+ json = expiry_at .model_dump (by_alias = True , mode = "json" ),
2283+ )
2284+
2285+ handle_server_errors (result )
2286+
2287+ return ServiceAccountTokenInfo (** result .json ())
2288+
2289+ async def refresh_service_account_token (
2290+ self , name : str , token_id : str , expiry_at : ServiceAccountToken | dict , ** kwargs
2291+ ) -> ServiceAccountTokenInfo :
2292+ if isinstance (expiry_at , dict ):
2293+ expiry_at = ServiceAccountToken .model_validate (expiry_at )
2294+
2295+ result = await self .c .patch (
2296+ url = f"{ self .v2api_host } /v2/serviceaccounts/{ name } /token/{ token_id } /" ,
2297+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2298+ json = expiry_at .model_dump (by_alias = True , mode = "json" ),
2299+ )
2300+
2301+ handle_server_errors (result )
2302+
2303+ return ServiceAccountTokenInfo (** result .json ())
2304+
2305+ async def delete_service_account_token (
2306+ self , name : str , token_id : str , ** kwargs
2307+ ) -> None :
2308+ result = await self .c .delete (
2309+ url = f"{ self .v2api_host } /v2/serviceaccounts/{ name } /token/{ token_id } /" ,
2310+ headers = self .config .get_headers (with_project = False , ** kwargs ),
2311+ )
2312+
2313+ handle_server_errors (result )
2314+
2315+ return None
0 commit comments