Files
member-console/internal/integration/provider_operations.sql.go
T
cgalo5758 88db730fcc Add dual licensing and SPDX headers
Introduce a commercial license option alongside AGPL-3.0-only, require a
CLA for contributors, and document the terms in COMMERCIAL.md and
NOTICE. Add a script to stamp SPDX headers on Go files and apply it
across the tree.
2026-09-06 02:29:42 -05:00

109 lines
2.9 KiB
Go

// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: provider_operations.sql
package integration
import (
"context"
"github.com/lib/pq"
)
const addProviderOperation = `-- name: AddProviderOperation :exec
INSERT INTO core.provider_operations (provider, operation)
VALUES ($1, $2)
ON CONFLICT (provider, operation) DO NOTHING
`
type AddProviderOperationParams struct {
Provider string `json:"provider"`
Operation string `json:"operation"`
}
func (q *Queries) AddProviderOperation(ctx context.Context, arg AddProviderOperationParams) error {
_, err := q.db.ExecContext(ctx, addProviderOperation, arg.Provider, arg.Operation)
return err
}
const deleteProviderOperationsNotIn = `-- name: DeleteProviderOperationsNotIn :exec
DELETE FROM core.provider_operations
WHERE provider = $1 AND operation <> ALL($2::text[])
`
type DeleteProviderOperationsNotInParams struct {
Provider string `json:"provider"`
Operations []string `json:"operations"`
}
// Boot reconciliation: drop operations a provider no longer declares.
func (q *Queries) DeleteProviderOperationsNotIn(ctx context.Context, arg DeleteProviderOperationsNotInParams) error {
_, err := q.db.ExecContext(ctx, deleteProviderOperationsNotIn, arg.Provider, pq.Array(arg.Operations))
return err
}
const listAllProviderOperations = `-- name: ListAllProviderOperations :many
SELECT provider, operation FROM core.provider_operations
ORDER BY provider, operation
`
type ListAllProviderOperationsRow struct {
Provider string `json:"provider"`
Operation string `json:"operation"`
}
func (q *Queries) ListAllProviderOperations(ctx context.Context) ([]ListAllProviderOperationsRow, error) {
rows, err := q.db.QueryContext(ctx, listAllProviderOperations)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListAllProviderOperationsRow{}
for rows.Next() {
var i ListAllProviderOperationsRow
if err := rows.Scan(&i.Provider, &i.Operation); 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 listProviderOperations = `-- name: ListProviderOperations :many
SELECT operation FROM core.provider_operations
WHERE provider = $1 ORDER BY operation
`
func (q *Queries) ListProviderOperations(ctx context.Context, provider string) ([]string, error) {
rows, err := q.db.QueryContext(ctx, listProviderOperations, provider)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var operation string
if err := rows.Scan(&operation); err != nil {
return nil, err
}
items = append(items, operation)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}