hanetai

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

README

hanetai

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAvatarSize = AvatarSize{
	Height: 736,
	Width:  1280,
}

Functions

func IsRetriable

func IsRetriable(err error) bool

IsRetriable checks if a given error is an Hanet retriable error

func NewOAuth2Config

func NewOAuth2Config(clientID, clientSecret, redirectURL string) *oauth2.Config

Types

type AvatarSize

type AvatarSize struct {
	Height int `json:"height"`
	Width  int `json:"width"`
}

AvatarSize store avatar size in height*width

func (AvatarSize) SetUrlValues

func (s AvatarSize) SetUrlValues(setter UrlValuesSetter)

type Client

type Client struct {

	// Base URL for API requests.
	BaseURL *url.URL

	// User agent used when communicating with the Hanet AI API.
	UserAgent string

	Devices *DeviceService
	Persons *PersonService
	Places  *PlaceService
	Profile *ProfileService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient HttpClient, ts oauth2.TokenSource) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

The provided ctx must be non-nil, if it is nil an error is returned. If it is canceled or times out, ctx.Err() will be returned.

func (*Client) NewRequest

func (c *Client) NewRequest(urlStr string, fn requestBodyFn) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

type ConnectionStatusRequest

type ConnectionStatusRequest struct {
	DeviceIDs []string `json:"deviceIDs" url:"deviceIDs,comma"`
}

type ConnectionStatusResponse

type ConnectionStatusResponse struct {
	Devices []DeviceStatus
}

type DeviceInfo

type DeviceInfo struct {
	DeviceID   string `json:"deviceID"`
	DeviceName string `json:"deviceName"`
	Address    string `json:"address"`

	PlaceID   int    `json:"placeID"`
	PlaceName string `json:"placeName"`
}

type DeviceService

type DeviceService service

func (*DeviceService) GetConnectionStatus

func (s *DeviceService) GetConnectionStatus(ctx context.Context, data *ConnectionStatusRequest) (*ConnectionStatusResponse, error)

func (*DeviceService) GetListDevices

func (s *DeviceService) GetListDevices(ctx context.Context) (*ListDevicesResponse, error)

func (*DeviceService) GetListDevicesByPlace

func (s *DeviceService) GetListDevicesByPlace(ctx context.Context, data *ListDevicesByPlaceRequest) (*ListDevicesResponse, error)

func (*DeviceService) SetDeviceMQTT

func (s *DeviceService) SetDeviceMQTT(ctx context.Context, data *SetDeviceMQTTRequest) error

func (*DeviceService) UpdateDevice

func (s *DeviceService) UpdateDevice(ctx context.Context, data *UpdateDeviceRequest) error

type DeviceStatus

type DeviceStatus struct {
	DeviceID string
	IsOnline bool
}

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
}

type ListByAliasIDAllPlaceRequest

type ListByAliasIDAllPlaceRequest struct {
	AliasID string `url:"aliasID"`
}

type ListDevicesByPlaceRequest

type ListDevicesByPlaceRequest struct {
	PlaceID int `url:"placeID"`
}

type ListDevicesResponse

type ListDevicesResponse struct {
	Devices []DeviceInfo
}

type Person

type Person struct {
	Name    string `json:"name"`
	AliasID string `json:"aliasID"`
	PlaceID int    `json:"placeID"`
	Title   string `json:"title"`
	Type    int    `json:"type"`
}

type PersonFaceURLUpdateRequest

type PersonFaceURLUpdateRequest struct {
	AliasID string `json:"aliasID"`
	PlaceID int    `json:"placeID"`
	FileURL string `json:"url"`
}

type PersonFaceUpdateRequest

type PersonFaceUpdateRequest struct {
	AliasID string `json:"aliasID"`
	PlaceID int    `json:"placeID"`
	File    io.Reader
}

type PersonListByPlaceRequest

type PersonListByPlaceRequest struct {
	PlaceID int    `url:"placeID"`
	Type    string `url:"type"`
	Page    int    `url:"page"`
	Size    int    `url:"size"`
}

type PersonListItem

type PersonListItem struct {
	Name     string `json:"name"`
	AliasID  string `json:"aliasID"`
	PersonID string `json:"personID"`
	Title    string `json:"title"`
	Avatar   string `json:"avatar"`
}

type PersonListItemWithPlace

type PersonListItemWithPlace struct {
	PersonListItem
	PlaceID int `json:"placeID"`
}

type PersonRegisterRequest

