Documentation
¶
Index ¶
- type APIKey
- type APIKeyKey
- type APIKeySpec
- type Organization
- type RoleBinding
- type S
- func (s *S) AutoMigrate() error
- func (s *S) CreateAPIKey(spec APIKeySpec) (*APIKey, error)
- func (s *S) CreateOrganization(tenantID, orgID, title string) (*Organization, error)
- func (s *S) CreateUserOrganization(tenantID, orgID, userID string) (*UserOrganization, error)
- func (s *S) DeleteAPIKey(k APIKeyKey) error
- func (s *S) DeleteOrganization(tenantID, orgID string) error
- func (s *S) GetAPIKeyByNameAndTenantID(name, tenantID string) (*APIKey, error)
- func (s *S) GetOrganization(orgID string) (*Organization, error)
- func (s *S) ListAPIKeysByTenantID(tenantID string) ([]*APIKey, error)
- func (s *S) ListAllAPIKeys() ([]*APIKey, error)
- func (s *S) ListOrganizations(tenantID string) ([]*Organization, error)
- type SubjectType
- type User
- type UserOrganization
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
gorm.Model
APIKeyID string `gorm:"uniqueIndex:idx_api_key_api_key_id_tenant_id"`
Name string `gorm:"uniqueIndex:idx_api_key_name_tenant_id"`
TenantID string `gorm:"uniqueIndex:idx_api_key_api_key_id_tenant_id;uniqueIndex:idx_api_key_name_tenant_id"`
OrganizationID string
UserID string
Secret string
}
APIKey represents an API key.
type APIKeySpec ¶
APIKeySpec is a spec of the API key.
type Organization ¶ added in v0.8.0
type Organization struct {
gorm.Model
TenantID string `gorm:"index"`
OrganizationID string `gorm:"uniqueIndex"`
Title string
}
Organization is a model for organization
func (*Organization) ToProto ¶ added in v0.10.0
func (o *Organization) ToProto() *v1.Organization
ToProto converts the organization to proto.
type RoleBinding ¶ added in v0.8.0
type RoleBinding struct {
gorm.Model
SubjectID uint `gorm:"uniqueIndex:subject_id_type"`
SubjectType SubjectType `gorm:"uniqueIndex:subject_id_type"`
Role string
}
RoleBinding is a model for role_binding
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) 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) (*Organization, error)
CreateOrganization creates a new organization.
func (*S) CreateUserOrganization ¶ added in v0.10.0
func (s *S) CreateUserOrganization(tenantID, orgID, userID string) (*UserOrganization, error)
CreateUserOrganization adds a user to an organization.
func (*S) DeleteAPIKey ¶
DeleteAPIKey deletes an APIKey by APIKey ID and tenant ID.
func (*S) DeleteOrganization ¶ added in v0.10.0
DeleteOrganization deletes an organization.
func (*S) GetAPIKeyByNameAndTenantID ¶ added in v0.7.0
GetAPIKeyByNameAndTenantID gets an API key by its name and tenant ID.
func (*S) GetOrganization ¶ added in v0.10.0
func (s *S) GetOrganization(orgID string) (*Organization, error)
GetOrganization gets an organization.
func (*S) ListAPIKeysByTenantID ¶
ListAPIKeysByTenantID lists API keys by a tenant ID.
func (*S) ListAllAPIKeys ¶
ListAllAPIKeys lists all API keys.
func (*S) ListOrganizations ¶ added in v0.10.0
func (s *S) ListOrganizations(tenantID string) ([]*Organization, error)
ListOrganizations lists all organizations in the tenant.
type SubjectType ¶ added in v0.8.0
type SubjectType int32
SubjectType is a type for subject.
const ( // SubjectTypeUser is subject type of user. SubjectTypeUser SubjectType = iota // SubjectTypeOrganization is subject type of organization. SubjectTypeOrganization // SubjectTypeAPIKey is subject type of API key. SubjectTypeAPIKey )