Documentation ¶
Overview ¶
Package api provides primitives to interact with the openapi HTTP API.
Code generated by github.com/discord-gophers/goapi-gen version v0.3.0 DO NOT EDIT.
Package api provides primitives to interact with the openapi HTTP API.
Code generated by github.com/discord-gophers/goapi-gen version v0.2.2 DO NOT EDIT.
Index ¶
- Constants
- Variables
- func Handler(si ServerInterface, opts ...ServerOption) http.Handler
- type AlertHistoryEntry
- type AuthLoginJSONBody
- type AuthLoginJSONRequestBody
- type CreateUserJSONBody
- type CreateUserJSONRequestBody
- type Error
- type InvalidParamFormatError
- type Middlewares
- type ParameterError
- type RegisterWebpushJSONBody
- type RegisterWebpushJSONRequestBody
- type RenameSensorParams
- type RequiredHeaderError
- type RequiredParamError
- type Response
- func AuthLoginJSON200Response(body struct{ ... }) *Response
- func AuthLoginJSONDefaultResponse(body Error) *Response
- func AuthLogoutJSONDefaultResponse(body Error) *Response
- func CreateUserJSON200Response(body User) *Response
- func CreateUserJSONDefaultResponse(body Error) *Response
- func DeleteUserByIDJSON200Response(body User) *Response
- func DeleteUserByIDJSONDefaultResponse(body Error) *Response
- func GetAlertsJSON200Response(body []AlertHistoryEntry) *Response
- func GetAlertsJSONDefaultResponse(body Error) *Response
- func GetSensorsJSON200Response(body []SensorInfo) *Response
- func GetSensorsJSONDefaultResponse(body Error) *Response
- func GetSensorsLiveJSON200Response(body []SensorData) *Response
- func GetSensorsLiveJSONDefaultResponse(body Error) *Response
- func GetUserByIDJSON200Response(body User) *Response
- func GetUserByIDJSONDefaultResponse(body Error) *Response
- func GetUsersJSON200Response(body []User) *Response
- func GetUsersJSONDefaultResponse(body Error) *Response
- func GetWebpushKeyJSON200Response(body WebpushKey) *Response
- func GetWebpushKeyJSONDefaultResponse(body Error) *Response
- func RegisterWebpushJSONDefaultResponse(body Error) *Response
- func RenameSensorJSON200Response(body SensorInfo) *Response
- func RenameSensorJSONDefaultResponse(body Error) *Response
- func (resp *Response) ContentType(contentType string) *Response
- func (resp *Response) MarshalJSON() ([]byte, error)
- func (resp *Response) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (resp *Response) Render(w http.ResponseWriter, r *http.Request) error
- func (resp *Response) Status(code int) *Response
- type SensorData
- type SensorDataKind
- type SensorInfo
- type SensorInfoCamera
- type SensorInfoHumidity
- type SensorInfoIAQ
- type SensorInfoTemperature
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) AuthLogin(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) AuthLogout(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) CreateUser(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) DeleteUserByID(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetAlerts(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetSensors(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetSensorsLive(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserByID(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUsers(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetWebpushKey(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) RegisterWebpush(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) RenameSensor(w http.ResponseWriter, r *http.Request)
- type ServerOption
- func WithAuthMiddleware(middleware func(http.Handler) http.Handler) ServerOption
- func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
- func WithMiddlewares(middlewares Middlewares) ServerOption
- func WithRouter(r chi.Router) ServerOption
- func WithServerBaseURL(url string) ServerOption
- type ServerOptions
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type UnmarshalingParamError
- type User
- type UserCreate
- type WebpushKey
- type WebpushRegistration
Constants ¶
const (
BearerAuthScopes = "bearerAuth.Scopes"
)
Variables ¶
var ( UnknownSensorDataKind = SensorDataKind{} SensorDataKindCamera = SensorDataKind{"camera"} SensorDataKindHumidity = SensorDataKind{"humidity"} SensorDataKindIaq = SensorDataKind{"iaq"} SensorDataKindTemperature = SensorDataKind{"temperature"} )
Defines values for SensorDataKind.
Functions ¶
func Handler ¶
func Handler(si ServerInterface, opts ...ServerOption) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
Types ¶
type AlertHistoryEntry ¶
type AlertHistoryEntry struct { CreatedAt time.Time `json:"created_at"` ID ulid.ULID `json:"id"` Kind string `json:"kind"` SensorID string `json:"sensor_id"` Value string `json:"value"` }
AlertHistoryEntry defines model for AlertHistoryEntry.
type AuthLoginJSONBody ¶
AuthLoginJSONBody defines parameters for AuthLogin.
type AuthLoginJSONRequestBody ¶
type AuthLoginJSONRequestBody AuthLoginJSONBody
AuthLoginJSONRequestBody defines body for AuthLogin for application/json ContentType.
type CreateUserJSONBody ¶
type CreateUserJSONBody UserCreate
CreateUserJSONBody defines parameters for CreateUser.
type CreateUserJSONRequestBody ¶
type CreateUserJSONRequestBody CreateUserJSONBody
CreateUserJSONRequestBody defines body for CreateUser for application/json ContentType.
type Error ¶
type Error struct { // Error message Message string `json:"message"` // Request ID RequestID *string `json:"request_id,omitempty"` }
Error defines model for Error.
type InvalidParamFormatError ¶
type InvalidParamFormatError struct {
// contains filtered or unexported fields
}
func (InvalidParamFormatError) Error ¶
func (err InvalidParamFormatError) Error() string
Error implements error.
func (InvalidParamFormatError) ParamName ¶
func (err InvalidParamFormatError) ParamName() string
func (InvalidParamFormatError) Unwrap ¶
func (err InvalidParamFormatError) Unwrap() error
type Middlewares ¶
Middlewares holds the set of middleware for this service
type ParameterError ¶
type ParameterError interface { error // ParamName is the name of the parameter that the error is referring to. ParamName() string }
ParameterName is an interface that is implemented by error types that are relevant to a specific parameter.
type RegisterWebpushJSONBody ¶
type RegisterWebpushJSONBody WebpushRegistration
RegisterWebpushJSONBody defines parameters for RegisterWebpush.
type RegisterWebpushJSONRequestBody ¶
type RegisterWebpushJSONRequestBody RegisterWebpushJSONBody
RegisterWebpushJSONRequestBody defines body for RegisterWebpush for application/json ContentType.
type RenameSensorParams ¶
type RenameSensorParams struct { // new name of sensor Name string `json:"name"` }
RenameSensorParams defines parameters for RenameSensor.
type RequiredHeaderError ¶
type RequiredHeaderError struct {
// contains filtered or unexported fields
}
func (RequiredHeaderError) Error ¶
func (err RequiredHeaderError) Error() string
Error implements error.
func (RequiredHeaderError) ParamName ¶
func (err RequiredHeaderError) ParamName() string
type RequiredParamError ¶
type RequiredParamError struct {
// contains filtered or unexported fields
}
func (RequiredParamError) Error ¶
func (err RequiredParamError) Error() string
Error implements error.
func (RequiredParamError) ParamName ¶
func (err RequiredParamError) ParamName() string
func (RequiredParamError) Unwrap ¶
func (err RequiredParamError) Unwrap() error
type Response ¶
type Response struct { Code int // contains filtered or unexported fields }
Response is a common response struct for all the API calls. A Response object may be instantiated via functions for specific operation responses. It may also be instantiated directly, for the purpose of responding with a single status code.
func AuthLoginJSON200Response ¶
func AuthLoginJSON200Response(body struct { ExpireAt time.Time `json:"expire_at"` Token string `json:"token"` }) *Response
AuthLoginJSON200Response is a constructor method for a AuthLogin response. A *Response is returned with the configured status code and content type from the spec.
func AuthLoginJSONDefaultResponse ¶
AuthLoginJSONDefaultResponse is a constructor method for a AuthLogin response. A *Response is returned with the configured status code and content type from the spec.
func AuthLogoutJSONDefaultResponse ¶
AuthLogoutJSONDefaultResponse is a constructor method for a AuthLogout response. A *Response is returned with the configured status code and content type from the spec.
func CreateUserJSON200Response ¶
CreateUserJSON200Response is a constructor method for a CreateUser response. A *Response is returned with the configured status code and content type from the spec.
func CreateUserJSONDefaultResponse ¶
CreateUserJSONDefaultResponse is a constructor method for a CreateUser response. A *Response is returned with the configured status code and content type from the spec.
func DeleteUserByIDJSON200Response ¶
DeleteUserByIDJSON200Response is a constructor method for a DeleteUserByID response. A *Response is returned with the configured status code and content type from the spec.
func DeleteUserByIDJSONDefaultResponse ¶
DeleteUserByIDJSONDefaultResponse is a constructor method for a DeleteUserByID response. A *Response is returned with the configured status code and content type from the spec.
func GetAlertsJSON200Response ¶
func GetAlertsJSON200Response(body []AlertHistoryEntry) *Response
GetAlertsJSON200Response is a constructor method for a GetAlerts response. A *Response is returned with the configured status code and content type from the spec.
func GetAlertsJSONDefaultResponse ¶
GetAlertsJSONDefaultResponse is a constructor method for a GetAlerts response. A *Response is returned with the configured status code and content type from the spec.
func GetSensorsJSON200Response ¶
func GetSensorsJSON200Response(body []SensorInfo) *Response
GetSensorsJSON200Response is a constructor method for a GetSensors response. A *Response is returned with the configured status code and content type from the spec.
func GetSensorsJSONDefaultResponse ¶
GetSensorsJSONDefaultResponse is a constructor method for a GetSensors response. A *Response is returned with the configured status code and content type from the spec.
func GetSensorsLiveJSON200Response ¶
func GetSensorsLiveJSON200Response(body []SensorData) *Response
GetSensorsLiveJSON200Response is a constructor method for a GetSensorsLive response. A *Response is returned with the configured status code and content type from the spec.
func GetSensorsLiveJSONDefaultResponse ¶
GetSensorsLiveJSONDefaultResponse is a constructor method for a GetSensorsLive response. A *Response is returned with the configured status code and content type from the spec.
func GetUserByIDJSON200Response ¶
GetUserByIDJSON200Response is a constructor method for a GetUserByID response. A *Response is returned with the configured status code and content type from the spec.
func GetUserByIDJSONDefaultResponse ¶
GetUserByIDJSONDefaultResponse is a constructor method for a GetUserByID response. A *Response is returned with the configured status code and content type from the spec.
func GetUsersJSON200Response ¶
GetUsersJSON200Response is a constructor method for a GetUsers response. A *Response is returned with the configured status code and content type from the spec.
func GetUsersJSONDefaultResponse ¶
GetUsersJSONDefaultResponse is a constructor method for a GetUsers response. A *Response is returned with the configured status code and content type from the spec.
func GetWebpushKeyJSON200Response ¶
func GetWebpushKeyJSON200Response(body WebpushKey) *Response
GetWebpushKeyJSON200Response is a constructor method for a GetWebpushKey response. A *Response is returned with the configured status code and content type from the spec.
func GetWebpushKeyJSONDefaultResponse ¶
GetWebpushKeyJSONDefaultResponse is a constructor method for a GetWebpushKey response. A *Response is returned with the configured status code and content type from the spec.
func RegisterWebpushJSONDefaultResponse ¶
RegisterWebpushJSONDefaultResponse is a constructor method for a RegisterWebpush response. A *Response is returned with the configured status code and content type from the spec.
func RenameSensorJSON200Response ¶
func RenameSensorJSON200Response(body SensorInfo) *Response
RenameSensorJSON200Response is a constructor method for a RenameSensor response. A *Response is returned with the configured status code and content type from the spec.
func RenameSensorJSONDefaultResponse ¶
RenameSensorJSONDefaultResponse is a constructor method for a RenameSensor response. A *Response is returned with the configured status code and content type from the spec.
func (*Response) ContentType ¶
ContentType is a builder method to override the default content type for a response.
func (*Response) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface. This is used to only marshal the body of the response.
func (*Response) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface. This is used to only marshal the body of the response.
type SensorData ¶
type SensorData struct { // The sensor data Data interface{} `json:"data"` ID string `json:"id"` // The kind of sensor Kind SensorDataKind `json:"kind"` }
SensorData defines model for SensorData.
type SensorDataKind ¶
type SensorDataKind struct {
// contains filtered or unexported fields
}
The kind of sensor
func (*SensorDataKind) FromValue ¶
func (t *SensorDataKind) FromValue(value string) error
func (*SensorDataKind) MarshalJSON ¶
func (t *SensorDataKind) MarshalJSON() ([]byte, error)
func (*SensorDataKind) ToValue ¶
func (t *SensorDataKind) ToValue() string
func (*SensorDataKind) UnmarshalJSON ¶
func (t *SensorDataKind) UnmarshalJSON(data []byte) error
type SensorInfo ¶
type SensorInfo struct { // Embedded struct due to allOf(#/components/schemas/SensorData) SensorData `yaml:",inline"` // Embedded fields due to inline allOf schema // A human readable label for the sensor Label string `json:"label"` }
SensorInfo defines model for SensorInfo.
type SensorInfoCamera ¶
type SensorInfoCamera struct {
FeedURI string `json:"feed_uri"`
}
SensorInfoCamera defines model for SensorInfoCamera.
type SensorInfoHumidity ¶
type SensorInfoHumidity struct {
Humidity float32 `json:"humidity"`
}
SensorInfoHumidity defines model for SensorInfoHumidity.
type SensorInfoIAQ ¶
type SensorInfoIAQ struct {
Iaq float32 `json:"iaq"`
}
SensorInfoIAQ defines model for SensorInfoIAQ.
type SensorInfoTemperature ¶
type SensorInfoTemperature struct {
Temperature float32 `json:"temperature"`
}
SensorInfoTemperature defines model for SensorInfoTemperature.
type ServerInterface ¶
type ServerInterface interface { // Get all alerts // (GET /alerts) GetAlerts(w http.ResponseWriter, r *http.Request) *Response // Login // (POST /auth/login) AuthLogin(w http.ResponseWriter, r *http.Request) *Response // Logout // (POST /auth/logout) AuthLogout(w http.ResponseWriter, r *http.Request) *Response // Send a webpush notification key // (GET /notifications/webpush) GetWebpushKey(w http.ResponseWriter, r *http.Request) *Response // Send a webpush notification registration payload // (POST /notifications/webpush) RegisterWebpush(w http.ResponseWriter, r *http.Request) *Response // Get all sensors // (GET /sensors) GetSensors(w http.ResponseWriter, r *http.Request) *Response // Get live sensor data // (GET /sensors/live) GetSensorsLive(w http.ResponseWriter, r *http.Request) *Response // Rename a sensor // (POST /sensors/{id}/rename) RenameSensor(w http.ResponseWriter, r *http.Request, id string, params RenameSensorParams) *Response // Get all users // (GET /users) GetUsers(w http.ResponseWriter, r *http.Request) *Response // Create a user // (POST /users) CreateUser(w http.ResponseWriter, r *http.Request) *Response // Delete a user by id // (DELETE /users/{id}) DeleteUserByID(w http.ResponseWriter, r *http.Request, id ulid.ULID) *Response // Get a user by id // (GET /users/{id}) GetUserByID(w http.ResponseWriter, r *http.Request, id ulid.ULID) *Response }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct { Handler ServerInterface Middlewares Middlewares ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) }
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) AuthLogin ¶
func (siw *ServerInterfaceWrapper) AuthLogin(w http.ResponseWriter, r *http.Request)
AuthLogin operation middleware
func (*ServerInterfaceWrapper) AuthLogout ¶
func (siw *ServerInterfaceWrapper) AuthLogout(w http.ResponseWriter, r *http.Request)
AuthLogout operation middleware
func (*ServerInterfaceWrapper) CreateUser ¶
func (siw *ServerInterfaceWrapper) CreateUser(w http.ResponseWriter, r *http.Request)
CreateUser operation middleware
func (*ServerInterfaceWrapper) DeleteUserByID ¶
func (siw *ServerInterfaceWrapper) DeleteUserByID(w http.ResponseWriter, r *http.Request)
DeleteUserByID operation middleware
func (*ServerInterfaceWrapper) GetAlerts ¶
func (siw *ServerInterfaceWrapper) GetAlerts(w http.ResponseWriter, r *http.Request)
GetAlerts operation middleware
func (*ServerInterfaceWrapper) GetSensors ¶
func (siw *ServerInterfaceWrapper) GetSensors(w http.ResponseWriter, r *http.Request)
GetSensors operation middleware
func (*ServerInterfaceWrapper) GetSensorsLive ¶
func (siw *ServerInterfaceWrapper) GetSensorsLive(w http.ResponseWriter, r *http.Request)
GetSensorsLive operation middleware
func (*ServerInterfaceWrapper) GetUserByID ¶
func (siw *ServerInterfaceWrapper) GetUserByID(w http.ResponseWriter, r *http.Request)
GetUserByID operation middleware
func (*ServerInterfaceWrapper) GetUsers ¶
func (siw *ServerInterfaceWrapper) GetUsers(w http.ResponseWriter, r *http.Request)
GetUsers operation middleware
func (*ServerInterfaceWrapper) GetWebpushKey ¶
func (siw *ServerInterfaceWrapper) GetWebpushKey(w http.ResponseWriter, r *http.Request)
GetWebpushKey operation middleware
func (*ServerInterfaceWrapper) RegisterWebpush ¶
func (siw *ServerInterfaceWrapper) RegisterWebpush(w http.ResponseWriter, r *http.Request)
RegisterWebpush operation middleware
func (*ServerInterfaceWrapper) RenameSensor ¶
func (siw *ServerInterfaceWrapper) RenameSensor(w http.ResponseWriter, r *http.Request)
RenameSensor operation middleware
type ServerOption ¶
type ServerOption func(*ServerOptions)
func WithAuthMiddleware ¶
func WithAuthMiddleware(middleware func(http.Handler) http.Handler) ServerOption
func WithErrorHandler ¶
func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
func WithMiddlewares ¶
func WithMiddlewares(middlewares Middlewares) ServerOption
func WithRouter ¶
func WithRouter(r chi.Router) ServerOption
func WithServerBaseURL ¶
func WithServerBaseURL(url string) ServerOption
type ServerOptions ¶
type ServerOptions struct { BaseURL string BaseRouter chi.Router Middlewares Middlewares ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) }
type TooManyValuesForParamError ¶
type TooManyValuesForParamError struct { NumValues int // contains filtered or unexported fields }
func (TooManyValuesForParamError) Error ¶
func (err TooManyValuesForParamError) Error() string
Error implements error.
func (TooManyValuesForParamError) ParamName ¶
func (err TooManyValuesForParamError) ParamName() string
type UnescapedCookieParamError ¶
type UnescapedCookieParamError struct {
// contains filtered or unexported fields
}
func (UnescapedCookieParamError) Error ¶
func (err UnescapedCookieParamError) Error() string
Error implements error.
func (UnescapedCookieParamError) ParamName ¶
func (err UnescapedCookieParamError) ParamName() string
func (UnescapedCookieParamError) Unwrap ¶
func (err UnescapedCookieParamError) Unwrap() error
type UnmarshalingParamError ¶
type UnmarshalingParamError struct {
// contains filtered or unexported fields
}
func (UnmarshalingParamError) Error ¶
func (err UnmarshalingParamError) Error() string
Error implements error.
func (UnmarshalingParamError) ParamName ¶
func (err UnmarshalingParamError) ParamName() string
func (UnmarshalingParamError) Unwrap ¶
func (err UnmarshalingParamError) Unwrap() error
type User ¶
type User struct { Email string `json:"email"` ID ulid.ULID `json:"id"` Name string `json:"name"` Permissions []string `json:"permissions"` }
User defines model for User.
type UserCreate ¶
type UserCreate struct { Email string `json:"email"` Name string `json:"name"` Password string `json:"password"` Permissions []string `json:"permissions"` }
UserCreate defines model for UserCreate.
type WebpushKey ¶
type WebpushKey struct { // Webpush key Key string `json:"key"` }
WebpushKey defines model for WebpushKey.
type WebpushRegistration ¶
type WebpushRegistration struct { // Webpush endpoint Endpoint string `json:"endpoint"` // Webpush keys Keys struct { // Webpush auth key Auth string `json:"auth"` // Webpush p256dh key P256dh string `json:"p256dh"` } `json:"keys"` }
WebpushRegistration defines model for WebpushRegistration.