Remove some API for now

This commit is contained in:
Radhi Fadlillah
2017-05-22 19:27:27 +07:00
parent 4dcb04bb5e
commit 68873cc459
3 changed files with 23 additions and 78 deletions

View File

@@ -1,7 +1,6 @@
package onvif
import (
"fmt"
"strings"
)
@@ -43,25 +42,6 @@ func (device Device) GetInformation() (DeviceInformation, error) {
return result, nil
}
// GetSystemDateAndTime fetch date and time from ONVIF camera
func (device Device) GetSystemDateAndTime() (string, error) {
// Create SOAP
soap := SOAP{
Body: "</tds:GetSystemDateAndTime>",
XMLNs: deviceXMLNs,
}
// Send SOAP request
response, err := soap.SendRequest(device.XAddr)
if err != nil {
return "", err
}
// Parse response
dateTime, _ := response.ValueForPathString("Envelope.Body.GetSystemDateAndTimeResponse.SystemDateAndTime")
return dateTime, nil
}
// GetCapabilities fetch info of ONVIF camera's capabilities
func (device Device) GetCapabilities() (DeviceCapabilities, error) {
// Create SOAP
@@ -211,62 +191,7 @@ func (device Device) GetHostname() (HostnameInformation, error) {
if mapHostInfo, ok := ifaceHostInfo.(map[string]interface{}); ok {
hostnameInfo.Name = interfaceToString(mapHostInfo["Name"])
hostnameInfo.FromDHCP = interfaceToBool(mapHostInfo["FromDHCP"])
hostnameInfo.Extension = interfaceToString(mapHostInfo["Extension"])
}
return hostnameInfo, nil
}
// GetDNS fetch DNS of an ONVIF camera
func (device Device) GetDNS() (string, error) {
// Create SOAP
soap := SOAP{
Body: "<tds:GetDNS/>",
XMLNs: deviceXMLNs,
}
// Send SOAP request
response, err := soap.SendRequest(device.XAddr)
if err != nil {
return "", err
}
bt, _ := response.JsonIndent("", " ")
fmt.Println(string(bt))
// Parse response
DNS, _ := response.ValueForPathString("Envelope.Body.GetDNSResponse.DNSInformation")
return DNS, nil
}
// GetDNS fetch DNS of an ONVIF camera
func (device Device) GetNetworkInterfaces() (string, error) {
// Create SOAP
soap := SOAP{
Body: "<tds:GetNetworkInterfaces/>",
XMLNs: deviceXMLNs,
}
// Send SOAP request
response, err := soap.SendRequest(device.XAddr)
if err != nil {
return "", err
}
bt, _ := response.JsonIndent("", " ")
fmt.Println(string(bt))
// Parse response
DNS, _ := response.ValueForPathString("Envelope.Body.GetDNSResponse.DNSInformation")
return DNS, nil
}
func interfaceToString(src interface{}) string {
str, _ := src.(string)
return str
}
func interfaceToBool(src interface{}) bool {
strBool := interfaceToString(src)
return strings.ToLower(strBool) == "true"
}

View File

@@ -35,7 +35,6 @@ type DeviceCapabilities struct {
// HostnameInformation contains hostname info of an ONVIF camera
type HostnameInformation struct {
Name string
FromDHCP bool
Extension string
Name string
FromDHCP bool
}

21
utils.go Normal file
View File

@@ -0,0 +1,21 @@
package onvif
import (
"encoding/json"
"strings"
)
func interfaceToString(src interface{}) string {
str, _ := src.(string)
return str
}
func interfaceToBool(src interface{}) bool {
strBool := interfaceToString(src)
return strings.ToLower(strBool) == "true"
}
func prettyJSON(src interface{}) string {
result, _ := json.MarshalIndent(&src, "", " ")
return string(result)
}