// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: channels.sql package db import ( "context" "github.com/google/uuid" ) const createChannel = `-- name: CreateChannel :one INSERT INTO notification_channels (id, project_id, type, config, secret_enc) VALUES ($1, $2, $3, $4, $5) RETURNING id, project_id, type, config, secret_enc, enabled, created_at ` type CreateChannelParams struct { ID uuid.UUID `json:"id"` ProjectID uuid.UUID `json:"project_id"` Type string `json:"type"` Config []byte `json:"config"` SecretEnc string `json:"secret_enc"` } func (q *Queries) CreateChannel(ctx context.Context, arg CreateChannelParams) (NotificationChannel, error) { row := q.db.QueryRow(ctx, createChannel, arg.ID, arg.ProjectID, arg.Type, arg.Config, arg.SecretEnc, ) var i NotificationChannel err := row.Scan( &i.ID, &i.ProjectID, &i.Type, &i.Config, &i.SecretEnc, &i.Enabled, &i.CreatedAt, ) return i, err } const deleteChannel = `-- name: DeleteChannel :exec DELETE FROM notification_channels WHERE id = $1 AND project_id = $2 ` type DeleteChannelParams struct { ID uuid.UUID `json:"id"` ProjectID uuid.UUID `json:"project_id"` } func (q *Queries) DeleteChannel(ctx context.Context, arg DeleteChannelParams) error { _, err := q.db.Exec(ctx, deleteChannel, arg.ID, arg.ProjectID) return err } const getChannel = `-- name: GetChannel :one SELECT id, project_id, type, config, secret_enc, enabled, created_at FROM notification_channels WHERE id = $1 AND project_id = $2 ` type GetChannelParams struct { ID uuid.UUID `json:"id"` ProjectID uuid.UUID `json:"project_id"` } func (q *Queries) GetChannel(ctx context.Context, arg GetChannelParams) (NotificationChannel, error) { row := q.db.QueryRow(ctx, getChannel, arg.ID, arg.ProjectID) var i NotificationChannel err := row.Scan( &i.ID, &i.ProjectID, &i.Type, &i.Config, &i.SecretEnc, &i.Enabled, &i.CreatedAt, ) return i, err } const listChannels = `-- name: ListChannels :many SELECT id, project_id, type, config, secret_enc, enabled, created_at FROM notification_channels WHERE project_id = $1 ORDER BY created_at ` func (q *Queries) ListChannels(ctx context.Context, projectID uuid.UUID) ([]NotificationChannel, error) { rows, err := q.db.Query(ctx, listChannels, projectID) if err != nil { return nil, err } defer rows.Close() var items []NotificationChannel for rows.Next() { var i NotificationChannel if err := rows.Scan( &i.ID, &i.ProjectID, &i.Type, &i.Config, &i.SecretEnc, &i.Enabled, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listEnabledChannels = `-- name: ListEnabledChannels :many SELECT id, project_id, type, config, secret_enc, enabled, created_at FROM notification_channels WHERE project_id = $1 AND enabled ORDER BY created_at ` func (q *Queries) ListEnabledChannels(ctx context.Context, projectID uuid.UUID) ([]NotificationChannel, error) { rows, err := q.db.Query(ctx, listEnabledChannels, projectID) if err != nil { return nil, err } defer rows.Close() var items []NotificationChannel for rows.Next() { var i NotificationChannel if err := rows.Scan( &i.ID, &i.ProjectID, &i.Type, &i.Config, &i.SecretEnc, &i.Enabled, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil }