api

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	BaseURL string
	// contains filtered or unexported fields
}

API 用于访问ThingsPanel API

func NewAPI

func NewAPI(baseURL string) *API

NewAPI 创建一个新的API实例

func (*API) GetDeviceConfig

func (a *API) GetDeviceConfig(request DeviceConfigRequest) (*DeviceConfigResponse, error)

获取设备配置(通过设备id或者设备令牌)

func (*API) GetDeviceConfigList

func (a *API) GetDeviceConfigList(request DeviceConfigListRequest) (*DeviceConfigListResponse, error)

响应内容会被解析到 DeviceConfigListResponse 结构体中。

func (*API) GetServiceAccess added in v1.1.8

func (a *API) GetServiceAccess(request ServiceAccessRequest) (*ServiceAccessResponseData, error)

获取服务接入点

func (*API) GetServiceAccessList added in v1.1.8

func (a *API) GetServiceAccessList(request ServiceAccessListRequest) (*ServiceAccessListResponseData, error)

获取服务接入点列表

func (*API) Heartbeat added in v1.1.8

func (a *API) Heartbeat(request HeartbeatRequest) (*HeartbeatResponseData, error)

心跳

type Device added in v1.1.8

type Device struct {
	ID                     string                 `json:"id"`
	Voucher                string                 `json:"voucher"`
	DeviceNumber           string                 `json:"device_number"`
	DeviceType             string                 `json:"device_type"`
	ProtocolType           string                 `json:"Protocol_type"`
	SubDevices             []SubDevice            `json:"sub_devices"`
	Config                 map[string]interface{} `json:"config"`
	ProtocolConfigTemplate map[string]interface{} `json:"protocol_config_template"` // 子设备配置的protocol_config(表单数据)
}

设备信息结构体

type DeviceConfigListRequest

type DeviceConfigListRequest struct {
	ProtocolType string `json:"protocol_type"`
	DeviceType   string `json:"device_type"`
}

请求结构体

type DeviceConfigListResponse

type DeviceConfigListResponse struct {
	Code    int                        `json:"code"`
	Message string                     `json:"message"`
	Data    []DeviceConfigResponseData `json:"data"`
}

响应结构体

type DeviceConfigListResponseData

type DeviceConfigListResponseData struct {
	ProtocolType string                 `json:"ProtocolType"`
	AccessToken  string                 `json:"AccessToken"`
	DeviceType   string                 `json:"DeviceType"`
	ID           string                 `json:"Id"`
	DeviceConfig map[string]interface{} `json:"DeviceConfig,omitempty"` // 表单配置
	SubDevices   []SubDeviceConfig      `json:"SubDevices,omitempty"`
}

设备信息结构体

type DeviceConfigRequest

type DeviceConfigRequest struct {
	DeviceID     string `json:"device_id"`
	Voucher      string `json:"voucher"`
	DeviceNumber string `json:"device_number"`
}

请求结构体

type DeviceConfigResponse

type DeviceConfigResponse struct {
	Code    int                      `json:"code"`
	Message string                   `json:"message"`
	Data    DeviceConfigResponseData `json:"data"`
}

响应结构体

type DeviceConfigResponseData

type DeviceConfigResponseData struct {
	Voucher                string                 `json:"voucher"`
	DeviceType             string                 `json:"device_type"`
	ID                     string                 `json:"id"`
	ProtocolType           string                 `json:"Protocol_type"`
	SubDevices             []SubDevice            `json:"sub_devices"`
	Config                 map[string]interface{} `json:"config"`
	ProtocolConfigTemplate map[string]interface{} `json:"protocol_config_template"` // 子设备配置的protocol_config
}

设备信息结构体

type HeartbeatRequest added in v1.1.8

type HeartbeatRequest struct {
	ServiceIdentifier string `json:"service_identifier"`
}

/api/v1/plugin/heartbeat 请求结构体

type HeartbeatResponseData added in v1.1.8

type HeartbeatResponseData struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

响应结构体

type ServiceAccess added in v1.1.8

type ServiceAccess struct {
	ServiceAccessID             string   `json:"service_access_id"`
	ServiceIdentifier           string   `json:"service_identifier"`
	Voucher                     string   `json:"voucher"`                        // 服务凭证(表单数据)
	ServiceAccessConfigTemplate string   `json:"service_access_config_template"` // 服务接入配置
	Description                 string   `json:"description"`
	Remark                      string   `json:"remark"`
	Devices                     []Device `json:"devices"`
}

服务接入结构体

type ServiceAccessListRequest added in v1.1.8

type ServiceAccessListRequest struct {
	ServiceIdentifier string `json:"service_identifier"`
}

请求结构体

type ServiceAccessListResponseData added in v1.1.8

type ServiceAccessListResponseData struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    []ServiceAccess `json:"data"`
}

响应结构体

type ServiceAccessRequest added in v1.1.8

type ServiceAccessRequest struct {
	ServiceAccessID string `json:"service_access_id"`
}

请求结构体

type ServiceAccessResponseData added in v1.1.8

type ServiceAccessResponseData struct {
	Code    int           `json:"code"`
	Message string        `json:"message"`
	Data    ServiceAccess `json:"data"`
}

响应结构体

type SubDevice

type SubDevice struct {
	DeviceID               string                 `json:"device_id"`
	Voucher                string                 `json:"voucher"`
	DeviceNumber           string                 `json:"device_number"`
	SubDeviceAddr          string                 `json:"sub_device_addr"`
	Config                 map[string]interface{} `json:"config"`
	ProtocolConfigTemplate map[string]interface{} `json:"protocol_config_template"` // 子设备配置的protocol_config(表单数据)
}

子设备信息结构体

type SubDeviceConfig

type SubDeviceConfig struct {
	AccessToken   string                 `json:"AccessToken"`
	DeviceID      string                 `json:"DeviceId"`
	SubDeviceAddr string                 `json:"SubDeviceAddr"`
	Config        map[string]interface{} `json:"Config"` // 表单配置
}

子设备信息结构体

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