Merge branch 'fronkdev' into 'master'
Fixed getting netzgebiete in AddressdbApicontroller See merge request fronk/thetool!1958
This commit is contained in:
@@ -691,7 +691,11 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
$addresses = [];
|
||||
$netzgebiete = ADBNetzgebietModel::getAll(true);
|
||||
$netzgebiete = [];
|
||||
$netzgebiete_unindexed = ADBNetzgebietModel::getAll();
|
||||
foreach($netzgebiete_unindexed as $nu) {
|
||||
$netzgebiete[$nu->id] = $nu;
|
||||
}
|
||||
|
||||
$stati = ADBStatusModel::getAll(true);
|
||||
|
||||
|
||||
@@ -17,6 +17,65 @@ class SnoppCitycom extends Modules\ApiControllerModule
|
||||
|
||||
}
|
||||
|
||||
public function getOntStatus($req_id) {
|
||||
if(!$req_id) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
}
|
||||
|
||||
$wohneinheit = false;
|
||||
if(is_numeric($req_id)) {
|
||||
$id = $req_id;
|
||||
$wohneinheit = new \ADBWohneinheit($id);
|
||||
}
|
||||
if(!$wohneinheit || !$wohneinheit->id) {
|
||||
$oaid = $req_id;
|
||||
$wohneinheit = \ADBWohneinheitModel::getFirst(["oaid" => $oaid]);
|
||||
if (!$wohneinheit) {
|
||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||
}
|
||||
}
|
||||
|
||||
$cc = new \Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
|
||||
$data = $cc->getOntStatus($wohneinheit->oaid);
|
||||
|
||||
$status = [];
|
||||
$status["online"] = ($data->{"oper-status"} == "present" && $data->status == "Confirmed") ? 1 : 0;
|
||||
$status["uptime"] = ($data->up_time) ? (date('U') - $data->up_time) : null;
|
||||
$status["downtime"] = null;
|
||||
$status["rx"] = $data->{"opt-signal-level"};
|
||||
$status["tx"] = $data->tx_opt_level_dbm;
|
||||
$status["distance"] = null;
|
||||
|
||||
|
||||
return \mfResponse::Ok(["status" => $status]);
|
||||
}
|
||||
|
||||
public function getOntTelemetry($req_id) {
|
||||
if(!$req_id) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
}
|
||||
|
||||
$wohneinheit = false;
|
||||
if(is_numeric($req_id)) {
|
||||
$id = $req_id;
|
||||
$wohneinheit = new \ADBWohneinheit($id);
|
||||
}
|
||||
if(!$wohneinheit || !$wohneinheit->id) {
|
||||
$oaid = $req_id;
|
||||
$wohneinheit = \ADBWohneinheitModel::getFirst(["oaid" => $oaid]);
|
||||
if (!$wohneinheit) {
|
||||
return \mfResponse::NotFound(["message" => "Home not found"]);
|
||||
}
|
||||
}
|
||||
|
||||
$cc = new \Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
|
||||
$data = $cc->getOntStatusDetail($wohneinheit->oaid);
|
||||
|
||||
print_r($data);exit;
|
||||
|
||||
return \mfResponse::Ok(["status" => $status]);
|
||||
}
|
||||
|
||||
public function orderService($req_id) {
|
||||
if(!$req_id) {
|
||||
return \mfResponse::BadRequest(["message" => "id missing"]);
|
||||
|
||||
@@ -50,8 +50,9 @@ class OperationaldataApicontroller extends mfBaseApicontroller
|
||||
$this->addRoute("/operationaldata/home/:id/connected", [$modules["Snopp"], "setPreorderConnected"], "POST");
|
||||
$this->addRoute("/operationaldata/home/:id/active", [$modules["Snopp"], "setPreorderActive"], "POST");
|
||||
|
||||
//$this->addRoute("/operationaldata/preorder/:id/orderServiceTest", [$modules["SnoppCitycom"], "orderServiceTest"], "POST");
|
||||
$this->addRoute("/operationaldata/preorder/:id/orderService", [$modules["SnoppCitycom"], "orderService"], "POST");
|
||||
$this->addRoute("/operationaldata/preorder/:id/ontStatus", [$modules["SnoppCitycom"], "getOntStatus"], "GET");
|
||||
$this->addRoute("/operationaldata/preorder/:id/ontTelemetry", [$modules["SnoppCitycom"], "getOntTelemetry"], "GET");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +266,122 @@ class Citycom_OanApiClient {
|
||||
return $types;
|
||||
}
|
||||
|
||||
public function getOntStatus($oan_id) {
|
||||
if(!$this->token) {
|
||||
$this->getAuthToken();
|
||||
if(!$this->token) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->baseurl.CITYCOM_OAN_API_EP_GET_ONT_STATUS;
|
||||
$url = str_replace("{oan_id}", $oan_id, $url);
|
||||
$ctx_options = [
|
||||
"http" => [
|
||||
"ignore_errors" => true,
|
||||
"method" => "GET",
|
||||
"header" => [
|
||||
"Accept: application/json",
|
||||
"Authorization: Bearer ".$this->token,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($ctx_options);
|
||||
$output = file_get_contents($url, false, $ctx);
|
||||
|
||||
$resp = json_decode($output);
|
||||
if(!is_object($resp)) {
|
||||
return false;
|
||||
}
|
||||
if(!property_exists($resp, "success") || !$resp->success || !property_exists($resp, "data")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp->data;
|
||||
}
|
||||
|
||||
public function getOntPortStatus($oan_id) {
|
||||
if(!$this->token) {
|
||||
$this->getAuthToken();
|
||||
if(!$this->token) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->baseurl.CITYCOM_OAN_API_EP_GET_ONT_PORTSTATUS;
|
||||
$url = str_replace("{oan_id}", $oan_id, $url);
|
||||
$ctx_options = [
|
||||
"http" => [
|
||||
"ignore_errors" => true,
|
||||
"method" => "GET",
|
||||
"header" => [
|
||||
"Accept: application/json",
|
||||
"Authorization: Bearer ".$this->token,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($ctx_options);
|
||||
$output = file_get_contents($url, false, $ctx);
|
||||
|
||||
$resp = json_decode($output);
|
||||
if(!is_object($resp)) {
|
||||
return false;
|
||||
}
|
||||
if(!property_exists($resp, "success") || !$resp->success || !property_exists($resp, "data")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $resp->data;
|
||||
}
|
||||
|
||||
public function getOntMacAddresses($oan_id) {
|
||||
if(!$this->token) {
|
||||
$this->getAuthToken();
|
||||
if(!$this->token) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->baseurl.CITYCOM_OAN_API_EP_GET_ONT_MACADDRESSES;
|
||||
$url = str_replace("{oan_id}", $oan_id, $url);
|
||||
$ctx_options = [
|
||||
"http" => [
|
||||
"ignore_errors" => true,
|
||||
"method" => "GET",
|
||||
"header" => [
|
||||
"Accept: application/json",
|
||||
"Authorization: Bearer ".$this->token,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($ctx_options);
|
||||
$output = file_get_contents($url, false, $ctx);
|
||||
|
||||
$resp = json_decode($output);
|
||||
if(!is_object($resp)) {
|
||||
return false;
|
||||
}
|
||||
if(!property_exists($resp, "success") || !$resp->success || !property_exists($resp, "data")) {
|
||||
return false;
|
||||
}
|
||||
return $resp->data;
|
||||
}
|
||||
|
||||
public function getOntStatusDetail($oan_id) {
|
||||
$ont_status = $this->getOntStatus($oan_id);
|
||||
$ont_port_status = $this->getOntPortStatus($oan_id);
|
||||
$ont_mac_addresses = $this->getOntMacAddresses($oan_id);
|
||||
|
||||
return [
|
||||
$ont_status,
|
||||
$ont_port_status,
|
||||
$ont_mac_addresses
|
||||
];
|
||||
}
|
||||
|
||||
private function getAuthToken() {
|
||||
$token = new mfConfig("adb.import.citycom.auth.token");
|
||||
if($token && $token->value()) {
|
||||
|
||||
Reference in New Issue
Block a user