service

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 20 Imported by: 0

README

Service

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDefaultAuthHeader added in v0.4.0

func AddDefaultAuthHeader(req *http.Request)

func GetTime

func GetTime() int64

get time

func GetUUID

func GetUUID() string

generate uuid

Types

type Config added in v0.3.0

type Config struct {
	ID                string                 `json:"id" mapstructure:"id"`
	Type              string                 `json:"type" mapstructure:"type"`
	Weight            int                    `json:"weight" mapstructure:"weight"`
	Enabled           bool                   `json:"enabled" mapstructure:"enabled"`
	EnabledSearch     bool                   `json:"enabled_search" mapstructure:"enabled_search"`
	EnabledTimeSeries bool                   `json:"enabled_time_series" mapstructure:"enabled_time_series"`
	Description       string                 `json:"description" mapstructure:"description"`
	Define            map[string]interface{} `json:"define" mapstructure:"define"`
	LastTime          int64                  `json:"last_time" mapstructure:"last_time"`
}

type CoreClient

type CoreClient struct {
}

func NewCoreClient

func NewCoreClient() *CoreClient

func (*CoreClient) CorePatchMethod added in v0.4.0

func (c *CoreClient) CorePatchMethod(ctx context.Context, entityId string, kv map[string]interface{}, path string, operator string, pathClassify string) (*emptypb.Empty, error)

func (*CoreClient) CreatEntityToken

func (c *CoreClient) CreatEntityToken(entityType, id, owner string, token string) (string, error)

func (*CoreClient) Delete

func (c *CoreClient) Delete(url string) ([]byte, error)

func (*CoreClient) Get

func (c *CoreClient) Get(url string) ([]byte, error)

func (*CoreClient) GetCoreUrl

func (c *CoreClient) GetCoreUrl(midUrl string, mapUrl map[string]string, entityType string) string

get core url

func (*CoreClient) GetTokenMap

func (c *CoreClient) GetTokenMap(ctx context.Context) (map[string]string, error)

get token

func (*CoreClient) ParseResp

func (c *CoreClient) ParseResp(resp *http.Response, err error) (interface{}, error)

func (*CoreClient) Patch

func (c *CoreClient) Patch(url string, data []byte) ([]byte, error)

func (*CoreClient) Post

func (c *CoreClient) Post(url string, data []byte) ([]byte, error)

func (*CoreClient) Put

func (c *CoreClient) Put(url string, data []byte) ([]byte, error)

type CorePatch

type CorePatch struct {
	Path     string      `json:"path"`
	Operator string      `json:"operator"`
	Value    interface{} `json:"value"`
}

type DeviceService

type DeviceService struct {
	pb.UnimplementedDeviceServer
	// contains filtered or unexported fields
}

func NewDeviceService

func NewDeviceService() *DeviceService

func (*DeviceService) AddDeviceExt

func (s *DeviceService) AddDeviceExt(ctx context.Context, req *pb.AddDeviceExtRequest) (*emptypb.Empty, error)

func (*DeviceService) CoreSearchEntity added in v0.4.0

func (s *DeviceService) CoreSearchEntity(ctx context.Context, listEntityQuery *pb.ListEntityQuery) (map[string]interface{}, error)

func (*DeviceService) CreateDevice

func (*DeviceService) CreateDeviceDataRelation added in v0.4.0

func (s *DeviceService) CreateDeviceDataRelation(ctx context.Context, req *pb.CreateDeviceDataRelationRequest) (*emptypb.Empty, error)

func (*DeviceService) DeleteDevice

func (*DeviceService) DeleteDeviceDataRelation added in v0.4.0

func (s *DeviceService) DeleteDeviceDataRelation(ctx context.Context, req *pb.DeleteDeviceDataRelationRequest) (*emptypb.Empty, error)

func (*DeviceService) DeleteDeviceExt

func (s *DeviceService) DeleteDeviceExt(ctx context.Context, req *pb.DeleteDeviceExtRequest) (*emptypb.Empty, error)

func (*DeviceService) EnableDevice

func (s *DeviceService) EnableDevice(ctx context.Context, req *pb.EnableDeviceRequest) (*emptypb.Empty, error)

func (*DeviceService) GetDevice

func (*DeviceService) ListDeviceDataRelation added in v0.4.0

func (s *DeviceService) ListDeviceDataRelation(ctx context.Context, req *pb.ListDeviceDataRelationRequest) (*emptypb.Empty, error)

