store

package
v0.13.0 Latest Latest
Warning

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

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

Documentation

Index

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 APIKeyKey

type APIKeyKey struct {
	APIKeyID       string
	TenantID       string
	OrganizationID string
	UserID         string
}

APIKeyKey represents a key of an API key.

type APIKeySpec

type APIKeySpec struct {
	Key APIKeyKey

	Name   string
	Secret string
}

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 OrganizationUser added in v0.13.0

type OrganizationUser struct {
	gorm.Model

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

	Role string
}

OrganizationUser is a model for user_organization.

func (*OrganizationUser) ToProto added in v0.13.0

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

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) (*Organization, error)

CreateOrganization creates a new organization.

func (*S) CreateOrganizationUser added in v0.13.0

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

CreateOrganizationUser creates a organization user.

func (*S) DeleteAPIKey

func (s *S) DeleteAPIKey(k APIKeyKey) error

DeleteAPIKey deletes an APIKey by APIKey ID and tenant ID.

func (*S) DeleteOrganization added in v0.10.0

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

DeleteOrganization deletes an organization.

func (*S) GetAPIKeyByNameAndTenantID added in v0.7.0

func (s *S) GetAPIKeyByNameAndTenantID(name, tenantID string) (*APIKey, error)

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

func (s *S) ListAPIKeysByTenantID(tenantID string) ([]*APIKey, error)

ListAPIKeysByTenantID 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) ListOrganizations added in v0.10.0

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

ListOrganizations lists all organizations in the tenant.

Jump to

Keyboard shortcuts

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