app.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. use Silex\Application;
  3. use Silex\Provider\AssetServiceProvider;
  4. use Silex\Provider\HttpFragmentServiceProvider;
  5. use Silex\Provider\ServiceControllerServiceProvider;
  6. use Silex\Provider\TwigServiceProvider;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. $app = new Application();
  10. $app->register(new ServiceControllerServiceProvider());
  11. $app->register(new AssetServiceProvider());
  12. $app->register(new TwigServiceProvider());
  13. $app->register(new HttpFragmentServiceProvider());
  14. $app->register(new HttpFragmentServiceProvider());
  15. //$app['twig'] = $app->extend('twig', function ($twig, $app) {
  16. // return $twig;
  17. //});
  18. // se muestra el readme.
  19. $app->get('/docs', function () {
  20. $file = file_get_contents("./docs/READMEv1.md");
  21. $Parsedown = new Parsedown();
  22. return $Parsedown->text($file);
  23. });
  24. // captura todos los options y responde con un 200 para que despues haga la peticion correcta.
  25. $app->options("/{anything}", function () {
  26. return new Response("", 200);
  27. })->assert("anything", ".*");
  28. // escribo el encabezado para evitar el cors
  29. $app->after(function (Request $req, Response $resp) {
  30. $resp->headers->set('Access-Control-Allow-Credentials', 'true');
  31. $resp->headers->set('Access-Control-Allow-Headers', 'Origin, Content-Type, Accept, Authorization');
  32. $resp->headers->set('Access-Control-Allow-Origin', '*');
  33. $resp->headers->set('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE, PATCH, OPTIONS');
  34. });
  35. $base = new \Swagger\Client\Base\Services();
  36. $base->getTenancyId($app);
  37. $base->getTenancies($app);
  38. $base->getClientId($app);
  39. $base->getClients($app);
  40. $base->postClient($app);
  41. $base->putClient($app);
  42. $base->deleteClient($app);
  43. $base->getClientActive($app);
  44. $base->getClientDisable($app);
  45. $ftth = new \Swagger\Client\FTTH\Services();
  46. $ftth->getNAPId($app);
  47. $ftth->getNAPs($app);
  48. $ftth->getOLTId($app);
  49. $ftth->getOLTs($app);
  50. $ftth->getONUModelId($app);
  51. $ftth->getONUModels($app);
  52. $ftth->getOLTModelId($app);
  53. $ftth->getOLTModels($app);
  54. $ftth->getONUProfileId($app);
  55. $ftth->getONUProfiles($app);
  56. $ftth->getVLanProfileId($app);
  57. $ftth->getVLanProfiles($app);
  58. $ftth->getONUTemplateId($app);
  59. $ftth->getONUTemplates($app);
  60. $ftth->getTContProfileId($app);
  61. $ftth->getTContProfiles($app);
  62. $ftth->getTrafficProfileId($app);
  63. $ftth->getTrafficProfiles($app);
  64. $ftth->getVLanIDId($app);
  65. $ftth->getVLanIDs($app);
  66. $ftth->getProfileId($app);
  67. $ftth->getProfiles($app);
  68. $ftth->getONUId($app);
  69. $ftth->getONUs($app);
  70. $ftth->postONU($app);
  71. $ftth->putONU($app);
  72. $ftth->deleteONU($app);
  73. $ftth->getONUActive($app);
  74. $ftth->getONUSuspend($app);
  75. $ftth->getONUEnable($app);
  76. $ftth->getONUDisable($app);
  77. $ftth->getONUSupply($app);
  78. $cablemodem = new \Swagger\Client\Cablemodem\Services();
  79. $cablemodem->getNodeId($app);
  80. $cablemodem->getNodes($app);
  81. $cablemodem->getModelId($app);
  82. $cablemodem->getModels($app);
  83. $cablemodem->getProfileId($app);
  84. $cablemodem->getProfiles($app);
  85. $cablemodem->getCablemodemId($app);
  86. $cablemodem->getCablemodems($app);
  87. $cablemodem->postCablemodem($app);
  88. $cablemodem->putCablemodem($app);
  89. $cablemodem->deleteCablemodem($app);
  90. $cablemodem->getCablemodemActive($app);
  91. $cablemodem->getCablemodemDisable($app);
  92. $cablemodem->getCablemodemSupply($app);
  93. $radius = new \Swagger\Client\Radius\Services();
  94. $radius->getProfileId($app);
  95. $radius->getProfiles($app);
  96. $radius->getAccessId($app);
  97. $radius->getAccesses($app);
  98. $radius->postAccess($app);
  99. $radius->putAccess($app);
  100. $radius->deleteAccess($app);
  101. $app->flush();
  102. return $app;
  103. ?>