1
0

IUserConfig.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace NCU\Config;
  8. use Generator;
  9. use NCU\Config\Exceptions\IncorrectTypeException;
  10. use NCU\Config\Exceptions\UnknownKeyException;
  11. /**
  12. * This class provides an easy way for apps to store user config in the
  13. * database.
  14. * Supports **lazy loading**
  15. *
  16. * ### What is lazy loading ?
  17. * In order to avoid loading useless user config into memory for each request,
  18. * only non-lazy values are now loaded.
  19. *
  20. * Once a value that is lazy is requested, all lazy values will be loaded.
  21. *
  22. * Similarly, some methods from this class are marked with a warning about ignoring
  23. * lazy loading. Use them wisely and only on parts of the code that are called
  24. * during specific requests or actions to avoid loading the lazy values all the time.
  25. *
  26. * @experimental 31.0.0
  27. */
  28. interface IUserConfig {
  29. /**
  30. * @experimental 31.0.0
  31. */
  32. public const FLAG_SENSITIVE = 1; // value is sensitive
  33. /**
  34. * @experimental 31.0.0
  35. */
  36. public const FLAG_INDEXED = 2; // value should be indexed
  37. /**
  38. * Get list of all userIds with config stored in database.
  39. * If $appId is specified, will only limit the search to this value
  40. *
  41. * **WARNING:** ignore any cache and get data directly from database.
  42. *
  43. * @param string $appId optional id of app
  44. *
  45. * @return list<string> list of userIds
  46. *
  47. * @experimental 31.0.0
  48. */
  49. public function getUserIds(string $appId = ''): array;
  50. /**
  51. * Get list of all apps that have at least one config
  52. * value related to $userId stored in database
  53. *
  54. * **WARNING:** ignore lazy filtering, all user config are loaded from database
  55. *
  56. * @param string $userId id of the user
  57. *
  58. * @return list<string> list of app ids
  59. *
  60. * @experimental 31.0.0
  61. */
  62. public function getApps(string $userId): array;
  63. /**
  64. * Returns all keys stored in database, related to user+app.
  65. * Please note that the values are not returned.
  66. *
  67. * **WARNING:** ignore lazy filtering, all user config are loaded from database
  68. *
  69. * @param string $userId id of the user
  70. * @param string $app id of the app
  71. *
  72. * @return list<string> list of stored config keys
  73. *
  74. * @experimental 31.0.0
  75. */
  76. public function getKeys(string $userId, string $app): array;
  77. /**
  78. * Check if a key exists in the list of stored config values.
  79. *
  80. * @param string $userId id of the user
  81. * @param string $app id of the app
  82. * @param string $key config key
  83. * @param bool $lazy search within lazy loaded config
  84. *
  85. * @return bool TRUE if key exists
  86. *
  87. * @experimental 31.0.0
  88. */
  89. public function hasKey(string $userId, string $app, string $key, ?bool $lazy = false): bool;
  90. /**
  91. * best way to see if a value is set as sensitive (not displayed in report)
  92. *
  93. * @param string $userId id of the user
  94. * @param string $app id of the app
  95. * @param string $key config key
  96. * @param bool|null $lazy search within lazy loaded config
  97. *
  98. * @return bool TRUE if value is sensitive
  99. * @throws UnknownKeyException if config key is not known
  100. *
  101. * @experimental 31.0.0
  102. */
  103. public function isSensitive(string $userId, string $app, string $key, ?bool $lazy = false): bool;
  104. /**
  105. * best way to see if a value is set as indexed (so it can be search)
  106. *
  107. * @see self::searchUsersByValueString()
  108. * @see self::searchUsersByValueInt()
  109. * @see self::searchUsersByValueBool()
  110. * @see self::searchUsersByValues()
  111. *
  112. * @param string $userId id of the user
  113. * @param string $app id of the app
  114. * @param string $key config key
  115. * @param bool|null $lazy search within lazy loaded config
  116. *
  117. * @return bool TRUE if value is sensitive
  118. * @throws UnknownKeyException if config key is not known
  119. *
  120. * @experimental 31.0.0
  121. */
  122. public function isIndexed(string $userId, string $app, string $key, ?bool $lazy = false): bool;
  123. /**
  124. * Returns if the config key stored in database is lazy loaded
  125. *
  126. * **WARNING:** ignore lazy filtering, all config values are loaded from database
  127. *
  128. * @param string $userId id of the user
  129. * @param string $app id of the app
  130. * @param string $key config key
  131. *
  132. * @return bool TRUE if config is lazy loaded
  133. * @throws UnknownKeyException if config key is not known
  134. * @see IUserConfig for details about lazy loading
  135. *
  136. * @experimental 31.0.0
  137. */
  138. public function isLazy(string $userId, string $app, string $key): bool;
  139. /**
  140. * List all config values from an app with config key starting with $key.
  141. * Returns an array with config key as key, stored value as value.
  142. *
  143. * **WARNING:** ignore lazy filtering, all config values are loaded from database
  144. *
  145. * @param string $userId id of the user
  146. * @param string $app id of the app
  147. * @param string $prefix config keys prefix to search, can be empty.
  148. * @param bool $filtered filter sensitive config values
  149. *
  150. * @return array<string, string|int|float|bool|array> [key => value]
  151. *
  152. * @experimental 31.0.0
  153. */
  154. public function getValues(string $userId, string $app, string $prefix = '', bool $filtered = false): array;
  155. /**
  156. * List all config values of a user.
  157. * Returns an array with config key as key, stored value as value.
  158. *
  159. * **WARNING:** ignore lazy filtering, all config values are loaded from database
  160. *
  161. * @param string $userId id of the user
  162. * @param bool $filtered filter sensitive config values
  163. *
  164. * @return array<string, string|int|float|bool|array> [key => value]
  165. *
  166. * @experimental 31.0.0
  167. */
  168. public function getAllValues(string $userId, bool $filtered = false): array;
  169. /**
  170. * List all apps storing a specific config key and its stored value.
  171. * Returns an array with appId as key, stored value as value.
  172. *
  173. * @param string $userId id of the user
  174. * @param string $key config key
  175. * @param bool $lazy search within lazy loaded config
  176. * @param ValueType|null $typedAs enforce type for the returned values
  177. *
  178. * @return array<string, string|int|float|bool|array> [appId => value]
  179. *
  180. * @experimental 31.0.0
  181. */
  182. public function getValuesByApps(string $userId, string $key, bool $lazy = false, ?ValueType $typedAs = null): array;
  183. /**
  184. * List all users storing a specific config key and its stored value.
  185. * Returns an array with userId as key, stored value as value.
  186. *
  187. * **WARNING:** no caching, generate a fresh request
  188. *
  189. * @param string $app id of the app
  190. * @param string $key config key
  191. * @param ValueType|null $typedAs enforce type for the returned values
  192. * @param array|null $userIds limit the search to a list of user ids
  193. *
  194. * @return array<string, string|int|float|bool|array> [userId => value]
  195. *
  196. * @experimental 31.0.0
  197. */
  198. public function getValuesByUsers(string $app, string $key, ?ValueType $typedAs = null, ?array $userIds = null): array;
  199. /**
  200. * List all users storing a specific config key/value pair.
  201. * Returns a list of user ids.
  202. *
  203. * **WARNING:** no caching, generate a fresh request
  204. *
  205. * @param string $app id of the app
  206. * @param string $key config key
  207. * @param string $value config value
  208. * @param bool $caseInsensitive non-case-sensitive search, only works if $value is a string
  209. *
  210. * @return Generator<string>
  211. *
  212. * @experimental 31.0.0
  213. */
  214. public function searchUsersByValueString(string $app, string $key, string $value, bool $caseInsensitive = false): Generator;
  215. /**
  216. * List all users storing a specific config key/value pair.
  217. * Returns a list of user ids.
  218. *
  219. * **WARNING:** no caching, generate a fresh request
  220. *
  221. * @param string $app id of the app
  222. * @param string $key config key
  223. * @param int $value config value
  224. *
  225. * @return Generator<string>
  226. *
  227. * @experimental 31.0.0
  228. */
  229. public function searchUsersByValueInt(string $app, string $key, int $value): Generator;
  230. /**
  231. * List all users storing a specific config key/value pair.
  232. * Returns a list of user ids.
  233. *
  234. * **WARNING:** no caching, generate a fresh request
  235. *
  236. * @param string $app id of the app
  237. * @param string $key config key
  238. * @param array $values list of possible config values
  239. *
  240. * @return Generator<string>
  241. *
  242. * @experimental 31.0.0
  243. */
  244. public function searchUsersByValues(string $app, string $key, array $values): Generator;
  245. /**
  246. * List all users storing a specific config key/value pair.
  247. * Returns a list of user ids.
  248. *
  249. * **WARNING:** no caching, generate a fresh request
  250. *
  251. * @param string $app id of the app
  252. * @param string $key config key
  253. * @param bool $value config value
  254. *
  255. * @return Generator<string>
  256. *
  257. * @experimental 31.0.0
  258. */
  259. public function searchUsersByValueBool(string $app, string $key, bool $value): Generator;
  260. /**
  261. * Get user config assigned to a config key.
  262. * If config key is not found in database, default value is returned.
  263. * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
  264. *
  265. * @param string $userId id of the user
  266. * @param string $app id of the app
  267. * @param string $key config key
  268. * @param string $default default value
  269. * @param bool $lazy search within lazy loaded config
  270. *
  271. * @return string stored config value or $default if not set in database
  272. *
  273. * @experimental 31.0.0
  274. *
  275. * @see IUserConfig for explanation about lazy loading
  276. * @see getValueInt()
  277. * @see getValueFloat()
  278. * @see getValueBool()
  279. * @see getValueArray()
  280. */
  281. public function getValueString(string $userId, string $app, string $key, string $default = '', bool $lazy = false): string;
  282. /**
  283. * Get config value assigned to a config key.
  284. * If config key is not found in database, default value is returned.
  285. * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
  286. *
  287. * @param string $userId id of the user
  288. * @param string $app id of the app
  289. * @param string $key config key
  290. * @param int $default default value
  291. * @param bool $lazy search within lazy loaded config
  292. *
  293. * @return int stored config value or $default if not set in database
  294. *
  295. * @experimental 31.0.0
  296. *
  297. * @see IUserConfig for explanation about lazy loading
  298. * @see getValueString()
  299. * @see getValueFloat()
  300. * @see getValueBool()
  301. * @see getValueArray()
  302. */
  303. public function getValueInt(string $userId, string $app, string $key, int $default = 0, bool $lazy = false): int;
  304. /**
  305. * Get config value assigned to a config key.
  306. * If config key is not found in database, default value is returned.
  307. * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
  308. *
  309. * @param string $userId id of the user
  310. * @param string $app id of the app
  311. * @param string $key config key
  312. * @param float $default default value
  313. * @param bool $lazy search within lazy loaded config
  314. *
  315. * @return float stored config value or $default if not set in database
  316. *
  317. * @experimental 31.0.0
  318. *
  319. * @see IUserConfig for explanation about lazy loading
  320. * @see getValueString()
  321. * @see getValueInt()
  322. * @see getValueBool()
  323. * @see getValueArray()
  324. */
  325. public function getValueFloat(string $userId, string $app, string $key, float $default = 0, bool $lazy = false): float;
  326. /**
  327. * Get config value assigned to a config key.
  328. * If config key is not found in database, default value is returned.
  329. * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
  330. *
  331. * @param string $userId id of the user
  332. * @param string $app id of the app
  333. * @param string $key config key
  334. * @param bool $default default value
  335. * @param bool $lazy search within lazy loaded config
  336. *
  337. * @return bool stored config value or $default if not set in database
  338. *
  339. * @experimental 31.0.0
  340. *
  341. * @see IUserPrefences for explanation about lazy loading
  342. * @see getValueString()
  343. * @see getValueInt()
  344. * @see getValueFloat()
  345. * @see getValueArray()
  346. */
  347. public function getValueBool(string $userId, string $app, string $key, bool $default = false, bool $lazy = false): bool;
  348. /**
  349. * Get config value assigned to a config key.
  350. * If config key is not found in database, default value is returned.
  351. * If config key is set as lazy loaded, the $lazy argument needs to be set to TRUE.
  352. *
  353. * @param string $userId id of the user
  354. * @param string $app id of the app
  355. * @param string $key config key
  356. * @param array $default default value`
  357. * @param bool $lazy search within lazy loaded config
  358. *
  359. * @return array stored config value or $default if not set in database
  360. *
  361. * @experimental 31.0.0
  362. *
  363. * @see IUserConfig for explanation about lazy loading
  364. * @see getValueString()
  365. * @see getValueInt()
  366. * @see getValueFloat()
  367. * @see getValueBool()
  368. */
  369. public function getValueArray(string $userId, string $app, string $key, array $default = [], bool $lazy = false): array;
  370. /**
  371. * returns the type of config value
  372. *
  373. * **WARNING:** ignore lazy filtering, all config values are loaded from database
  374. * unless lazy is set to false
  375. *
  376. * @param string $userId id of the user
  377. * @param string $app id of the app
  378. * @param string $key config key
  379. * @param bool|null $lazy
  380. *
  381. * @return ValueType type of the value
  382. * @throws UnknownKeyException if config key is not known
  383. * @throws IncorrectTypeException if config value type is not known
  384. *
  385. * @experimental 31.0.0
  386. */
  387. public function getValueType(string $userId, string $app, string $key, ?bool $lazy = null): ValueType;
  388. /**
  389. * returns a bitflag related to config value
  390. *
  391. * **WARNING:** ignore lazy filtering, all config values are loaded from database
  392. * unless lazy is set to false
  393. *
  394. * @param string $userId id of the user
  395. * @param string $app id of the app
  396. * @param string $key config key
  397. * @param bool $lazy lazy loading
  398. *
  399. * @return int a bitflag in relation to the config value
  400. * @throws UnknownKeyException if config key is not known
  401. * @throws IncorrectTypeException if config value type is not known
  402. *
  403. * @experimental 31.0.0
  404. */
  405. public function getValueFlags(string $userId, string $app, string $key, bool $lazy = false): int;
  406. /**
  407. * Store a config key and its value in database
  408. *
  409. * If config key is already known with the exact same config value, the database is not updated.
  410. * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
  411. *
  412. * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
  413. *
  414. * @param string $userId id of the user
  415. * @param string $app id of the app
  416. * @param string $key config key
  417. * @param string $value config value
  418. * @param bool $sensitive if TRUE value will be hidden when listing config values.
  419. * @param bool $lazy set config as lazy loaded
  420. *
  421. * @return bool TRUE if value was different, therefor updated in database
  422. *
  423. * @experimental 31.0.0
  424. *
  425. * @see IUserConfig for explanation about lazy loading
  426. * @see setValueInt()
  427. * @see setValueFloat()
  428. * @see setValueBool()
  429. * @see setValueArray()
  430. */
  431. public function setValueString(string $userId, string $app, string $key, string $value, bool $lazy = false, int $flags = 0): bool;
  432. /**
  433. * Store a config key and its value in database
  434. *
  435. * When handling huge value around and/or above 2,147,483,647, a debug log will be generated
  436. * on 64bits system, as php int type reach its limit (and throw an exception) on 32bits when using huge numbers.
  437. *
  438. * When using huge numbers, it is advised to use {@see \OCP\Util::numericToNumber()} and {@see setValueString()}
  439. *
  440. * If config key is already known with the exact same config value, the database is not updated.
  441. * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
  442. *
  443. * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
  444. *
  445. * @param string $userId id of the user
  446. * @param string $app id of the app
  447. * @param string $key config key
  448. * @param int $value config value
  449. * @param bool $sensitive if TRUE value will be hidden when listing config values.
  450. * @param bool $lazy set config as lazy loaded
  451. *
  452. * @return bool TRUE if value was different, therefor updated in database
  453. *
  454. * @experimental 31.0.0
  455. *
  456. * @see IUserConfig for explanation about lazy loading
  457. * @see setValueString()
  458. * @see setValueFloat()
  459. * @see setValueBool()
  460. * @see setValueArray()
  461. */
  462. public function setValueInt(string $userId, string $app, string $key, int $value, bool $lazy = false, int $flags = 0): bool;
  463. /**
  464. * Store a config key and its value in database.
  465. *
  466. * If config key is already known with the exact same config value, the database is not updated.
  467. * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
  468. *
  469. * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
  470. *
  471. * @param string $userId id of the user
  472. * @param string $app id of the app
  473. * @param string $key config key
  474. * @param float $value config value
  475. * @param bool $sensitive if TRUE value will be hidden when listing config values.
  476. * @param bool $lazy set config as lazy loaded
  477. *
  478. * @return bool TRUE if value was different, therefor updated in database
  479. *
  480. * @experimental 31.0.0
  481. *
  482. * @see IUserConfig for explanation about lazy loading
  483. * @see setValueString()
  484. * @see setValueInt()
  485. * @see setValueBool()
  486. * @see setValueArray()
  487. */
  488. public function setValueFloat(string $userId, string $app, string $key, float $value, bool $lazy = false, int $flags = 0): bool;
  489. /**
  490. * Store a config key and its value in database
  491. *
  492. * If config key is already known with the exact same config value, the database is not updated.
  493. * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
  494. *
  495. * If config value was previously stored as lazy loaded, status cannot be altered without using {@see deleteKey()} first
  496. *
  497. * @param string $userId id of the user
  498. * @param string $app id of the app
  499. * @param string $key config key
  500. * @param bool $value config value
  501. * @param bool $lazy set config as lazy loaded
  502. *
  503. * @return bool TRUE if value was different, therefor updated in database
  504. *
  505. * @experimental 31.0.0
  506. *
  507. * @see IUserConfig for explanation about lazy loading
  508. * @see setValueString()
  509. * @see setValueInt()
  510. * @see setValueFloat()
  511. * @see setValueArray()
  512. */
  513. public function setValueBool(string $userId, string $app, string $key, bool $value, bool $lazy = false): bool;
  514. /**
  515. * Store a config key and its value in database
  516. *
  517. * If config key is already known with the exact same config value, the database is not updated.
  518. * If config key is not supposed to be read during the boot of the cloud, it is advised to set it as lazy loaded.
  519. *
  520. * If config value was previously stored as sensitive or lazy loaded, status cannot be altered without using {@see deleteKey()} first
  521. *
  522. * @param string $userId id of the user
  523. * @param string $app id of the app
  524. * @param string $key config key
  525. * @param array $value config value
  526. * @param bool $sensitive if TRUE value will be hidden when listing config values.
  527. * @param bool $lazy set config as lazy loaded
  528. *
  529. * @return bool TRUE if value was different, therefor updated in database
  530. *
  531. * @experimental 31.0.0
  532. *
  533. * @see IUserConfig for explanation about lazy loading
  534. * @see setValueString()
  535. * @see setValueInt()
  536. * @see setValueFloat()
  537. * @see setValueBool()
  538. */
  539. public function setValueArray(string $userId, string $app, string $key, array $value, bool $lazy = false, int $flags = 0): bool;
  540. /**
  541. * switch sensitive status of a config value
  542. *
  543. * **WARNING:** ignore lazy filtering, all config values are loaded from database
  544. *
  545. * @param string $userId id of the user
  546. * @param string $app id of the app
  547. * @param string $key config key
  548. * @param bool $sensitive TRUE to set as sensitive, FALSE to unset
  549. *
  550. * @return bool TRUE if database update were necessary
  551. *
  552. * @experimental 31.0.0
  553. */
  554. public function updateSensitive(string $userId, string $app, string $key, bool $sensitive): bool;
  555. /**
  556. * switch sensitive loading status of a config key for all users
  557. *
  558. * **Warning:** heavy on resources, MUST only be used on occ command or migrations
  559. *
  560. * @param string $app id of the app
  561. * @param string $key config key
  562. * @param bool $sensitive TRUE to set as sensitive, FALSE to unset
  563. *
  564. * @experimental 31.0.0
  565. */
  566. public function updateGlobalSensitive(string $app, string $key, bool $sensitive): void;
  567. /**
  568. * switch indexed status of a config value
  569. *
  570. * **WARNING:** ignore lazy filtering, all config values are loaded from database
  571. *
  572. * @param string $userId id of the user
  573. * @param string $app id of the app
  574. * @param string $key config key
  575. * @param bool $indexed TRUE to set as indexed, FALSE to unset
  576. *
  577. * @return bool TRUE if database update were necessary
  578. *
  579. * @experimental 31.0.0
  580. */
  581. public function updateIndexed(string $userId, string $app, string $key, bool $indexed): bool;
  582. /**
  583. * switch sensitive loading status of a config key for all users
  584. *
  585. * **Warning:** heavy on resources, MUST only be used on occ command or migrations
  586. *
  587. * @param string $app id of the app
  588. * @param string $key config key
  589. * @param bool $indexed TRUE to set as indexed, FALSE to unset
  590. *
  591. * @experimental 31.0.0
  592. */
  593. public function updateGlobalIndexed(string $app, string $key, bool $indexed): void;
  594. /**
  595. * switch lazy loading status of a config value
  596. *
  597. * @param string $userId id of the user
  598. * @param string $app id of the app
  599. * @param string $key config key
  600. * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
  601. *
  602. * @return bool TRUE if database update was necessary
  603. *
  604. * @experimental 31.0.0
  605. */
  606. public function updateLazy(string $userId, string $app, string $key, bool $lazy): bool;
  607. /**
  608. * switch lazy loading status of a config key for all users
  609. *
  610. * **Warning:** heavy on resources, MUST only be used on occ command or migrations
  611. *
  612. * @param string $app id of the app
  613. * @param string $key config key
  614. * @param bool $lazy TRUE to set as lazy loaded, FALSE to unset
  615. *
  616. * @experimental 31.0.0
  617. */
  618. public function updateGlobalLazy(string $app, string $key, bool $lazy): void;
  619. /**
  620. * returns an array contains details about a config value
  621. *
  622. * ```
  623. * [
  624. * "app" => "myapp",
  625. * "key" => "mykey",
  626. * "value" => "its_value",
  627. * "lazy" => false,
  628. * "type" => 4,
  629. * "typeString" => "string",
  630. * 'sensitive' => true
  631. * ]
  632. * ```
  633. *
  634. * @param string $userId id of the user
  635. * @param string $app id of the app
  636. * @param string $key config key
  637. *
  638. * @return array
  639. * @throws UnknownKeyException if config key is not known in database
  640. *
  641. * @experimental 31.0.0
  642. */
  643. public function getDetails(string $userId, string $app, string $key): array;
  644. /**
  645. * Delete single config key from database.
  646. *
  647. * @param string $userId id of the user
  648. * @param string $app id of the app
  649. * @param string $key config key
  650. *
  651. * @experimental 31.0.0
  652. */
  653. public function deleteUserConfig(string $userId, string $app, string $key): void;
  654. /**
  655. * Delete config values from all users linked to a specific config keys
  656. *
  657. * @param string $app id of the app
  658. * @param string $key config key
  659. *
  660. * @experimental 31.0.0
  661. */
  662. public function deleteKey(string $app, string $key): void;
  663. /**
  664. * delete all config keys linked to an app
  665. *
  666. * @param string $app id of the app
  667. *
  668. * @experimental 31.0.0
  669. */
  670. public function deleteApp(string $app): void;
  671. /**
  672. * delete all config keys linked to a user
  673. *
  674. * @param string $userId id of the user
  675. *
  676. * @experimental 31.0.0
  677. */
  678. public function deleteAllUserConfig(string $userId): void;
  679. /**
  680. * Clear the cache for a single user
  681. *
  682. * The cache will be rebuilt only the next time a user config is requested.
  683. *
  684. * @param string $userId id of the user
  685. * @param bool $reload set to TRUE to refill cache instantly after clearing it
  686. *
  687. * @experimental 31.0.0
  688. */
  689. public function clearCache(string $userId, bool $reload = false): void;
  690. /**
  691. * Clear the cache for all users.
  692. * The cache will be rebuilt only the next time a user config is requested.
  693. *
  694. * @experimental 31.0.0
  695. */
  696. public function clearCacheAll(): void;
  697. }