mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-06-19 14:25:16 +03:00
114 lines
2.4 KiB
Go
114 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: agent.sql
|
|
|
|
package gen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createAgent = `-- name: CreateAgent :exec
|
|
INSERT INTO agents (agent_id, agent_name, architecture, system, hostname, version, capabilities)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
`
|
|
|
|
type CreateAgentParams struct {
|
|
AgentID string
|
|
AgentName *string
|
|
Architecture string
|
|
System string
|
|
Hostname string
|
|
Version string
|
|
Capabilities []byte
|
|
}
|
|
|
|
func (q *Queries) CreateAgent(ctx context.Context, arg CreateAgentParams) error {
|
|
_, err := q.db.Exec(ctx, createAgent,
|
|
arg.AgentID,
|
|
arg.AgentName,
|
|
arg.Architecture,
|
|
arg.System,
|
|
arg.Hostname,
|
|
arg.Version,
|
|
arg.Capabilities,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getAgentByAgentID = `-- name: GetAgentByAgentID :one
|
|
SELECT id, agent_id, agent_name, architecture, system, hostname, version, capabilities, registered_at from agents
|
|
WHERE agent_id=$1
|
|
`
|
|
|
|
func (q *Queries) GetAgentByAgentID(ctx context.Context, agentID string) (Agent, error) {
|
|
row := q.db.QueryRow(ctx, getAgentByAgentID, agentID)
|
|
var i Agent
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AgentID,
|
|
&i.AgentName,
|
|
&i.Architecture,
|
|
&i.System,
|
|
&i.Hostname,
|
|
&i.Version,
|
|
&i.Capabilities,
|
|
&i.RegisteredAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getAgentByID = `-- name: GetAgentByID :one
|
|
SELECT id, agent_id, agent_name, architecture, system, hostname, version, capabilities, registered_at from agents
|
|
WHERE id=$1
|
|
`
|
|
|
|
func (q *Queries) GetAgentByID(ctx context.Context, id int32) (Agent, error) {
|
|
row := q.db.QueryRow(ctx, getAgentByID, id)
|
|
var i Agent
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.AgentID,
|
|
&i.AgentName,
|
|
&i.Architecture,
|
|
&i.System,
|
|
&i.Hostname,
|
|
&i.Version,
|
|
&i.Capabilities,
|
|
&i.RegisteredAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateAgentByID = `-- name: UpdateAgentByID :exec
|
|
UPDATE agents
|
|
SET agent_id=$1, agent_name=$2, architecture=$3, system=$4, hostname=$5, version=$6, capabilities=$7
|
|
WHERE id=$8
|
|
`
|
|
|
|
type UpdateAgentByIDParams struct {
|
|
AgentID string
|
|
AgentName *string
|
|
Architecture string
|
|
System string
|
|
Hostname string
|
|
Version string
|
|
Capabilities []byte
|
|
ID int32
|
|
}
|
|
|
|
func (q *Queries) UpdateAgentByID(ctx context.Context, arg UpdateAgentByIDParams) error {
|
|
_, err := q.db.Exec(ctx, updateAgentByID,
|
|
arg.AgentID,
|
|
arg.AgentName,
|
|
arg.Architecture,
|
|
arg.System,
|
|
arg.Hostname,
|
|
arg.Version,
|
|
arg.Capabilities,
|
|
arg.ID,
|
|
)
|
|
return err
|
|
}
|