connectionTester.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  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/rtorrent', function ($request, $response, $args) {
  204. /**
  205. * @OA\Post(
  206. * security={{ "api_key":{} }},
  207. * tags={"test connection"},
  208. * path="/api/v2/test/rtorrent",
  209. * summary="Test connection to rTorrent",
  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->testConnectionRTorrent($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/sonarr', function ($request, $response, $args) {
  226. /**
  227. * @OA\Post(
  228. * security={{ "api_key":{} }},
  229. * tags={"test connection"},
  230. * path="/api/v2/test/sonarr",
  231. * summary="Test connection to Sonarr",
  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->testConnectionSonarr($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/radarr', function ($request, $response, $args) {
  248. /**
  249. * @OA\Post(
  250. * security={{ "api_key":{} }},
  251. * tags={"test connection"},
  252. * path="/api/v2/test/radarr",
  253. * summary="Test connection to Radarr",
  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->testConnectionRadarr($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/lidarr', function ($request, $response, $args) {
  270. /**
  271. * @OA\Post(
  272. * security={{ "api_key":{} }},
  273. * tags={"test connection"},
  274. * path="/api/v2/test/lidarr",
  275. * summary="Test connection to Lidarr",
  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->testConnectionLidarr($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/sickrage', function ($request, $response, $args) {
  292. /**
  293. * @OA\Post(
  294. * security={{ "api_key":{} }},
  295. * tags={"test connection"},
  296. * path="/api/v2/test/sickrage",
  297. * summary="Test connection to SickRage",
  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->testConnectionSickRage($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/ombi', function ($request, $response, $args) {
  314. /**
  315. * @OA\Post(
  316. * security={{ "api_key":{} }},
  317. * tags={"test connection"},
  318. * path="/api/v2/test/ombi",
  319. * summary="Test connection to Ombi",
  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->testConnectionOmbi($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/nzbget', function ($request, $response, $args) {
  336. /**
  337. * @OA\Post(
  338. * security={{ "api_key":{} }},
  339. * tags={"test connection"},
  340. * path="/api/v2/test/nzbget",
  341. * summary="Test connection to NzbGet",
  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->testConnectionNZBGet($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/utorrent', function ($request, $response, $args) {
  358. /**
  359. * @OA\Post(
  360. * security={{ "api_key":{} }},
  361. * tags={"test connection"},
  362. * path="/api/v2/test/utorrent",
  363. * summary="Test connection to uTorrent",
  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="400",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->testConnectionuTorrent($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/deluge', function ($request, $response, $args) {
  380. /**
  381. * @OA\Post(
  382. * security={{ "api_key":{} }},
  383. * tags={"test connection"},
  384. * path="/api/v2/test/deluge",
  385. * summary="Test connection to Deluge",
  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->testConnectionDeluge($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/jdownloader', function ($request, $response, $args) {
  402. /**
  403. * @OA\Post(
  404. * security={{ "api_key":{} }},
  405. * tags={"test connection"},
  406. * path="/api/v2/test/jdownloader",
  407. * summary="Test connection to jDownloader",
  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="422",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->testConnectionJDownloader($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/transmission', function ($request, $response, $args) {
  424. /**
  425. * @OA\Post(
  426. * security={{ "api_key":{} }},
  427. * tags={"test connection"},
  428. * path="/api/v2/test/transmission",
  429. * summary="Test connection to Transmission",
  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->testConnectionTransmission($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/qbittorrent', function ($request, $response, $args) {
  446. /**
  447. * @OA\Post(
  448. * security={{ "api_key":{} }},
  449. * tags={"test connection"},
  450. * path="/api/v2/test/qbittorrent",
  451. * summary="Test connection to qBittorrent",
  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->testConnectionQBittorrent($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/unifi', function ($request, $response, $args) {
  468. /**
  469. * @OA\Post(
  470. * security={{ "api_key":{} }},
  471. * tags={"test connection"},
  472. * path="/api/v2/test/unifi",
  473. * summary="Test connection to Unifi",
  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->testConnectionUnifi($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/unifi/site', function ($request, $response, $args) {
  490. /**
  491. * @OA\Post(
  492. * security={{ "api_key":{} }},
  493. * tags={"test connection"},
  494. * path="/api/v2/test/unifi/site",
  495. * summary="Test connection to Unifi Sites",
  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->getUnifiSiteName($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/tautulli', function ($request, $response, $args) {
  512. /**
  513. * @OA\Post(
  514. * security={{ "api_key":{} }},
  515. * tags={"test connection"},
  516. * path="/api/v2/test/tautulli",
  517. * summary="Test connection to Tautulli",
  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->testConnectionTautulli($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. });