database

package
v0.0.0-...-b96ae8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	Logger *logger.Logger
	Config *config.Config
	DB     *sql.DB
}

Service handles database operations

func New

func New(cfg *config.Config, log *logger.Logger) (*Service, error)

New creates a new database service

func (*Service) CheckPermission

func (s *Service) CheckPermission(userID, resourceType, resourceID, action string) (bool, error)

CheckPermission checks if a user has permission to perform an action on a resource

func (*Service) CheckResourceOwnership

func (s *Service) CheckResourceOwnership(userID, resourceType, resourceID string) (bool, error)

CheckResourceOwnership checks if a user owns a resource

func (*Service) CreateSandbox

func (s *Service) CreateSandbox(ctx context.Context, sandbox *types.SandboxMetadata) error

CreateSandbox creates a new sandbox

func (*Service) CreateUser

func (s *Service) CreateUser(ctx context.Context, user *types.User) error

CreateUser creates a new user

func (*Service) DeleteSandbox

func (s *Service) DeleteSandbox(ctx context.Context, sandboxID string) error

DeleteSandbox deletes a sandbox

func (*Service) DeleteUser

func (s *Service) DeleteUser(ctx context.Context, userID string) error

DeleteUser deletes a user

func (*Service) GetSandbox

func (s *Service) GetSandbox(ctx context.Context, sandboxID string) (*types.SandboxMetadata, error)

GetSandbox gets a sandbox by ID

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, userID string) (*types.User, error)

GetUser gets a user by ID

func (*Service) GetUserByAPIKey

func (s *Service) GetUserByAPIKey(ctx context.Context, apiKey string) (*types.User, error)

GetUserByAPIKey gets the user associated with an API key

func (*Service) ListSandboxes

func (s *Service) ListSandboxes(ctx context.Context, userID string, limit, offset int) ([]*types.SandboxMetadata, *types.PaginationMetadata, error)

ListSandboxes lists sandboxes for a user

func (*Service) Ping

func (s *Service) Ping(ctx context.Context) error

Ping checks the database connection

func (*Service) Start

func (s *Service) Start() error

Start starts the database service

func (*Service) Stop

func (s *Service) Stop() error

Stop stops the database service

func (*Service) UpdateSandbox

func (s *Service) UpdateSandbox(ctx context.Context, sandboxID string, updates map[string]interface{}) error

UpdateSandbox updates a sandbox

func (*Service) UpdateUser

func (s *Service) UpdateUser(ctx context.Context, userID string, updates map[string]interface{}) error

UpdateUser updates a user

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL