diff --git a/config/types.go b/config/types.go new file mode 100644 index 0000000..a6a3728 --- /dev/null +++ b/config/types.go @@ -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"` +}