From 66f44292da001c815e449f7c1536f13b661abdb5 Mon Sep 17 00:00:00 2001 From: PrasadhNanjundan Date: Mon, 3 Jun 2024 13:24:40 +0530 Subject: [PATCH] removing the php sdk method based on soap api + correcting wrong rest api paths --- Reference/Common/Library/customer_rest.php | 4 +- Reference/Common/Library/device_rest.php | 62 +------------------ Reference/Common/Library/lookup_rest.php | 17 ----- .../Common/Library/orchestration_rest.php | 21 ------- .../Common/Library/order_command_rest.php | 28 --------- .../Common/Library/widget_portal_rest.php | 59 ------------------ 6 files changed, 4 insertions(+), 187 deletions(-) delete mode 100755 Reference/Common/Library/widget_portal_rest.php diff --git a/Reference/Common/Library/customer_rest.php b/Reference/Common/Library/customer_rest.php index ed1a55a44..20a1c9264 100755 --- a/Reference/Common/Library/customer_rest.php +++ b/Reference/Common/Library/customer_rest.php @@ -189,7 +189,7 @@ function _customer_delete_configuration_variable ($customer_reference, $name) { */ function _customer_attach_profile ($customer_reference, $profile_reference) { - $msa_rest_api = "customer/reference/{$customer_reference}/attach?profile={$profile_reference}"; + $msa_rest_api = "customer/{$customer_reference}/attach?profile={$profile_reference}"; $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api); $response = perform_curl_operation($curl_cmd, "ATTACH A PROFILE TO CUSTOMER"); return $response; @@ -202,7 +202,7 @@ function _customer_attach_profile ($customer_reference, $profile_reference) { */ function _customer_detach_profile ($customer_reference, $profile_reference) { - $msa_rest_api = "customer/reference/{$customer_reference}/detach?profile={$profile_reference}"; + $msa_rest_api = "customer/{$customer_reference}/detach?profile={$profile_reference}"; $curl_cmd = create_msa_operation_request(OP_PUT, $msa_rest_api); $response = perform_curl_operation($curl_cmd, "DETACH A PROFILE FROM CUSTOMER"); return $response; diff --git a/Reference/Common/Library/device_rest.php b/Reference/Common/Library/device_rest.php index a84bde815..dde892973 100755 --- a/Reference/Common/Library/device_rest.php +++ b/Reference/Common/Library/device_rest.php @@ -195,7 +195,7 @@ function _device_set_hostname_by_id ($device_id, $hostname) { * @param $device_id */ function _device_get_nature_by_id ($device_id) { - $msa_rest_api = "device/v1/nature/{$device_id}"; + $msa_rest_api = "device/v1/nature/device/{$device_id}"; $curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api); $response = perform_curl_operation($curl_cmd, "READ DEVICE NATURE BY ID"); $response = json_decode($response, true); @@ -486,17 +486,6 @@ function _device_update_credentials ($device_id, $login, $password) { return $response; } - -function _device_do_update_firmware ($device_id) { - logToFile('[device_rest][do_update_firmware] update firmware on '.$device_id); - $api_cmd='/opt/ubi-jentreprise/bin/api/device/doFirmwareUpdateByDeviceId.sh '.$device_id; - logToFile("[device_rest][do_update_firmware] -> ".$api_cmd); - $res=shell_exec($api_cmd); - logToFile("[device_rest][do_update_firmware] ".$res); - return $res; -} - - /** * REST endpoint available in MSA NB : Update the firmware by rest * Put $option='REST-API' to run the firmware update on the device via rest API. CLI by default @@ -512,16 +501,6 @@ function _device_do_update_firmware_rest ($device_id, $option='') { return $response; } - -function _device_check_update_firmware ($device_id) { - logToFile('[device_rest][check_update_firmware] update firmware on '.$device_id); - $api_cmd='/opt/ubi-jentreprise/bin/api/device/getFirmwareUpdateStatusByDeviceId.sh '.$device_id; - logToFile("[device_rest][check_update_firmware] -> ".$api_cmd); - $res=shell_exec($api_cmd); - logToFile("[device_rest][check_update_firmware] ".$res); - return $res; -} - /** * REST endpoint available in MSA NB : Get the update firmware status by rest * ex: @@ -537,43 +516,6 @@ function _device_check_update_firmware_rest ($device_id) { return $response; } - -function _device_create_configure_variable ($device_id, $variablename, $variablevalue) { - logToFile('[device_rest][create_configure_variable] Add variable '.$variablename.' ('.$variablevalue.') to '.$device_id); - $api_cmd='/opt/ubi-jentreprise/bin/api/deviceconfigurationvariable/createConfigurationVariable.sh '.$device_id.' '.$variablename.' '.$variablevalue; - logToFile("[device_rest][create_configure_variable] -> ".$api_cmd); - $res=shell_exec($api_cmd); - logToFile("[device_rest][create_configure_variable] ".$res); - return $res; -} - -function _device_rollback_do_backup ($device_id) { - logToFile('[device_rest][rollback_do_backup] Backup device '.$device_id); - $api_cmd='/opt/ubi-jentreprise/bin/api/rollback/doBackup.sh '.$device_id; - logToFile("[device_rest][rollback_do_backup] -> ".$api_cmd); - $res=shell_exec($api_cmd); - logToFile("[device_rest][rollback_do_backup] ".$res); - return $res; -} - -function _device_rollback_list_revision ($device_id) { - logToFile('[device_rest][rollback_list_revision] List revision for device '.$device_id); - $api_cmd='/opt/ubi-jentreprise/bin/api/rollback/doListRevisions.sh '.$device_id; - logToFile("[device_rest][rollback_list_revision] -> ".$api_cmd); - $res=shell_exec($api_cmd); - logToFile("[device_rest][rollback_list_revision] ".$res); - return $res; -} - -function _device_rollback_do_restore ($device_id, $revision_id) { - logToFile('[device_rest][rollback_do_restore] Restore device '.$device_id.' using revision '.$revision_id); - $api_cmd='/opt/ubi-jentreprise/bin/api/rollback/doRestore.sh '.$device_id.' '.$revision_id; - logToFile("[device_rest][rollback_do_restore] -> ".$api_cmd); - $res=shell_exec($api_cmd); - logToFile("[device_rest][rollback_do_restore] ".$res); - return $res; -} - /** * Get devices list by customer (customerId integer) * @@ -585,7 +527,7 @@ function _device_rollback_do_restore ($device_id, $revision_id) { * $response */ function _device_get_by_customer ($customerId) { - $msa_rest_api = "lookup/v1/customers/{$customerId}/devices"; + $msa_rest_api = "lookup/v1/customer/{$customerId}/devices"; $curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api); $response = perform_curl_operation($curl_cmd, "GET DEVICES BY CUSTOMER"); return $response; diff --git a/Reference/Common/Library/lookup_rest.php b/Reference/Common/Library/lookup_rest.php index 8e6c0691b..fe69c8191 100755 --- a/Reference/Common/Library/lookup_rest.php +++ b/Reference/Common/Library/lookup_rest.php @@ -93,22 +93,5 @@ function _lookup_list_operator_ids ($manager_id) { return $response; } -/** - * List SecEngine Nodes - * - * curl -u ncroot:ubiqube -XGET http://localhost:10080/ubi-api-rest/lookup/sec_nodes - */ -function _lookup_list_sec_nodes () { - $msa_rest_api = "lookup/sec_nodes"; - $curl_cmd = create_msa_operation_request(OP_GET, $msa_rest_api); - $response = perform_curl_operation($curl_cmd, "LIST SEC NODES"); - $response = json_decode($response, true); - if ($response['wo_status'] !== ENDED) { - $response = json_encode($response); - return $response; - } - $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); - return $response; -} ?> \ No newline at end of file diff --git a/Reference/Common/Library/orchestration_rest.php b/Reference/Common/Library/orchestration_rest.php index 8cfbdae94..7834893d1 100755 --- a/Reference/Common/Library/orchestration_rest.php +++ b/Reference/Common/Library/orchestration_rest.php @@ -184,27 +184,6 @@ function _orchestration_execute_service_by_instance ($ubiqube_id, $service_insta return $response; } -/** - curl -u ncroot:ubiqube -XPOST http://localhost:10080/ubi-api-rest/orchestration/service/execute/{ubiqubeId}?serviceName={serviceName}&processName={processName} -d ' - { - "var1": "val1", - "var2": "val2" - } - ' - */ -function _orchestration_launch_sub_process ($ubiqube_id, $service_instance, $service_name, $process_name, $json_body = "{}") { - $msa_rest_api = "orchestration/subprocess/execute/{$ubiqube_id}?serviceName={$service_name}&processName={$process_name}&serviceInstance={$service_instance}"; - $curl_cmd = create_msa_operation_request(OP_POST, $msa_rest_api, $json_body); - $response = perform_curl_operation($curl_cmd, "EXECUTE SERVICE"); - $response = json_decode($response, true); - if ($response['wo_status'] !== ENDED) { - $response = json_encode($response); - return $response; - } - $response = prepare_json_response(ENDED, ENDED_SUCCESSFULLY, $response['wo_newparams']['response_body']); - return $response; -} - /** * curl -u ncroot:ubiqube -XPOST http://localhost:10080/ubi-api-rest/orchestration/service/execute/{externalReference}/{serviceExternalReference}?serviceName={serviceName}&processName={processName} -d ' * { diff --git a/Reference/Common/Library/order_command_rest.php b/Reference/Common/Library/order_command_rest.php index 7ca636d24..11d3dd3ee 100755 --- a/Reference/Common/Library/order_command_rest.php +++ b/Reference/Common/Library/order_command_rest.php @@ -77,34 +77,6 @@ function _order_command_synchronize ($device_id, $connection_timeout = 300, $max return $response; } - -function _obmf_create($message,$deviceId){ - return _obmf_exec($message,$deviceId,"CREATE"); -} - -function _obmf_delete($message,$deviceId){ - return _obmf_exec($message,$deviceId,"DELETE"); -} - -function _obmf_update($message,$deviceId){ - return _obmf_exec($message,$deviceId,"UPDATE"); -} - -function _obmf_import($message,$deviceId){ - return _obmf_exec($message,$deviceId,"IMPORT"); -} - -function _obmf_exec($message,$deviceId,$method){ - $jsonFile='/tmp/'.rand().'.json'; - shell_exec('echo '.json_encode($message).' > '.$jsonFile); - $cmd="/opt/ubi-jentreprise/bin/api/ordercommand/executeCommand.sh ".$deviceId." ".$method." ".$jsonFile; - logToFile("[OBMF_EXEC]".$cmd); - $res=shell_exec($cmd); - logToFile("[OBMF_EXEC]".$res); - shell_exec('rm -f '.$jsonFile); - return $res; -} - /** *
diff --git a/Reference/Common/Library/widget_portal_rest.php b/Reference/Common/Library/widget_portal_rest.php
deleted file mode 100755
index 8abc18947..000000000
--- a/Reference/Common/Library/widget_portal_rest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-
\ No newline at end of file