Documentation
¶
Index ¶
- Constants
- type APIToken
- type APITokenStore
- type AllocationStore
- type BlockStore
- type CloudConnection
- type CloudConnectionStore
- 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) (*APIToken, string, error)
- func (s *PostgresStore) CreateAPITokenWithRaw(userID uuid.UUID, name string, rawToken string, expiresAt *time.Time, ...) (*APIToken, error)
- func (s *PostgresStore) CreateAllocation(id uuid.UUID, alloc *network.Allocation) error
- func (s *PostgresStore) CreateBlock(block *network.Block) error
- func (s *PostgresStore) CreateCloudConnection(c *CloudConnection) 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) DeleteCloudConnection(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) GetCloudConnection(id uuid.UUID) (*CloudConnection, 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) ListAllocationsFilteredIncludingDeleted(name string, blockName string, environmentID uuid.UUID, ...) ([]*network.Allocation, int, error)
- func (s *PostgresStore) ListAllocationsPendingCloudDelete(connID uuid.UUID) ([]*network.Allocation, 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) ListBlocksFilteredIncludingDeleted(name string, environmentID *uuid.UUID, poolID *uuid.UUID, ...) ([]*network.Block, int, error)
- func (s *PostgresStore) ListBlocksPendingCloudDelete(connID uuid.UUID) ([]*network.Block, error)
- func (s *PostgresStore) ListCloudConnections() ([]*CloudConnection, error)
- func (s *PostgresStore) ListCloudConnectionsByOrganization(orgID uuid.UUID) ([]*CloudConnection, 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) ListPoolsByOrganizationIncludingDeleted(orgID uuid.UUID) ([]*network.Pool, error)
- func (s *PostgresStore) ListPoolsPendingCloudDelete(connID 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) SoftDeleteAllocation(id uuid.UUID) error
- func (s *PostgresStore) SoftDeleteBlock(id uuid.UUID) error
- func (s *PostgresStore) SoftDeletePool(id uuid.UUID) 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) UpdateCloudConnection(id uuid.UUID, c *CloudConnection) 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
- func (s *PostgresStore) WithSyncLock(ctx context.Context, connectionID uuid.UUID, fn func() error) (acquired bool, err 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) CreateAPITokenWithRaw(userID uuid.UUID, name string, rawToken string, expiresAt *time.Time, ...) (*APIToken, error)
- func (s *Store) CreateAllocation(id uuid.UUID, alloc *network.Allocation) error
- func (s *Store) CreateBlock(block *network.Block) error
- func (s *Store) CreateCloudConnection(c *CloudConnection) 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) DeleteCloudConnection(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) GetCloudConnection(id uuid.UUID) (*CloudConnection, 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) ListAllocationsFilteredIncludingDeleted(name string, blockName string, environmentID uuid.UUID, ...) ([]*network.Allocation, int, error)
- func (s *Store) ListAllocationsPendingCloudDelete(connID uuid.UUID) ([]*network.Allocation, 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) ListBlocksFilteredIncludingDeleted(name string, environmentID *uuid.UUID, poolID *uuid.UUID, ...) ([]*network.Block, int, error)
- func (s *Store) ListBlocksPendingCloudDelete(connID uuid.UUID) ([]*network.Block, error)
- func (s *Store) ListCloudConnections() ([]*CloudConnection, error)
- func (s *Store) ListCloudConnectionsByOrganization(orgID uuid.UUID) ([]*CloudConnection, 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) ListPoolsByOrganizationIncludingDeleted(orgID uuid.UUID) ([]*network.Pool, error)
- func (s *Store) ListPoolsPendingCloudDelete(connID 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) SoftDeleteAllocation(id uuid.UUID) error
- func (s *Store) SoftDeleteBlock(id uuid.UUID) error
- func (s *Store) SoftDeletePool(id uuid.UUID) 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) UpdateCloudConnection(id uuid.UUID, c *CloudConnection) 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
- func (s *Store) WithSyncLock(ctx context.Context, connectionID uuid.UUID, fn func() error) (acquired bool, err 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)
CreateAPITokenWithRaw(userID uuid.UUID, name string, rawToken string, expiresAt *time.Time, organizationID *uuid.UUID) (*APIToken, 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, provider string, connectionID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)
ListAllocationsFilteredIncludingDeleted(name string, blockName string, environmentID uuid.UUID, organizationID *uuid.UUID, provider string, connectionID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)
UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error
DeleteAllocation(id uuid.UUID) error
SoftDeleteAllocation(id uuid.UUID) error
ListAllocationsPendingCloudDelete(connID uuid.UUID) ([]*network.Allocation, 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, provider string, connectionID *uuid.UUID, limit, offset int) ([]*network.Block, int, error)
ListBlocksFilteredIncludingDeleted(name string, environmentID *uuid.UUID, poolID *uuid.UUID, organizationID *uuid.UUID, orphanedOnly bool, provider string, connectionID *uuid.UUID, 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
SoftDeleteBlock(id uuid.UUID) error
ListBlocksPendingCloudDelete(connID uuid.UUID) ([]*network.Block, error)
}
type CloudConnection ¶ added in v0.1.1
type CloudConnection struct {
ID uuid.UUID `json:"id"`
OrganizationID uuid.UUID `json:"organization_id"`
Provider string `json:"provider"` // "aws", "azure", "gcp"
Name string `json:"name"`
Config json.RawMessage `json:"config"`
CredentialsRef *string `json:"credentials_ref,omitempty"`
SyncIntervalMinutes int `json:"sync_interval_minutes"` // 0 = off; default 5
SyncMode string `json:"sync_mode"` // "read_only" | "read_write"; default "read_only"
ConflictResolution string `json:"conflict_resolution"` // "cloud" | "ipam"; default "cloud"
LastSyncAt *time.Time `json:"last_sync_at,omitempty"`
LastSyncStatus *string `json:"last_sync_status,omitempty"`
LastSyncError *string `json:"last_sync_error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
CloudConnection is a per-organization link to a cloud provider (AWS, Azure, GCP). Config holds provider-specific settings (e.g. role ARN, regions); no raw secrets. SyncIntervalMinutes: 0 = background sync disabled; 1–1440 = minutes between syncs. Default 5. SyncMode: "read_only" = pull only; "read_write" = bi-directional (push allowed). ConflictResolution: "cloud" = overwrite with cloud on pull; "ipam" = never overwrite existing IPAM resource on pull.
type CloudConnectionStore ¶ added in v0.1.1
type CloudConnectionStore interface {
CreateCloudConnection(c *CloudConnection) error
GetCloudConnection(id uuid.UUID) (*CloudConnection, error)
ListCloudConnectionsByOrganization(orgID uuid.UUID) ([]*CloudConnection, error)
ListCloudConnections() ([]*CloudConnection, error) // all connections, for background sync
UpdateCloudConnection(id uuid.UUID, c *CloudConnection) error
DeleteCloudConnection(id uuid.UUID) error
WithSyncLock(ctx context.Context, connectionID uuid.UUID, fn func() error) (acquired bool, err error)
}
CloudConnectionStore is implemented by store/connection.go and used for integrations.
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)
ListPoolsByOrganizationIncludingDeleted(orgID uuid.UUID) ([]*network.Pool, error) // for sync to match cloud pools to soft-deleted rows
UpdatePool(id uuid.UUID, pool *network.Pool) error
DeletePool(id uuid.UUID) error
SoftDeletePool(id uuid.UUID) error
ListPoolsPendingCloudDelete(connID uuid.UUID) ([]*network.Pool, 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) CreateAPITokenWithRaw ¶ added in v0.1.1
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) CreateCloudConnection ¶ added in v0.1.1
func (s *PostgresStore) CreateCloudConnection(c *CloudConnection) error
CloudConnection CRUD
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) DeleteCloudConnection ¶ added in v0.1.1
func (s *PostgresStore) DeleteCloudConnection(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) GetCloudConnection ¶ added in v0.1.1
func (s *PostgresStore) GetCloudConnection(id uuid.UUID) (*CloudConnection, 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) ListAllocationsFilteredIncludingDeleted ¶ added in v0.1.1
func (*PostgresStore) ListAllocationsPendingCloudDelete ¶ added in v0.1.1
func (s *PostgresStore) ListAllocationsPendingCloudDelete(connID uuid.UUID) ([]*network.Allocation, error)
func (*PostgresStore) ListBlocks ¶
func (s *PostgresStore) ListBlocks() ([]*network.Block, error)
func (*PostgresStore) ListBlocksByEnvironment ¶
func (*PostgresStore) ListBlocksByPool ¶
func (*PostgresStore) ListBlocksFiltered ¶
func (*PostgresStore) ListBlocksFilteredIncludingDeleted ¶ added in v0.1.1
func (*PostgresStore) ListBlocksPendingCloudDelete ¶ added in v0.1.1
func (*PostgresStore) ListCloudConnections ¶ added in v0.1.1
func (s *PostgresStore) ListCloudConnections() ([]*CloudConnection, error)
func (*PostgresStore) ListCloudConnectionsByOrganization ¶ added in v0.1.1
func (s *PostgresStore) ListCloudConnectionsByOrganization(orgID uuid.UUID) ([]*CloudConnection, error)
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) ListPoolsByOrganizationIncludingDeleted ¶ added in v0.1.1
func (*PostgresStore) ListPoolsPendingCloudDelete ¶ added in v0.1.1
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) SoftDeleteAllocation ¶ added in v0.1.1
func (s *PostgresStore) SoftDeleteAllocation(id uuid.UUID) error
func (*PostgresStore) SoftDeleteBlock ¶ added in v0.1.1
func (s *PostgresStore) SoftDeleteBlock(id uuid.UUID) error
func (*PostgresStore) SoftDeletePool ¶ added in v0.1.1
func (s *PostgresStore) SoftDeletePool(id uuid.UUID) error
func (*PostgresStore) UpdateAllocation ¶
func (s *PostgresStore) UpdateAllocation(id uuid.UUID, alloc *network.Allocation) error
func (*PostgresStore) UpdateBlock ¶
func (*PostgresStore) UpdateCloudConnection ¶ added in v0.1.1
func (s *PostgresStore) UpdateCloudConnection(id uuid.UUID, c *CloudConnection) error
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
func (*PostgresStore) WithSyncLock ¶ added in v0.1.1
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) CreateAPITokenWithRaw ¶ added in v0.1.1
func (s *Store) CreateAPITokenWithRaw(userID uuid.UUID, name string, rawToken string, expiresAt *time.Time, organizationID *uuid.UUID) (*APIToken, error)
CreateAPITokenWithRaw stores a caller-supplied raw token (hashed at rest).
func (*Store) CreateAllocation ¶
Allocation operations
func (*Store) CreateBlock ¶
Block operations
func (*Store) CreateCloudConnection ¶ added in v0.1.1
func (s *Store) CreateCloudConnection(c *CloudConnection) error
CloudConnection 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) DeleteCloudConnection ¶ added in v0.1.1
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) GetCloudConnection ¶ added in v0.1.1
func (s *Store) GetCloudConnection(id uuid.UUID) (*CloudConnection, error)
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, provider string, connectionID *uuid.UUID, limit, offset int) ([]*network.Allocation, int, error)
ListAllocationsFiltered returns allocations matching name (substring), optionally blockName, environmentID, organizationID, provider, and connectionID. 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) ListAllocationsFilteredIncludingDeleted ¶ added in v0.1.1
func (*Store) ListAllocationsPendingCloudDelete ¶ added in v0.1.1
func (*Store) ListBlocksByEnvironment ¶
ListBlocksByEnvironment returns all blocks belonging to the given environment (excluding soft-deleted).
func (*Store) ListBlocksByPool ¶
ListBlocksByPool returns all blocks assigned to the given pool (excluding soft-deleted).
func (*Store) ListBlocksFiltered ¶
func (s *Store) ListBlocksFiltered(name string, environmentID *uuid.UUID, poolID *uuid.UUID, organizationID *uuid.UUID, orphanedOnly bool, provider string, connectionID *uuid.UUID, limit, offset int) ([]*network.Block, int, error)
ListBlocksFiltered returns blocks matching name (substring), optionally environmentID, poolID, organizationID, orphaned only, provider, connectionID. If organizationID != nil, only blocks in envs belonging to that org are returned. If limit <= 0, no limit is applied.
func (*Store) ListBlocksFilteredIncludingDeleted ¶ added in v0.1.1
func (*Store) ListBlocksPendingCloudDelete ¶ added in v0.1.1
func (*Store) ListCloudConnections ¶ added in v0.1.1
func (s *Store) ListCloudConnections() ([]*CloudConnection, error)
func (*Store) ListCloudConnectionsByOrganization ¶ added in v0.1.1
func (s *Store) ListCloudConnectionsByOrganization(orgID uuid.UUID) ([]*CloudConnection, error)
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) ListPoolsByOrganizationIncludingDeleted ¶ added in v0.1.1
func (*Store) ListPoolsPendingCloudDelete ¶ added in v0.1.1
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) SoftDeleteAllocation ¶ added in v0.1.1
func (*Store) UpdateAllocation ¶
func (*Store) UpdateCloudConnection ¶ added in v0.1.1
func (s *Store) UpdateCloudConnection(id uuid.UUID, c *CloudConnection) error
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
CloudConnectionStore
}
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
}
OrganizationID is uuid.Nil for the global admin (created at setup); otherwise the user belongs to that organization.
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
}