Documentation
¶
Index ¶
- func Paginate[R any](value interface{}, pagination *Pagination[R], db *gorm.DB) func(db *gorm.DB) *gorm.DB
- type Account
- type AccountPagination
- type Cluster
- type FromAPI
- type NKey
- type Operator
- type OperatorPagination
- type OwnerType
- type Pagination
- type SigningKeyGroup
- type System
- type Tag
- type TaggableType
- type ToAPI
- type Token
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account struct {
// ID is the unique identifier for the account.
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
// Name is the name of the account.
Name string `json:"name"`
// Description is the description of the account.
Description *string `json:"description"`
// Key is the issuer key identifier.
Key NKey `json:"key" gorm:"foreignKey:ID;polymorphic:Owner;polymorphicValue:account"`
// Token is the JWT token used to authenticate the account.
Token Token `json:"token" gorm:"foreignKey:ID;polymorphic:Owner;polymorphicValue:account"`
// Operator is the operator this account is associated with.
Operator Operator `json:"operator" gorm:"foreignKey:OperatorID"`
// OperatorID is the operator ID.
OperatorID uuid.UUID `json:"operator_id" gorm:"foreignKey:ID"`
// SigningKeyGroups is the list of signing key groups the account has.
SigningKeyGroups []SigningKeyGroup `` /* 141-byte string literal not displayed */
// Users is the list of users the account has.
Users []User `json:"users" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
// CreatedAt is the time the account was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the account was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the account was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
Account ...
func (*Account) AfterDelete ¶ added in v0.1.17
AfterDelete ...
func (*Account) FindSigningKeyGroupByID ¶ added in v0.1.17
func (a *Account) FindSigningKeyGroupByID(id uuid.UUID) *SigningKeyGroup
FindSigningKeyGroupByID ...
type AccountPagination ¶ added in v0.1.15
type AccountPagination Pagination[Operator]
AccountPagination is the pagination for operators.
type Cluster ¶
type Cluster struct {
// ID is the unique identifier for the cluster.
ID uuid.UUID `json:"id" gorm:"primaryKey,type:uuid;default:gen_random_uuid()"`
// Name is the name of the cluster.
Name string `json:"name" gorm:"unique" validate:"required,min=3,max=128"`
// Description is the description of the cluster.
Description string `json:"description" validate:"max=1024"`
// ServerURL is the URL of the server.
ServerURL string `json:"url" validate:"required"`
// SystemID is the ID of the system the cluster belongs to.
SystemID uuid.UUID `json:"system_id"`
// CreatedAt is the time the cluster was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the cluster was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the cluster was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
Cluster ...
type NKey ¶
type NKey struct {
// ID is the public key portion of the NKey.
ID string `json:"id" gorm:"primaryKey"`
// Seed is the private key portion of the NKey.
Seed []byte `json:"seed"`
// OwnerID is the owner of the token.
OwnerID uuid.UUID `json:"owner_id"`
// OwnerType is the type of the owner.
OwnerType OwnerType `json:"owner_type"`
// CreatedAt is the timestamp the key was created
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the timestamp the key was last updated
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the timestamp the key was deleted
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
NKey holds a private key and its metadata.
func (*NKey) PrivateKey ¶ added in v0.1.15
PrivateKey returns the private key portion of the NKey.
type Operator ¶
type Operator struct {
// ID is the unique identifier for the operator.
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
// Name is the name of the operator.
Name string `json:"name" validate:"required,min=3,max=128"`
// Description is the description of the operator.
Description string `json:"description" validate:"max=1024"`
// Key is the issuer key identifier.
Key NKey `json:"key" gorm:"foreignKey:ID;polymorphic:Owner;polymorphicValue:operator"`
// Token is the JWT token used to authenticate the account.
Token Token `json:"token" gorm:"foreignKey:ID;polymorphic:Owner;polymorphicValue:operator"`
// SystemAdminAccount is the account that is used to manage the systems.
SystemAdminAccount *Account `json:"system_admin_account"`
SystemAdminAccountID *uuid.UUID `json:"system_admin_account_id"`
// Systems is the systems that are associated with the operator.
Systems []System `json:"systems" gorm:"foreignKey:OperatorID"`
// SigningKeyGroups is the list of signing key groups the account has.
SigningKeyGroups []SigningKeyGroup `` /* 143-byte string literal not displayed */
// Accounts is the list of accounts the operator has.
Accounts []Account `json:"accounts"`
// CreatedAt is the time the operator was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the operator was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the operator was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
Operator is the operator that is used to manage the systems.
func NewOperator ¶ added in v0.1.17
NewOperator is creating a new operator.
type OperatorPagination ¶ added in v0.1.15
type OperatorPagination Pagination[Operator]
OperatorPagination is the pagination for operators.
type OwnerType ¶ added in v0.1.17
type OwnerType string
OwnerType is the struct that is used to define the owner of the token.
type Pagination ¶
type Pagination[R any] struct { // Limit is the number of items to return. Limit int `json:"limit" xml:"limit" form:"limit"` // Offset is the number of items to skip. Offset int `json:"offset" xml:"offset" form:"offset"` // Search is the search term to filter the results. Search string `json:"search" xml:"search" form:"search"` // Sort is the sorting order. Sort string `json:"sort,omitempty" xml:"sort" form:"sort"` // TotalRows is the total number of rows. TotalRows int `json:"total_rows"` // TotalPages is the total number of pages. TotalPages int `json:"total_pages"` // Rows is the items to return. Rows []R `json:"rows"` }
Pagination is a struct that contains the pagination information.
func NewPagination ¶
func NewPagination[R any]() Pagination[R]
NewPagination returns a new pagination.
func (*Pagination[R]) GetOffset ¶
func (p *Pagination[R]) GetOffset() int
GetOffset returns the page.
type SigningKeyGroup ¶ added in v0.1.15
type SigningKeyGroup struct {
// ID is the unique identifier for the group.
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
// Name is the name of the group.
Name string `json:"name" validate:"required,min=3,max=128"`
// Description is the description of the group.
Description string `json:"description" validate:"max=1024"`
// Key is the signing key of this group.
Key NKey `json:"key"`
// KeyID is the foreign key for the key.
KeyID string `json:"key_id" gorm:"foreignKey:ID"`
// CreatedAt is the time the group was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the group was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the group was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
SigningKeyGroup is a model for storing the signing key group.
type System ¶
type System struct {
// ID is the unique identifier for the system.
ID uuid.UUID `json:"id" gorm:"type:uuid;default:gen_random_uuid()"`
// Name is the name of the system.
Name string `json:"name" gorm:"unique" validate:"required,min=3,max=128"`
// Description is the description of the system.
Description string `json:"description" validate:"max=1024"`
// Clusters is the clusters that are associated with the system.
Clusters []Cluster `json:"clusters" gorm:"foreignKey:SystemID"`
// Operator is the operator this is associated with this system to operate.
Operator Operator `json:"operator" gorm:"foreignKey:OperatorID"`
OperatorID uuid.UUID `json:"operator_id"`
// Tags is the tags that are associated with the system.
Tags []*Tag `json:"tags" gorm:"polymorphic:Taggable;polymorphicValue:system;"`
// CreatedAt is the time the system was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the system was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the system was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
System ...
type Tag ¶
type Tag struct {
// ID is the unique identifier for the tag.
ID int `json:"id" gorm:"primary_key"`
// Name is the name of the tag.
Name string `json:"name"`
// TaggableID is the unique identifier for the taggable.
TaggableID uuid.UUID `json:"taggable_id"`
// TaggableType is the type of the taggable.
TaggableType TaggableType `json:"taggable_type"`
// CreatedAt is the time the tag was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the tag was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the tag was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at"`
}
Tag is the model for adding tags to resources.
type TaggableType ¶
type TaggableType string
TaggableType ...
const (
SystemTaggable TaggableType = "system"
)
TaggableType ...
type Token ¶
type Token struct {
// ID is the unique identifier for the token.
// This is the public key portion of the NKey.
ID string `json:"token_id" gorm:"primaryKey"`
// Token is the JWT token used to authenticate the account.
Token string `json:"token"`
// OwnerID is the owner of the token.
OwnerID uuid.UUID `json:"owner_id"`
// OwnerType is the type of the owner.
OwnerType OwnerType `json:"owner_type"`
// CreatedAt is the time the token was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the token was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the token was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
Token is a model for storing the the JWT token used to authenticate the user.
func (*Token) Claim ¶ added in v0.1.15
func (t *Token) Claim() (*jwt.GenericClaims, error)
Claim is returning the claim of the token.
type User ¶
type User struct {
// ID is the unique identifier for the user.
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
// Name is the name of the user.
Name string `json:"name" validate:"required,min=3,max=128"`
// Description is the description of the user.
Description string `json:"description" validate:"max=1024"`
// Key is the issuer key identifier.
Key NKey `json:"key" gorm:"foreignKey:ID;polymorphic:Owner;polymorphicValue:account"`
// KeyID is the foreign key for the key.
KeyID string `json:"key_id" gorm:"foreignKey:ID"`
// Token is the JWT token used to authenticate the account.
Token Token `json:"token" gorm:"foreignKey:ID;polymorphic:Owner;polymorphicValue:user"`
// Account is the account that the user belongs to.
Account Account `json:"account" gorm:"foreignKey:AccountID"`
// AccountID is the foreign key for the account.
AccountID uuid.UUID `json:"account_id"`
// CreatedAt is the time the user was created.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the time the user was updated.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the time the user was deleted.
DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"`
}
User ...
func (*User) Credentials ¶ added in v0.1.15
Credentials returns the user's credentials.