@@ -153,13 +153,15 @@ def _full_uri(self, endpoint: str) -> str:
153
153
return f"{ self .CONTROLLER_BASE_URL } { endpoint } "
154
154
155
155
@staticmethod
156
- def __request_or_raise (method : str ,
157
- uri : str ,
158
- object_name : str = "" ,
159
- json_decode : bool = True ,
160
- single_element : bool = False ,
161
- expected_status_code : int = 200 ,
162
- ** kwargs : dict [str , str ]):
156
+ def __request_or_raise (
157
+ method : str ,
158
+ uri : str ,
159
+ object_name : str = "" ,
160
+ json_decode : bool = True ,
161
+ single_element : bool = False ,
162
+ expected_status_code : int = 200 ,
163
+ ** kwargs : dict [str , str ]
164
+ ) -> Callable [[Callable [..., Any ]], Callable [..., str | list [dict [str , str ]] | dict [str , str ]]]:
163
165
"""Private method.
164
166
165
167
Uplink-style decorator for requests. Use like `_request_or_raise` but as decorator.
@@ -192,12 +194,13 @@ def get_application_decorated(application_name):
192
194
outer_kwargs = kwargs
193
195
194
196
def _inner_request_or_raise_decorator (
195
- func : Callable [[ Any ] , Any ]) -> Callable [[ Any ] , str | list [dict [str , str ]]]:
197
+ func : Callable [... , Any ]) -> Callable [... , str | list [dict [str , str ]] | dict [ str , str ]]:
196
198
"""Handles function."""
197
199
198
200
@wraps (func )
199
- def __inner_request_or_raise_decorator (* args : list [Any ],
200
- ** kwargs : dict [str , str ]) -> str | list [dict [str , str ]]:
201
+ def __inner_request_or_raise_decorator (
202
+ * args : list [Any ], ** kwargs : dict [str ,
203
+ str ]) -> str | list [dict [str , str ]] | dict [str , str ]:
201
204
"""Handles arguments passed to function."""
202
205
self : AppDController = args [0 ] # type: ignore
203
206
@@ -229,7 +232,7 @@ def __inner_request_or_raise_decorator(*args: list[Any],
229
232
return _inner_request_or_raise_decorator
230
233
231
234
@__request_or_raise ("GET" , "/controller/rest/applications" , "applications" )
232
- def get_applications (self ) -> list [dict [str , str ]]: # type: ignore
235
+ def get_applications (self ) -> list [dict [str , str ]]:
233
236
"""Request all applications from the controller, formatted in JSON.
234
237
235
238
Returns:
@@ -239,8 +242,8 @@ def get_applications(self) -> list[dict[str, str]]: # type: ignore
239
242
@__request_or_raise ("GET" ,
240
243
"/controller/rest/applications/{application_name}" ,
241
244
"application {application_name}" ,
242
- single_element = True ) # type: ignore
243
- def get_application (self , application_name : str ) -> dict [str , str ]: # type: ignore
245
+ single_element = True )
246
+ def get_application (self , application_name : str ) -> dict [str , str ]:
244
247
"""Request an application from the controller by application name, formatted in JSON.
245
248
246
249
Args:
@@ -251,8 +254,8 @@ def get_application(self, application_name: str) -> dict[str, str]: # type: ign
251
254
"""
252
255
253
256
@__request_or_raise ("GET" , "/controller/rest/applications/{application_name}/business-transactions" ,
254
- "business transaction for {application_name}" ) # type: ignore
255
- def get_business_transactions (self , application_name : str ) -> list [dict [str , str ]]: # type: ignore
257
+ "business transaction for {application_name}" )
258
+ def get_business_transactions (self , application_name : str ) -> list [dict [str , str ]]:
256
259
"""Request all business transactions for an application by application name, formatted in JSON.
257
260
258
261
Args:
@@ -265,8 +268,8 @@ def get_business_transactions(self, application_name: str) -> list[dict[str, str
265
268
@__request_or_raise ("GET" ,
266
269
"/controller/transactiondetection/{application_id}/custom" ,
267
270
"custom detection rules for application with ID {application_id}" ,
268
- json_decode = False ) # type: ignore
269
- def get_custom_transaction_detection_rules (self , application_id : int ) -> str : # type: ignore
271
+ json_decode = False )
272
+ def get_custom_transaction_detection_rules (self , application_id : int ) -> str :
270
273
"""Request all custom transaction detection rules for an application by application ID,
271
274
formatted in XML.
272
275
@@ -280,8 +283,8 @@ def get_custom_transaction_detection_rules(self, application_id: int) -> str: #
280
283
@__request_or_raise ("GET" ,
281
284
"/controller/transactiondetection/{application_id}/auto" ,
282
285
"auto detection rules for application with ID {application_id}" ,
283
- json_decode = False ) # type: ignore
284
- def get_auto_transaction_detection_rules (self , application_id : int ) -> str : # type: ignore
286
+ json_decode = False )
287
+ def get_auto_transaction_detection_rules (self , application_id : int ) -> str :
285
288
"""Request all automatic transaction detection rules for an application by application ID,
286
289
formatted in XML.
287
290
@@ -305,7 +308,7 @@ def get_account_id(self) -> int:
305
308
}).json ()["id" ])
306
309
307
310
@__request_or_raise ("GET" , "/controller/licensing/v1/account/{accountId}/allocation" ,
308
- "licensing allocations for account {accountId}" ) #type: ignore
311
+ "licensing allocations for account {accountId}" )
309
312
def get_license_allocations (self , accountId : int ):
310
313
"""Requires Infrastructure-Based Licensing (IBL). Retrieve all license allocations for account with ID `accountId`.
311
314
@@ -316,19 +319,19 @@ def get_license_allocations(self, accountId: int):
316
319
list[dict[str, str | int | list[str]]]: The parsed API response.
317
320
"""
318
321
319
- @__request_or_raise (
320
- "GET" , "/controller/licensing/v1/account/{accountId}/allocation?name={allocation_name}" ,
321
- "licensing allocations for account {accountId} for allocation {allocation_name}" ) #type: ignore
322
+ @__request_or_raise ("GET" ,
323
+ "/controller/licensing/v1/account/{accountId}/allocation?name={allocation_name}" ,
324
+ "licensing allocations for account {accountId} for allocation {allocation_name}" )
322
325
def get_license_allocation_by_name (self , accountId : int , allocation_name : str ):
323
326
"""Requires Infrastructure-Based Licensing (IBL). Like `get_license_allocations`, but additionally filtered by allocation name."""
324
327
325
- @__request_or_raise (
326
- "GET" , "/controller/licensing/v1/account/{accountId}/allocation?license-key={license_key}" ,
327
- "licensing allocations for account {accountId} for allocation {license_key}" ) #type: ignore
328
+ @__request_or_raise ("GET" ,
329
+ "/controller/licensing/v1/account/{accountId}/allocation?license-key={license_key}" ,
330
+ "licensing allocations for account {accountId} for allocation {license_key}" )
328
331
def get_license_allocation_by_license_key (self , accountId : int , license_key : str ):
329
332
"""Requires Infrastructure-Based Licensing (IBL). Like `get_license_allocations`, but additionally filtered by license key."""
330
333
331
334
@__request_or_raise ("GET" , "/controller/licensing/v1/account/{accountId}/allocation?tag={tag}" ,
332
- "licensing allocations for account {accountId} for allocation {tag}" ) #type: ignore
335
+ "licensing allocations for account {accountId} for allocation {tag}" )
333
336
def get_license_allocations_by_tag (self , accountId : int , tag : str ):
334
337
"""Requires Infrastructure-Based Licensing (IBL). Like `get_license_allocations`, but additionally filtered by tag assocatied with allocations."""
0 commit comments