store

package
v0.77.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteAllOrganizationUsersInTransaction added in v0.73.0

func DeleteAllOrganizationUsersInTransaction(tx *gorm.DB, orgID string) error

DeleteAllOrganizationUsersInTransaction deletes all organization users in the specified organization.

func DeleteAllProjectUsersInTransaction added in v0.73.0

func DeleteAllProjectUsersInTransaction(tx *gorm.DB, projectID string) error

DeleteAllProjectUsersInTransaction deletes all project users in a transaction.

func DeleteOrganizationInTransaction added in v0.73.0

func DeleteOrganizationInTransaction(tx *gorm.DB, orgID string) error

DeleteOrganizationInTransaction deletes an organization in a transaction.

func DeleteOrganizationUserInTransaction added in v0.73.0

func DeleteOrganizationUserInTransaction(tx *gorm.DB, orgID, userID string) error

DeleteOrganizationUserInTransaction deletes a organization user in a transaction.

func DeleteProjectInTransaction added in v0.73.0

func DeleteProjectInTransaction(tx *gorm.DB, projectID string) error

DeleteProjectInTransaction deletes an project in a transaction.

func DeleteProjectUserInTransaction added in v0.73.0

func DeleteProjectUserInTransaction(tx *gorm.DB, projectID, userID string) error

DeleteProjectUserInTransaction deletes a project user in a transaction.

Types

type APIKey

type APIKey struct {
	gorm.Model

	APIKeyID string `gorm:"uniqueIndex"`

	Name string `gorm:"uniqueIndex:idx_api_key_name_user_id"`

	TenantID string

	OrganizationID string
	ProjectID      string
	UserID         string `gorm:"uniqueIndex:idx_api_key_name_user_id"`

	Secret string
}

APIKey represents an API key.

type APIKeySpec

type APIKeySpec struct {
	APIKeyID       string
	TenantID       string
	OrganizationID string
	ProjectID      string
	UserID         string

	Name   string
	Secret string
}

APIKeySpec is a spec of the API key.

type CreateProjectParams added in v0.35.0

type CreateProjectParams struct {
	ProjectID           string
	OrganizationID      string
	TenantID            string
	Title               string
	KubernetesNamespace string
	IsDefault           bool
}

CreateProjectParams is the parameters for CreateProject.xo

type CreateProjectUserParams added in v0.35.0

type CreateProjectUserParams struct {
	ProjectID      string
	OrganizationID string
	UserID         string
	Role           v1.ProjectRole
}

CreateProjectUserParams is the parameters for CreateProjectUser.

type GetProjectParams added in v0.35.0

type GetProjectParams struct {
	TenantID       string
	OrganizationID string
	ProjectID      string
}

GetProjectParams is the parameters for GetProject.

type Organization added in v0.8.0

type Organization struct {
	gorm.Model

	OrganizationID string `gorm:"uniqueIndex"`

	TenantID string `gorm:"uniqueIndex:idx_orgs_tenant_id_title"`
	Title    string `gorm:"uniqueIndex:idx_orgs_tenant_id_title"`

	IsDefault bool
}

Organization is a model for organization

func CreateOrganizationInTransaction added in v0.73.0

func CreateOrganizationInTransaction(tx *gorm.DB, tenantID, orgID, title string, isDefault bool) (*Organization, error)

CreateOrganizationInTransaction creates a new organization in a transaction.

func (*Organization) ToProto added in v0.10.0

func (o *Organization) ToProto() *v1.Organization

ToProto converts the organization to proto.

type OrganizationUser added in v0.13.0

type OrganizationUser struct {
	gorm.Model

	OrganizationID string `gorm:"uniqueIndex:user_id_org_id"`
	UserID         string `gorm:"uniqueIndex:user_id_org_id"`

	Role string
}

OrganizationUser is a model for user_organization.

func CreateOrganizationUserInTransaction added in v0.73.0

func CreateOrganizationUserInTransaction(tx *gorm.DB, orgID, userID, role string) (*OrganizationUser, error)

