Documentation
¶
Index ¶
- Variables
- func Hash(s string) string
- type AuthTransport
- type Challenge
- type Client
- func (c *Client) Do(r *http.Request) ([]byte, error)
- func (c *Client) Get(u *url.URL) ([]byte, error)
- func (c *Client) GetDeviceInfo() (resp *DeviceInfo, err error)
- func (c *Client) GetDeviceInfoCapabilities() (resp *DeviceInfoCap, err error)
- func (c *Client) GetFocusConf(channelId string) (resp *FocusConfiguration, err error)
- func (c *Client) GetImageFlip(channelId string) (resp *ImageFlip, err error)
- func (c *Client) GetTime() (resp *Time, err error)
- func (c *Client) Put(u *url.URL, contentType string, data []byte) ([]byte, error)
- func (c *Client) PutFocusConf(data *FocusConfiguration, channelId string) (resp *ResponseStatus, err error)
- func (c *Client) PutImageFlip(data *ImageFlip, channelId string) (resp *ResponseStatus, err error)
- func (c *Client) PutJSON(u *url.URL, contentType string, data interface{}) ([]byte, error)
- func (c *Client) PutTime(data *Time) (resp *ResponseStatus, err error)
- func (c *Client) PutXML(u *url.URL, data interface{}) ([]byte, error)
- type DeviceInfo
- type DeviceInfoCap
- type DeviceInfoDetailAbnormalStatus
- type FocusConfiguration
- type ImageFlip
- type Response
- type ResponseStatus
- type ResponseStatusAdditionalErr
- type ResponseStatusAdditionalErrStatus
- type ResponseStatusAdditionalErrStatusInfo
- type Time
Constants ¶
This section is empty.
Variables ¶
var ( // ErrResponseNotOk is returned by Client.Get calls when the // the API returns a response with a non-200 HTTP status code. ErrResponseNotOk = errors.New("hikvision: response not ok") // ErrParseErrorMessageFailure is returned by Client.Get calls // when the API call is not successful but there the error // message could not be successfully parsed. ErrParseErrorMessageFailure = errors.New("hikvision: error parsing error message") // ErrUnhandledContentType is returned when the Content-Type // header is not unhandled by the client. ErrUnhandledContentType = errors.New("hikvision: unhandled content type") )
Functions ¶
Types ¶
type AuthTransport ¶
type AuthTransport struct { Username string Password string Transport http.RoundTripper }
AuthTransport is a http.RoundTripper that takes care of authenticating with the API using HTTP Digest Authentication.
func NewAuthTransport ¶
func NewAuthTransport(username, password string) *AuthTransport
NewAuthTransport is a constructor for AuthTransport.
type Challenge ¶
type Challenge struct { Realm string Domain string Nonce string Opaque string Stale string Algorithm string Qop string // TODO: Should Qop be an array of strings? }
Challenge represents the digest challenge, which is found on the `WWW-Authenticate` header on the initial request.
func NewChallenge ¶
NewChallenge is a constructor for Challenge
type Client ¶
Client is a http.Client wrapper that handles authentication.
func (*Client) GetDeviceInfo ¶
func (c *Client) GetDeviceInfo() (resp *DeviceInfo, err error)
GetDeviceInfo executes a HTTP GET request to the /ISAPI/System/deviceInfo endpoint.
func (*Client) GetDeviceInfoCapabilities ¶
func (c *Client) GetDeviceInfoCapabilities() (resp *DeviceInfoCap, err error)
GetDeviceInfoCapabilities executes a HTTP GET request to the /ISAPI/System/deviceInfo/capabilities endpoint.
func (*Client) GetFocusConf ¶
func (c *Client) GetFocusConf(channelId string) (resp *FocusConfiguration, err error)
func (*Client) GetImageFlip ¶
func (*Client) PutFocusConf ¶
func (c *Client) PutFocusConf(data *FocusConfiguration, channelId string) (resp *ResponseStatus, err error)
func (*Client) PutImageFlip ¶
func (c *Client) PutImageFlip(data *ImageFlip, channelId string) (resp *ResponseStatus, err error)
type DeviceInfo ¶
type DeviceInfo struct { XMLName xml.Name `xml:"DeviceInfo,omitempty"` XMLVersion string `xml:"version,attr"` XMLNamespace string `xml:"xmlns,attr"` DeviceName string `xml:"deviceName,omitempty" json:"deviceName,omitempty"` DeviceID string `xml:"deviceID,omitempty" json:"deviceID,omitempty"` DeviceDescription string `xml:"deviceDescription,omitempty" json:"deviceDescription,omitempty"` DeviceLocation string `xml:"deviceLocation,omitempty" json:"deviceLocation,omitempty"` DeviceStatus string `xml:"deviceStatus,omitempty" json:"deviceStatus,omitempty"` DetailAbnormalStatus *DeviceInfoDetailAbnormalStatus `xml:"DetailAbnormalStatus,omitempty" json:"DetailAbnormalStatus,omitempty"` SystemContact string `xml:"systemContact,omitempty" json:"systemContact,omitempty"` Model string `xml:"model,omitempty" json:"model,omitempty"` SerialNumber string `xml:"serialNumber,omitempty" json:"serialNumber,omitempty"` MacAddress string `xml:"macAddress,omitempty" json:"macAddress,omitempty"` FirmwareVersion string `xml:"firmwareVersion,omitempty" json:"firmwareVersion,omitempty"` FirmwareReleasedDate string `xml:"firmwareReleasedDate,omitempty" json:"firmwareReleasedDate,omitempty"` BootVersion string `xml:"bootVersion,omitempty" json:"bootVersion,omitempty"` BootReleasedDate string `xml:"bootReleasedDate,omitempty" json:"bootReleasedDate,omitempty"` HardwareVersion string `xml:"hardwareVersion,omitempty" json:"hardwareVersion,omitempty"` EncoderVersion string `xml:"encoderVersion,omitempty" json:"encoderVersion,omitempty"` EncoderReleasedDate string `xml:"encoderReleasedDate,omitempty" json:"encoderReleasedDate,omitempty"` DecoderVersion string `xml:"decoderVersion,omitempty" json:"decoderVersion,omitempty"` DecoderReleasedDate string `xml:"decoderReleasedDate,omitempty" json:"decoderReleasedDate,omitempty"` SoftwareVersion string `xml:"softwareVersion,omitempty" json:"softwareVersion,omitempty"` Capacity int `xml:"capacity,omitempty" json:"capacity,omitempty"` UsedCapacity int `xml:"usedCapacity,omitempty" json:"usedCapacity,omitempty"` DeviceType string `xml:"deviceType,omitempty" json:"deviceType,omitempty"` TelecontrolID int `xml:"telecontrolID,omitempty" json:"telecontrolID,omitempty"` SupportBeep bool `xml:"supportBeep,omitempty" json:"supportBeep,omitempty"` ActualFloorNum int `xml:"actualFloorNum,omitempty" json:"actualFloorNum,omitempty"` SubChannelEnabled bool `xml:"subChannelEnabled,omitempty" json:"subChannelEnabled,omitempty"` ThrChannelEnabled bool `xml:"thrChannelEnabled,omitempty" json:"thrChannelEnabled,omitempty"` RadarVersion string `xml:"radarVersion,omitempty" json:"radarVersion,omitempty"` LocalZoneNum int `xml:"localZoneNum,omitempty" json:"localZoneNum,omitempty"` AlarmOutNum int `xml:"alarmOutNum,omitempty" json:"alarmOutNum,omitempty"` DistanceResolution float32 `xml:"distanceResolution,omitempty" json:"distanceResolution,omitempty"` AngleResolution float32 `xml:"angleResolution,omitempty" json:"angleResolution,omitempty"` SpeedResolution float32 `xml:"speedResolution,omitempty" json:"speedResolution,omitempty"` DetectDistance float32 `xml:"detectDistance,omitempty" json:"detectDistance,omitempty"` LanguageType string `xml:"languageType,omitempty" json:"languageType,omitempty"` RelayNum int `xml:"relayNum,omitempty" json:"relayNum,omitempty"` ElectroLockNum int `xml:"electroLockNum,omitempty" json:"electroLockNum,omitempty"` RS485Num int `xml:"RS485Num,omitempty" json:"RS485Num,omitempty"` PowerOnMode string `xml:"powerOnMode,omitempty" json:"powerOnMode,omitempty"` }
DeviceInfo represents the XML_DeviceInfo and JSON_DeviceInfo resource.
type DeviceInfoCap ¶
type DeviceInfoCap struct { XMLName xml.Name `xml:"DeviceInfo,omitempty"` XMLVersion string `xml:"version,attr"` XMLNamespace string `xml:"xmlns,attr"` DeviceName string `xml:"deviceName,omitempty" json:"deviceName,omitempty"` LanguageType string `xml:"languageType,omitempty" json:"languageType,omitempty"` DeviceID string `xml:"deviceID,omitempty" json:"deviceID,omitempty"` DeviceDescription string `xml:"deviceDescription,omitempty" json:"deviceDescription,omitempty"` DeviceLocation string `xml:"deviceLocation,omitempty" json:"deviceLocation,omitempty"` SystemContact string `xml:"systemContact,omitempty" json:"systemContact,omitempty"` Model string `xml:"model,omitempty" json:"model,omitempty"` SerialNumber string `xml:"serialNumber,omitempty" json:"serialNumber,omitempty"` MacAddress string `xml:"macAddress,omitempty" json:"macAddress,omitempty"` FirmwareVersion string `xml:"firmwareVersion,omitempty" json:"firmwareVersion,omitempty"` FirmwareReleasedDate string `xml:"firmwareReleasedDate,omitempty" json:"firmwareReleasedDate,omitempty"` BootVersion string `xml:"bootVersion,omitempty" json:"bootVersion,omitempty"` BootReleasedDate string `xml:"bootReleasedDate,omitempty" json:"bootReleasedDate,omitempty"` HardwareVersion string `xml:"hardwareVersion,omitempty" json:"hardwareVersion,omitempty"` EncoderVersion string `xml:"encoderVersion,omitempty" json:"encoderVersion,omitempty"` EncoderReleasedDate string `xml:"encoderReleasedDate,omitempty" json:"encoderReleasedDate,omitempty"` DecoderVersion string `xml:"decoderVersion,omitempty" json:"decoderVersion,omitempty"` DecoderReleasedDate string `xml:"decoderReleasedDate,omitempty" json:"decoderReleasedDate,omitempty"` DeviceType string `xml:"deviceType,omitempty" json:"deviceType,omitempty"` TelecontrolID int `xml:"telecontrolID,omitempty" json:"telecontrolID,omitempty"` SupportBeep bool `xml:"supportBeep,omitempty" json:"supportBeep,omitempty"` FirmwareVersionInfo string `xml:"firmwareVersionInfo,omitempty" json:"firmwareVersionInfo,omitempty"` SubChannelEnabled bool `xml:"subChannelEnabled,omitempty" json:"subChannelEnabled,omitempty"` ThrChannelEnabled bool `xml:"thrChannelEnabled,omitempty" json:"thrChannelEnabled,omitempty"` ActualFloorNum int `xml:"actualFloorNum,omitempty" json:"actualFloorNum,omitempty"` RadarVersion string `xml:"radarVersion,omitempty" json:"radarVersion,omitempty"` PowerOnMode string `xml:"powerOnMode,omitempty" json:"powerOnMode,omitempty"` }
DeviceInfoCap represents the XML_Cap_DeviceInfo and JSON_Cap_DeviceInfo resource.
type DeviceInfoDetailAbnormalStatus ¶
type DeviceInfoDetailAbnormalStatus struct { HardDiskFull bool `xml:"hardDiskFull,omitempty" json:"hardDiskFull,omitempty"` HardDiskError bool `xml:"hardDiskError,omitempty" json:"hardDiskError,omitempty"` EthernetBroken bool `xml:"ethernetBroken,omitempty" json:"ethernetBroken,omitempty"` IPAddrConflict bool `xml:"ipaddrConflict,omitempty" json:"ipaddrConflict,omitempty"` IllegalAccess bool `xml:"illegalAccess,omitempty" json:"illegalAccess,omitempty"` RecordError bool `xml:"recordError,omitempty" json:"recordError,omitempty"` RaidLogicDiskError bool `xml:"raidLogicDiskError,omitempty" json:"raidLogicDiskError,omitempty"` SpareWorkDeviceError bool `xml:"spareWorkDeviceError,omitempty" json:"spareWorkDeviceError,omitempty"` }
DeviceInfoDetailAbnormalStatus represents the device abnormal status, which is used in the XML_DeviceInfo resource.
type FocusConfiguration ¶
type FocusConfiguration struct { XMLName xml.Name `xml:"FocusConfiguration,omitempty"` XMLVersion string `xml:"version,attr"` XMLNamespace string `xml:"xmlns,attr"` FocusStyle string `xml:"focusStyle,omitempty" json:"focusStyle,omitempty"` //req FocusLimited int `xml:"focusLimited,omitempty" json:"focusLimited,omitempty"` //opt FocusPosition int `xml:"focusPosition,omitempty" json:"focusPosition,omitempty"` //dep depends on "FocusStyle" FocusSpeed int `xml:"focusSpeed,omitempty" json:"focusSpeed,omitempty"` //opt FocusSensitivity int `xml:"focusSensitivity,omitempty" json:"focusSensitivity,omitempty"` //opt TemperatureChangeAdaptEnabled bool `xml:"temperatureChangeAdaptEnabled,omitempty" json:"temperatureChangeAdaptEnabled,omitempty"` //opt RelativeFocusPos int `xml:"relativeFocusPos,omitempty" json:"relativeFocusPos,omitempty"` //opt HighTemperaturePriority bool `xml:"highTemperaturePriority,omitempty" json:"highTemperaturePriority,omitempty"` //opt }
type ImageFlip ¶
type ImageFlip struct { XMLName xml.Name `xml:"ImageFlip,omitempty"` XMLVersion string `xml:"version,attr"` XMLNamespace string `xml:"xmlns,attr"` Enabled bool `xml:"enabled,omitempty" json:"enabled,omitempty"` //req ImageFlipStyle string `xml:"ImageFlipStyle,omitempty" json:"ImageFlipStyle,omitempty"` //"LEFTRIGHT, UPDOWN, CENTER, AUTO FlipAngle string `xml:"flipAngle,omitempty" json:"flipAngle,omitempty"` //"90, 180, 270" }
type Response ¶
type Response struct { Username string Realm string Nonce string URI string Qop string Cnonce string Nc string Response string Opaque string }
Response represents the digest response, which is embedded on the `Authorization` header on every subsequent requests.
type ResponseStatus ¶
type ResponseStatus struct { XMLName xml.Name `xml:"ResponseStatus,omitempty"` XMLVersion string `xml:"version,attr"` XMLNamespace string `xml:"xmlns,attr"` RequestURL string `xml:"requestURL,omitempty" json:"requestURL,omitempty"` StatusCode int `xml:"statusCode,omitempty" json:"statusCode,omitempty"` StatusString string `xml:"statusString,omitempty" json:"statusString,omitempty"` ID int `xml:"id,omitempty" json:"id,omitempty"` SubStatusCode string `xml:"subStatusCode,omitempty" json:"subStatusCode,omitempty"` ErrorCode int `xml:"errorCode,omitempty" json:"errorCode,omitempty"` ErrorMsg string `xml:"errorMsg,omitempty" json:"errorMsg,omitempty"` AdditionalErr *ResponseStatusAdditionalErr `xml:"AdditionalErr,omitempty" json:"AdditionalErr,omitempty"` }
ResponseStatus represents the XML_ResponseStatus and JSON_ResponseStatus resource.
type ResponseStatusAdditionalErr ¶
type ResponseStatusAdditionalErr struct {
StatusList []ResponseStatusAdditionalErrStatus `xml:"StatusList,omitempty" json:"StatusList,omitempty"`
}
ResponseStatusAdditionalErr represents the additional error status, which is valid when StatusCode is set to 9.
type ResponseStatusAdditionalErrStatus ¶
type ResponseStatusAdditionalErrStatus struct {
Status string `xml:"Status,omitempty" json:"Status,omitempty"`
}
ResponseStatusAdditionalErrStatus represents a single status information.
type ResponseStatusAdditionalErrStatusInfo ¶
type ResponseStatusAdditionalErrStatusInfo struct { ID string `xml:"id,omitempty" json:"id,omitempty"` StatusCode int `xml:"statusCode,omitempty" json:"statusCode,omitempty"` StatusString string `xml:"statusString,omitempty" json:"statusString,omitempty"` SubStatusCode string `xml:"subStatusCode,omitempty" json:"subStatusCode,omitempty"` ErrorCode int `xml:"errorCode,omitempty" json:"errorCode,omitempty"` ErrorMsg string `xml:"errorMsg,omitempty" json:"errorMsg,omitempty"` }
ResponseStatusAdditionalErrStatusInfo represents information of status.
type Time ¶
type Time struct { XMLName xml.Name `xml:"Time,omitempty"` XMLVersion string `xml:"version,attr"` XMLNamespace string `xml:"xmlns,attr"` TimeMode string `xml:"timeMode,omitempty" json:"timeMode,omitempty"` LocalTime string `xml:"localTime,omitempty" json:"localTime,omitempty"` TimeZone string `xml:"timeZone,omitempty" json:"timeZone,omitempty"` SatelliteInterval string `xml:"satelliteInterval,omitempty" json:"satelliteInterval,omitempty"` }
Time represents the XML_Time and JSON_Time resource.