lavender/database/manage-oauth.sql.go

188 lines
4.3 KiB
Go
Raw Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: manage-oauth.sql
package database
import (
"context"
)
const getAppList = `-- name: GetAppList :many
2024-09-02 22:54:03 +01:00
SELECT subject,
name,
domain,
owner_subject,
perms,
public,
sso,
active
FROM client_store
2024-09-02 22:54:03 +01:00
WHERE owner_subject = ?
OR CAST(? AS BOOLEAN) = 1
LIMIT 25 OFFSET ?
`
type GetAppListParams struct {
OwnerSubject string `json:"owner_subject"`
Column2 bool `json:"column_2"`
Offset int64 `json:"offset"`
}
type GetAppListRow struct {
2024-09-02 22:54:03 +01:00
Subject string `json:"subject"`
Name string `json:"name"`
Domain string `json:"domain"`
OwnerSubject string `json:"owner_subject"`
Perms string `json:"perms"`
Public bool `json:"public"`
Sso bool `json:"sso"`
Active bool `json:"active"`
}
func (q *Queries) GetAppList(ctx context.Context, arg GetAppListParams) ([]GetAppListRow, error) {
2024-09-02 22:54:03 +01:00
rows, err := q.db.QueryContext(ctx, getAppList, arg.OwnerSubject, arg.Column2, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetAppListRow
for rows.Next() {
var i GetAppListRow
if err := rows.Scan(
&i.Subject,
&i.Name,
&i.Domain,
2024-09-02 22:54:03 +01:00
&i.OwnerSubject,
2024-05-18 01:48:18 +01:00
&i.Perms,
&i.Public,
&i.Sso,
&i.Active,
); 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 getClientInfo = `-- name: GetClientInfo :one
2024-09-02 22:54:03 +01:00
SELECT subject, name, secret, domain, owner_subject, perms, public, sso, active
FROM client_store
WHERE subject = ?
LIMIT 1
`
func (q *Queries) GetClientInfo(ctx context.Context, subject string) (ClientStore, error) {
row := q.db.QueryRowContext(ctx, getClientInfo, subject)
var i ClientStore
err := row.Scan(
&i.Subject,
&i.Name,
&i.Secret,
&i.Domain,
2024-09-02 22:54:03 +01:00
&i.OwnerSubject,
&i.Perms,
&i.Public,
&i.Sso,
&i.Active,
)
return i, err
}
const insertClientApp = `-- name: InsertClientApp :exec
2024-09-02 22:54:03 +01:00
INSERT INTO client_store (subject, name, secret, domain, perms, public, sso, active, owner_subject)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
`
type InsertClientAppParams struct {
2024-09-02 22:54:03 +01:00
Subject string `json:"subject"`
Name string `json:"name"`
Secret string `json:"secret"`
Domain string `json:"domain"`
Perms string `json:"perms"`
Public bool `json:"public"`
Sso bool `json:"sso"`
Active bool `json:"active"`
OwnerSubject string `json:"owner_subject"`
}
func (q *Queries) InsertClientApp(ctx context.Context, arg InsertClientAppParams) error {
_, err := q.db.ExecContext(ctx, insertClientApp,
arg.Subject,
arg.Name,
arg.Secret,
arg.Domain,
arg.Perms,
arg.Public,
arg.Sso,
arg.Active,
2024-09-02 22:54:03 +01:00
arg.OwnerSubject,
)
return err
}
const resetClientAppSecret = `-- name: ResetClientAppSecret :exec
UPDATE client_store
SET secret = ?
WHERE subject = ?
2024-09-02 22:54:03 +01:00
AND owner_subject = ?
`
type ResetClientAppSecretParams struct {
2024-09-02 22:54:03 +01:00
Secret string `json:"secret"`
Subject string `json:"subject"`
OwnerSubject string `json:"owner_subject"`
}
func (q *Queries) ResetClientAppSecret(ctx context.Context, arg ResetClientAppSecretParams) error {
2024-09-02 22:54:03 +01:00
_, err := q.db.ExecContext(ctx, resetClientAppSecret, arg.Secret, arg.Subject, arg.OwnerSubject)
return err
}
const updateClientApp = `-- name: UpdateClientApp :exec
UPDATE client_store
SET name = ?,
domain = ?,
perms = CASE WHEN CAST(? AS BOOLEAN) = true THEN ? ELSE perms END,
public = ?,
sso = ?,
active = ?
WHERE subject = ?
2024-09-02 22:54:03 +01:00
AND owner_subject = ?
`
type UpdateClientAppParams struct {
2024-09-02 22:54:03 +01:00
Name string `json:"name"`
Domain string `json:"domain"`
Column3 bool `json:"column_3"`
Perms string `json:"perms"`
Public bool `json:"public"`
Sso bool `json:"sso"`
Active bool `json:"active"`
Subject string `json:"subject"`
OwnerSubject string `json:"owner_subject"`
}
func (q *Queries) UpdateClientApp(ctx context.Context, arg UpdateClientAppParams) error {
_, err := q.db.ExecContext(ctx, updateClientApp,
arg.Name,
arg.Domain,
arg.Column3,
arg.Perms,
arg.Public,
arg.Sso,
arg.Active,
arg.Subject,
2024-09-02 22:54:03 +01:00
arg.OwnerSubject,
)
return err
}