CreateOrganizationUserInTransaction creates a organization user in a transaction.

func (*OrganizationUser) ToProto added in v0.13.0

func (o *OrganizationUser) ToProto() *v1.OrganizationUser

ToProto converts the model to Porto.

type Project added in v0.35.0

type Project struct {
	gorm.Model

	ProjectID      string `gorm:"uniqueIndex"`
	OrganizationID string

	TenantID string `gorm:"uniqueIndex:idx_projects_tenant_id_title"`
	Title    string `gorm:"uniqueIndex:idx_projects_tenant_id_title"`

	IsDefault bool

	// KubernetesNamespace is the namespace where the fine-tuning jobs for the organization run.
	// TODO(kenji): Currently we don't set the unique constraint so that multiple orgs can use the same namespace,
	// but revisit the design.
	KubernetesNamespace string
}

Project is a model for project.

func CreateProjectInTransaction added in v0.73.0

func CreateProjectInTransaction(tx *gorm.DB, p CreateProjectParams) (*Project, error)

CreateProjectInTransaction creates a new project in a transaction.

func (*Project) ToProto added in v0.35.0

func (p *Project) ToProto() *v1.Project

ToProto converts the organization to proto.

type ProjectUser added in v0.35.0

type ProjectUser struct {
	gorm.Model

	ProjectID      string `gorm:"uniqueIndex:user_id_project_id"`
	OrganizationID string
	UserID         string `gorm:"uniqueIndex:user_id_project_id"`

	Role string
}

ProjectUser is a model for user_project.

func CreateProjectUserInTransaction added in v0.73.0

func CreateProjectUserInTransaction(tx *gorm.DB, p CreateProjectUserParams) (*ProjectUser, error)

CreateProjectUserInTransaction creates a project user in a transaction.

func (*ProjectUser) ToProto added in v0.35.0

func (p *ProjectUser) ToProto() *v1.ProjectUser

ToProto converts the model to Porto.

type S

type S struct {
	// contains filtered or unexported fields
}

S represents the data store.

func New

func New(db *gorm.DB) *S

New creates a new store instance.

func NewTest

func NewTest(t *testing.T) (*S, func())

NewTest returns a new test store.

func (*S) AutoMigrate

func (s *S) AutoMigrate() error

AutoMigrate sets up the auto-migration task of the database.

func (*S) CreateAPIKey

func (s *S) CreateAPIKey(spec APIKeySpec) (*APIKey, error)

CreateAPIKey creates a new API key.

func (*S) CreateOrganization added in v0.10.0

func (s *S) CreateOrganization(tenantID, orgID, title string, isDefault bool) (*Organization, error)

CreateOrganization creates a new organization.

func (*S) CreateOrganizationUser added in v0.13.0

func (s *S) CreateOrganizationUser(orgID, userID, role string) (*OrganizationUser, error)

CreateOrganizationUser creates a organization user.

func (*S) CreateProject added in v0.35.0

func (s *S) CreateProject(p CreateProjectParams) (*Project, error)

CreateProject creates a new project.

func (*S) CreateProjectUser added in v0.35.0

func (s *S) CreateProjectUser(p CreateProjectUserParams) (*ProjectUser, error)

CreateProjectUser creates a project user.

func (*S) DeleteAPIKey

func (s *S) DeleteAPIKey(apiKeyID, projectID string) error

DeleteAPIKey deletes an APIKey by APIKey ID and tenant ID.

func (*S) DeleteOrganization added in v0.10.0

func (s *S) DeleteOrganization(orgID string) error

DeleteOrganization deletes an organization.

func (*S) DeleteOrganizationUser added in v0.22.0

func (s *S) DeleteOrganizationUser(orgID, userID string) error

DeleteOrganizationUser deletes a organization user.

func (*S) DeleteProject added in v0.35.0

func (s *S) DeleteProject(projectID string) error

DeleteProject deletes an project.

