Documentation
¶
Index ¶
- Constants
- type APIToken
- type APITokenStore
- type AllocationStore
- type BlockStore
- type EnvironmentStore
- type IDGenerator
- type Organization
- type OrganizationStore
- type PoolStore
- type PostgresStore
- func (s *PostgresStore) Close() error
- func (s *PostgresStore) CreateAPIToken(userID uuid.UUID, name string, expiresAt *time.Time, organizationID *uuid.UUID) (token *APIToken, rawToken string, err error)
- func (s *PostgresStore) CreateAllocation(id uuid.UUID, alloc *network.Allocation) error
- func (s *PostgresStore) CreateBlock(block *network.Block) error
- func (s *PostgresStore) CreateEnvironment(env *network.Environment) error
- func (s *PostgresStore) CreateOrganization(org *Organization) error
- func (s *PostgresStore) CreatePool(pool *network.Pool) error
- func (s *PostgresStore) CreateReservedBlock(r *ReservedBlock) error
- func (s *PostgresStore) CreateSession(sessionID string, userID uuid.UUID, expiry time.Time)
- func (s *PostgresStore) CreateSignupInvite(createdBy uuid.UUID, expiresAt time.Time, organizationID uuid.UUID, ...) (*SignupInvite, string, error)
- func (s *PostgresStore) CreateUser(u *User) error
- func (s *PostgresStore) DeleteAPIToken(tokenID, userID uuid.UUID) error
- func (s *PostgresStore) DeleteAllocation(id uuid.UUID) error
- func (s *PostgresStore) DeleteBlock(id uuid.UUID) error
- func (s *PostgresStore) DeleteEnvironment(id uuid.UUID) error
- func (s *PostgresStore) DeleteOrganization(id uuid.UUID) error
- func (s *PostgresStore) DeletePool(id uuid.UUID) error
- func (s *PostgresStore) DeleteReservedBlock(id uuid.UUID) error
- func (s *PostgresStore) DeleteSession(sessionID string)
- func (s *PostgresStore) DeleteSignupInvite(id uuid.UUID) error
- func (s *PostgresStore) DeleteUser(userID uuid.UUID) error
- func (s *PostgresStore) GenerateID() uuid.UUID
- func (s *PostgresStore) GetAPIToken(tokenID uuid.UUID) (*APIToken, error)
- func (s *PostgresStore) GetAPITokenByKeyHash(keyHash string) (*APIToken, error)
- func (s *PostgresStore) GetAllocation(id uuid.UUID) (*network.Allocation, error)
- func (s *PostgresStore) GetBlock(id uuid.UUID) (*network.Block, error)
- func (s *PostgresStore) GetEnvironment(id uuid.UUID) (*network.Environment, error)
- func (s *PostgresStore) GetOrganization(id uuid.UUID) (*Organization, error)
- func (s *PostgresStore) GetPool(id uuid.UUID) (*network.Pool, error)
- func (s *PostgresStore) GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)
- func (s *PostgresStore) GetSession(sessionID string) (*Session, error)
- func (s *PostgresStore) GetSignupInviteByToken(rawToken string) (*SignupInvite, error)
- func (s *PostgresStore) GetUser(id uuid.UUID) (*User, error)
- func (s *PostgresStore) GetUserByEmail(email string) (*User, error)
- func (s *PostgresStore) GetUserByOAuth(provider, providerUserID string) (*User, error)
- func (s *PostgresStore) GetUserByTokenHash(keyHash string) (*User, error)
- func (s *PostgresStore) ListAPITokens(userID uuid.UUID) ([]*APIToken, error)
- func (s *PostgresStore) ListAllocations() ([]*network.Allocation, error)
- func (s *PostgresStore) ListAllocationsFiltered(name string, blockName string, environmentID uuid.UUID, ...) ([]*network.Allocation, int, error)
- func (s *PostgresStore) ListBlocks() ([]*network.Block, error)
- func (s *PostgresStore) ListBlocksByEnvironment(envID uuid.UUID) ([]*network.Block, error)
- func (s *PostgresStore) ListBlocksByPool(poolID uuid.UUID) ([]*network.Block, error)
- func (s *PostgresStore) ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, ...) ([]*network.Block, int, error)
- func (s *PostgresStore) ListEnvironments() ([]*network.Environment, error)
- func (s *PostgresStore) ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)
- func (s *PostgresStore) ListOrganizations() ([]*Organization, error)
- func (s *PostgresStore) ListPoolsByEnvironment(envID uuid.UUID) ([]*network.Pool, error)
- func (s *PostgresStore) ListPoolsByOrganization(orgID uuid.UUID) ([]*network.Pool, error)
- func (s *PostgresStore) ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)
- func (s *PostgresStore) ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)
- func (s *PostgresStore) ListUsers(organizationID *uuid.UUID) ([]*User, error)
- func (s *PostgresStore) MarkSignupInviteUsed(inviteID, userID uuid.UUID) error
- func (s *PostgresStore) OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)
- func (s *PostgresStore) SetUserOAuth(userID uuid.UUID, provider, providerUserID string) error
- func (s *PostgresStore) SetUserOrganization(userID uuid.UUID, organizationID uuid.UUID) error
- func (s *PostgresStore) SetUserRole(userID uuid.UUID, role string) error
- func (s *PostgresStore) SetUserTourCompleted(userID uuid.UUID, completed bool) error
- func (s *PostgresStore) UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error
- func (s *PostgresStore) UpdateBlock(id uuid.UUID, block *network.Block) error
- func (s *PostgresStore) UpdateEnvironment(id uuid.UUID, env *network.Environment) error
- func (s *PostgresStore) UpdateOrganization(org *Organization) error
- func (s *PostgresStore) UpdatePool(id uuid.UUID, pool *network.Pool) error
- func (s *PostgresStore) UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error
- type ReservedBlock
- type ReservedBlockStore
- type Session
- type SessionStore
- type SignupInvite
- type SignupInviteStore
- type Store
- func (s *Store) CreateAPIToken(userID uuid.UUID, name string, expiresAt *time.Time, organizationID *uuid.UUID) (token *APIToken, rawToken string, err error)
- func (s *Store) CreateAllocation(id uuid.UUID, alloc *network.Allocation) error
- func (s *Store) CreateBlock(block *network.Block) error
- func (s *Store) CreateEnvironment(env *network.Environment) error
- func (s *Store) CreateOrganization(org *Organization) error
- func (s *Store) CreatePool(pool *network.Pool) error
- func (s *Store) CreateReservedBlock(r *ReservedBlock) error
- func (s *Store) CreateSession(sessionID string, userID uuid.UUID, expiry time.Time)
- func (s *Store) CreateSignupInvite(createdBy uuid.UUID, expiresAt time.Time, organizationID uuid.UUID, ...) (*SignupInvite, string, error)
- func (s *Store) CreateUser(u *User) error
- func (s *Store) DeleteAPIToken(tokenID, userID uuid.UUID) error
- func (s *Store) DeleteAllocation(id uuid.UUID) error
- func (s *Store) DeleteBlock(id uuid.UUID) error
- func (s *Store) DeleteEnvironment(id uuid.UUID) error
- func (s *Store) DeleteOrganization(id uuid.UUID) error
- func (s *Store) DeletePool(id uuid.UUID) error
- func (s *Store) DeleteReservedBlock(id uuid.UUID) error
- func (s *Store) DeleteSession(sessionID string)
- func (s *Store) DeleteSignupInvite(id uuid.UUID) error
- func (s *Store) DeleteUser(userID uuid.UUID) error
- func (s *Store) GenerateID() uuid.UUID
- func (s *Store) GetAPIToken(tokenID uuid.UUID) (*APIToken, error)
- func (s *Store) GetAPITokenByKeyHash(keyHash string) (*APIToken, error)
- func (s *Store) GetAllocation(id uuid.UUID) (*network.Allocation, error)
- func (s *Store) GetBlock(id uuid.UUID) (*network.Block, error)
- func (s *Store) GetEnvironment(id uuid.UUID) (*network.Environment, error)
- func (s *Store) GetOrganization(id uuid.UUID) (*Organization, error)
- func (s *Store) GetPool(id uuid.UUID) (*network.Pool, error)
- func (s *Store) GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)
- func (s *Store) GetSession(sessionID string) (*Session, error)
- func (s *Store) GetSignupInviteByToken(rawToken string) (*SignupInvite, error)
- func (s *Store) GetUser(id uuid.UUID) (*User, error)
- func (s *Store) GetUserByEmail(email string) (*User, error)
- func (s *Store) GetUserByOAuth(provider, providerUserID string) (*User, error)
- func (s *Store) GetUserByTokenHash(keyHash string) (*User, error)
- func (s *Store) ListAPITokens(userID uuid.UUID) ([]*APIToken, error)
- func (s *Store) ListAllocations() ([]*network.Allocation, error)
- func (s *Store) ListAllocationsFiltered(name string, blockName string, environmentID uuid.UUID, ...) ([]*network.Allocation, int, error)
- func (s *Store) ListBlocks() ([]*network.Block, error)
- func (s *Store) ListBlocksByEnvironment(envID uuid.UUID) ([]*network.Block, error)
- func (s *Store) ListBlocksByPool(poolID uuid.UUID) ([]*network.Block, error)
- func (s *Store) ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, ...) ([]*network.Block, int, error)
- func (s *Store) ListEnvironments() ([]*network.Environment, error)
- func (s *Store) ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)
- func (s *Store) ListOrganizations() ([]*Organization, error)
- func (s *Store) ListPoolsByEnvironment(envID uuid.UUID) ([]*network.Pool, error)
- func (s *Store) ListPoolsByOrganization(orgID uuid.UUID) ([]*network.Pool, error)
- func (s *Store) ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)
- func (s *Store) ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)
- func (s *Store) ListUsers(organizationID *uuid.UUID) ([]*User, error)
- func (s *Store) MarkSignupInviteUsed(inviteID, userID uuid.UUID) error
- func (s *Store) OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)
- func (s *Store) SetUserOAuth(userID uuid.UUID, provider, providerUserID string) error
- func (s *Store) SetUserOrganization(userID uuid.UUID, organizationID uuid.UUID) error
- func (s *Store) SetUserRole(userID uuid.UUID, role string) error
- func (s *Store) SetUserTourCompleted(userID uuid.UUID, completed bool) error
- func (s *Store) UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error
- func (s *Store) UpdateBlock(id uuid.UUID, block *network.Block) error
- func (s *Store) UpdateEnvironment(id uuid.UUID, env *network.Environment) error
- func (s *Store) UpdateOrganization(org *Organization) error
- func (s *Store) UpdatePool(id uuid.UUID, pool *network.Pool) error
- func (s *Store) UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error
- type Storer
- type User
- type UserStore
Constants ¶
const ( RoleUser = "user" RoleAdmin = "admin" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIToken ¶
type APIToken struct {
ID uuid.UUID
UserID uuid.UUID
Name string
KeyHash string
CreatedAt time.Time
ExpiresAt *time.Time
OrganizationID uuid.UUID // optional; when set, token is scoped to this org (global admin only)
}
APIToken represents an API key for a user. The secret is hashed; the raw token is only returned once at creation. ExpiresAt is optional; nil means never expires. OrganizationID, when set, scopes the token to that org (global admin only); uuid.Nil means full access.
type APITokenStore ¶
type APITokenStore interface {
CreateAPIToken(userID uuid.UUID, name string, expiresAt *time.Time, organizationID *uuid.UUID) (token *APIToken, rawToken string, err error)
GetUserByTokenHash(keyHash string) (*User, error)
GetAPITokenByKeyHash(keyHash string) (*APIToken, error)
ListAPITokens(userID uuid.UUID) ([]*APIToken, error)
DeleteAPIToken(tokenID, userID uuid.UUID) error
GetAPIToken(tokenID uuid.UUID) (*APIToken, error)
}
type AllocationStore ¶
type AllocationStore interface {
CreateAllocation(id uuid.UUID, alloc *network.Allocation) error
GetAllocation(id uuid.UUID) (*network.Allocation, error)
ListAllocations() ([]*network.Allocation, error)
ListAllocationsFiltered(name string, blockName string, environmentID uuid.UUID, organizationID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)
UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error
DeleteAllocation(id uuid.UUID) error
}
type BlockStore ¶
type BlockStore interface {
CreateBlock(block *network.Block) error
GetBlock(id uuid.UUID) (*network.Block, error)
ListBlocks() ([]*network.Block, error)
ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, organizationID *uuid.UUID, orphanedOnly bool, limit, offset int) ([]*network.Block, int, error)
ListBlocksByEnvironment(envID uuid.UUID) ([]*network.Block, error)
ListBlocksByPool(poolID uuid.UUID) ([]*network.Block, error)
UpdateBlock(id uuid.UUID, block *network.Block) error
DeleteBlock(id uuid.UUID) error
}
type EnvironmentStore ¶
type EnvironmentStore interface {
CreateEnvironment(env *network.Environment) error
GetEnvironment(id uuid.UUID) (*network.Environment, error)
ListEnvironments() ([]*network.Environment, error)
ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)
UpdateEnvironment(id uuid.UUID, env *network.Environment) error
DeleteEnvironment(id uuid.UUID) error
}
type IDGenerator ¶
type Organization ¶
Organization represents a tenant. Users and environments belong to an organization.
type OrganizationStore ¶
type OrganizationStore interface {
CreateOrganization(org *Organization) error
GetOrganization(id uuid.UUID) (*Organization, error)
ListOrganizations() ([]*Organization, error)
UpdateOrganization(org *Organization) error
DeleteOrganization(id uuid.UUID) error
}
type PoolStore ¶
type PoolStore interface {
CreatePool(pool *network.Pool) error
GetPool(id uuid.UUID) (*network.Pool, error)
ListPoolsByEnvironment(envID uuid.UUID) ([]*network.Pool, error)
ListPoolsByOrganization(orgID uuid.UUID) ([]*network.Pool, error)
UpdatePool(id uuid.UUID, pool *network.Pool) error
DeletePool(id uuid.UUID) error
}
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore implements Storer using PostgreSQL.
func (*PostgresStore) Close ¶
func (s *PostgresStore) Close() error
Close closes the database connection. Call this when shutting down.
func (*PostgresStore) CreateAPIToken ¶
func (*PostgresStore) CreateAllocation ¶
func (s *PostgresStore) CreateAllocation(id uuid.UUID, alloc *network.Allocation) error
func (*PostgresStore) CreateBlock ¶
func (s *PostgresStore) CreateBlock(block *network.Block) error
func (*PostgresStore) CreateEnvironment ¶
func (s *PostgresStore) CreateEnvironment(env *network.Environment) error
func (*PostgresStore) CreateOrganization ¶
func (s *PostgresStore) CreateOrganization(org *Organization) error
func (*PostgresStore) CreatePool ¶
func (s *PostgresStore) CreatePool(pool *network.Pool) error
func (*PostgresStore) CreateReservedBlock ¶
func (s *PostgresStore) CreateReservedBlock(r *ReservedBlock) error
func (*PostgresStore) CreateSession ¶
func (*PostgresStore) CreateSignupInvite ¶
func (*PostgresStore) CreateUser ¶
func (s *PostgresStore) CreateUser(u *User) error
func (*PostgresStore) DeleteAPIToken ¶
func (s *PostgresStore) DeleteAPIToken(tokenID, userID uuid.UUID) error
func (*PostgresStore) DeleteAllocation ¶
func (s *PostgresStore) DeleteAllocation(id uuid.UUID) error
func (*PostgresStore) DeleteBlock ¶
func (s *PostgresStore) DeleteBlock(id uuid.UUID) error
func (*PostgresStore) DeleteEnvironment ¶
func (s *PostgresStore) DeleteEnvironment(id uuid.UUID) error
func (*PostgresStore) DeleteOrganization ¶
func (s *PostgresStore) DeleteOrganization(id uuid.UUID) error
func (*PostgresStore) DeletePool ¶
func (s *PostgresStore) DeletePool(id uuid.UUID) error
func (*PostgresStore) DeleteReservedBlock ¶
func (s *PostgresStore) DeleteReservedBlock(id uuid.UUID) error
func (*PostgresStore) DeleteSession ¶
func (s *PostgresStore) DeleteSession(sessionID string)
func (*PostgresStore) DeleteSignupInvite ¶
func (s *PostgresStore) DeleteSignupInvite(id uuid.UUID) error
func (*PostgresStore) DeleteUser ¶
func (s *PostgresStore) DeleteUser(userID uuid.UUID) error
func (*PostgresStore) GenerateID ¶
func (s *PostgresStore) GenerateID() uuid.UUID
func (*PostgresStore) GetAPIToken ¶
func (s *PostgresStore) GetAPIToken(tokenID uuid.UUID) (*APIToken, error)
func (*PostgresStore) GetAPITokenByKeyHash ¶
func (s *PostgresStore) GetAPITokenByKeyHash(keyHash string) (*APIToken, error)
func (*PostgresStore) GetAllocation ¶
func (s *PostgresStore) GetAllocation(id uuid.UUID) (*network.Allocation, error)
func (*PostgresStore) GetEnvironment ¶
func (s *PostgresStore) GetEnvironment(id uuid.UUID) (*network.Environment, error)
func (*PostgresStore) GetOrganization ¶
func (s *PostgresStore) GetOrganization(id uuid.UUID) (*Organization, error)
func (*PostgresStore) GetReservedBlock ¶
func (s *PostgresStore) GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)
func (*PostgresStore) GetSession ¶
func (s *PostgresStore) GetSession(sessionID string) (*Session, error)
func (*PostgresStore) GetSignupInviteByToken ¶
func (s *PostgresStore) GetSignupInviteByToken(rawToken string) (*SignupInvite, error)
func (*PostgresStore) GetUserByEmail ¶
func (s *PostgresStore) GetUserByEmail(email string) (*User, error)
func (*PostgresStore) GetUserByOAuth ¶
func (s *PostgresStore) GetUserByOAuth(provider, providerUserID string) (*User, error)
func (*PostgresStore) GetUserByTokenHash ¶
func (s *PostgresStore) GetUserByTokenHash(keyHash string) (*User, error)
func (*PostgresStore) ListAPITokens ¶
func (s *PostgresStore) ListAPITokens(userID uuid.UUID) ([]*APIToken, error)
func (*PostgresStore) ListAllocations ¶
func (s *PostgresStore) ListAllocations() ([]*network.Allocation, error)
func (*PostgresStore) ListAllocationsFiltered ¶
func (*PostgresStore) ListBlocks ¶
func (s *PostgresStore) ListBlocks() ([]*network.Block, error)
func (*PostgresStore) ListBlocksByEnvironment ¶
func (*PostgresStore) ListBlocksByPool ¶
func (*PostgresStore) ListBlocksFiltered ¶
func (*PostgresStore) ListEnvironments ¶
func (s *PostgresStore) ListEnvironments() ([]*network.Environment, error)
func (*PostgresStore) ListEnvironmentsFiltered ¶
func (s *PostgresStore) ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)
func (*PostgresStore) ListOrganizations ¶
func (s *PostgresStore) ListOrganizations() ([]*Organization, error)
func (*PostgresStore) ListPoolsByEnvironment ¶
func (*PostgresStore) ListPoolsByOrganization ¶
func (*PostgresStore) ListReservedBlocks ¶
func (s *PostgresStore) ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)
func (*PostgresStore) ListSignupInvites ¶
func (s *PostgresStore) ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)
func (*PostgresStore) ListUsers ¶
func (s *PostgresStore) ListUsers(organizationID *uuid.UUID) ([]*User, error)
func (*PostgresStore) MarkSignupInviteUsed ¶
func (s *PostgresStore) MarkSignupInviteUsed(inviteID, userID uuid.UUID) error
func (*PostgresStore) OverlapsReservedBlock ¶
func (s *PostgresStore) OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)
func (*PostgresStore) SetUserOAuth ¶
func (s *PostgresStore) SetUserOAuth(userID uuid.UUID, provider, providerUserID string) error
func (*PostgresStore) SetUserOrganization ¶
func (*PostgresStore) SetUserRole ¶
func (s *PostgresStore) SetUserRole(userID uuid.UUID, role string) error
func (*PostgresStore) SetUserTourCompleted ¶
func (s *PostgresStore) SetUserTourCompleted(userID uuid.UUID, completed bool) error
func (*PostgresStore) UpdateAllocation ¶
func (s *PostgresStore) UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error
func (*PostgresStore) UpdateBlock ¶
func (*PostgresStore) UpdateEnvironment ¶
func (s *PostgresStore) UpdateEnvironment(id uuid.UUID, env *network.Environment) error
func (*PostgresStore) UpdateOrganization ¶
func (s *PostgresStore) UpdateOrganization(org *Organization) error
func (*PostgresStore) UpdatePool ¶
func (*PostgresStore) UpdateReservedBlock ¶
func (s *PostgresStore) UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error
type ReservedBlock ¶
type ReservedBlock struct {
ID uuid.UUID
Name string
CIDR string
Reason string
CreatedAt time.Time
OrganizationID uuid.UUID
}
ReservedBlock is a CIDR range that cannot be used as a network block or allocation (blacklisted). Used to preserve ranges for future use or other systems. Scoped to an organization; overlap checks use the org's reserved list (or all orgs when nil).
type ReservedBlockStore ¶
type ReservedBlockStore interface {
ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)
CreateReservedBlock(r *ReservedBlock) error
GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)
UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error
DeleteReservedBlock(id uuid.UUID) error
OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)
}
type SessionStore ¶
type SignupInvite ¶
type SignupInvite struct {
ID uuid.UUID
TokenHash string
CreatedBy uuid.UUID
ExpiresAt time.Time
CreatedAt time.Time
UsedAt *time.Time
UsedByUserID *uuid.UUID
OrganizationID uuid.UUID
Role string
}
SignupInvite represents a time-bound invite link for new user signup. The token is hashed in storage; the raw token is only returned at creation. UsedAt/UsedByUserID are set when someone signs up with the invite. OrganizationID and Role are set when creating the invite (global admin can set; org admin gets their org and user role). If OrganizationID is uuid.Nil at use time, the inviter's org is used (backward compat).
type SignupInviteStore ¶
type SignupInviteStore interface {
CreateSignupInvite(createdBy uuid.UUID, expiresAt time.Time, organizationID uuid.UUID, role string) (*SignupInvite, string, error)
GetSignupInviteByToken(rawToken string) (*SignupInvite, error)
MarkSignupInviteUsed(inviteID, userID uuid.UUID) error
DeleteSignupInvite(id uuid.UUID) error
ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages all IPAM data
func (*Store) CreateAPIToken ¶
func (s *Store) CreateAPIToken(userID uuid.UUID, name string, expiresAt *time.Time, organizationID *uuid.UUID) (token *APIToken, rawToken string, err error)
CreateAPIToken creates a new API token for the user. Returns the raw token (only shown once). expiresAt is optional; nil means the token never expires. organizationID is optional; when set (global admin only), the token is scoped to that org.
func (*Store) CreateAllocation ¶
Allocation operations
func (*Store) CreateBlock ¶
Block operations
func (*Store) CreateEnvironment ¶
func (s *Store) CreateEnvironment(env *network.Environment) error
Environment operations
func (*Store) CreateOrganization ¶
func (s *Store) CreateOrganization(org *Organization) error
Organization operations
func (*Store) CreateReservedBlock ¶
func (s *Store) CreateReservedBlock(r *ReservedBlock) error
func (*Store) CreateSession ¶
Session operations
func (*Store) CreateSignupInvite ¶
func (s *Store) CreateSignupInvite(createdBy uuid.UUID, expiresAt time.Time, organizationID uuid.UUID, role string) (*SignupInvite, string, error)
CreateSignupInvite creates a time-bound signup invite. Returns the invite and raw token (only shown once).
func (*Store) DeleteAPIToken ¶
DeleteAPIToken removes the token. Returns error if token not found or not owned by user.
func (*Store) DeleteEnvironment ¶
DeleteEnvironment removes the environment, its pools, all blocks that belong to it, and all allocations in those blocks.
func (*Store) DeleteSession ¶
func (*Store) DeleteSignupInvite ¶
DeleteSignupInvite removes the invite (revoke).
func (*Store) GetAPIToken ¶
GetAPIToken returns the token by ID (for ownership check).
func (*Store) GetAPITokenByKeyHash ¶
GetAPITokenByKeyHash returns the API token for the given key hash, or error if not found or expired.
func (*Store) GetAllocation ¶
func (*Store) GetEnvironment ¶
func (*Store) GetOrganization ¶
func (s *Store) GetOrganization(id uuid.UUID) (*Organization, error)
func (*Store) GetReservedBlock ¶
func (s *Store) GetReservedBlock(id uuid.UUID) (*ReservedBlock, error)
func (*Store) GetSignupInviteByToken ¶
func (s *Store) GetSignupInviteByToken(rawToken string) (*SignupInvite, error)
GetSignupInviteByToken returns the invite for the given raw token if valid and not expired.
func (*Store) GetUserByOAuth ¶
func (*Store) GetUserByTokenHash ¶
GetUserByTokenHash returns the user for the given token hash, or nil if not found or token expired.
func (*Store) ListAPITokens ¶
ListAPITokens returns all API tokens for the user (without secret).
func (*Store) ListAllocations ¶
func (s *Store) ListAllocations() ([]*network.Allocation, error)
func (*Store) ListAllocationsFiltered ¶
func (s *Store) ListAllocationsFiltered(name string, blockName string, environmentID uuid.UUID, organizationID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)
ListAllocationsFiltered returns allocations matching name (substring), optionally blockName, environmentID, and organizationID. When organizationID != nil, only allocations in blocks belonging to that org are returned (blocks in envs in that org, or orphan blocks with that organization_id).
func (*Store) ListBlocksByEnvironment ¶
ListBlocksByEnvironment returns all blocks belonging to the given environment.
func (*Store) ListBlocksByPool ¶
ListBlocksByPool returns all blocks assigned to the given pool.
func (*Store) ListBlocksFiltered ¶
func (s *Store) ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, organizationID *uuid.UUID, orphanedOnly bool, limit, offset int) ([]*network.Block, int, error)
ListBlocksFiltered returns blocks matching name (substring), optionally environmentID, poolID, organizationID, and orphaned only. If organizationID != nil, only blocks in envs belonging to that org are returned. If limit <= 0, no limit is applied.
func (*Store) ListEnvironments ¶
func (s *Store) ListEnvironments() ([]*network.Environment, error)
func (*Store) ListEnvironmentsFiltered ¶
func (s *Store) ListEnvironmentsFiltered(name string, organizationID *uuid.UUID, limit, offset int) ([]*network.Environment, int, error)
ListEnvironmentsFiltered returns environments matching name (substring, case-insensitive), optionally scoped by organizationID. If organizationID is nil, all environments are returned (global admin). If limit <= 0, no limit is applied. offset is 0-based.
func (*Store) ListOrganizations ¶
func (s *Store) ListOrganizations() ([]*Organization, error)
func (*Store) ListPoolsByEnvironment ¶
func (*Store) ListPoolsByOrganization ¶
func (*Store) ListReservedBlocks ¶
func (s *Store) ListReservedBlocks(organizationID *uuid.UUID) ([]*ReservedBlock, error)
ReservedBlock operations (blacklisted CIDR ranges; cannot be used as blocks or allocations).
func (*Store) ListSignupInvites ¶
func (s *Store) ListSignupInvites(createdBy uuid.UUID) ([]*SignupInvite, error)
ListSignupInvites returns all signup invites created by the given user (for admin UI).
func (*Store) MarkSignupInviteUsed ¶
MarkSignupInviteUsed marks the invite as used by the given user (on signup).
func (*Store) OverlapsReservedBlock ¶
func (s *Store) OverlapsReservedBlock(cidr string, organizationID *uuid.UUID) (*ReservedBlock, error)
OverlapsReservedBlock returns the first reserved block that overlaps the given CIDR, or nil.
func (*Store) SetUserOAuth ¶
func (*Store) SetUserOrganization ¶
func (*Store) SetUserTourCompleted ¶
SetUserTourCompleted marks the onboarding tour as completed for the user.
func (*Store) UpdateAllocation ¶
func (*Store) UpdateEnvironment ¶
func (*Store) UpdateOrganization ¶
func (s *Store) UpdateOrganization(org *Organization) error
func (*Store) UpdateReservedBlock ¶
func (s *Store) UpdateReservedBlock(id uuid.UUID, r *ReservedBlock) error
type Storer ¶
type Storer interface {
IDGenerator
OrganizationStore
EnvironmentStore
PoolStore
BlockStore
AllocationStore
ReservedBlockStore
UserStore
SessionStore
APITokenStore
SignupInviteStore
}
Storer is the full IPAM persistence interface, composed from smaller store interfaces. Implemented by the in-memory Store and PostgresStore.
type User ¶
type User struct {
ID uuid.UUID
Email string
PasswordHash string
Role string
TourCompleted bool
OrganizationID uuid.UUID
OAuthProvider string
OAuthProviderUserID string
}
User represents a user account. OrganizationID is uuid.Nil for the global admin (created at setup); otherwise the user belongs to that organization. OAuthProvider and OAuthProviderUserID are set when the user signs in via OAuth (e.g. "github", "12345"). PasswordHash may be empty for OAuth-only users.
type UserStore ¶
type UserStore interface {
CreateUser(u *User) error
GetUser(id uuid.UUID) (*User, error)
GetUserByEmail(email string) (*User, error)
GetUserByOAuth(provider, providerUserID string) (*User, error)
ListUsers(organizationID *uuid.UUID) ([]*User, error)
DeleteUser(userID uuid.UUID) error
SetUserRole(userID uuid.UUID, role string) error
SetUserOrganization(userID uuid.UUID, organizationID uuid.UUID) error
SetUserTourCompleted(userID uuid.UUID, completed bool) error
SetUserOAuth(userID uuid.UUID, provider, providerUserID string) error
}