func (*DeviceService) SearchEntity added in v0.4.0

func (*DeviceService) SetDeviceAttribte added in v0.4.0

func (s *DeviceService) SetDeviceAttribte(ctx context.Context, req *pb.SetDeviceAttributeRequest) (*emptypb.Empty, error)

func (*DeviceService) SetDeviceCommand added in v0.4.0

func (s *DeviceService) SetDeviceCommand(ctx context.Context, req *pb.SetDeviceCommandRequest) (*emptypb.Empty, error)

func (*DeviceService) SetDeviceRaw added in v0.4.0

func (s *DeviceService) SetDeviceRaw(ctx context.Context, req *pb.SetDeviceRawRequest) (*emptypb.Empty, error)

func (*DeviceService) UpdateDevice

func (*DeviceService) UpdateDeviceDataRelation added in v0.4.0

func (s *DeviceService) UpdateDeviceDataRelation(ctx context.Context, req *pb.UpdateDeviceDataRelationRequest) (*emptypb.Empty, error)

func (*DeviceService) UpdateDeviceExt

func (s *DeviceService) UpdateDeviceExt(ctx context.Context, req *pb.UpdateDeviceExtRequest) (*emptypb.Empty, error)

type GroupService

type GroupService struct {
	pb.UnimplementedGroupServer
	// contains filtered or unexported fields
}

func NewGroupService

func NewGroupService() *GroupService

func (*GroupService) AddGroupExt

func (s *GroupService) AddGroupExt(ctx context.Context, req *pb.AddGroupExtRequest) (*emptypb.Empty, error)

func (*GroupService) CoreSearchEntity added in v0.4.0

func (s *GroupService) CoreSearchEntity(ctx context.Context, listEntityQuery *pb.ListEntityQuery) (map[string]interface{}, error)

func (*GroupService) CreateGroup

func (*GroupService) DelGroupExt

func (s *GroupService) DelGroupExt(ctx context.Context, req *pb.DelGroupExtRequest) (*emptypb.Empty, error)

func (*GroupService) DeleteGroup

func (*GroupService) GetGroup

func (*GroupService) GetGroupTree added in v0.4.0

func (*GroupService) UpdateGroup

func (*GroupService) UpdateGroupExt

func (s *GroupService) UpdateGroupExt(ctx context.Context, req *pb.UpdateGroupExtRequest) (*emptypb.Empty, error)

type OpenapiService

type OpenapiService struct {
	v1.UnimplementedOpenapiServer
}

OpenapiService is a openapi service.

func NewOpenapiService

func NewOpenapiService() *OpenapiService

NewOpenapiService new a openapi service.

func (*OpenapiService) AddonsIdentify

AddonsIdentify implements AddonsIdentify.OpenapiServer.

func (*OpenapiService) Identify

Identify implements Identify.OpenapiServer.

func (*OpenapiService) Status

Status implements Status.OpenapiServer.

func (*OpenapiService) TenantDisable added in v0.4.0

TenantDisable implements TenantDisable.OpenapiServer.

func (*OpenapiService) TenantEnable added in v0.4.0

TenantEnable implements TenantEnable.OpenapiServer.

type SpaceTreeNode added in v0.4.0

type SpaceTreeNode struct {
	NodeInfo *map[string]interface{}
	SubNode  *map[string]interface{}
}

type TemplateService added in v0.3.0

type TemplateService struct {
	pb.UnimplementedTemplateServer
	// contains filtered or unexported fields
}

func NewTemplateService added in v0.3.0

func NewTemplateService() *TemplateService

func (*TemplateService) AddTemplateAttribute added in v0.3.0

func (s *TemplateService) AddTemplateAttribute(ctx context.Context, req *pb.AddTemplateAttributeRequest) (*emptypb.Empty, error)
func (s *TemplateService) ListTemplate(ctx context.Context, req *pb.ListTemplateRequest) (*pb.ListTemplateResponse, error) {
	log.Debug("ListTemplate")
	log.Debug("req:", req)

	//get token
	tm, err := s.httpClient.GetTokenMap(ctx)
	if nil != err {
		return nil, err
	}

	//get core url
	midUrl := "/search"
	url := s.httpClient.GetCoreUrl(midUrl, tm, "template")
	log.Debug("url :", url)

	data, err := json.Marshal(req.ListEntityQuery)
	if nil != err {
		return nil, err
	}

	//do it
	res, err2 := s.httpClient.Post(url, data)
	if nil != err2 {
		log.Error("error get data from core : ", err2)
		return nil, err2
	}

	//fmt response
	listEntityTotalInfo := &pb.ListEntityResponse{}
	err3 := json.Unmarshal(res, listEntityTotalInfo)
	if err3 != nil {
		log.Error("error Unmarshal data from core")
		return nil, err3
	}
	out := &pb.ListTemplateResponse{
		ListTemplateObject: listEntityTotalInfo,
	}

	return out, nil
}

