isapi_event_notification.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package isapi
  2. import (
  3. "encoding/xml"
  4. "net/url"
  5. )
  6. type HttpHostNotification struct {
  7. ID string `xml:"id"`
  8. URL string `xml:"url"`
  9. ProtocolType string `xml:"protocolType"`
  10. ParameterFormatType string `xml:"parameterFormatType"`
  11. AddressingFormatType string `xml:"addressingFormatType"`
  12. IpAddress string `xml:"ipAddress"`
  13. PortNo string `xml:"portNo"`
  14. UserName string `xml:"userName"`
  15. HttpAuthenticationMethod string `xml:"httpAuthenticationMethod"`
  16. HttpBroken string `xml:"httpBroken"`
  17. }
  18. // GetOneHost 获取单个监听主机参数
  19. func (c *Client) GetOneHost(hostID string) (resp []byte, err error) {
  20. u, err := url.Parse("/ISAPI/Event/notification/httpHosts/" + hostID + "?security=1&iv=1")
  21. if err != nil {
  22. return nil, err
  23. }
  24. resp, err = c.Get(u)
  25. if err != nil {
  26. return nil, err
  27. }
  28. return resp, nil
  29. }
  30. // PutOneHost 配置单个监听主机参数
  31. func (c *Client) PutOneHost(hostID string, data []byte) (resp []byte, err error) {
  32. u, err := url.Parse("/ISAPI/Event/notification/httpHosts/" + hostID + "?security=1&iv=1")
  33. if err != nil {
  34. return nil, err
  35. }
  36. resp, err = c.PutXML(u, data)
  37. return resp, err
  38. }
  39. // HttpHostNotificationCap 获取监听主机参数能力
  40. type HttpHostNotificationCap struct {
  41. HostNumber string `xml:"hostNumber"`
  42. UrlLen struct {
  43. Min string `xml:"min,attr"`
  44. Max string `xml:"max,attr"`
  45. } `xml:"urlLen"`
  46. ProtocolType struct {
  47. Opt string `xml:"opt,attr"`
  48. } `xml:"protocolType"`
  49. ParameterFormatType struct {
  50. Opt string `xml:"opt,attr"`
  51. } `xml:"parameterFormatType"`
  52. AddressingFormatType struct {
  53. Opt string `xml:"opt,attr"`
  54. } `xml:"addressingFormatType"`
  55. IpAddress struct {
  56. Opt string `xml:"opt,attr"`
  57. } `xml:"ipAddress"`
  58. PortNo struct {
  59. Min string `xml:"min,attr"`
  60. Max string `xml:"max,attr"`
  61. } `xml:"portNo"`
  62. UserNameLen struct {
  63. Min string `xml:"min,attr"`
  64. Max string `xml:"max,attr"`
  65. } `xml:"userNameLen"`
  66. PasswordLen struct {
  67. Min string `xml:"min,attr"`
  68. Max string `xml:"max,attr"`
  69. } `xml:"passwordLen"`
  70. HttpAuthenticationMethod struct {
  71. Opt string `xml:"opt,attr"`
  72. } `xml:"httpAuthenticationMethod"`
  73. UploadImagesDataType struct {
  74. Opt string `xml:"opt,attr"`
  75. } `xml:"uploadImagesDataType"`
  76. HttpBroken struct {
  77. Opt string `xml:"opt,attr"`
  78. Def string `xml:"def,attr"`
  79. } `xml:"httpBroken"`
  80. }
  81. // GetParamHost 获取监听主机参数能力
  82. func (c *Client) GetParamHost() (resp *HttpHostNotification, err error) {
  83. u, err := url.Parse("/ISAPI/Event/notification/httpHosts/capabilities")
  84. if err != nil {
  85. return nil, err
  86. }
  87. get, err := c.Get(u)
  88. if err != nil {
  89. return nil, err
  90. }
  91. err = xml.Unmarshal(get, &resp)
  92. if err != nil {
  93. return nil, err
  94. }
  95. return resp, nil
  96. }