Add type definitions for new config format
This commit is contained in:
parent
ab0a91d5f2
commit
7bb676887f
41
config/types.go
Normal file
41
config/types.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"gitlab.hamburg.ccc.de/ccchh/spaceapid/types"
|
||||
)
|
||||
|
||||
type HTTPBACredentialID string
|
||||
|
||||
type HTTPBACredentials map[HTTPBACredentialID]HTTPBACredential
|
||||
|
||||
type HTTPBACredential struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type EnvironmentSensorConfig struct {
|
||||
SensorData types.EnvironmentSensor `json:"sensor_data"`
|
||||
AllowedCredentials []HTTPBACredentialID `json:"allowed_credentials"`
|
||||
}
|
||||
|
||||
type DynamicStateConfig struct {
|
||||
Sensors struct {
|
||||
Temperature []EnvironmentSensorConfig `json:"temperature"`
|
||||
Humidity []EnvironmentSensorConfig `json:"humidity"`
|
||||
} `json:"sensors"`
|
||||
State struct {
|
||||
Open struct {
|
||||
AllowedCredentials []HTTPBACredentialID `json:"allowed_credentials"`
|
||||
} `json:"open"`
|
||||
} `json:"state"`
|
||||
}
|
||||
|
||||
// SpaceapidConfig is the representation of the config.json file
|
||||
type SpaceapidConfig struct {
|
||||
// A list of username/password pairs for BasicAuth endpoints
|
||||
Credentials HTTPBACredentials `json:"credentials"`
|
||||
// The dynamic part of the spaceapi JSON
|
||||
Dynamic DynamicStateConfig `json:"dynamic"`
|
||||
// The static part of the spaceapi JSON
|
||||
Response types.SpaceAPIResponseV14 `json:"static"`
|
||||
}
|
Loading…
Reference in a new issue