1
1
"""Nextcloud API for working with apps V2's storage w/wo user context(table oc_appconfig_ex/oc_preferences_ex)."""
2
2
3
3
import dataclasses
4
- import typing
5
4
6
5
from ._exceptions import NextcloudExceptionNotFound
7
6
from ._misc import require_capabilities
@@ -26,7 +25,7 @@ class _BasicAppCfgPref:
26
25
def __init__ (self , session : NcSessionBasic ):
27
26
self ._session = session
28
27
29
- def get_value (self , key : str , default = None ) -> typing . Optional [ str ] :
28
+ def get_value (self , key : str , default = None ) -> str | None :
30
29
"""Returns the value of the key, if found, or the specified default value."""
31
30
if not key :
32
31
raise ValueError ("`key` parameter can not be empty" )
@@ -47,7 +46,7 @@ def get_values(self, keys: list[str]) -> list[CfgRecord]:
47
46
results = self ._session .ocs ("POST" , f"{ self ._session .ae_url } /{ self ._url_suffix } /get-values" , json = data )
48
47
return [CfgRecord (i ) for i in results ]
49
48
50
- def delete (self , keys : typing . Union [ str , list [str ] ], not_fail = True ) -> None :
49
+ def delete (self , keys : str | list [str ], not_fail = True ) -> None :
51
50
"""Deletes config/preference entries by the provided keys."""
52
51
if isinstance (keys , str ):
53
52
keys = [keys ]
@@ -82,7 +81,7 @@ class AppConfigExAPI(_BasicAppCfgPref):
82
81
83
82
_url_suffix = "ex-app/config"
84
83
85
- def set_value (self , key : str , value : str , sensitive : typing . Optional [ bool ] = None ) -> None :
84
+ def set_value (self , key : str , value : str , sensitive : bool | None = None ) -> None :
86
85
"""Sets a value and if specified the sensitive flag for a key.
87
86
88
87
.. note:: A sensitive flag ensures key values are truncated in Nextcloud logs.
0 commit comments