You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

301 lines
6.9 KiB

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.13.0
// source: device.sql
package mysqlgen
import (
"context"
"encoding/json"
"time"
"github.com/google/uuid"
)
const deleteDeviceAlias = `-- name: DeleteDeviceAlias :exec
DELETE
FROM device_alias
WHERE id = ?
AND alias = ?
`
type DeleteDeviceAliasParams struct {
ID string
Alias string
}
func (q *Queries) DeleteDeviceAlias(ctx context.Context, arg DeleteDeviceAliasParams) error {
_, err := q.exec(ctx, q.deleteDeviceAliasStmt, deleteDeviceAlias, arg.ID, arg.Alias)
return err
}
const deleteDeviceAliasByID = `-- name: DeleteDeviceAliasByID :exec
DELETE
FROM device_alias
WHERE id = ?
`
func (q *Queries) DeleteDeviceAliasByID(ctx context.Context, id string) error {
_, err := q.exec(ctx, q.deleteDeviceAliasByIDStmt, deleteDeviceAliasByID, id)
return err
}
const deleteDeviceAliasByIDLike = `-- name: DeleteDeviceAliasByIDLike :exec
DELETE
FROM device_alias
WHERE id LIKE ?
`
func (q *Queries) DeleteDeviceAliasByIDLike(ctx context.Context, id string) error {
_, err := q.exec(ctx, q.deleteDeviceAliasByIDLikeStmt, deleteDeviceAliasByIDLike, id)
return err
}
const deleteDeviceAssignment = `-- name: DeleteDeviceAssignment :exec
DELETE
FROM device_assignment
WHERE id = ?
`
func (q *Queries) DeleteDeviceAssignment(ctx context.Context, id uuid.UUID) error {
_, err := q.exec(ctx, q.deleteDeviceAssignmentStmt, deleteDeviceAssignment, id)
return err
}
const deleteDeviceAuth = `-- name: DeleteDeviceAuth :exec
DELETE
FROM device_auth
WHERE id = ?
`
func (q *Queries) DeleteDeviceAuth(ctx context.Context, id string) error {
_, err := q.exec(ctx, q.deleteDeviceAuthStmt, deleteDeviceAuth, id)
return err
}
const deleteDeviceInfo = `-- name: DeleteDeviceInfo :exec
DELETE
FROM device_info
WHERE id = ?
AND kind = ?
`
type DeleteDeviceInfoParams struct {
ID string
Kind string
}
func (q *Queries) DeleteDeviceInfo(ctx context.Context, arg DeleteDeviceInfoParams) error {
_, err := q.exec(ctx, q.deleteDeviceInfoStmt, deleteDeviceInfo, arg.ID, arg.Kind)
return err
}
const deleteDeviceInfoByID = `-- name: DeleteDeviceInfoByID :exec
DELETE
FROM device_info
WHERE id = ?
`
func (q *Queries) DeleteDeviceInfoByID(ctx context.Context, id string) error {
_, err := q.exec(ctx, q.deleteDeviceInfoByIDStmt, deleteDeviceInfoByID, id)
return err
}
const deleteDeviceInfoLike = `-- name: DeleteDeviceInfoLike :exec
DELETE
FROM device_info
WHERE id LIKE ?
`
func (q *Queries) DeleteDeviceInfoLike(ctx context.Context, id string) error {
_, err := q.exec(ctx, q.deleteDeviceInfoLikeStmt, deleteDeviceInfoLike, id)
return err
}
const insertDeviceAlias = `-- name: InsertDeviceAlias :exec
INSERT INTO device_alias (id, alias)
VALUES (?, ?)
`
type InsertDeviceAliasParams struct {
ID string
Alias string
}
func (q *Queries) InsertDeviceAlias(ctx context.Context, arg InsertDeviceAliasParams) error {
_, err := q.exec(ctx, q.insertDeviceAliasStmt, insertDeviceAlias, arg.ID, arg.Alias)
return err
}
const listDeviceAliases = `-- name: ListDeviceAliases :many
SELECT id, alias
FROM device_alias
`
func (q *Queries) ListDeviceAliases(ctx context.Context) ([]DeviceAlias, error) {
rows, err := q.query(ctx, q.listDeviceAliasesStmt, listDeviceAliases)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DeviceAlias{}
for rows.Next() {
var i DeviceAlias
if err := rows.Scan(&i.ID, &i.Alias); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listDeviceAssignments = `-- name: ListDeviceAssignments :many
SELECT id, created_date, ` + "`" + `match` + "`" + `, effect
FROM device_assignment
ORDER BY created_date
`
func (q *Queries) ListDeviceAssignments(ctx context.Context) ([]DeviceAssignment, error) {
rows, err := q.query(ctx, q.listDeviceAssignmentsStmt, listDeviceAssignments)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DeviceAssignment{}
for rows.Next() {
var i DeviceAssignment
if err := rows.Scan(
&i.ID,
&i.CreatedDate,
&i.Match,
&i.Effect,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listDeviceAuth = `-- name: ListDeviceAuth :many
SELECT id, api_key, extras
FROM device_auth
`
func (q *Queries) ListDeviceAuth(ctx context.Context) ([]DeviceAuth, error) {
rows, err := q.query(ctx, q.listDeviceAuthStmt, listDeviceAuth)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DeviceAuth{}
for rows.Next() {
var i DeviceAuth
if err := rows.Scan(&i.ID, &i.ApiKey, &i.Extras); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listDeviceInfos = `-- name: ListDeviceInfos :many
SELECT id, kind, data
FROM device_info
`
func (q *Queries) ListDeviceInfos(ctx context.Context) ([]DeviceInfo, error) {
rows, err := q.query(ctx, q.listDeviceInfosStmt, listDeviceInfos)
if err != nil {
return nil, err
}
defer rows.Close()
items := []DeviceInfo{}
for rows.Next() {
var i DeviceInfo
if err := rows.Scan(&i.ID, &i.Kind, &i.Data); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const replaceDeviceAssignment = `-- name: ReplaceDeviceAssignment :exec
REPLACE INTO device_assignment (id, created_date, ` + "`" + `match` + "`" + `, effect)
VALUES (?, ?, ?, ?)
`
type ReplaceDeviceAssignmentParams struct {
ID uuid.UUID
CreatedDate time.Time
Match string
Effect json.RawMessage
}
func (q *Queries) ReplaceDeviceAssignment(ctx context.Context, arg ReplaceDeviceAssignmentParams) error {
_, err := q.exec(ctx, q.replaceDeviceAssignmentStmt, replaceDeviceAssignment,
arg.ID,
arg.CreatedDate,
arg.Match,
arg.Effect,
)
return err
}
const replaceDeviceAuth = `-- name: ReplaceDeviceAuth :exec
REPLACE INTO device_auth (id, api_key, extras)
VALUES (?, ?, ?)
`
type ReplaceDeviceAuthParams struct {
ID string
ApiKey string
Extras json.RawMessage
}
func (q *Queries) ReplaceDeviceAuth(ctx context.Context, arg ReplaceDeviceAuthParams) error {
_, err := q.exec(ctx, q.replaceDeviceAuthStmt, replaceDeviceAuth, arg.ID, arg.ApiKey, arg.Extras)
return err
}
const replaceDeviceInfo = `-- name: ReplaceDeviceInfo :exec
REPLACE INTO device_info (id, kind, data)
VALUES (?, ?, ?)
`
type ReplaceDeviceInfoParams struct {
ID string
Kind string
Data json.RawMessage
}
func (q *Queries) ReplaceDeviceInfo(ctx context.Context, arg ReplaceDeviceInfoParams) error {
_, err := q.exec(ctx, q.replaceDeviceInfoStmt, replaceDeviceInfo, arg.ID, arg.Kind, arg.Data)
return err
}