// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.13.0 // source: script.sql package mysqlgen import ( "context" "encoding/json" "github.com/google/uuid" ) const deleteScript = `-- name: DeleteScript :exec DELETE FROM script WHERE name = ? ` func (q *Queries) DeleteScript(ctx context.Context, name string) error { _, err := q.exec(ctx, q.deleteScriptStmt, deleteScript, name) return err } const deleteScriptTrigger = `-- name: DeleteScriptTrigger :exec DELETE FROM script_trigger WHERE id = ? ` func (q *Queries) DeleteScriptTrigger(ctx context.Context, id uuid.UUID) error { _, err := q.exec(ctx, q.deleteScriptTriggerStmt, deleteScriptTrigger, id) return err } const listScriptTriggers = `-- name: ListScriptTriggers :many SELECT id, event, device_match, parameter, script_target, script_name, script_pre, script_post, name FROM script_trigger ` func (q *Queries) ListScriptTriggers(ctx context.Context) ([]ScriptTrigger, error) { rows, err := q.query(ctx, q.listScriptTriggersStmt, listScriptTriggers) if err != nil { return nil, err } defer rows.Close() items := []ScriptTrigger{} for rows.Next() { var i ScriptTrigger if err := rows.Scan( &i.ID, &i.Event, &i.DeviceMatch, &i.Parameter, &i.ScriptTarget, &i.ScriptName, &i.ScriptPre, &i.ScriptPost, &i.Name, ); 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 listScriptVariables = `-- name: ListScriptVariables :many SELECT scope, name, value FROM script_variable ` func (q *Queries) ListScriptVariables(ctx context.Context) ([]ScriptVariable, error) { rows, err := q.query(ctx, q.listScriptVariablesStmt, listScriptVariables) if err != nil { return nil, err } defer rows.Close() items := []ScriptVariable{} for rows.Next() { var i ScriptVariable if err := rows.Scan(&i.Scope, &i.Name, &i.Value); 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 listScripts = `-- name: ListScripts :many SELECT name, data FROM script ` func (q *Queries) ListScripts(ctx context.Context) ([]Script, error) { rows, err := q.query(ctx, q.listScriptsStmt, listScripts) if err != nil { return nil, err } defer rows.Close() items := []Script{} for rows.Next() { var i Script if err := rows.Scan(&i.Name, &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 replaceScriptTrigger = `-- name: ReplaceScriptTrigger :exec REPLACE INTO script_trigger (id, name, event, device_match, parameter, script_target, script_name, script_pre, script_post) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) ` type ReplaceScriptTriggerParams struct { ID uuid.UUID Name string Event string DeviceMatch string Parameter string ScriptTarget string ScriptName string ScriptPre json.RawMessage ScriptPost json.RawMessage } func (q *Queries) ReplaceScriptTrigger(ctx context.Context, arg ReplaceScriptTriggerParams) error { _, err := q.exec(ctx, q.replaceScriptTriggerStmt, replaceScriptTrigger, arg.ID, arg.Name, arg.Event, arg.DeviceMatch, arg.Parameter, arg.ScriptTarget, arg.ScriptName, arg.ScriptPre, arg.ScriptPost, ) return err } const saveScript = `-- name: SaveScript :exec REPLACE INTO script (name, data) VALUES (?, ?) ` type SaveScriptParams struct { Name string Data json.RawMessage } func (q *Queries) SaveScript(ctx context.Context, arg SaveScriptParams) error { _, err := q.exec(ctx, q.saveScriptStmt, saveScript, arg.Name, arg.Data) return err } const updateScriptVariables = `-- name: UpdateScriptVariables :exec REPLACE INTO script_variable (scope, name, value) VALUES (?, ?, ?) ` type UpdateScriptVariablesParams struct { Scope string Name string Value string } func (q *Queries) UpdateScriptVariables(ctx context.Context, arg UpdateScriptVariablesParams) error { _, err := q.exec(ctx, q.updateScriptVariablesStmt, updateScriptVariables, arg.Scope, arg.Name, arg.Value) return err }