123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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
- }
|