joshuar-go-hass-agent/internal/hass/api/rest.gen.go

439 lines
14 KiB
Go

// Package api provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
package api
import (
"encoding/json"
externalRef0 "github.com/joshuar/go-hass-agent/internal/models"
"github.com/oapi-codegen/nullable"
"github.com/oapi-codegen/runtime"
)
// Defines values for RequestType.
const (
Auth RequestType = "auth"
AuthInvalid RequestType = "auth_invalid"
AuthOk RequestType = "auth_ok"
AuthRequired RequestType = "auth_required"
Encrypted RequestType = "encrypted"
FireEvent RequestType = "fire_event"
GetConfig RequestType = "get_config"
MobileApppushNotificationChannel RequestType = "mobile_app/push_notification_channel"
Ping RequestType = "ping"
Pong RequestType = "pong"
RegisterSensor RequestType = "register_sensor"
Result RequestType = "result"
UpdateLocation RequestType = "update_location"
UpdateSensorStates RequestType = "update_sensor_states"
)
// APIError defines an error status returned by the API.
type APIError struct {
Code *string `json:"code,omitempty"`
Message *string `json:"message,omitempty"`
}
// Config defines model for Config.
type Config = map[string]interface{}
// ConfigResponse is a response containing Home Assistant configuration details.
type ConfigResponse struct {
Components *[]string `json:"components,omitempty"`
ConfigDir *string `json:"config_dir,omitempty"`
Elevation *int `json:"elevation,omitempty"`
// Entities is the list sensor entities registered with this app and their status.
Entities nullable.Nullable[map[string]map[string]interface{}] `json:"entities,omitempty"`
Latitude *float32 `json:"latitude,omitempty"`
LocationName *string `json:"location_name,omitempty"`
Longitude *float32 `json:"longitude,omitempty"`
// TimeZone is the configured timezone of the Home Assistant instance.
TimeZone *string `json:"time_zone,omitempty"`
// UnitSystem is the current unit systems used by the Home Assistant instance.
UnitSystem *struct {
Length *string `json:"length,omitempty"`
Mass *string `json:"mass,omitempty"`
Temperature *string `json:"temperature,omitempty"`
Volume *string `json:"volume,omitempty"`
} `json:"unit_system,omitempty"`
// Version is the version of Home Assistant.
Version *string `json:"version,omitempty"`
WhitelistExternalDirs *[]string `json:"whitelist_external_dirs,omitempty"`
}
// DeviceRegistrationRequest defines the registration details for the device running the agent.
type DeviceRegistrationRequest struct {
// AppData Contains app data can be used if the app has a supporting component that extends mobile_app functionality.
AppData *map[string]interface{} `json:"app_data,omitempty"`
// AppID is a unique identifier for this app.
AppID string `json:"app_id"`
// AppName is the name of the mobile app.
AppName string `json:"app_name"`
// AppVersion is the version of the mobile app.
AppVersion string `json:"app_version"`
// DeviceID is a unique identifier for this device.
DeviceID string `json:"device_id"`
// DeviceName is the name for this device.
DeviceName string `json:"device_name"`
// Manufacturer is the manufacturer of the device running the app.
Manufacturer string `json:"manufacturer"`
// Model is the model of the device running the app.
Model string `json:"model"`
// OsName is the name of the OS running the app.
OsName string `json:"os_name"`
// OsVersion is the OS version of the device running the app.
OsVersion string `json:"os_version"`
// SupportsEncryption indicates if the app supports encryption.
SupportsEncryption bool `json:"supports_encryption"`
}
// DeviceRegistrationResponse defines the reponse for a device registration from Home Assistant. Contains URLs to use for connecting to Home Assistant.
type DeviceRegistrationResponse struct {
// CloudhookURL is the cloudhook URL provided by Home Assistant Cloud. Only will be provided if user is actively subscribed to Nabu Casa.
CloudhookURL *string `json:"cloudhook_url,omitempty"`
// RemoteUIURL is the remote UI URL provided by Home Assistant Cloud. Only will be provided if user is actively subscribed to Nabu Casa.
RemoteUIURL *string `json:"remote_ui_url,omitempty"`
// Secret is the secret to use for encrypted communication. Will only be included if encryption is supported by both the app and the Home Assistant instance. More info.
Secret *string `json:"secret,omitempty"`
// WebhookID is the webhook ID that can be used to send data back.
WebhookID WebhookID `json:"webhook_id"`
}
// Event defines model for Event.
type Event = externalRef0.Event
// Location defines location details of the device.
type Location = externalRef0.Location
// Request defines a request sent through the API.
type Request struct {
// Data is the request payload.
Data *Request_Data `json:"data,omitempty"`
// Encrypted indicates the request payload is encrypted.
Encrypted *bool `json:"encrypted,omitempty"`
// Retryable indicates whether the request can be retried.
Retryable *bool `json:"-"`
// Type is the type of request.
Type RequestType `json:"type"`
}
// Request_Data is the request payload.
type Request_Data struct {
union json.RawMessage
}
// RequestType is the type of request.
type RequestType string
// Response defines a response received through the API.
type Response struct {
union json.RawMessage
}
// ResponseStatus contains response specific details returned from the Home Assistant API.
type ResponseStatus struct {
// Error contains API specific error details for a failed request.
Error nullable.Nullable[APIError] `json:"error,omitempty"`
// IsDisabled is returned for sensor entity requests and indicates whether the sensor entity has been disabled in Home Assistant.
IsDisabled nullable.Nullable[bool] `json:"is_disabled,omitempty"`
// IsSuccess is returned to indicate that the success status of the request.
IsSuccess nullable.Nullable[bool] `json:"success,omitempty"`
}
// SensorRegistration defines a sensor to be registered with Home Assistant.
type SensorRegistration = externalRef0.SensorRegistration
// SensorRegistrationResponse contains details on sensor registration status.
type SensorRegistrationResponse struct {
Error *APIError `json:"error,omitempty"`
// Success indicates if the sensor registration was successful.
Success *bool `json:"success,omitempty"`
}
// SensorState defines the current state of a sensor.
type SensorState = externalRef0.SensorState
// SensorStateResponse contains a map of response status for each sensor state sent.
type SensorStateResponse map[string]ResponseStatus
// WebhookID is the webhook ID that can be used to send data back.
type WebhookID = string
// AsLocation returns the union data inside the Request_Data as a Location
func (t Request_Data) AsLocation() (Location, error) {
var body Location
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromLocation overwrites any union data inside the Request_Data as the provided Location
func (t *Request_Data) FromLocation(v Location) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeLocation performs a merge with any union data inside the Request_Data, using the provided Location
func (t *Request_Data) MergeLocation(v Location) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
// AsSensorState returns the union data inside the Request_Data as a SensorState
func (t Request_Data) AsSensorState() (SensorState, error) {
var body SensorState
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromSensorState overwrites any union data inside the Request_Data as the provided SensorState
func (t *Request_Data) FromSensorState(v SensorState) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeSensorState performs a merge with any union data inside the Request_Data, using the provided SensorState
func (t *Request_Data) MergeSensorState(v SensorState) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
// AsSensorRegistration returns the union data inside the Request_Data as a SensorRegistration
func (t Request_Data) AsSensorRegistration() (SensorRegistration, error) {
var body SensorRegistration
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromSensorRegistration overwrites any union data inside the Request_Data as the provided SensorRegistration
func (t *Request_Data) FromSensorRegistration(v SensorRegistration) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeSensorRegistration performs a merge with any union data inside the Request_Data, using the provided SensorRegistration
func (t *Request_Data) MergeSensorRegistration(v SensorRegistration) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
// AsEvent returns the union data inside the Request_Data as a Event
func (t Request_Data) AsEvent() (Event, error) {
var body Event
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromEvent overwrites any union data inside the Request_Data as the provided Event
func (t *Request_Data) FromEvent(v Event) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeEvent performs a merge with any union data inside the Request_Data, using the provided Event
func (t *Request_Data) MergeEvent(v Event) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
// AsConfig returns the union data inside the Request_Data as a Config
func (t Request_Data) AsConfig() (Config, error) {
var body Config
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromConfig overwrites any union data inside the Request_Data as the provided Config
func (t *Request_Data) FromConfig(v Config) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeConfig performs a merge with any union data inside the Request_Data, using the provided Config
func (t *Request_Data) MergeConfig(v Config) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
func (t Request_Data) MarshalJSON() ([]byte, error) {
b, err := t.union.MarshalJSON()
return b, err
}
func (t *Request_Data) UnmarshalJSON(b []byte) error {
err := t.union.UnmarshalJSON(b)
return err
}
// AsSensorStateResponse returns the union data inside the Response as a SensorStateResponse
func (t Response) AsSensorStateResponse() (SensorStateResponse, error) {
var body SensorStateResponse
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromSensorStateResponse overwrites any union data inside the Response as the provided SensorStateResponse
func (t *Response) FromSensorStateResponse(v SensorStateResponse) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeSensorStateResponse performs a merge with any union data inside the Response, using the provided SensorStateResponse
func (t *Response) MergeSensorStateResponse(v SensorStateResponse) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
// AsSensorRegistrationResponse returns the union data inside the Response as a SensorRegistrationResponse
func (t Response) AsSensorRegistrationResponse() (SensorRegistrationResponse, error) {
var body SensorRegistrationResponse
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromSensorRegistrationResponse overwrites any union data inside the Response as the provided SensorRegistrationResponse
func (t *Response) FromSensorRegistrationResponse(v SensorRegistrationResponse) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeSensorRegistrationResponse performs a merge with any union data inside the Response, using the provided SensorRegistrationResponse
func (t *Response) MergeSensorRegistrationResponse(v SensorRegistrationResponse) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
// AsConfigResponse returns the union data inside the Response as a ConfigResponse
func (t Response) AsConfigResponse() (ConfigResponse, error) {
var body ConfigResponse
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromConfigResponse overwrites any union data inside the Response as the provided ConfigResponse
func (t *Response) FromConfigResponse(v ConfigResponse) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeConfigResponse performs a merge with any union data inside the Response, using the provided ConfigResponse
func (t *Response) MergeConfigResponse(v ConfigResponse) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
// AsResponseStatus returns the union data inside the Response as a ResponseStatus
func (t Response) AsResponseStatus() (ResponseStatus, error) {
var body ResponseStatus
err := json.Unmarshal(t.union, &body)
return body, err
}
// FromResponseStatus overwrites any union data inside the Response as the provided ResponseStatus
func (t *Response) FromResponseStatus(v ResponseStatus) error {
b, err := json.Marshal(v)
t.union = b
return err
}
// MergeResponseStatus performs a merge with any union data inside the Response, using the provided ResponseStatus
func (t *Response) MergeResponseStatus(v ResponseStatus) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
merged, err := runtime.JSONMerge(t.union, b)
t.union = merged
return err
}
func (t Response) MarshalJSON() ([]byte, error) {
b, err := t.union.MarshalJSON()
return b, err
}
func (t *Response) UnmarshalJSON(b []byte) error {
err := t.union.UnmarshalJSON(b)
return err
}