mirror of
https://github.com/MizuchiLabs/mantrae.git
synced 2025-12-16 20:05:17 -06:00
264 lines
5.8 KiB
Go
264 lines
5.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: traefik_instances.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/mizuchilabs/mantrae/server/internal/store/schema"
|
|
)
|
|
|
|
const countTraefikInstances = `-- name: CountTraefikInstances :one
|
|
SELECT
|
|
COUNT(*)
|
|
FROM
|
|
traefik_instances
|
|
WHERE
|
|
profile_id = ?
|
|
`
|
|
|
|
func (q *Queries) CountTraefikInstances(ctx context.Context, profileID int64) (int64, error) {
|
|
row := q.queryRow(ctx, q.countTraefikInstancesStmt, countTraefikInstances, profileID)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const deleteTraefikInstance = `-- name: DeleteTraefikInstance :exec
|
|
DELETE FROM traefik_instances
|
|
WHERE
|
|
id = ?
|
|
`
|
|
|
|
func (q *Queries) DeleteTraefikInstance(ctx context.Context, id int64) error {
|
|
_, err := q.exec(ctx, q.deleteTraefikInstanceStmt, deleteTraefikInstance, id)
|
|
return err
|
|
}
|
|
|
|
const getTraefikInstanceByID = `-- name: GetTraefikInstanceByID :one
|
|
SELECT
|
|
id, profile_id, name, entrypoints, overview, config, version, url, username, password, tls, created_at, updated_at
|
|
FROM
|
|
traefik_instances
|
|
WHERE
|
|
id = ?
|
|
`
|
|
|
|
func (q *Queries) GetTraefikInstanceByID(ctx context.Context, id int64) (TraefikInstance, error) {
|
|
row := q.queryRow(ctx, q.getTraefikInstanceByIDStmt, getTraefikInstanceByID, id)
|
|
var i TraefikInstance
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.Name,
|
|
&i.Entrypoints,
|
|
&i.Overview,
|
|
&i.Config,
|
|
&i.Version,
|
|
&i.Url,
|
|
&i.Username,
|
|
&i.Password,
|
|
&i.Tls,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getTraefikInstanceByName = `-- name: GetTraefikInstanceByName :one
|
|
SELECT
|
|
id, profile_id, name, entrypoints, overview, config, version, url, username, password, tls, created_at, updated_at
|
|
FROM
|
|
traefik_instances
|
|
WHERE
|
|
profile_id = ?
|
|
AND name = ?
|
|
`
|
|
|
|
type GetTraefikInstanceByNameParams struct {
|
|
ProfileID int64 `json:"profileId"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func (q *Queries) GetTraefikInstanceByName(ctx context.Context, arg GetTraefikInstanceByNameParams) (TraefikInstance, error) {
|
|
row := q.queryRow(ctx, q.getTraefikInstanceByNameStmt, getTraefikInstanceByName, arg.ProfileID, arg.Name)
|
|
var i TraefikInstance
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.Name,
|
|
&i.Entrypoints,
|
|
&i.Overview,
|
|
&i.Config,
|
|
&i.Version,
|
|
&i.Url,
|
|
&i.Username,
|
|
&i.Password,
|
|
&i.Tls,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listTraefikInstances = `-- name: ListTraefikInstances :many
|
|
SELECT
|
|
id, profile_id, name, entrypoints, overview, config, version, url, username, password, tls, created_at, updated_at
|
|
FROM
|
|
traefik_instances
|
|
WHERE
|
|
profile_id = ?1
|
|
ORDER BY
|
|
created_at DESC
|
|
LIMIT
|
|
COALESCE(CAST(?3 AS INTEGER), -1)
|
|
OFFSET
|
|
COALESCE(CAST(?2 AS INTEGER), 0)
|
|
`
|
|
|
|
type ListTraefikInstancesParams struct {
|
|
ProfileID int64 `json:"profileId"`
|
|
Offset *int64 `json:"offset"`
|
|
Limit *int64 `json:"limit"`
|
|
}
|
|
|
|
func (q *Queries) ListTraefikInstances(ctx context.Context, arg ListTraefikInstancesParams) ([]TraefikInstance, error) {
|
|
rows, err := q.query(ctx, q.listTraefikInstancesStmt, listTraefikInstances, arg.ProfileID, arg.Offset, arg.Limit)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []TraefikInstance
|
|
for rows.Next() {
|
|
var i TraefikInstance
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.Name,
|
|
&i.Entrypoints,
|
|
&i.Overview,
|
|
&i.Config,
|
|
&i.Version,
|
|
&i.Url,
|
|
&i.Username,
|
|
&i.Password,
|
|
&i.Tls,
|
|
&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 purgeTraefikInstances = `-- name: PurgeTraefikInstances :exec
|
|
DELETE FROM traefik_instances
|
|
WHERE
|
|
updated_at < DATETIME ('now', '-10 minutes')
|
|
`
|
|
|
|
func (q *Queries) PurgeTraefikInstances(ctx context.Context) error {
|
|
_, err := q.exec(ctx, q.purgeTraefikInstancesStmt, purgeTraefikInstances)
|
|
return err
|
|
}
|
|
|
|
const upsertTraefikInstance = `-- name: UpsertTraefikInstance :one
|
|
INSERT INTO
|
|
traefik_instances (
|
|
profile_id,
|
|
name,
|
|
url,
|
|
username,
|
|
password,
|
|
tls,
|
|
entrypoints,
|
|
overview,
|
|
config,
|
|
version,
|
|
created_at,
|
|
updated_at
|
|
)
|
|
VALUES
|
|
(
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
?,
|
|
CURRENT_TIMESTAMP,
|
|
CURRENT_TIMESTAMP
|
|
) ON CONFLICT (profile_id, name) DO
|
|
UPDATE
|
|
SET
|
|
url = EXCLUDED.url,
|
|
username = EXCLUDED.username,
|
|
password = EXCLUDED.password,
|
|
tls = EXCLUDED.tls,
|
|
entrypoints = EXCLUDED.entrypoints,
|
|
overview = EXCLUDED.overview,
|
|
config = EXCLUDED.config,
|
|
version = EXCLUDED.version,
|
|
updated_at = CURRENT_TIMESTAMP RETURNING id, profile_id, name, entrypoints, overview, config, version, url, username, password, tls, created_at, updated_at
|
|
`
|
|
|
|
type UpsertTraefikInstanceParams struct {
|
|
ProfileID int64 `json:"profileId"`
|
|
Name string `json:"name"`
|
|
Url string `json:"url"`
|
|
Username *string `json:"username"`
|
|
Password *string `json:"password"`
|
|
Tls bool `json:"tls"`
|
|
Entrypoints *schema.EntryPoints `json:"entrypoints"`
|
|
Overview *schema.Overview `json:"overview"`
|
|
Config *schema.Configuration `json:"config"`
|
|
Version *schema.Version `json:"version"`
|
|
}
|
|
|
|
func (q *Queries) UpsertTraefikInstance(ctx context.Context, arg UpsertTraefikInstanceParams) (TraefikInstance, error) {
|
|
row := q.queryRow(ctx, q.upsertTraefikInstanceStmt, upsertTraefikInstance,
|
|
arg.ProfileID,
|
|
arg.Name,
|
|
arg.Url,
|
|
arg.Username,
|
|
arg.Password,
|
|
arg.Tls,
|
|
arg.Entrypoints,
|
|
arg.Overview,
|
|
arg.Config,
|
|
arg.Version,
|
|
)
|
|
var i TraefikInstance
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProfileID,
|
|
&i.Name,
|
|
&i.Entrypoints,
|
|
&i.Overview,
|
|
&i.Config,
|
|
&i.Version,
|
|
&i.Url,
|
|
&i.Username,
|
|
&i.Password,
|
|
&i.Tls,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|