Files
member-console/internal/entitlements/resource_pools.sql.go
Christian Galo 8f6a93f74d Add operator enrollment UI and plan docs
Introduce operator enrollment partials and handlers that route plan-tier
granting and revocation through entitlements.Transition(). Add
member-facing
tier labels, plan architecture and grant-plan-safety documentation, plus
unit and e2e tests. Also add small querier helpers and wire Temporal
client
hooks for trial expiration scheduling.
2026-04-24 12:28:00 -05:00

144 lines
3.5 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: resource_pools.sql
package entitlements
import (
"context"
)
const createResourcePool = `-- name: CreateResourcePool :one
INSERT INTO entitlements.resource_pools (org_id, name, slug, pool_type, is_auto_managed)
VALUES ($1, $2, $3, $4, $5)
RETURNING pool_id, org_id, name, slug, pool_type, is_auto_managed, description, status, suspended_at, archived_at, created_at, updated_at
`
type CreateResourcePoolParams struct {
OrgID string `json:"org_id"`
Name string `json:"name"`
Slug string `json:"slug"`
PoolType string `json:"pool_type"`
IsAutoManaged bool `json:"is_auto_managed"`
}
func (q *Queries) CreateResourcePool(ctx context.Context, arg CreateResourcePoolParams) (ResourcePool, error) {
row := q.db.QueryRowContext(ctx, createResourcePool,
arg.OrgID,
arg.Name,
arg.Slug,
arg.PoolType,
arg.IsAutoManaged,
)
var i ResourcePool
err := row.Scan(
&i.PoolID,
&i.OrgID,
&i.Name,
&i.Slug,
&i.PoolType,
&i.IsAutoManaged,
&i.Description,
&i.Status,
&i.SuspendedAt,
&i.ArchivedAt,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getDefaultPoolByOrgID = `-- name: GetDefaultPoolByOrgID :one
SELECT pool_id, org_id, name, slug, pool_type, is_auto_managed, description, status, suspended_at, archived_at, created_at, updated_at FROM entitlements.resource_pools
WHERE org_id = $1 AND pool_type = 'default' AND status = 'active'
LIMIT 1
`
func (q *Queries) GetDefaultPoolByOrgID(ctx context.Context, orgID string) (ResourcePool, error) {
row := q.db.QueryRowContext(ctx, getDefaultPoolByOrgID, orgID)
var i ResourcePool
err := row.Scan(
&i.PoolID,
&i.OrgID,
&i.Name,
&i.Slug,
&i.PoolType,
&i.IsAutoManaged,
&i.Description,
&i.Status,
&i.SuspendedAt,
&i.ArchivedAt,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getResourcePoolByID = `-- name: GetResourcePoolByID :one
SELECT pool_id, org_id, name, slug, pool_type, is_auto_managed, description, status, suspended_at, archived_at, created_at, updated_at FROM entitlements.resource_pools
WHERE pool_id = $1
`
func (q *Queries) GetResourcePoolByID(ctx context.Context, poolID string) (ResourcePool, error) {
row := q.db.QueryRowContext(ctx, getResourcePoolByID, poolID)
var i ResourcePool
err := row.Scan(
&i.PoolID,
&i.OrgID,
&i.Name,
&i.Slug,
&i.PoolType,
&i.IsAutoManaged,
&i.Description,
&i.Status,
&i.SuspendedAt,
&i.ArchivedAt,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const getResourcePoolsByOrgID = `-- name: GetResourcePoolsByOrgID :many
SELECT pool_id, org_id, name, slug, pool_type, is_auto_managed, description, status, suspended_at, archived_at, created_at, updated_at FROM entitlements.resource_pools
WHERE org_id = $1 AND status = 'active'
ORDER BY pool_type ASC, name ASC
`
func (q *Queries) GetResourcePoolsByOrgID(ctx context.Context, orgID string) ([]ResourcePool, error) {
rows, err := q.db.QueryContext(ctx, getResourcePoolsByOrgID, orgID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ResourcePool{}
for rows.Next() {
var i ResourcePool
if err := rows.Scan(
&i.PoolID,
&i.OrgID,
&i.Name,
&i.Slug,
&i.PoolType,
&i.IsAutoManaged,
&i.Description,
&i.Status,
&i.SuspendedAt,
&i.ArchivedAt,
&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
}