func (*TemplateService) AddTemplateCommand added in v0.3.0

func (s *TemplateService) AddTemplateCommand(ctx context.Context, req *pb.AddTemplateCommandRequest) (*emptypb.Empty, error)

func (*TemplateService) AddTemplateTelemetry added in v0.3.0

func (s *TemplateService) AddTemplateTelemetry(ctx context.Context, req *pb.AddTemplateTelemetryRequest) (*emptypb.Empty, error)

func (*TemplateService) AddTemplateTelemetryExt added in v0.3.0

func (s *TemplateService) AddTemplateTelemetryExt(ctx context.Context, req *pb.AddTemplateTelemetryExtRequest) (*emptypb.Empty, error)

func (*TemplateService) CoreSearchEntity added in v0.4.0

func (s *TemplateService) CoreSearchEntity(ctx context.Context, listEntityQuery *pb.ListEntityQuery) (map[string]interface{}, error)

func (*TemplateService) CreateTemplate added in v0.3.0

func (*TemplateService) DeleteTemplate added in v0.3.0

func (*TemplateService) DeleteTemplateAttribute added in v0.3.0

func (s *TemplateService) DeleteTemplateAttribute(ctx context.Context, req *pb.DeleteTemplateAttributeRequest) (*emptypb.Empty, error)

func (*TemplateService) DeleteTemplateCommand added in v0.3.0

func (s *TemplateService) DeleteTemplateCommand(ctx context.Context, req *pb.DeleteTemplateCommandRequest) (*emptypb.Empty, error)

func (*TemplateService) DeleteTemplateTelemetry added in v0.3.0

func (s *TemplateService) DeleteTemplateTelemetry(ctx context.Context, req *pb.DeleteTemplateTelemetryRequest) (*emptypb.Empty, error)

func (*TemplateService) DeleteTemplateTelemetryExt added in v0.3.0

func (s *TemplateService) DeleteTemplateTelemetryExt(ctx context.Context, req *pb.DeleteTemplateTelemetryExtRequest) (*emptypb.Empty, error)

func (*TemplateService) GetSinglePropConfExt added in v0.4.0

func (s *TemplateService) GetSinglePropConfExt(propConfig map[string]interface{}, pid string) (map[string]interface{}, error)

func (*TemplateService) GetTemplate added in v0.3.0

func (*TemplateService) GetTemplateAttribute added in v0.3.0

func (*TemplateService) GetTemplateCommand added in v0.3.0

func (*TemplateService) GetTemplatePropConfig added in v0.3.0

func (s *TemplateService) GetTemplatePropConfig(ctx context.Context, entityId string, pid string) (map[string]interface{}, error)

func (*TemplateService) GetTemplateTelemetry added in v0.3.0

func (*TemplateService) ListTemplateAttribute added in v0.3.0

func (*TemplateService) ListTemplateCommand added in v0.3.0

func (*TemplateService) ListTemplateTelemetry added in v0.3.0

func (*TemplateService) UpdateTemplate added in v0.3.0

func (*TemplateService) UpdateTemplateAttribute added in v0.3.0

func (s *TemplateService) UpdateTemplateAttribute(ctx context.Context, req *pb.UpdateTemplateAttributeRequest) (*emptypb.Empty, error)

func (*TemplateService) UpdateTemplateCommand added in v0.3.0

func (s *TemplateService) UpdateTemplateCommand(ctx context.Context, req *pb.UpdateTemplateCommandRequest) (*emptypb.Empty, error)

func (*TemplateService) UpdateTemplateTelemetry added in v0.3.0

func (s *TemplateService) UpdateTemplateTelemetry(ctx context.Context, req *pb.UpdateTemplateTelemetryRequest) (*emptypb.Empty, error)

func (*TemplateService) UpdateTemplateTelemetryExt added in v0.3.0

func (s *TemplateService) UpdateTemplateTelemetryExt(ctx context.Context, req *pb.UpdateTemplateTelemetryExtRequest) (*emptypb.Empty, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL