api

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: GPL-3.0 Imports: 12 Imported by: 2

Documentation

Overview

Package api implements a wrapper around the rest api

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helper

type Helper struct {
	AlarmURL          string
	ExtraHeader       string
	ExtreaHeaderValue string
}

Helper struct to define the api settings being used

func GetHelperFromEnv added in v1.1.0

func GetHelperFromEnv() Helper

GetHelperFromEnv Returns the working helper object with the config loaded from a .env file It uses dotenv this means a .env file is required.

ALARMURL=URL-TO-ALARM  # https://example.com
EXTRAHEADER=EXTRA-HEADER # eg. ApiKey
EXTRAHEADERVALUE=VALUE-FOR-THE-HEADER  # eg. password1234

func (*Helper) AddAlarm

func (helper *Helper) AddAlarm(alarm types.Alarm) ([]types.Alarm, error)

AddAlarm adds the given alarm

func (*Helper) ChangeAlarm

func (helper *Helper) ChangeAlarm(alarm types.Alarm, idx int) (types.Alarm, error)

ChangeAlarm changes the alarm on the given index with the data of the passed instance

func (*Helper) CheckHealth

func (helper *Helper) CheckHealth() error

CheckHealth checks wether the api is reachable and returns 200 on the health endpoint

func (*Helper) DeleteAlarm

func (helper *Helper) DeleteAlarm(idx int) ([]types.Alarm, error)

DeleteAlarm deletes the alarm with the given index

func (*Helper) GetAlarm

func (helper *Helper) GetAlarm(idx int, withWritePermission bool) (types.Alarm, error)

GetAlarm gets a specific alarm by index

func (*Helper) GetAlarms

func (helper *Helper) GetAlarms(withWritePermission bool) ([]types.Alarm, error)

GetAlarms gets all alarms

func (*Helper) GetRadio

func (helper *Helper) GetRadio(withWritePermission bool) (types.Radio, error)

GetRadio returns the radio status

func (*Helper) SaveAlarm added in v1.1.0

func (helper *Helper) SaveAlarm(idx int, alarm types.Alarm) (types.Alarm, error)

SaveAlarm saves the given alarm on the given index

func (*Helper) SaveRadio added in v1.1.0

func (helper *Helper) SaveRadio(radio types.Radio) (types.Radio, error)

SaveRadio saves the radio and returns it

func (*Helper) StartRadio

func (helper *Helper) StartRadio() (types.Radio, error)

StartRadio starts the radio

func (*Helper) StopRadio

func (helper *Helper) StopRadio() (types.Radio, error)

StopRadio stops the radio

func (*Helper) SwitchRadio added in v1.1.0

func (helper *Helper) SwitchRadio(running bool) (types.Radio, error)

SwitchRadio changes the radio to the state running passed as argument

Jump to

Keyboard shortcuts

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