소스 검색

Ref #15 - Created new service, corrected a transitions name and added
more info in the service description.

Maximiliano Schvindt 6 년 전
부모
커밋
4d5b2f6527
2개의 변경된 파일42개의 추가작업 그리고 3개의 파일을 삭제
  1. 41 3
      src/Swagger/Client/FTTH/Services.php
  2. 1 0
      src/app.php

+ 41 - 3
src/Swagger/Client/FTTH/Services.php

@@ -1097,7 +1097,7 @@ class Services extends ApiServices
                 $ch = new Checks();
                 $id = $ch->integer($request, "id", true);
                 $workflow = "onu_workflow";
-                $transition = "disable_delete";
+                $transition = "disable_deleted";
                 $apiInstance->setDisabledTenancy(true);
                 $result = $apiInstance->getById($id);
                 $apiInstance->setDisabledTenancy(false);
@@ -1196,6 +1196,44 @@ class Services extends ApiServices
             return Utils::returnJSON($content, $codeResponse);
         });
     }
+    
+    public function getONUDeletedToActive(Application $app)
+    {
+        $app->get('/api/v1/ftth/onu/deletedToActive', function (Application $app, Request $request) {
+            $codeResponse = 400;
+            try {
+                $config = $this->setUserPasswordConfig($request, Configuration::getDefaultConfiguration());
+                $apiInstance = new ONUApi(
+                    new Client(),
+                    $config
+                );
+                $ch = new Checks();
+                $id = $ch->integer($request, "id", true);
+                $workflow = "onu_workflow";
+                $transition = "deleted_active";
+                $apiInstance->setDisabledTenancy(true);
+                $result = $apiInstance->getById($id);
+                $apiInstance->setDisabledTenancy(false);
+                if (!is_null($result)) {
+                    $apiInstance->apply($id, $workflow, $transition);
+                    $apiInstance->setDisabledTenancy(true);
+                    $result = $apiInstance->getById($id);
+                    $apiInstance->setDisabledTenancy(false);
+                    if ($result) {
+                        $content = $result->__toString();
+                        $codeResponse = 200;
+                    } else {
+                        $content = "No se pudo obtener el acceso cargado. Verifique por sistema si la carga se realizo correctamente.";
+                    }
+                } else {
+                    $content = "No se encontro la onu de id = " . $id;
+                }
+            } catch (Throwable $t) {
+                $content = $t->getCode() . " - " . $t->getMessage();
+            }
+            return Utils::returnJSON($content, $codeResponse);
+        });
+    }
 
     public function getONUSupply(Application $app)
     {
@@ -1221,7 +1259,7 @@ class Services extends ApiServices
                     "getPonSerialNumber");
                 if (is_null($result)) {
                     $apiInstance->setDisabledTenancy(true);
-                    $result = $apiInstance->getList(null, null, null, null, null, null, null, null, null, $ponSerialNumber);
+                    $result = $apiInstance->getList(null, null, null, null, null, null, null, null, null, null, $ponSerialNumber);
                     $apiInstance->setDisabledTenancy(false);
                     $result = $util->valueExistsLower($ponSerialNumber,
                         $result,
@@ -1229,7 +1267,7 @@ class Services extends ApiServices
                 }
                 if (is_null($result)) {
                     $apiInstance->setDisabledTenancy(true);
-                    $result = $apiInstance->getList(null, null, null, null, null, null, null, null, $ponSerialNumber);
+                    $result = $apiInstance->getList(null, null, null, null, null, null, null, null, null, $ponSerialNumber);
                     $apiInstance->setDisabledTenancy(false);
                     $result = $util->valueExistsLower($ponSerialNumber,
                         $result,

+ 1 - 0
src/app.php

@@ -79,6 +79,7 @@ $ftth->deleteONU($app);
 $ftth->getONUActive($app);
 $ftth->getONUSuspend($app);
 $ftth->getONUEnable($app);
+$ftth->getONUDeletedToActive($app);
 $ftth->getONUDisable($app);
 $ftth->getONUSupply($app);