type PersonRegisterRequest struct {
	*PersonFaceUpdateRequest
	Name  string `json:"name"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

type PersonRegisterResponse

type PersonRegisterResponse struct {
	*Person
	ID   string `json:"personID"`
	File string `json:"file"`
}

type PersonRegisterURLRequest

type PersonRegisterURLRequest struct {
	*PersonFaceURLUpdateRequest
	Name  string `json:"name"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

type PersonRemoveByIDRequest

type PersonRemoveByIDRequest struct {
	PersonID string `url:"personID"`
}

type PersonRemoveByListAliasIDRequest

type PersonRemoveByListAliasIDRequest struct {
	AliasIDs []string `url:"aliasIDs,comma"`
	PlaceIDs []int    `url:"placeIDs,comma"`
}

type PersonRemoveByPlaceRequest

type PersonRemoveByPlaceRequest struct {
	AliasID string `url:"aliasID"`
	PlaceID int    `url:"placeID"`
}

type PersonRemoveRequest

type PersonRemoveRequest struct {
	AliasID string `url:"aliasID"`
}

type PersonService

type PersonService service

func (*PersonService) ListByAliasIDAllPlace

func (*PersonService) ListByPlace

func (*PersonService) Register

func (*PersonService) RegisterByURL

func (*PersonService) Remove

func (s *PersonService) Remove(ctx context.Context, data PersonRemoveRequest) error

func (*PersonService) RemoveByID

func (s *PersonService) RemoveByID(ctx context.Context, data PersonRemoveByIDRequest) error

func (*PersonService) RemoveByListAliasID

func (s *PersonService) RemoveByListAliasID(ctx context.Context, data PersonRemoveByListAliasIDRequest) error

func (*PersonService) RemoveByPlace

func (s *PersonService) RemoveByPlace(ctx context.Context, data PersonRemoveByPlaceRequest) error

func (*PersonService) TakeFacePicture

func (s *PersonService) TakeFacePicture(ctx context.Context, data TakeFacePictureRequest) error

func (*PersonService) Update

func (s *PersonService) Update(ctx context.Context, data PersonUpdateRequest) error

func (*PersonService) UpdateAliasID

func (s *PersonService) UpdateAliasID(ctx context.Context, data PersonUpdateAliasRequest) error

func (*PersonService) UpdateByFaceImage

func (s *PersonService) UpdateByFaceImage(ctx context.Context, pu PersonFaceUpdateRequest) error

func (*PersonService) UpdateByFaceURL

func (s *PersonService) UpdateByFaceURL(ctx context.Context, pu PersonFaceURLUpdateRequest) error

func (*PersonService) UserInfoByAliasID

type PersonUpdateAliasRequest

type PersonUpdateAliasRequest struct {
	// NOTE(giautm): persionID is typo from Hanet
	PersonID string `url:"persionID"`
	AliasID  string `url:"aliasID"`
}

type PersonUpdateRequest

type PersonUpdateRequest struct {
	Name    string `json:"name"`
	Title   string `json:"title"`
	AliasID string `json:"-"`
	PlaceID int    `json:"-"`
}

type Place

type Place struct {
	ID      int    `json:"id" url:"placeID"`
	Name    string `json:"name" url:"name"`
	Address string `json:"address" url:"address"`
}

type PlaceService

type PlaceService service

func (*PlaceService) AddPlace

func (s *PlaceService) AddPlace(ctx context.Context, place Place) (*Place, error)

func (*PlaceService) Places

func (s *PlaceService) Places(ctx context.Context) ([]Place, error)

func (*PlaceService) Remove

func (s *PlaceService) Remove(ctx context.Context, place Place) error

func (*PlaceService) UpdatePlace

func (s *PlaceService) UpdatePlace(ctx context.Context, place Place) error

type Profile

type Profile struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

type ProfileService

type ProfileService service

func (*ProfileService) Me

func (s *ProfileService) Me(ctx context.Context) (*Profile, error)

type ServerError

type ServerError struct {
	Code    int
	Message string

	// Person is set if the error is caused by a duplicated
	Person *Person
}

func (ServerError) Error

func (se ServerError) Error() string

type SetDeviceMQTTRequest

type SetDeviceMQTTRequest struct {
	DeviceID    string `json:"deviceID" url:"deviceID"`
	Enable      bool   `json:"enable" url:"enable,int"`
	URL         string `json:"url" url:"url"`
	Username    string `json:"username" url:"username"`
	Password    string `json:"password" url:"password"`
	Base64Image bool   `json:"image" url:"image,int"`
}

type TakeFacePictureRequest

type TakeFacePictureRequest struct {
	DeviceID string `url:"deviceID"`
}

type UpdateDeviceRequest

type UpdateDeviceRequest struct {
	DeviceID   string `json:"deviceID" url:"deviceID"`
	DeviceName string `json:"deviceName" url:"deviceName"`
}

type UrlValuesSetter

type UrlValuesSetter interface {
	Set(field string, value string)
}

type UserInfoByAliasIDRequest

type UserInfoByAliasIDRequest struct {
	AliasID string `url:"aliasID"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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