Documentation
¶
Index ¶
- func DeleteAPIKeyInTransaction(tx *gorm.DB, apiKeyID, projectID string) error
- func DeleteAllOrganizationUsersInTransaction(tx *gorm.DB, orgID string) error
- func DeleteAllProjectUsersInTransaction(tx *gorm.DB, projectID string) error
- func DeleteOrganizationInTransaction(tx *gorm.DB, orgID string) error
- func DeleteOrganizationUserInTransaction(tx *gorm.DB, orgID, userID string) error
- func DeleteProjectInTransaction(tx *gorm.DB, projectID string) error
- func DeleteProjectUserInTransaction(tx *gorm.DB, projectID, userID string) error
- func DeleteUserInTransaction(tx *gorm.DB, userID string) error
- type APIKey
- type APIKeySpec
- type CreateProjectParams
- type CreateProjectUserParams
- type DataKey
- type DataKeyManagementClient
- type GetProjectParams
- type Organization
- type OrganizationUser
- type Project
- type ProjectUser
- type S
- func (s *S) AutoMigrate() error
- func (s *S) CountProjectUsersByProjectID(projectID string) (int64, error)
- func (s *S) CreateAPIKey(spec APIKeySpec) (*APIKey, error)
- func (s *S) CreateDataKey(ctx context.Context, kmsClient DataKeyManagementClient) ([]byte, error)
- func (s *S) CreateOrganization(tenantID, orgID, title string, isDefault bool) (*Organization, error)
- func (s *S) CreateOrganizationUser(orgID, userID, role string) (*OrganizationUser, error)
- func (s *S) CreateProject(p CreateProjectParams) (*Project, error)
- func (s *S) CreateProjectUser(p CreateProjectUserParams) (*ProjectUser, error)
- func (s *S) DeleteAPIKey(apiKeyID, projectID string) error
- func (s *S) DeleteOrganization(orgID string) error
- func (s *S) DeleteOrganizationUser(orgID, userID string) error
- func (s *S) DeleteProject(projectID string) error
- func (s *S) DeleteProjectUser(projectID, userID string) error
- func (s *S) FindOrCreateUser(userID, internalUserID string) (*User, error)
- func (s *S) GetAPIKey(id, projectID string) (*APIKey, error)
- func (s *S) GetAPIKeyByID(id string) (*APIKey, error)
- func (s *S) GetAPIKeyByNameAndUserID(name, userID string) (*APIKey, error)
- func (s *S) GetDataKey(ctx context.Context, kmsClient DataKeyManagementClient) ([]byte, error)
- func (s *S) GetDefaultOrganization(tenantID string) (*Organization, error)
- func (s *S) GetDefaultProject(tenantID string) (*Project, error)
- func (s *S) GetOrganizationByTenantIDAndOrgID(tenantID, orgID string) (*Organization, error)
- func (s *S) GetOrganizationUser(orgID, userID string) (*OrganizationUser, error)
- func (s *S) GetProject(p GetProjectParams) (*Project, error)
- func (s *S) GetProjectUser(projectID, userID string) (*ProjectUser, error)
- func (s *S) GetUserByUserID(userID string) (*User, error)
- func (s *S) HideOrganizationUser(orgID, userID string) error
- func (s *S) HideProjectUser(projectID, userID string) error
- func (s *S) ListAPIKeysByProjectID(projectID string) ([]*APIKey, error)
- func (s *S) ListAPIKeysByTenantID(tenantID string) ([]*APIKey, error)
- func (s *S) ListAllAPIKeys() ([]*APIKey, error)
- func (s *S) ListAllOrganizationUsers() ([]OrganizationUser, error)
- func (s *S) ListAllOrganizations() ([]*Organization, error)
- func (s *S) ListAllProjectUsers() ([]ProjectUser, error)
- func (s *S) ListAllProjects() ([]*Project, error)
- func (s *S) ListAllUsers() ([]User, error)
- func (s *S) ListOrganizationNonHiddenUsersByOrganizationID(orgID string) ([]OrganizationUser, error)
- func (s *S) ListOrganizationUsersByOrganizationID(orgID string) ([]OrganizationUser, error)
- func (s *S) ListOrganizationUsersByUserID(userID string) ([]OrganizationUser, error)
- func (s *S) ListOrganizations(tenantID string) ([]*Organization, error)
- func (s *S) ListProjectUsersByProjectID(projectID string) ([]ProjectUser, error)
- func (s *S) ListProjectUsersByUserID(userID string) ([]ProjectUser, error)
- func (s *S) ListProjectsByTenantID(tenantID string) ([]*Project, error)
- func (s *S) ListProjectsByTenantIDAndOrganizationID(tenantID, orgID string) ([]*Project, error)
- func (s *S) Transaction(f func(*gorm.DB) error) error
- func (s *S) UpdateAPIKey(key *APIKey) error
- func (s *S) UpdateProject(projectID string, updates map[string]interface{}) error
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteAPIKeyInTransaction ¶ added in v1.9.0
DeleteAPIKeyInTransaction deletes an APIKey in a transaction.
func DeleteAllOrganizationUsersInTransaction ¶
DeleteAllOrganizationUsersInTransaction deletes all organization users in the specified organization.
func DeleteAllProjectUsersInTransaction ¶
DeleteAllProjectUsersInTransaction deletes all project users in a transaction.
func DeleteOrganizationInTransaction ¶
DeleteOrganizationInTransaction deletes an organization in a transaction.
func DeleteOrganizationUserInTransaction ¶
DeleteOrganizationUserInTransaction deletes a organization user in a transaction.
func DeleteProjectInTransaction ¶
DeleteProjectInTransaction deletes an project in a transaction.
func DeleteProjectUserInTransaction ¶
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"`
IsServiceAccount bool
// ExcludedFromRateLimiting indicates whether this API key is excluded from rate limiting
ExcludedFromRateLimiting bool
// Secret is set when kms encryption is disabled.
Secret string
// EncryptedSecret is encrypted by data key, and it is set when kms encryption is enabled.
EncryptedSecret []byte
}
APIKey represents an API key.
func CreateAPIKeyInTransaction ¶ added in v1.9.0
func CreateAPIKeyInTransaction(db *gorm.DB, spec APIKeySpec) (*APIKey, error)
CreateAPIKeyInTransaction creates a new API key in a transaction.
type APIKeySpec ¶
type APIKeySpec struct {
APIKeyID string
TenantID string
OrganizationID string
ProjectID string
UserID string
IsServiceAccount bool
// ExcludedFromRateLimiting indicates whether this API key is excluded from rate limiting
ExcludedFromRateLimiting bool
Name string
Secret string
// EncryptedSecret is encrypted by data key.
EncryptedSecret []byte
}
APIKeySpec is a spec of the API key.
type CreateProjectParams ¶
type CreateProjectParams struct {
ProjectID string
OrganizationID string
TenantID string
Title string
Assignments []*v1.ProjectAssignment
IsDefault bool
}
CreateProjectParams is the parameters for CreateProject.xo
type CreateProjectUserParams ¶
type CreateProjectUserParams struct {
ProjectID string
OrganizationID string
UserID string
Role v1.ProjectRole
}
CreateProjectUserParams is the parameters for CreateProjectUser.
type DataKey ¶ added in v0.97.0
DataKey represents an data key, which is generated from AWS KMS master key.
type DataKeyManagementClient ¶ added in v0.97.0
type DataKeyManagementClient interface {
CreateDataKey(ctx context.Context) ([]byte, []byte, error)
DecryptDataKey(ctx context.Context, encryptedKey []byte) ([]byte, error)
}
DataKeyManagementClient contains the methods to manage data keys for users.
type GetProjectParams ¶
GetProjectParams is the parameters for GetProject.
type Organization ¶
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 ¶
func CreateOrganizationInTransaction(tx *gorm.DB, tenantID, orgID, title string, isDefault bool) (*Organization, error)
CreateOrganizationInTransaction creates a new organization in a transaction.
func (*Organization) ToProto ¶
func (o *Organization) ToProto() *v1.Organization
ToProto converts the organization to proto.
type OrganizationUser ¶
type OrganizationUser struct {
gorm.Model
OrganizationID string `gorm:"uniqueIndex:user_id_org_id"`
UserID string `gorm:"uniqueIndex:user_id_org_id"`
Role string
// Hidden is set to true if the user is not visible from the list/get API call.
Hidden bool
}
OrganizationUser is a model for user_organization.
func CreateOrganizationUserInTransaction ¶
func CreateOrganizationUserInTransaction(tx *gorm.DB, orgID, userID, role string) (*OrganizationUser, error)
CreateOrganizationUserInTransaction creates a organization user in a transaction.
func (*OrganizationUser) ToProto ¶
func (o *OrganizationUser) ToProto(internalUserID string) *v1.OrganizationUser
ToProto converts the model to Porto.
type Project ¶
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
// Assignments is the assignments of the project. It is a marshaled v1.ProjectAssignments.
Assignments []byte
}
Project is a model for project.
func CreateProjectInTransaction ¶
func CreateProjectInTransaction(tx *gorm.DB, p CreateProjectParams) (*Project, error)
CreateProjectInTransaction creates a new project in a transaction.
type ProjectUser ¶
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
// Hidden is set to true if the user is not visible from the list/get API call.
Hidden bool
}
ProjectUser is a model for user_project.
func CreateProjectUserInTransaction ¶
func CreateProjectUserInTransaction(tx *gorm.DB, p CreateProjectUserParams) (*ProjectUser, error)
CreateProjectUserInTransaction creates a project user in a transaction.
func (*ProjectUser) ToProto ¶
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 (*S) AutoMigrate ¶
AutoMigrate sets up the auto-migration task of the database.
func (*S) CountProjectUsersByProjectID ¶ added in v1.5.0
CountProjectUsersByProjectID counts the number of project users in the specified project.
func (*S) CreateAPIKey ¶
func (s *S) CreateAPIKey(spec APIKeySpec) (*APIKey, error)
CreateAPIKey creates a new API key.
func (*S) CreateDataKey ¶ added in v0.97.0
CreateDataKey creates a data key.
func (*S) CreateOrganization ¶
func (s *S) CreateOrganization(tenantID, orgID, title string, isDefault bool) (*Organization, error)
CreateOrganization creates a new organization.
func (*S) CreateOrganizationUser ¶
func (s *S) CreateOrganizationUser(orgID, userID, role string) (*OrganizationUser, error)
CreateOrganizationUser creates a organization user.
func (*S) CreateProject ¶
func (s *S) CreateProject(p CreateProjectParams) (*Project, error)
CreateProject creates a new project.
func (*S) CreateProjectUser ¶
func (s *S) CreateProjectUser(p CreateProjectUserParams) (*ProjectUser, error)
CreateProjectUser creates a project user.
func (*S) DeleteAPIKey ¶
DeleteAPIKey deletes an APIKey by APIKey ID and tenant ID.
func (*S) DeleteOrganization ¶
DeleteOrganization deletes an organization.
func (*S) DeleteOrganizationUser ¶
DeleteOrganizationUser deletes a organization user.
func (*S) DeleteProject ¶
DeleteProject deletes an project.
func (*S) DeleteProjectUser ¶
DeleteProjectUser deletes a project user.
func (*S) FindOrCreateUser ¶ added in v1.26.0
FindOrCreateUser finds or creates a user.
func (*S) GetAPIKeyByID ¶ added in v1.7.0
GetAPIKeyByID gets an API key by its ID.
func (*S) GetAPIKeyByNameAndUserID ¶
GetAPIKeyByNameAndUserID gets an API key by its name and user ID.
func (*S) GetDataKey ¶ added in v0.97.0
GetDataKey gets the data key.
func (*S) GetDefaultOrganization ¶
func (s *S) GetDefaultOrganization(tenantID string) (*Organization, error)
GetDefaultOrganization gets a default organization.
func (*S) GetDefaultProject ¶
GetDefaultProject gets a default project.
func (*S) GetOrganizationByTenantIDAndOrgID ¶
func (s *S) GetOrganizationByTenantIDAndOrgID(tenantID, orgID string) (*Organization, error)
GetOrganizationByTenantIDAndOrgID gets an organization.
func (*S) GetOrganizationUser ¶
func (s *S) GetOrganizationUser(orgID, userID string) (*OrganizationUser, error)
GetOrganizationUser gets a organization user.
func (*S) GetProject ¶
func (s *S) GetProject(p GetProjectParams) (*Project, error)
GetProject gets an project.
func (*S) GetProjectUser ¶
func (s *S) GetProjectUser(projectID, userID string) (*ProjectUser, error)
GetProjectUser gets a project user.
func (*S) GetUserByUserID ¶ added in v0.89.0
GetUserByUserID returns the user with the given ID.
func (*S) HideOrganizationUser ¶ added in v1.15.0
HideOrganizationUser sets the hide field of the organization user to true.
func (*S) HideProjectUser ¶ added in v1.15.0
HideProjectUser sets the hide field of the project user to true.
func (*S) ListAPIKeysByProjectID ¶
ListAPIKeysByProjectID lists API keys by a tenant ID.
func (*S) ListAPIKeysByTenantID ¶ added in v1.7.0
ListAPIKeysByTenantID lists API keys by a tenant ID.
func (*S) ListAllAPIKeys ¶
ListAllAPIKeys lists all API keys.
func (*S) ListAllOrganizationUsers ¶
func (s *S) ListAllOrganizationUsers() ([]OrganizationUser, error)
ListAllOrganizationUsers lists all organization users.
func (*S) ListAllOrganizations ¶
func (s *S) ListAllOrganizations() ([]*Organization, error)
ListAllOrganizations lists all organizations.
func (*S) ListAllProjectUsers ¶
func (s *S) ListAllProjectUsers() ([]ProjectUser, error)
ListAllProjectUsers lists all project users.
func (*S) ListAllProjects ¶
ListAllProjects lists all projects.
func (*S) ListAllUsers ¶ added in v0.89.0
ListAllUsers lists all users.
func (*S) ListOrganizationNonHiddenUsersByOrganizationID ¶ added in v1.16.0
func (s *S) ListOrganizationNonHiddenUsersByOrganizationID(orgID string) ([]OrganizationUser, error)
ListOrganizationNonHiddenUsersByOrganizationID lists organization users in the specified organization.
func (*S) ListOrganizationUsersByOrganizationID ¶
func (s *S) ListOrganizationUsersByOrganizationID(orgID string) ([]OrganizationUser, error)
ListOrganizationUsersByOrganizationID lists organization users in the specified organization.
func (*S) ListOrganizationUsersByUserID ¶ added in v1.25.0
func (s *S) ListOrganizationUsersByUserID(userID string) ([]OrganizationUser, error)
ListOrganizationUsersByUserID lists organization users for the specified user.
func (*S) ListOrganizations ¶
func (s *S) ListOrganizations(tenantID string) ([]*Organization, error)
ListOrganizations lists all organizations in the tenant.
func (*S) ListProjectUsersByProjectID ¶
func (s *S) ListProjectUsersByProjectID(projectID string) ([]ProjectUser, error)
ListProjectUsersByProjectID lists project users in the specified project.
func (*S) ListProjectUsersByUserID ¶ added in v1.25.0
func (s *S) ListProjectUsersByUserID(userID string) ([]ProjectUser, error)
ListProjectUsersByUserID lists project users for the specified user.
func (*S) ListProjectsByTenantID ¶ added in v1.7.0
ListProjectsByTenantID lists projects by tenant ID.
func (*S) ListProjectsByTenantIDAndOrganizationID ¶
ListProjectsByTenantIDAndOrganizationID lists projects by tenant ID and organization ID.
func (*S) Transaction ¶
Transaction runs a given function in a transaction.
func (*S) UpdateAPIKey ¶ added in v1.7.0
UpdateAPIKey updates an API key.
type User ¶ added in v0.88.0
type User struct {
gorm.Model
UserID string `gorm:"uniqueIndex"`
InternalUserID string `gorm:"uniqueIndex"`
Hidden bool
}
User provides a mapping between the external user ID (= email address) and the internal user ID.
Internal UserIDs can be used to uniquely idently users without exposing PII.