package isapi import ( "encoding/xml" "net/url" ) type HttpHostNotification struct { ID string `xml:"id"` URL string `xml:"url"` ProtocolType string `xml:"protocolType"` ParameterFormatType string `xml:"parameterFormatType"` AddressingFormatType string `xml:"addressingFormatType"` IpAddress string `xml:"ipAddress"` PortNo string `xml:"portNo"` UserName string `xml:"userName"` HttpAuthenticationMethod string `xml:"httpAuthenticationMethod"` HttpBroken string `xml:"httpBroken"` } // GetOneHost 获取单个监听主机参数 func (c *Client) GetOneHost(hostID string) (resp []byte, err error) { u, err := url.Parse("/ISAPI/Event/notification/httpHosts/" + hostID + "?security=1&iv=1") if err != nil { return nil, err } resp, err = c.Get(u) if err != nil { return nil, err } return resp, nil } // PutOneHost 配置单个监听主机参数 func (c *Client) PutOneHost(hostID string, data []byte) (resp []byte, err error) { u, err := url.Parse("/ISAPI/Event/notification/httpHosts/" + hostID + "?security=1&iv=1") if err != nil { return nil, err } resp, err = c.PutXML(u, data) return resp, err } // HttpHostNotificationCap 获取监听主机参数能力 type HttpHostNotificationCap struct { HostNumber string `xml:"hostNumber"` UrlLen struct { Min string `xml:"min,attr"` Max string `xml:"max,attr"` } `xml:"urlLen"` ProtocolType struct { Opt string `xml:"opt,attr"` } `xml:"protocolType"` ParameterFormatType struct { Opt string `xml:"opt,attr"` } `xml:"parameterFormatType"` AddressingFormatType struct { Opt string `xml:"opt,attr"` } `xml:"addressingFormatType"` IpAddress struct { Opt string `xml:"opt,attr"` } `xml:"ipAddress"` PortNo struct { Min string `xml:"min,attr"` Max string `xml:"max,attr"` } `xml:"portNo"` UserNameLen struct { Min string `xml:"min,attr"` Max string `xml:"max,attr"` } `xml:"userNameLen"` PasswordLen struct { Min string `xml:"min,attr"` Max string `xml:"max,attr"` } `xml:"passwordLen"` HttpAuthenticationMethod struct { Opt string `xml:"opt,attr"` } `xml:"httpAuthenticationMethod"` UploadImagesDataType struct { Opt string `xml:"opt,attr"` } `xml:"uploadImagesDataType"` HttpBroken struct { Opt string `xml:"opt,attr"` Def string `xml:"def,attr"` } `xml:"httpBroken"` } // GetParamHost 获取监听主机参数能力 func (c *Client) GetParamHost() (resp *HttpHostNotification, err error) { u, err := url.Parse("/ISAPI/Event/notification/httpHosts/capabilities") if err != nil { return nil, err } get, err := c.Get(u) if err != nil { return nil, err } err = xml.Unmarshal(get, &resp) if err != nil { return nil, err } return resp, nil }