func (*S) DeleteProjectUser added in v0.35.0

func (s *S) DeleteProjectUser(projectID, userID string) error

DeleteProjectUser deletes a project user.

func (*S) GetAPIKey added in v0.63.0

func (s *S) GetAPIKey(id, projectID string) (*APIKey, error)

GetAPIKey gets an API key by its ID and tenant ID.

func (*S) GetAPIKeyByNameAndUserID added in v0.63.0

func (s *S) GetAPIKeyByNameAndUserID(name, userID string) (*APIKey, error)

GetAPIKeyByNameAndUserID gets an API key by its name and user ID.

func (*S) GetDefaultOrganization added in v0.52.0

func (s *S) GetDefaultOrganization(tenantID string) (*Organization, error)

GetDefaultOrganization gets a default organization.

func (*S) GetDefaultProject added in v0.52.0

func (s *S) GetDefaultProject(tenantID string) (*Project, error)

GetDefaultProject gets a default project.

func (*S) GetOrganizationByTenantIDAndOrgID added in v0.21.0

func (s *S) GetOrganizationByTenantIDAndOrgID(tenantID, orgID string) (*Organization, error)

GetOrganizationByTenantIDAndOrgID gets an organization.

func (*S) GetOrganizationUser added in v0.51.0

func (s *S) GetOrganizationUser(orgID, userID string) (*OrganizationUser, error)

GetOrganizationUser gets a organization user.

func (*S) GetProject added in v0.35.0

func (s *S) GetProject(p GetProjectParams) (*Project, error)

GetProject gets an project.

func (*S) GetProjectUser added in v0.51.0

func (s *S) GetProjectUser(projectID, userID string) (*ProjectUser, error)

GetProjectUser gets a project user.

func (*S) ListAPIKeysByProjectID added in v0.45.0

func (s *S) ListAPIKeysByProjectID(projectID string) ([]*APIKey, error)

ListAPIKeysByProjectID lists API keys by a tenant ID.

func (*S) ListAllAPIKeys

func (s *S) ListAllAPIKeys() ([]*APIKey, error)

ListAllAPIKeys lists all API keys.

func (*S) ListAllOrganizationUsers added in v0.13.0

func (s *S) ListAllOrganizationUsers() ([]OrganizationUser, error)

ListAllOrganizationUsers lists all organization users.

func (*S) ListAllOrganizations added in v0.25.0

func (s *S) ListAllOrganizations() ([]*Organization, error)

ListAllOrganizations lists all organizations.

func (*S) ListAllProjectUsers added in v0.35.0

func (s *S) ListAllProjectUsers() ([]ProjectUser, error)

ListAllProjectUsers lists all project users.

func (*S) ListAllProjects added in v0.35.0

func (s *S) ListAllProjects() ([]*Project, error)

ListAllProjects lists all projects.

func (*S) ListOrganizationUsersByOrganizationID added in v0.21.0

func (s *S) ListOrganizationUsersByOrganizationID(orgID string) ([]OrganizationUser, error)

ListOrganizationUsersByOrganizationID lists organization users in the specified organization.

func (*S) ListOrganizations added in v0.10.0

func (s *S) ListOrganizations(tenantID string) ([]*Organization, error)

ListOrganizations lists all organizations in the tenant.

func (*S) ListProjectUsersByProjectID added in v0.35.0

func (s *S) ListProjectUsersByProjectID(projectID string) ([]ProjectUser, error)

ListProjectUsersByProjectID lists project users in the specified project.

func (*S) ListProjectsByTenantIDAndOrganizationID added in v0.35.0

func (s *S) ListProjectsByTenantIDAndOrganizationID(tenantID, orgID string) ([]*Project, error)

ListProjectsByTenantIDAndOrganizationID lists projects by tenant ID and organization ID.

func (*S) Transaction added in v0.73.0

func (s *S) Transaction(f func(*gorm.DB) error) error

Transaction runs a given function in a transaction.

Jump to

Keyboard shortcuts

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