hanetai

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

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 added in v0.2.0

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 added in v0.2.1

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    string `json:"type"`
}

type PersonFaceURLUpdateRequest added in v0.1.1

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 added in v0.2.1

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 added in v0.1.1

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

type PersonRemoveByIDRequest added in v0.2.1

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

type PersonRemoveByListAliasIDRequest added in v0.2.1

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 added in v0.2.1

func (*PersonService) ListByPlace

func (*PersonService) Register

func (*PersonService) RegisterByURL added in v0.1.1

func (*PersonService) Remove

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

func (*PersonService) RemoveByID added in v0.2.1

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

func (*PersonService) RemoveByListAliasID added in v0.2.1

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 added in v0.1.1

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 added in v0.1.1

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

func (*PersonService) UserInfoByAliasID added in v0.2.1

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 added in v0.2.1

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

type ProfileService added in v0.2.1

type ProfileService service

func (*ProfileService) Me added in v0.2.1

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 added in v0.2.0

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 added in v0.1.1

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 added in v0.2.1

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