connectionTester.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  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/embyLiveTVTracker', function ($request, $response, $args) {
  138. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  139. if ($Organizr->qualifyRequest(1, true)) {
  140. $Organizr->testConnectionEmbyLiveTVTracker($Organizr->apiData($request));
  141. }
  142. $response->getBody()->write(jsonE($GLOBALS['api']));
  143. return $response
  144. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  145. ->withStatus($GLOBALS['responseCode']);
  146. });
  147. $app->post('/test/jellyfin', function ($request, $response, $args) {
  148. /**
  149. * @OA\Post(
  150. * security={{ "api_key":{} }},
  151. * tags={"test connection"},
  152. * path="/api/v2/test/jellyfin",
  153. * summary="Test connection to Jellyfin",
  154. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  155. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  156. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  157. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  158. * )
  159. */
  160. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  161. if ($Organizr->qualifyRequest(1, true)) {
  162. $Organizr->testConnectionJellyfin($Organizr->apiData($request));
  163. }
  164. $response->getBody()->write(jsonE($GLOBALS['api']));
  165. return $response
  166. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  167. ->withStatus($GLOBALS['responseCode']);
  168. });
  169. $app->post('/test/sabnzbd', function ($request, $response, $args) {
  170. /**
  171. * @OA\Post(
  172. * security={{ "api_key":{} }},
  173. * tags={"test connection"},
  174. * path="/api/v2/test/sabnzbd",
  175. * summary="Test connection to SabNZBd",
  176. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  177. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  178. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  179. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  180. * )
  181. */
  182. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  183. if ($Organizr->qualifyRequest(1, true)) {
  184. $Organizr->testConnectionSabNZBd($Organizr->apiData($request));
  185. }
  186. $response->getBody()->write(jsonE($GLOBALS['api']));
  187. return $response
  188. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  189. ->withStatus($GLOBALS['responseCode']);
  190. });
  191. $app->post('/test/pihole', function ($request, $response, $args) {
  192. /**
  193. * @OA\Post(
  194. * security={{ "api_key":{} }},
  195. * tags={"test connection"},
  196. * path="/api/v2/test/pihole",
  197. * summary="Test connection to PiHole",
  198. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  199. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  200. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  201. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  202. * )
  203. */
  204. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  205. if ($Organizr->qualifyRequest(1, true)) {
  206. $Organizr->testConnectionPihole($Organizr->apiData($request));
  207. }
  208. $response->getBody()->write(jsonE($GLOBALS['api']));
  209. return $response
  210. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  211. ->withStatus($GLOBALS['responseCode']);
  212. });
  213. $app->post('/test/adguard', function ($request, $response, $args) {
  214. /**
  215. * @OA\Post(
  216. * security={{ "api_key":{} }},
  217. * tags={"test connection"},
  218. * path="/api/v2/test/adguard",
  219. * summary="Test connection to AdGuard",
  220. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  221. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  222. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  223. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  224. * )
  225. */
  226. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  227. if ($Organizr->qualifyRequest(1, true)) {
  228. $Organizr->testConnectionAdGuard($Organizr->apiData($request));
  229. }
  230. $response->getBody()->write(jsonE($GLOBALS['api']));
  231. return $response
  232. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  233. ->withStatus($GLOBALS['responseCode']);
  234. });
  235. $app->post('/test/rtorrent', function ($request, $response, $args) {
  236. /**
  237. * @OA\Post(
  238. * security={{ "api_key":{} }},
  239. * tags={"test connection"},
  240. * path="/api/v2/test/rtorrent",
  241. * summary="Test connection to rTorrent",
  242. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  243. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  244. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  245. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  246. * )
  247. */
  248. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  249. if ($Organizr->qualifyRequest(1, true)) {
  250. $Organizr->testConnectionRTorrent($Organizr->apiData($request));
  251. }
  252. $response->getBody()->write(jsonE($GLOBALS['api']));
  253. return $response
  254. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  255. ->withStatus($GLOBALS['responseCode']);
  256. });
  257. $app->post('/test/sonarr', function ($request, $response, $args) {
  258. /**
  259. * @OA\Post(
  260. * security={{ "api_key":{} }},
  261. * tags={"test connection"},
  262. * path="/api/v2/test/sonarr",
  263. * summary="Test connection to Sonarr",
  264. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  265. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  266. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  267. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  268. * )
  269. */
  270. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  271. if ($Organizr->qualifyRequest(1, true)) {
  272. $Organizr->testConnectionSonarr($Organizr->apiData($request));
  273. }
  274. $response->getBody()->write(jsonE($GLOBALS['api']));
  275. return $response
  276. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  277. ->withStatus($GLOBALS['responseCode']);
  278. });
  279. $app->post('/test/radarr', function ($request, $response, $args) {
  280. /**
  281. * @OA\Post(
  282. * security={{ "api_key":{} }},
  283. * tags={"test connection"},
  284. * path="/api/v2/test/radarr",
  285. * summary="Test connection to Radarr",
  286. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  287. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  288. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  289. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  290. * )
  291. */
  292. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  293. if ($Organizr->qualifyRequest(1, true)) {
  294. $Organizr->testConnectionRadarr($Organizr->apiData($request));
  295. }
  296. $response->getBody()->write(jsonE($GLOBALS['api']));
  297. return $response
  298. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  299. ->withStatus($GLOBALS['responseCode']);
  300. });
  301. $app->post('/test/lidarr', function ($request, $response, $args) {
  302. /**
  303. * @OA\Post(
  304. * security={{ "api_key":{} }},
  305. * tags={"test connection"},
  306. * path="/api/v2/test/lidarr",
  307. * summary="Test connection to Lidarr",
  308. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  309. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  310. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  311. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  312. * )
  313. */
  314. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  315. if ($Organizr->qualifyRequest(1, true)) {
  316. $Organizr->testConnectionLidarr($Organizr->apiData($request));
  317. }
  318. $response->getBody()->write(jsonE($GLOBALS['api']));
  319. return $response
  320. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  321. ->withStatus($GLOBALS['responseCode']);
  322. });
  323. $app->post('/test/sickrage', function ($request, $response, $args) {
  324. /**
  325. * @OA\Post(
  326. * security={{ "api_key":{} }},
  327. * tags={"test connection"},
  328. * path="/api/v2/test/sickrage",
  329. * summary="Test connection to SickRage",
  330. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  331. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  332. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  333. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  334. * )
  335. */
  336. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  337. if ($Organizr->qualifyRequest(1, true)) {
  338. $Organizr->testConnectionSickRage($Organizr->apiData($request));
  339. }
  340. $response->getBody()->write(jsonE($GLOBALS['api']));
  341. return $response
  342. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  343. ->withStatus($GLOBALS['responseCode']);
  344. });
  345. $app->post('/test/ombi', function ($request, $response, $args) {
  346. /**
  347. * @OA\Post(
  348. * security={{ "api_key":{} }},
  349. * tags={"test connection"},
  350. * path="/api/v2/test/ombi",
  351. * summary="Test connection to Ombi",
  352. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  353. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  354. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  355. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  356. * )
  357. */
  358. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  359. if ($Organizr->qualifyRequest(1, true)) {
  360. $Organizr->testConnectionOmbi($Organizr->apiData($request));
  361. }
  362. $response->getBody()->write(jsonE($GLOBALS['api']));
  363. return $response
  364. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  365. ->withStatus($GLOBALS['responseCode']);
  366. });
  367. $app->post('/test/overseerr', function ($request, $response, $args) {
  368. /**
  369. * @OA\Post(
  370. * security={{ "api_key":{} }},
  371. * tags={"test connection"},
  372. * path="/api/v2/test/overseerr",
  373. * summary="Test connection to Overseerr",
  374. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  375. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  376. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  377. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  378. * )
  379. */
  380. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  381. if ($Organizr->qualifyRequest(1, true)) {
  382. $Organizr->testConnectionOverseerr($Organizr->apiData($request));
  383. }
  384. $response->getBody()->write(jsonE($GLOBALS['api']));
  385. return $response
  386. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  387. ->withStatus($GLOBALS['responseCode']);
  388. });
  389. $app->post('/test/nzbget', function ($request, $response, $args) {
  390. /**
  391. * @OA\Post(
  392. * security={{ "api_key":{} }},
  393. * tags={"test connection"},
  394. * path="/api/v2/test/nzbget",
  395. * summary="Test connection to NzbGet",
  396. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  397. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  398. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  399. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  400. * )
  401. */
  402. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  403. if ($Organizr->qualifyRequest(1, true)) {
  404. $Organizr->testConnectionNZBGet($Organizr->apiData($request));
  405. }
  406. $response->getBody()->write(jsonE($GLOBALS['api']));
  407. return $response
  408. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  409. ->withStatus($GLOBALS['responseCode']);
  410. });
  411. $app->post('/test/utorrent', function ($request, $response, $args) {
  412. /**
  413. * @OA\Post(
  414. * security={{ "api_key":{} }},
  415. * tags={"test connection"},
  416. * path="/api/v2/test/utorrent",
  417. * summary="Test connection to uTorrent",
  418. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  419. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  420. * @OA\Response(response="400",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  421. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  422. * )
  423. */
  424. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  425. if ($Organizr->qualifyRequest(1, true)) {
  426. $Organizr->testConnectionuTorrent($Organizr->apiData($request));
  427. }
  428. $response->getBody()->write(jsonE($GLOBALS['api']));
  429. return $response
  430. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  431. ->withStatus($GLOBALS['responseCode']);
  432. });
  433. $app->post('/test/deluge', function ($request, $response, $args) {
  434. /**
  435. * @OA\Post(
  436. * security={{ "api_key":{} }},
  437. * tags={"test connection"},
  438. * path="/api/v2/test/deluge",
  439. * summary="Test connection to Deluge",
  440. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  441. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  442. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  443. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  444. * )
  445. */
  446. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  447. if ($Organizr->qualifyRequest(1, true)) {
  448. $Organizr->testConnectionDeluge($Organizr->apiData($request));
  449. }
  450. $response->getBody()->write(jsonE($GLOBALS['api']));
  451. return $response
  452. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  453. ->withStatus($GLOBALS['responseCode']);
  454. });
  455. $app->post('/test/jdownloader', function ($request, $response, $args) {
  456. /**
  457. * @OA\Post(
  458. * security={{ "api_key":{} }},
  459. * tags={"test connection"},
  460. * path="/api/v2/test/jdownloader",
  461. * summary="Test connection to jDownloader",
  462. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  463. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  464. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  465. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  466. * )
  467. */
  468. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  469. if ($Organizr->qualifyRequest(1, true)) {
  470. $Organizr->testConnectionJDownloader($Organizr->apiData($request));
  471. }
  472. $response->getBody()->write(jsonE($GLOBALS['api']));
  473. return $response
  474. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  475. ->withStatus($GLOBALS['responseCode']);
  476. });
  477. $app->post('/test/transmission', function ($request, $response, $args) {
  478. /**
  479. * @OA\Post(
  480. * security={{ "api_key":{} }},
  481. * tags={"test connection"},
  482. * path="/api/v2/test/transmission",
  483. * summary="Test connection to Transmission",
  484. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  485. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  486. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  487. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  488. * )
  489. */
  490. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  491. if ($Organizr->qualifyRequest(1, true)) {
  492. $Organizr->testConnectionTransmission($Organizr->apiData($request));
  493. }
  494. $response->getBody()->write(jsonE($GLOBALS['api']));
  495. return $response
  496. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  497. ->withStatus($GLOBALS['responseCode']);
  498. });
  499. $app->post('/test/qbittorrent', function ($request, $response, $args) {
  500. /**
  501. * @OA\Post(
  502. * security={{ "api_key":{} }},
  503. * tags={"test connection"},
  504. * path="/api/v2/test/qbittorrent",
  505. * summary="Test connection to qBittorrent",
  506. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  507. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  508. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  509. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  510. * )
  511. */
  512. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  513. if ($Organizr->qualifyRequest(1, true)) {
  514. $Organizr->testConnectionQBittorrent($Organizr->apiData($request));
  515. }
  516. $response->getBody()->write(jsonE($GLOBALS['api']));
  517. return $response
  518. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  519. ->withStatus($GLOBALS['responseCode']);
  520. });
  521. $app->post('/test/unifi', function ($request, $response, $args) {
  522. /**
  523. * @OA\Post(
  524. * security={{ "api_key":{} }},
  525. * tags={"test connection"},
  526. * path="/api/v2/test/unifi",
  527. * summary="Test connection to Unifi",
  528. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  529. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  530. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  531. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  532. * )
  533. */
  534. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  535. if ($Organizr->qualifyRequest(1, true)) {
  536. $Organizr->testConnectionUnifi($Organizr->apiData($request));
  537. }
  538. $response->getBody()->write(jsonE($GLOBALS['api']));
  539. return $response
  540. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  541. ->withStatus($GLOBALS['responseCode']);
  542. });
  543. $app->post('/test/unifi/site', function ($request, $response, $args) {
  544. /**
  545. * @OA\Post(
  546. * security={{ "api_key":{} }},
  547. * tags={"test connection"},
  548. * path="/api/v2/test/unifi/site",
  549. * summary="Test connection to Unifi Sites",
  550. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  551. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  552. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  553. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  554. * )
  555. */
  556. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  557. if ($Organizr->qualifyRequest(1, true)) {
  558. $Organizr->getUnifiSiteName($Organizr->apiData($request));
  559. }
  560. $response->getBody()->write(jsonE($GLOBALS['api']));
  561. return $response
  562. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  563. ->withStatus($GLOBALS['responseCode']);
  564. });
  565. $app->post('/test/tautulli', function ($request, $response, $args) {
  566. /**
  567. * @OA\Post(
  568. * security={{ "api_key":{} }},
  569. * tags={"test connection"},
  570. * path="/api/v2/test/tautulli",
  571. * summary="Test connection to Tautulli",
  572. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  573. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  574. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  575. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  576. * )
  577. */
  578. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  579. if ($Organizr->qualifyRequest(1, true)) {
  580. $Organizr->testConnectionTautulli($Organizr->apiData($request));
  581. }
  582. $response->getBody()->write(jsonE($GLOBALS['api']));
  583. return $response
  584. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  585. ->withStatus($GLOBALS['responseCode']);
  586. });
  587. $app->post('/test/cron', function ($request, $response, $args) {
  588. /**
  589. * @OA\Post(
  590. * security={{ "api_key":{} }},
  591. * tags={"test connection"},
  592. * path="/api/v2/test/cron",
  593. * summary="Test cron schedule",
  594. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  595. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  596. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  597. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  598. * )
  599. */
  600. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  601. if ($Organizr->qualifyRequest(1, true)) {
  602. $Organizr->testCronSchedule($Organizr->apiData($request));
  603. }
  604. $response->getBody()->write(jsonE($GLOBALS['api']));
  605. return $response
  606. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  607. ->withStatus($GLOBALS['responseCode']);
  608. });
  609. $app->get('/test/cron', function ($request, $response, $args) {
  610. /**
  611. * @OA\Get(
  612. * security={{ "api_key":{} }},
  613. * tags={"test connection"},
  614. * path="/api/v2/test/cron",
  615. * summary="Test if cron is setup correctly",
  616. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  617. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  618. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  619. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  620. * )
  621. */
  622. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  623. if ($Organizr->qualifyRequest(1, true)) {
  624. $file = $Organizr->checkCronFile();
  625. if ($file) {
  626. $Organizr->setResponse(200, 'Cron file is setup');
  627. } else {
  628. $Organizr->setResponse(500, 'Cron file is not setup correctly');
  629. }
  630. }
  631. $response->getBody()->write(jsonE($GLOBALS['api']));
  632. return $response
  633. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  634. ->withStatus($GLOBALS['responseCode']);
  635. });
  636. $app->post('/test/folder', function ($request, $response, $args) {
  637. /**
  638. * @OA\Post(
  639. * security={{ "api_key":{} }},
  640. * tags={"test connection"},
  641. * path="/api/v2/test/folder",
  642. * summary="Test folder path",
  643. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  644. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  645. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  646. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  647. * )
  648. */
  649. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  650. if ($Organizr->qualifyRequest(1, true)) {
  651. $Organizr->testFolder($Organizr->apiData($request));
  652. }
  653. $response->getBody()->write(jsonE($GLOBALS['api']));
  654. return $response
  655. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  656. ->withStatus($GLOBALS['responseCode']);
  657. });
  658. $app->post('/test/database', function ($request, $response, $args) {
  659. /**
  660. * @OA\Post(
  661. * security={{ "api_key":{} }},
  662. * tags={"test connection"},
  663. * path="/api/v2/test/database",
  664. * summary="Test Database connection",
  665. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  666. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  667. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  668. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  669. * )
  670. */
  671. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  672. if ($Organizr->qualifyRequest(1, true) || !$Organizr->hasConfig()) {
  673. $Organizr->testDatabaseConnection($Organizr->apiData($request));
  674. }
  675. $response->getBody()->write(jsonE($GLOBALS['api']));
  676. return $response
  677. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  678. ->withStatus($GLOBALS['responseCode']);
  679. });
  680. $app->post('/test/jackett', function ($request, $response, $args) {
  681. /**
  682. * @OA\Post(
  683. * security={{ "api_key":{} }},
  684. * tags={"test connection"},
  685. * path="/api/v2/test/jackett",
  686. * summary="Test connection to Jackett",
  687. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  688. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  689. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  690. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  691. * )
  692. */
  693. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  694. if ($Organizr->qualifyRequest(1, true)) {
  695. $Organizr->testConnectionJackett();
  696. }
  697. $response->getBody()->write(jsonE($GLOBALS['api']));
  698. return $response
  699. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  700. ->withStatus($GLOBALS['responseCode']);
  701. });
  702. $app->post('/test/prowlarr', function ($request, $response, $args) {
  703. /**
  704. * @OA\Post(
  705. * security={{ "api_key":{} }},
  706. * tags={"test connection"},
  707. * path="/api/v2/test/prowlarr",
  708. * summary="Test connection to prowlarr",
  709. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  710. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  711. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  712. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  713. * )
  714. */
  715. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  716. if ($Organizr->qualifyRequest(1, true)) {
  717. $Organizr->testConnectionProwlarr();
  718. }
  719. $response->getBody()->write(jsonE($GLOBALS['api']));
  720. return $response
  721. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  722. ->withStatus($GLOBALS['responseCode']);
  723. });
  724. $app->post('/test/slack-logs', function ($request, $response, $args) {
  725. /**
  726. * @OA\Post(
  727. * security={{ "api_key":{} }},
  728. * tags={"test connection"},
  729. * path="/api/v2/test/slack-logs",
  730. * summary="Test connection to Slack/Discord",
  731. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  732. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  733. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  734. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  735. * )
  736. */
  737. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  738. if ($Organizr->qualifyRequest(1, true)) {
  739. $Organizr->testConnectionSlackLogs();
  740. }
  741. $response->getBody()->write(jsonE($GLOBALS['api']));
  742. return $response
  743. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  744. ->withStatus($GLOBALS['responseCode']);
  745. });
  746. $app->post('/test/jellystat', function ($request, $response, $args) {
  747. /**
  748. * @OA\Post(
  749. * security={{ "api_key":{} }},
  750. * tags={"test connection"},
  751. * path="/api/v2/test/jellystat",
  752. * summary="Test connection to JellyStat",
  753. * @OA\Response(response="200",description="Success",@OA\JsonContent(ref="#/components/schemas/success-message")),
  754. * @OA\Response(response="401",description="Unauthorized",@OA\JsonContent(ref="#/components/schemas/unauthorized-message")),
  755. * @OA\Response(response="422",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  756. * @OA\Response(response="500",description="Error",@OA\JsonContent(ref="#/components/schemas/error-message")),
  757. * )
  758. */
  759. $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
  760. if ($Organizr->qualifyRequest(1, true)) {
  761. $Organizr->testConnectionJellyStat();
  762. }
  763. $response->getBody()->write(jsonE($GLOBALS['api']));
  764. return $response
  765. ->withHeader('Content-Type', 'application/json;charset=UTF-8')
  766. ->withStatus($GLOBALS['responseCode']);
  767. });