Documentation ¶
Index ¶
- func AddReminder(w http.ResponseWriter, r *http.Request)
- func AddRoom(w http.ResponseWriter, r *http.Request)
- func AddSwitchPermission(w http.ResponseWriter, r *http.Request)
- func AddUser(w http.ResponseWriter, r *http.Request)
- func AddUserPermission(w http.ResponseWriter, r *http.Request)
- func ChangeActivationAutomation(w http.ResponseWriter, r *http.Request)
- func CreateCamera(w http.ResponseWriter, r *http.Request)
- func CreateNewAutomation(w http.ResponseWriter, r *http.Request)
- func CreateNewHomescript(w http.ResponseWriter, r *http.Request)
- func CreateNewSchedule(w http.ResponseWriter, r *http.Request)
- func CreateSwitch(w http.ResponseWriter, r *http.Request)
- func DebugInfo(w http.ResponseWriter, r *http.Request)
- func DeleteAllUserNotifications(w http.ResponseWriter, r *http.Request)
- func DeleteAvatar(w http.ResponseWriter, r *http.Request)
- func DeleteCamera(w http.ResponseWriter, r *http.Request)
- func DeleteHomescriptById(w http.ResponseWriter, r *http.Request)
- func DeleteReminder(w http.ResponseWriter, r *http.Request)
- func DeleteRoom(w http.ResponseWriter, r *http.Request)
- func DeleteSwitch(w http.ResponseWriter, r *http.Request)
- func DeleteUser(w http.ResponseWriter, r *http.Request)
- func DeleteUserNotificationById(w http.ResponseWriter, r *http.Request)
- func FlushAllLogs(w http.ResponseWriter, r *http.Request)
- func FlushOldLogs(w http.ResponseWriter, r *http.Request)
- func GetAllCameras(w http.ResponseWriter, _ *http.Request)
- func GetAllSwitches(w http.ResponseWriter, r *http.Request)
- func GetAvatar(w http.ResponseWriter, r *http.Request)
- func GetCameraFeed(w http.ResponseWriter, r *http.Request)
- func GetCurrentUserPermissions(w http.ResponseWriter, r *http.Request)
- func GetForeignUserAvatar(w http.ResponseWriter, r *http.Request)
- func GetForeignUserPermissions(w http.ResponseWriter, r *http.Request)
- func GetForeignUserSwitchPermissions(w http.ResponseWriter, r *http.Request)
- func GetNotificationCount(w http.ResponseWriter, r *http.Request)
- func GetNotifications(w http.ResponseWriter, r *http.Request)
- func GetPowerStates(w http.ResponseWriter, r *http.Request)
- func GetReminders(w http.ResponseWriter, r *http.Request)
- func GetUserAutomations(w http.ResponseWriter, r *http.Request)
- func GetUserCameras(w http.ResponseWriter, r *http.Request)
- func GetUserDetails(w http.ResponseWriter, r *http.Request)
- func GetUserHomescriptById(w http.ResponseWriter, r *http.Request)
- func GetUserSchedules(w http.ResponseWriter, r *http.Request)
- func GetUserSwitches(w http.ResponseWriter, r *http.Request)
- func HandleAvatarUpload(w http.ResponseWriter, r *http.Request)
- func HealthCheck(w http.ResponseWriter, r *http.Request)
- func InitLogger(logger *logrus.Logger)
- func ListAllRoomsWithSwitches(w http.ResponseWriter, r *http.Request)
- func ListLogs(w http.ResponseWriter, r *http.Request)
- func ListPermissions(w http.ResponseWriter, r *http.Request)
- func ListPersonalHomescripts(w http.ResponseWriter, r *http.Request)
- func ListUserRoomsWithSwitches(w http.ResponseWriter, r *http.Request)
- func ListUsers(w http.ResponseWriter, r *http.Request)
- func ModifyAutomation(w http.ResponseWriter, r *http.Request)
- func ModifyCamera(w http.ResponseWriter, r *http.Request)
- func ModifyCurrentUserMetadata(w http.ResponseWriter, r *http.Request)
- func ModifyHomescript(w http.ResponseWriter, r *http.Request)
- func ModifyReminder(w http.ResponseWriter, r *http.Request)
- func ModifyRoomData(w http.ResponseWriter, r *http.Request)
- func ModifySchedule(w http.ResponseWriter, r *http.Request)
- func ModifySwitch(w http.ResponseWriter, r *http.Request)
- func ModifyUserMetadata(w http.ResponseWriter, r *http.Request)
- func PowerPostHandler(w http.ResponseWriter, r *http.Request)
- func RemoveAutomation(w http.ResponseWriter, r *http.Request)
- func RemoveSchedule(w http.ResponseWriter, r *http.Request)
- func RemoveSwitchPermission(w http.ResponseWriter, r *http.Request)
- func RemoveUserPermission(w http.ResponseWriter, r *http.Request)
- func Res(w http.ResponseWriter, res Response)
- func RunHomescriptString(w http.ResponseWriter, r *http.Request)
- func SetCurrentUserColorTheme(w http.ResponseWriter, r *http.Request)
- func SetCurrentUserSchedulerEnabled(w http.ResponseWriter, r *http.Request)
- func SetUserColorTheme(w http.ResponseWriter, r *http.Request)
- func SetUserSchedulerEnabled(w http.ResponseWriter, r *http.Request)
- func UpdateLocation(w http.ResponseWriter, r *http.Request)
- type AddCameraRequest
- type AddReminderRequest
- type AddSwitchRequest
- type AddUserRequest
- type AddedReminderResponse
- type AutomationActivationRequest
- type CreateHomescriptRequest
- type CurrentUserSchedulerEnabledRequest
- type DeleteAutomationRequest
- type DeleteCameraRequest
- type DeleteNotificationByIdRequest
- type DeleteRoomRequest
- type DeleteScheduleRequest
- type DeleteSwitchRequest
- type HomescriptIdRequest
- type HomescriptLiveRunRequest
- type HomescriptResponse
- type LoginRequest
- type ModifyAutomationRequest
- type ModifyCameraRequest
- type ModifyForeignUserMetadataRequest
- type ModifyGenericScheduleRequest
- type ModifyPowerScheduleRequest
- type ModifyReminderRequest
- type ModifySwitchRequest
- type ModifyUserMetadataRequest
- type NewAutomationRequest
- type NewPowerScheduleRequest
- type NewScheduleRequest
- type NotificationCountResponse
- type PowerRequest
- type RemoveReminderRequest
- type RemoveUserRequest
- type Response
- type RoomRequest
- type SetColorThemeRequest
- type SetForeignUserColorThemeRequest
- type UpdateLocationRequest
- type UserPermissionRequest
- type UserSchedulerEnabledRequest
- type UserSwitchPermissionRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddReminder ¶
func AddReminder(w http.ResponseWriter, r *http.Request)
Adds a new reminder to the database
func AddSwitchPermission ¶
func AddSwitchPermission(w http.ResponseWriter, r *http.Request)
Add a switchPermission to a given user, admin authentication required Request: `{"username": "x", "switch": "y"}` | Response: Response
func AddUser ¶
func AddUser(w http.ResponseWriter, r *http.Request)
Creates a new user and gives him a provided password Request: `{"username": "x", "password": "y"}`, admin auth required
func AddUserPermission ¶
func AddUserPermission(w http.ResponseWriter, r *http.Request)
Adds a given permission to a given user, admin authentication required If the permission is invalid, a `422` is returned Request: `{"username": "", "permission": ""}` | Response: Response
func ChangeActivationAutomation ¶
func ChangeActivationAutomation(w http.ResponseWriter, r *http.Request)
Activate or deactivate the entire automation system
func CreateCamera ¶
func CreateCamera(w http.ResponseWriter, r *http.Request)
Creates a new camera with the provided metadata
func CreateNewAutomation ¶
func CreateNewAutomation(w http.ResponseWriter, r *http.Request)
Creates a new automation
func CreateNewHomescript ¶
func CreateNewHomescript(w http.ResponseWriter, r *http.Request)
Creates a new Homescript
func CreateNewSchedule ¶
func CreateNewSchedule(w http.ResponseWriter, r *http.Request)
Creates a new generic schedule which runs homescript
func CreateSwitch ¶
func CreateSwitch(w http.ResponseWriter, r *http.Request)
Creates a switch in the database
func DebugInfo ¶
func DebugInfo(w http.ResponseWriter, r *http.Request)
Reading system debug information, admin authentication required Todo: read raspberry pi information
func DeleteAllUserNotifications ¶
func DeleteAllUserNotifications(w http.ResponseWriter, r *http.Request)
func DeleteAvatar ¶
func DeleteAvatar(w http.ResponseWriter, r *http.Request)
Deletes the user's currently saved avatar and sets it to default, authentication required
func DeleteCamera ¶
func DeleteCamera(w http.ResponseWriter, r *http.Request)
func DeleteHomescriptById ¶
func DeleteHomescriptById(w http.ResponseWriter, r *http.Request)
Deletes a Homescript by its Id, checks if it exists and if the user has permission to delete it
func DeleteReminder ¶
func DeleteReminder(w http.ResponseWriter, r *http.Request)
Deletes a reminder, for example if it's task is finished
func DeleteRoom ¶
func DeleteRoom(w http.ResponseWriter, r *http.Request)
Deletes a room and all its dependencies
func DeleteSwitch ¶
func DeleteSwitch(w http.ResponseWriter, r *http.Request)
func DeleteUser ¶
func DeleteUser(w http.ResponseWriter, r *http.Request)
Deletes a user given a valid username This also needs to delete any data that depends on this user in terms of a foreign key Admin auth required
func DeleteUserNotificationById ¶
func DeleteUserNotificationById(w http.ResponseWriter, r *http.Request)
Delete a given notification from the current user
func FlushAllLogs ¶
func FlushAllLogs(w http.ResponseWriter, r *http.Request)
Triggers deletion of ALL internal server logs, admin authentication required Request: empty | Response: Response
func FlushOldLogs ¶
func FlushOldLogs(w http.ResponseWriter, r *http.Request)
Triggers deletion of internal server logs which are older than 30 days, admin authentication required Request: empty | Response: Response
func GetAllCameras ¶
func GetAllCameras(w http.ResponseWriter, _ *http.Request)
Returns a list of available cameras as JSON to the user, admin authentication is required because such information is confidential
func GetAllSwitches ¶
func GetAllSwitches(w http.ResponseWriter, r *http.Request)
Returns a list of available switches as JSON to the user, no authentication required
func GetAvatar ¶
func GetAvatar(w http.ResponseWriter, r *http.Request)
Returns the user's current avatar as an image, authentication required
func GetCameraFeed ¶
func GetCameraFeed(w http.ResponseWriter, r *http.Request)
/Camera feed and image fetching ///
func GetCurrentUserPermissions ¶
func GetCurrentUserPermissions(w http.ResponseWriter, r *http.Request)
Returns a list of strings which represent permissions of the currently logged in user, admin authentication required Request: empty | Response: `["a", "b", "c"]`
func GetForeignUserAvatar ¶
func GetForeignUserAvatar(w http.ResponseWriter, r *http.Request)
Returns the avatar of any given user. Used for the user management panel
func GetForeignUserPermissions ¶
func GetForeignUserPermissions(w http.ResponseWriter, r *http.Request)
Returns a list of strings which represent the permissions of an arbitrary user, admin authentication required
func GetForeignUserSwitchPermissions ¶
func GetForeignUserSwitchPermissions(w http.ResponseWriter, r *http.Request)
Returns a list of strings which represent the switch permissions of an arbitrary user, admin authentication required
func GetNotificationCount ¶
func GetNotificationCount(w http.ResponseWriter, r *http.Request)
Returns a uin16 that indicates the number of notifications the current user has, no authentication required
func GetNotifications ¶
func GetNotifications(w http.ResponseWriter, r *http.Request)
Returns a list containing notifications of the current user
func GetPowerStates ¶
func GetPowerStates(w http.ResponseWriter, r *http.Request)
Returns a list of power states, no authentication required Request: empty | Response: `[{"switchId": "x", power: false}, {...}]`
func GetReminders ¶
func GetReminders(w http.ResponseWriter, r *http.Request)
Returns a list of reminders that the current user has added
func GetUserAutomations ¶
func GetUserAutomations(w http.ResponseWriter, r *http.Request)
Returns a list of all automations set up by the current user
func GetUserCameras ¶
func GetUserCameras(w http.ResponseWriter, r *http.Request)
Only returns cameras to which the user has access to, authentication required
func GetUserDetails ¶
func GetUserDetails(w http.ResponseWriter, r *http.Request)
Returns the user's personal data, auth required
func GetUserHomescriptById ¶
func GetUserHomescriptById(w http.ResponseWriter, r *http.Request)
Returns the metadata of an arbitrary homescript-id to which the user has access to
func GetUserSchedules ¶
func GetUserSchedules(w http.ResponseWriter, r *http.Request)
Returns a list of all schedules set up by the current user
func GetUserSwitches ¶
func GetUserSwitches(w http.ResponseWriter, r *http.Request)
Only returns switches which the user has access to, authentication required
func HandleAvatarUpload ¶
func HandleAvatarUpload(w http.ResponseWriter, r *http.Request)
Accepts the upload of an image of following allowed formats (png / webp / jpeg / jpg) Image should ideally be in `1:1` aspect ratio, authentication required`
func HealthCheck ¶
func HealthCheck(w http.ResponseWriter, r *http.Request)
Runs a healthcheck of most systems on which the appplication relies on, will be used by e.g `Uptime Kuma`, no authentication required
func InitLogger ¶
func ListAllRoomsWithSwitches ¶
func ListAllRoomsWithSwitches(w http.ResponseWriter, r *http.Request)
Returns list of all rooms
func ListLogs ¶
func ListLogs(w http.ResponseWriter, r *http.Request)
Returns a list of logging items in the logging table, admin authentication required
func ListPermissions ¶
func ListPermissions(w http.ResponseWriter, r *http.Request)
Returns the list of all available permissions
func ListPersonalHomescripts ¶
func ListPersonalHomescripts(w http.ResponseWriter, r *http.Request)
Returns a list of homescripts which are owned by the current user
func ListUserRoomsWithSwitches ¶
func ListUserRoomsWithSwitches(w http.ResponseWriter, r *http.Request)
Returns list of rooms which contain switches that the user is allowed to use
func ListUsers ¶
func ListUsers(w http.ResponseWriter, r *http.Request)
Returns a list of users and their metadata, admin auth required
func ModifyAutomation ¶
func ModifyAutomation(w http.ResponseWriter, r *http.Request)
Modifies a existing automation, also restarts the schedule
func ModifyCamera ¶
func ModifyCamera(w http.ResponseWriter, r *http.Request)
func ModifyCurrentUserMetadata ¶
func ModifyCurrentUserMetadata(w http.ResponseWriter, r *http.Request)
Modifies the metadata of the current user
func ModifyHomescript ¶
func ModifyHomescript(w http.ResponseWriter, r *http.Request)
Modifies the metadata of a given homescript
func ModifyReminder ¶
func ModifyReminder(w http.ResponseWriter, r *http.Request)
Modifies a reminder given its id and new metadata
func ModifyRoomData ¶
func ModifyRoomData(w http.ResponseWriter, r *http.Request)
Modifies the room's name and description
func ModifySchedule ¶
func ModifySchedule(w http.ResponseWriter, r *http.Request)
Modify a generic schedule which already exists
func ModifySwitch ¶
func ModifySwitch(w http.ResponseWriter, r *http.Request)
func ModifyUserMetadata ¶
func ModifyUserMetadata(w http.ResponseWriter, r *http.Request)
Modifies the metadata of a given user
func PowerPostHandler ¶
func PowerPostHandler(w http.ResponseWriter, r *http.Request)
API endpoint for manipulating power states and (de) activating sockets, authentication required Permission and switch permission is needed to interact with this endpoint
func RemoveAutomation ¶
func RemoveAutomation(w http.ResponseWriter, r *http.Request)
Stops, then removes the given automation from the system
func RemoveSchedule ¶
func RemoveSchedule(w http.ResponseWriter, r *http.Request)
Stops, then removes the given schedule from the system
func RemoveSwitchPermission ¶
func RemoveSwitchPermission(w http.ResponseWriter, r *http.Request)
Removes a given switch permission from a given user, admin authentication required Request: `{"username": "x", "switch": "y"}` | Response: Response
func RemoveUserPermission ¶
func RemoveUserPermission(w http.ResponseWriter, r *http.Request)
Todo: unit tests for some of the subfunction Removes a given permission from a user, admin authentication required Request: `{"username": "x", "permission": "y"}` | Response: Response
func Res ¶
func Res(w http.ResponseWriter, res Response)
func RunHomescriptString ¶
func RunHomescriptString(w http.ResponseWriter, r *http.Request)
Runs any given Homescript as a string
func SetCurrentUserColorTheme ¶
func SetCurrentUserColorTheme(w http.ResponseWriter, r *http.Request)
Allows the user to change whether they want to use the light or dark theme
func SetCurrentUserSchedulerEnabled ¶
func SetCurrentUserSchedulerEnabled(w http.ResponseWriter, r *http.Request)
Set if the user scheduler is enabled or disabled
func SetUserColorTheme ¶
func SetUserColorTheme(w http.ResponseWriter, r *http.Request)
func SetUserSchedulerEnabled ¶
func SetUserSchedulerEnabled(w http.ResponseWriter, r *http.Request)
Set if the user scheduler is enabled or disabled
func UpdateLocation ¶
func UpdateLocation(w http.ResponseWriter, r *http.Request)
Admin endpoints for changing the servers global configuration
Types ¶
type AddCameraRequest ¶
type AddReminderRequest ¶
type AddReminderRequest struct { Name string `json:"name"` Description string `json:"description"` Priority database.NotificationPriority `json:"priority"` DueDate uint `json:"dueDate"` // Will be sent as unix millis }
type AddSwitchRequest ¶
type AddUserRequest ¶
type AddedReminderResponse ¶
type AutomationActivationRequest ¶
type AutomationActivationRequest struct {
Enabled bool `json:"enabled"`
}
type CreateHomescriptRequest ¶
type CurrentUserSchedulerEnabledRequest ¶
type CurrentUserSchedulerEnabledRequest struct {
Enabled bool `json:"enabled"`
}
type DeleteAutomationRequest ¶
type DeleteAutomationRequest struct {
Id uint `json:"id"`
}
type DeleteCameraRequest ¶
type DeleteCameraRequest struct {
Id string `json:"id"`
}
type DeleteNotificationByIdRequest ¶
type DeleteNotificationByIdRequest struct {
Id uint `json:"id"`
}
type DeleteRoomRequest ¶
type DeleteRoomRequest struct {
Id string `json:"id"`
}
type DeleteScheduleRequest ¶
type DeleteScheduleRequest struct {
Id uint `json:"id"`
}
type DeleteSwitchRequest ¶
type DeleteSwitchRequest struct {
Id string `json:"id"`
}
type HomescriptIdRequest ¶
type HomescriptIdRequest struct {
Id string `json:"id"`
}
type HomescriptLiveRunRequest ¶
type HomescriptLiveRunRequest struct {
Code string `json:"code"`
}
type HomescriptResponse ¶
type HomescriptResponse struct { Success bool `json:"success"` Exitcode int `json:"exitCode"` Message string `json:"message"` Output string `json:"output"` Errors []homescript.HomescriptError `json:"error"` }
type LoginRequest ¶
type ModifyAutomationRequest ¶
type ModifyAutomationRequest struct { Id uint `json:"id"` Name string `json:"name"` Description string `json:"description"` Hour uint `json:"hour"` Minute uint `json:"minute"` Days []uint8 `json:"days"` HomescriptId string `json:"homescriptId"` Enabled bool `json:"enabled"` TimingMode database.TimingMode `json:"timingMode"` }
type ModifyCameraRequest ¶
type ModifyForeignUserMetadataRequest ¶
type ModifyForeignUserMetadataRequest struct { Username string `json:"username"` Data ModifyUserMetadataRequest `json:"data"` }
type ModifyReminderRequest ¶
type ModifySwitchRequest ¶
type NewAutomationRequest ¶
type NewAutomationRequest struct { Name string `json:"name"` Description string `json:"description"` Hour uint `json:"hour"` // 24 >= h >= 0 | Can only be used with minute, specifies the exact hour in which the automation will run, 0 is midnight, 15 is 3PM, 3 is 3AM -> 24h format Minute uint `json:"minute"` // 60 >= m >= 0 | Can only be used with hour, specifies the exact minute on which the automation will run Days []uint8 `json:"days"` // 6 >= d >= 0 | Can contain 7 elements at maximum, value `0` represents Sunday, value `6` represents Saturday HomescriptId string `json:"homescriptId"` Enabled bool `json:"enabled"` TimingMode database.TimingMode `json:"timingMode"` }
type NewPowerScheduleRequest ¶
type NewPowerScheduleRequest struct { Name string `json:"name"` Hour uint `json:"hour"` Minute uint `json:"minute"` PowerJobs []hardware.PowerRequest `json:"powerJobs"` }
type NewScheduleRequest ¶
type NotificationCountResponse ¶
type NotificationCountResponse struct {
NotificationCount uint16 `json:"count"`
}
type PowerRequest ¶
type RemoveReminderRequest ¶
type RemoveReminderRequest struct {
Id uint `json:"id"`
}
type RemoveUserRequest ¶
type RemoveUserRequest struct {
Username string `json:"username"`
}
type RoomRequest ¶
type SetColorThemeRequest ¶
type SetColorThemeRequest struct {
DarkTheme bool `json:"darkTheme"`
}