mirror of
https://github.com/MizuchiLabs/mantrae.git
synced 2026-04-26 02:19:27 -05:00
223 lines
4.6 KiB
Go
223 lines
4.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: tcp_services.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/config/dynamic"
|
|
)
|
|
|
|
const countTcpServices = `-- name: CountTcpServices :one
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
tcp_services
|
|
`
|
|
|
|
func (q *Queries) CountTcpServices(ctx context.Context) (int64, error) {
|
|
row := q.queryRow(ctx, q.countTcpServicesStmt, countTcpServices)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createTcpService = `-- name: CreateTcpService :one
|
|
INSERT INTO
|
|
tcp_services (
|
|
profile_id,
|
|
agent_id,
|
|
name,
|
|
config,
|
|
created_at,
|
|
updated_at
|
|
)
|
|
VALUES
|
|
(?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) RETURNING id, profile_id, agent_id, name, config, created_at, updated_at
|
|
`
|
|
|
|
type CreateTcpServiceParams struct {
|
|
ProfileID int64 `json:"profileId"`
|
|
AgentID *string `json:"agentId"`
|
|
Name string `json:"name"`
|
|
Config *dynamic.TCPService `json:"config"`
|
|
}
|
|
|
|
func (q *Queries) CreateTcpService(ctx context.Context, arg CreateTcpServiceParams) (TcpService, error) {
|
|
row := q.queryRow(ctx, q.createTcpServiceStmt, createTcpService,
|
|
arg.ProfileID,
|
|
arg.AgentID,
|
|
arg.Name,
|
|
arg.Config,
|
|
)
|
|
var i TcpService
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.AgentID,
|
|
&i.Name,
|
|
&i.Config,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteTcpService = `-- name: DeleteTcpService :exec
|
|
DELETE FROM tcp_services
|
|
WHERE
|
|
id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteTcpService(ctx context.Context, id int64) error {
|
|
_, err := q.exec(ctx, q.deleteTcpServiceStmt, deleteTcpService, id)
|
|
return err
|
|
}
|
|
|
|
const getTcpService = `-- name: GetTcpService :one
|
|
SELECT
|
|
id, profile_id, agent_id, name, config, created_at, updated_at
|
|
FROM
|
|
tcp_services
|
|
WHERE
|
|
id = ?
|
|
`
|
|
|
|
func (q *Queries) GetTcpService(ctx context.Context, id int64) (TcpService, error) {
|
|
row := q.queryRow(ctx, q.getTcpServiceStmt, getTcpService, id)
|
|
var i TcpService
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.AgentID,
|
|
&i.Name,
|
|
&i.Config,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getTcpServicesByProfile = `-- name: GetTcpServicesByProfile :many
|
|
SELECT
|
|
id, profile_id, agent_id, name, config, created_at, updated_at
|
|
FROM
|
|
tcp_services
|
|
WHERE
|
|
profile_id = ?
|
|
`
|
|
|
|
func (q *Queries) GetTcpServicesByProfile(ctx context.Context, profileID int64) ([]TcpService, error) {
|
|
rows, err := q.query(ctx, q.getTcpServicesByProfileStmt, getTcpServicesByProfile, profileID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []TcpService
|
|
for rows.Next() {
|
|
var i TcpService
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.AgentID,
|
|
&i.Name,
|
|
&i.Config,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); 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 listTcpServices = `-- name: ListTcpServices :many
|
|
SELECT
|
|
id, profile_id, agent_id, name, config, created_at, updated_at
|
|
FROM
|
|
tcp_services
|
|
ORDER BY
|
|
name
|
|
LIMIT
|
|
?
|
|
OFFSET
|
|
?
|
|
`
|
|
|
|
type ListTcpServicesParams struct {
|
|
Limit int64 `json:"limit"`
|
|
Offset int64 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListTcpServices(ctx context.Context, arg ListTcpServicesParams) ([]TcpService, error) {
|
|
rows, err := q.query(ctx, q.listTcpServicesStmt, listTcpServices, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []TcpService
|
|
for rows.Next() {
|
|
var i TcpService
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.AgentID,
|
|
&i.Name,
|
|
&i.Config,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); 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 updateTcpService = `-- name: UpdateTcpService :one
|
|
UPDATE tcp_services
|
|
SET
|
|
name = ?,
|
|
config = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE
|
|
id = ? RETURNING id, profile_id, agent_id, name, config, created_at, updated_at
|
|
`
|
|
|
|
type UpdateTcpServiceParams struct {
|
|
Name string `json:"name"`
|
|
Config *dynamic.TCPService `json:"config"`
|
|
ID int64 `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateTcpService(ctx context.Context, arg UpdateTcpServiceParams) (TcpService, error) {
|
|
row := q.queryRow(ctx, q.updateTcpServiceStmt, updateTcpService, arg.Name, arg.Config, arg.ID)
|
|
var i TcpService
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.AgentID,
|
|
&i.Name,
|
|
&i.Config,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|