connectionTester.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. <?php
  2. /**
  3. * @OA\Tag(
  4. * name="test connection",
  5. * description="Test Connections"
  6. * )
  7. */
  8. $app->post('/test/ldap', function ($request, $response, $args) {
  9. /**
  10. * @OA\Post(
  11. * security={{ "api_key":{} }},
  12. * tags={"test connection"},
  13. * path="/api/v2/test/ldap",
  14. * summary="Test LDAP connection",
  15. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  16. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  17. * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  18. * @OA\Response(response="409",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  19. * )
  20. */
  21. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  22. if ($Organizr->qualifyRequest(1, true)) {
  23. $Organizr->testConnectionLdap();
  24. }
  25. $response->getBody()->write(jsonE($GLOBALS['api']));
  26. return $response
  27. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  28. ->withStatus($GLOBALS['responseCode']);
  29. });
  30. $app->post('/test/ldap/login', function ($request, $response, $args) {
  31. /**
  32. * @OA\Post(
  33. * security={{ "api_key":{} }},
  34. * tags={"test connection"},
  35. * path="/api/v2/test/ldap/login",
  36. * summary="Test LDAP connection using account login",
  37. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  38. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  39. * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  40. * @OA\Response(response="409",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  41. * )
  42. */
  43. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  44. if ($Organizr->qualifyRequest(1, true)) {
  45. $Organizr->testConnectionLdapLogin($Organizr->apiData($request));
  46. }
  47. $response->getBody()->write(jsonE($GLOBALS['api']));
  48. return $response
  49. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  50. ->withStatus($GLOBALS['responseCode']);
  51. });
  52. $app->post('/test/iframe', function ($request, $response, $args) {
  53. /**
  54. * @OA\Post(
  55. * security={{ "api_key":{} }},
  56. * tags={"test connection"},
  57. * path="/api/v2/test/iframe",
  58. * summary="Test if URL can be iFramed",
  59. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  60. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  61. * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  62. * @OA\Response(response="409",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  63. * )
  64. */
  65. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  66. if ($Organizr->qualifyRequest(1, true)) {
  67. $Organizr->frameTest($Organizr->apiData($request)['url']);
  68. }
  69. $response->getBody()->write(jsonE($GLOBALS['api']));
  70. return $response
  71. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  72. ->withStatus($GLOBALS['responseCode']);
  73. });
  74. $app->post('/test/path', function ($request, $response, $args) {
  75. /**
  76. * @OA\Post(
  77. * security={{ "api_key":{} }},
  78. * tags={"test connection"},
  79. * path="/api/v2/test/path",
  80. * summary="Test if path has correct permissions",
  81. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  82. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  83. * @OA\Response(response="404",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  84. * )
  85. */
  86. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  87. $Organizr->testWizardPath($Organizr->apiData($request));
  88. $response->getBody()->write(jsonE($GLOBALS['api']));
  89. return $response
  90. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  91. ->withStatus($GLOBALS['responseCode']);
  92. });
  93. $app->post('/test/plex', function ($request, $response, $args) {
  94. /**
  95. * @OA\Post(
  96. * security={{ "api_key":{} }},
  97. * tags={"test connection"},
  98. * path="/api/v2/test/plex",
  99. * summary="Test connection to Plex",
  100. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  101. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  102. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  103. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  104. * )
  105. */
  106. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  107. if ($Organizr->qualifyRequest(1, true)) {
  108. $Organizr->testConnectionPlex($Organizr->apiData($request));
  109. }
  110. $response->getBody()->write(jsonE($GLOBALS['api']));
  111. return $response
  112. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  113. ->withStatus($GLOBALS['responseCode']);
  114. });
  115. $app->post('/test/emby', function ($request, $response, $args) {
  116. /**
  117. * @OA\Post(
  118. * security={{ "api_key":{} }},
  119. * tags={"test connection"},
  120. * path="/api/v2/test/emby",
  121. * summary="Test connection to Emby",
  122. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  123. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  124. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  125. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  126. * )
  127. */
  128. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  129. if ($Organizr->qualifyRequest(1, true)) {
  130. $Organizr->testConnectionEmby($Organizr->apiData($request));
  131. }
  132. $response->getBody()->write(jsonE($GLOBALS['api']));
  133. return $response
  134. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  135. ->withStatus($GLOBALS['responseCode']);
  136. });
  137. $app->post('/test/jellyfin', function ($request, $response, $args) {
  138. /**
  139. * @OA\Post(
  140. * security={{ "api_key":{} }},
  141. * tags={"test connection"},
  142. * path="/api/v2/test/jellyfin",
  143. * summary="Test connection to Jellyfin",
  144. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  145. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  146. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  147. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  148. * )
  149. */
  150. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  151. if ($Organizr->qualifyRequest(1, true)) {
  152. $Organizr->testConnectionJellyfin($Organizr->apiData($request));
  153. }
  154. $response->getBody()->write(jsonE($GLOBALS['api']));
  155. return $response
  156. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  157. ->withStatus($GLOBALS['responseCode']);
  158. });
  159. $app->post('/test/sabnzbd', function ($request, $response, $args) {
  160. /**
  161. * @OA\Post(
  162. * security={{ "api_key":{} }},
  163. * tags={"test connection"},
  164. * path="/api/v2/test/sabnzbd",
  165. * summary="Test connection to SabNZBd",
  166. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  167. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  168. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  169. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  170. * )
  171. */
  172. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  173. if ($Organizr->qualifyRequest(1, true)) {
  174. $Organizr->testConnectionSabNZBd($Organizr->apiData($request));
  175. }
  176. $response->getBody()->write(jsonE($GLOBALS['api']));
  177. return $response
  178. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  179. ->withStatus($GLOBALS['responseCode']);
  180. });
  181. $app->post('/test/pihole', function ($request, $response, $args) {
  182. /**
  183. * @OA\Post(
  184. * security={{ "api_key":{} }},
  185. * tags={"test connection"},
  186. * path="/api/v2/test/pihole",
  187. * summary="Test connection to PiHole",
  188. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  189. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  190. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  191. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  192. * )
  193. */
  194. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  195. if ($Organizr->qualifyRequest(1, true)) {
  196. $Organizr->testConnectionPihole($Organizr->apiData($request));
  197. }
  198. $response->getBody()->write(jsonE($GLOBALS['api']));
  199. return $response
  200. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  201. ->withStatus($GLOBALS['responseCode']);
  202. });
  203. $app->post('/test/adguard', function ($request, $response, $args) {
  204. /**
  205. * @OA\Post(
  206. * security={{ "api_key":{} }},
  207. * tags={"test connection"},
  208. * path="/api/v2/test/adguard",
  209. * summary="Test connection to AdGuard",
  210. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  211. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  212. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  213. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  214. * )
  215. */
  216. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  217. if ($Organizr->qualifyRequest(1, true)) {
  218. $Organizr->testConnectionAdGuard($Organizr->apiData($request));
  219. }
  220. $response->getBody()->write(jsonE($GLOBALS['api']));
  221. return $response
  222. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  223. ->withStatus($GLOBALS['responseCode']);
  224. });
  225. $app->post('/test/rtorrent', function ($request, $response, $args) {
  226. /**
  227. * @OA\Post(
  228. * security={{ "api_key":{} }},
  229. * tags={"test connection"},
  230. * path="/api/v2/test/rtorrent",
  231. * summary="Test connection to rTorrent",
  232. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  233. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  234. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  235. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  236. * )
  237. */
  238. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  239. if ($Organizr->qualifyRequest(1, true)) {
  240. $Organizr->testConnectionRTorrent($Organizr->apiData($request));
  241. }
  242. $response->getBody()->write(jsonE($GLOBALS['api']));
  243. return $response
  244. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  245. ->withStatus($GLOBALS['responseCode']);
  246. });
  247. $app->post('/test/sonarr', function ($request, $response, $args) {
  248. /**
  249. * @OA\Post(
  250. * security={{ "api_key":{} }},
  251. * tags={"test connection"},
  252. * path="/api/v2/test/sonarr",
  253. * summary="Test connection to Sonarr",
  254. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  255. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  256. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  257. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  258. * )
  259. */
  260. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  261. if ($Organizr->qualifyRequest(1, true)) {
  262. $Organizr->testConnectionSonarr($Organizr->apiData($request));
  263. }
  264. $response->getBody()->write(jsonE($GLOBALS['api']));
  265. return $response
  266. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  267. ->withStatus($GLOBALS['responseCode']);
  268. });
  269. $app->post('/test/radarr', function ($request, $response, $args) {
  270. /**
  271. * @OA\Post(
  272. * security={{ "api_key":{} }},
  273. * tags={"test connection"},
  274. * path="/api/v2/test/radarr",
  275. * summary="Test connection to Radarr",
  276. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  277. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  278. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  279. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  280. * )
  281. */
  282. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  283. if ($Organizr->qualifyRequest(1, true)) {
  284. $Organizr->testConnectionRadarr($Organizr->apiData($request));
  285. }
  286. $response->getBody()->write(jsonE($GLOBALS['api']));
  287. return $response
  288. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  289. ->withStatus($GLOBALS['responseCode']);
  290. });
  291. $app->post('/test/lidarr', function ($request, $response, $args) {
  292. /**
  293. * @OA\Post(
  294. * security={{ "api_key":{} }},
  295. * tags={"test connection"},
  296. * path="/api/v2/test/lidarr",
  297. * summary="Test connection to Lidarr",
  298. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  299. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  300. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  301. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  302. * )
  303. */
  304. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  305. if ($Organizr->qualifyRequest(1, true)) {
  306. $Organizr->testConnectionLidarr($Organizr->apiData($request));
  307. }
  308. $response->getBody()->write(jsonE($GLOBALS['api']));
  309. return $response
  310. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  311. ->withStatus($GLOBALS['responseCode']);
  312. });
  313. $app->post('/test/sickrage', function ($request, $response, $args) {
  314. /**
  315. * @OA\Post(
  316. * security={{ "api_key":{} }},
  317. * tags={"test connection"},
  318. * path="/api/v2/test/sickrage",
  319. * summary="Test connection to SickRage",
  320. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  321. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  322. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  323. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  324. * )
  325. */
  326. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  327. if ($Organizr->qualifyRequest(1, true)) {
  328. $Organizr->testConnectionSickRage($Organizr->apiData($request));
  329. }
  330. $response->getBody()->write(jsonE($GLOBALS['api']));
  331. return $response
  332. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  333. ->withStatus($GLOBALS['responseCode']);
  334. });
  335. $app->post('/test/ombi', function ($request, $response, $args) {
  336. /**
  337. * @OA\Post(
  338. * security={{ "api_key":{} }},
  339. * tags={"test connection"},
  340. * path="/api/v2/test/ombi",
  341. * summary="Test connection to Ombi",
  342. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  343. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  344. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  345. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  346. * )
  347. */
  348. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  349. if ($Organizr->qualifyRequest(1, true)) {
  350. $Organizr->testConnectionOmbi($Organizr->apiData($request));
  351. }
  352. $response->getBody()->write(jsonE($GLOBALS['api']));
  353. return $response
  354. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  355. ->withStatus($GLOBALS['responseCode']);
  356. });
  357. $app->post('/test/overseerr', function ($request, $response, $args) {
  358. /**
  359. * @OA\Post(
  360. * security={{ "api_key":{} }},
  361. * tags={"test connection"},
  362. * path="/api/v2/test/overseerr",
  363. * summary="Test connection to Overseerr",
  364. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  365. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  366. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  367. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  368. * )
  369. */
  370. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  371. if ($Organizr->qualifyRequest(1, true)) {
  372. $Organizr->testConnectionOverseerr($Organizr->apiData($request));
  373. }
  374. $response->getBody()->write(jsonE($GLOBALS['api']));
  375. return $response
  376. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  377. ->withStatus($GLOBALS['responseCode']);
  378. });
  379. $app->post('/test/nzbget', function ($request, $response, $args) {
  380. /**
  381. * @OA\Post(
  382. * security={{ "api_key":{} }},
  383. * tags={"test connection"},
  384. * path="/api/v2/test/nzbget",
  385. * summary="Test connection to NzbGet",
  386. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  387. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  388. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  389. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  390. * )
  391. */
  392. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  393. if ($Organizr->qualifyRequest(1, true)) {
  394. $Organizr->testConnectionNZBGet($Organizr->apiData($request));
  395. }
  396. $response->getBody()->write(jsonE($GLOBALS['api']));
  397. return $response
  398. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  399. ->withStatus($GLOBALS['responseCode']);
  400. });
  401. $app->post('/test/utorrent', function ($request, $response, $args) {
  402. /**
  403. * @OA\Post(
  404. * security={{ "api_key":{} }},
  405. * tags={"test connection"},
  406. * path="/api/v2/test/utorrent",
  407. * summary="Test connection to uTorrent",
  408. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  409. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  410. * @OA\Response(response="400",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  411. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  412. * )
  413. */
  414. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  415. if ($Organizr->qualifyRequest(1, true)) {
  416. $Organizr->testConnectionuTorrent($Organizr->apiData($request));
  417. }
  418. $response->getBody()->write(jsonE($GLOBALS['api']));
  419. return $response
  420. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  421. ->withStatus($GLOBALS['responseCode']);
  422. });
  423. $app->post('/test/deluge', function ($request, $response, $args) {
  424. /**
  425. * @OA\Post(
  426. * security={{ "api_key":{} }},
  427. * tags={"test connection"},
  428. * path="/api/v2/test/deluge",
  429. * summary="Test connection to Deluge",
  430. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  431. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  432. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  433. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  434. * )
  435. */
  436. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  437. if ($Organizr->qualifyRequest(1, true)) {
  438. $Organizr->testConnectionDeluge($Organizr->apiData($request));
  439. }
  440. $response->getBody()->write(jsonE($GLOBALS['api']));
  441. return $response
  442. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  443. ->withStatus($GLOBALS['responseCode']);
  444. });
  445. $app->post('/test/jdownloader', function ($request, $response, $args) {
  446. /**
  447. * @OA\Post(
  448. * security={{ "api_key":{} }},
  449. * tags={"test connection"},
  450. * path="/api/v2/test/jdownloader",
  451. * summary="Test connection to jDownloader",
  452. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  453. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  454. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  455. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  456. * )
  457. */
  458. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  459. if ($Organizr->qualifyRequest(1, true)) {
  460. $Organizr->testConnectionJDownloader($Organizr->apiData($request));
  461. }
  462. $response->getBody()->write(jsonE($GLOBALS['api']));
  463. return $response
  464. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  465. ->withStatus($GLOBALS['responseCode']);
  466. });
  467. $app->post('/test/transmission', function ($request, $response, $args) {
  468. /**
  469. * @OA\Post(
  470. * security={{ "api_key":{} }},
  471. * tags={"test connection"},
  472. * path="/api/v2/test/transmission",
  473. * summary="Test connection to Transmission",
  474. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  475. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  476. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  477. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  478. * )
  479. */
  480. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  481. if ($Organizr->qualifyRequest(1, true)) {
  482. $Organizr->testConnectionTransmission($Organizr->apiData($request));
  483. }
  484. $response->getBody()->write(jsonE($GLOBALS['api']));
  485. return $response
  486. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  487. ->withStatus($GLOBALS['responseCode']);
  488. });
  489. $app->post('/test/qbittorrent', function ($request, $response, $args) {
  490. /**
  491. * @OA\Post(
  492. * security={{ "api_key":{} }},
  493. * tags={"test connection"},
  494. * path="/api/v2/test/qbittorrent",
  495. * summary="Test connection to qBittorrent",
  496. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  497. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  498. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  499. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  500. * )
  501. */
  502. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  503. if ($Organizr->qualifyRequest(1, true)) {
  504. $Organizr->testConnectionQBittorrent($Organizr->apiData($request));
  505. }
  506. $response->getBody()->write(jsonE($GLOBALS['api']));
  507. return $response
  508. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  509. ->withStatus($GLOBALS['responseCode']);
  510. });
  511. $app->post('/test/unifi', function ($request, $response, $args) {
  512. /**
  513. * @OA\Post(
  514. * security={{ "api_key":{} }},
  515. * tags={"test connection"},
  516. * path="/api/v2/test/unifi",
  517. * summary="Test connection to Unifi",
  518. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  519. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  520. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  521. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  522. * )
  523. */
  524. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  525. if ($Organizr->qualifyRequest(1, true)) {
  526. $Organizr->testConnectionUnifi($Organizr->apiData($request));
  527. }
  528. $response->getBody()->write(jsonE($GLOBALS['api']));
  529. return $response
  530. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  531. ->withStatus($GLOBALS['responseCode']);
  532. });
  533. $app->post('/test/unifi/site', function ($request, $response, $args) {
  534. /**
  535. * @OA\Post(
  536. * security={{ "api_key":{} }},
  537. * tags={"test connection"},
  538. * path="/api/v2/test/unifi/site",
  539. * summary="Test connection to Unifi Sites",
  540. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  541. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  542. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  543. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  544. * )
  545. */
  546. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  547. if ($Organizr->qualifyRequest(1, true)) {
  548. $Organizr->getUnifiSiteName($Organizr->apiData($request));
  549. }
  550. $response->getBody()->write(jsonE($GLOBALS['api']));
  551. return $response
  552. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  553. ->withStatus($GLOBALS['responseCode']);
  554. });
  555. $app->post('/test/tautulli', function ($request, $response, $args) {
  556. /**
  557. * @OA\Post(
  558. * security={{ "api_key":{} }},
  559. * tags={"test connection"},
  560. * path="/api/v2/test/tautulli",
  561. * summary="Test connection to Tautulli",
  562. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  563. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  564. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  565. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  566. * )
  567. */
  568. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  569. if ($Organizr->qualifyRequest(1, true)) {
  570. $Organizr->testConnectionTautulli($Organizr->apiData($request));
  571. }
  572. $response->getBody()->write(jsonE($GLOBALS['api']));
  573. return $response
  574. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  575. ->withStatus($GLOBALS['responseCode']);
  576. });
  577. $app->post('/test/cron', function ($request, $response, $args) {
  578. /**
  579. * @OA\Post(
  580. * security={{ "api_key":{} }},
  581. * tags={"test connection"},
  582. * path="/api/v2/test/cron",
  583. * summary="Test cron schedule",
  584. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  585. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  586. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  587. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  588. * )
  589. */
  590. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  591. if ($Organizr->qualifyRequest(1, true)) {
  592. $Organizr->testCronSchedule($Organizr->apiData($request));
  593. }
  594. $response->getBody()->write(jsonE($GLOBALS['api']));
  595. return $response
  596. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  597. ->withStatus($GLOBALS['responseCode']);
  598. });
  599. $app->get('/test/cron', function ($request, $response, $args) {
  600. /**
  601. * @OA\Get(
  602. * security={{ "api_key":{} }},
  603. * tags={"test connection"},
  604. * path="/api/v2/test/cron",
  605. * summary="Test if cron is setup correctly",
  606. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  607. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  608. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  609. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  610. * )
  611. */
  612. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  613. if ($Organizr->qualifyRequest(1, true)) {
  614. $file = $Organizr->checkCronFile();
  615. if ($file) {
  616. $Organizr->setResponse(200, 'Cron file is setup');
  617. } else {
  618. $Organizr->setResponse(500, 'Cron file is not setup correctly');
  619. }
  620. }
  621. $response->getBody()->write(jsonE($GLOBALS['api']));
  622. return $response
  623. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  624. ->withStatus($GLOBALS['responseCode']);
  625. });
  626. $app->post('/test/folder', function ($request, $response, $args) {
  627. /**
  628. * @OA\Post(
  629. * security={{ "api_key":{} }},
  630. * tags={"test connection"},
  631. * path="/api/v2/test/folder",
  632. * summary="Test folder path",
  633. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  634. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  635. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  636. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  637. * )
  638. */
  639. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  640. if ($Organizr->qualifyRequest(1, true)) {
  641. $Organizr->testFolder($Organizr->apiData($request));
  642. }
  643. $response->getBody()->write(jsonE($GLOBALS['api']));
  644. return $response
  645. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  646. ->withStatus($GLOBALS['responseCode']);
  647. });
  648. $app->post('/test/database', function ($request, $response, $args) {
  649. /**
  650. * @OA\Post(
  651. * security={{ "api_key":{} }},
  652. * tags={"test connection"},
  653. * path="/api/v2/test/database",
  654. * summary="Test Database connection",
  655. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  656. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  657. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  658. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  659. * )
  660. */
  661. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  662. if ($Organizr->qualifyRequest(1, true) || !$Organizr->hasConfig()) {
  663. $Organizr->testDatabaseConnection($Organizr->apiData($request));
  664. }
  665. $response->getBody()->write(jsonE($GLOBALS['api']));
  666. return $response
  667. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  668. ->withStatus($GLOBALS['responseCode']);
  669. });
  670. $app->post('/test/jackett', function ($request, $response, $args) {
  671. /**
  672. * @OA\Post(
  673. * security={{ "api_key":{} }},
  674. * tags={"test connection"},
  675. * path="/api/v2/test/jackett",
  676. * summary="Test connection to Jackett",
  677. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  678. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  679. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  680. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  681. * )
  682. */
  683. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  684. if ($Organizr->qualifyRequest(1, true)) {
  685. $Organizr->testConnectionJackett();
  686. }
  687. $response->getBody()->write(jsonE($GLOBALS['api']));
  688. return $response
  689. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  690. ->withStatus($GLOBALS['responseCode']);
  691. });
  692. $app->post('/test/prowlarr', function ($request, $response, $args) {
  693. /**
  694. * @OA\Post(
  695. * security={{ "api_key":{} }},
  696. * tags={"test connection"},
  697. * path="/api/v2/test/prowlarr",
  698. * summary="Test connection to prowlarr",
  699. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  700. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  701. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  702. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  703. * )
  704. */
  705. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  706. if ($Organizr->qualifyRequest(1, true)) {
  707. $Organizr->testConnectionProwlarr();
  708. }
  709. $response->getBody()->write(jsonE($GLOBALS['api']));
  710. return $response
  711. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  712. ->withStatus($GLOBALS['responseCode']);
  713. });
  714. $app->post('/test/slack-logs', function ($request, $response, $args) {
  715. /**
  716. * @OA\Post(
  717. * security={{ "api_key":{} }},
  718. * tags={"test connection"},
  719. * path="/api/v2/test/slack-logs",
  720. * summary="Test connection to Slack/Discord",
  721. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  722. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  723. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  724. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  725. * )
  726. */
  727. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  728. if ($Organizr->qualifyRequest(1, true)) {
  729. $Organizr->testConnectionSlackLogs();
  730. }
  731. $response->getBody()->write(jsonE($GLOBALS['api']));
  732. return $response
  733. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  734. ->withStatus($GLOBALS['responseCode']);
  735. });