Documentation
¶
Index ¶
- func Paginate[R any](value interface{}, pagination *Pagination[R], db *gorm.DB) func(db *gorm.DB) *gorm.DB
- type Account
- type Cluster
- type FromAPI
- type NKey
- type Operator
- type OperatorPagination
- type OwnerType
- type Pagination
- type SigningKeyGroup
- type System
- type Tag
- type Team
- type ToAPI
- type Token
- type User
- type UserLimits
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶ added in v0.1.48
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"`
// 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"`
// 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"`
// Signer is the signer for the account.
Signer NKey `json:"signer" gorm:"foreignKey:SignerID" validate:"-"`
// SignerID is the signer ID for the account.
SignerID string `json:"signer_id" form:"signer_id" validate:"-"`
// LimitJetStreamEnabled indicates if JetStream is enabled.
LimitJetStreamEnabled bool `json:"limit_jetstream_enabled"`
// LimitJetStreamMaxDiskStorage is the limit for JetStream maximum disk storage.
LimitJetStreamMaxDiskStorage int64 `json:"limit_jetstream_max_disk_storage"`
// LimitJetStreamMaxStreams is the limit for JetStream maximum streams.
LimitJetStreamMaxStreams int64 `json:"limit_jetstream_max_streams"`
// LimitJetStreamMaxAckPending is the limit for JetStream maximum ack pending.
LimitJetStreamMaxAckPending int64 `json:"limit_jetstream_max_ack_pending"`
/// LimitJetStreamMaxStreamBytes is the limit for JetStream maximum stream bytes.
LimitJetStreamMaxStreamBytes int64 `json:"limit_jetstream_max_stream_bytes"`
// LimitJetStreamMaxBytesRequired indicates if JetStream maximum bytes required is limited.
LimitJetStreamMaxBytesRequired bool `json:"limit_jetstream_max_bytes_required"`
// LimitJetStreamMaxConsumers indicates if JetStream maximum consumer is limited.
LimitJetStreamMaxConsumers int64 `json:"limit_jetstream_max_consumers"`
// 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.48
AfterDelete ...
func (*Account) FindSigningKeyGroupByID ¶ added in v0.1.48
func (a *Account) FindSigningKeyGroupByID(id uuid.UUID) *SigningKeyGroup
FindSigningKeyGroupByID ...
type Cluster ¶ added in v0.1.48
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 ¶ added in v0.1.48
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.48
PrivateKey returns the private key portion of the NKey.
type Operator ¶ added in v0.1.48
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"`
// SystemAccount is the account that is used to manage the systems.
SystemAccount Account `json:"system_account" gorm:"polymorphic:Owner;polymorphicValue:operator;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
// AccountServerURL is the URL of the account server.
AccountServerURL string `json:"account_server_url" form:"account_server_url" xml:"account_server_url" validate:"url"`
// 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 */
// Tags are the tags associated with the environment
Tags []Tag `json:"tags" gorm:"many2many:operator_tags;"`
// 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.48
NewOperator is creating a new operator.
type OperatorPagination ¶ added in v0.1.48
type OperatorPagination Pagination[Operator]
OperatorPagination is the pagination for operators.
type OwnerType ¶ added in v0.1.48
type OwnerType string
OwnerType is the struct that is used to define the owner of the token.
type Pagination ¶ added in v0.1.48
type Pagination[R any] struct { // Limit is the number of items to return. Limit int `json:"limit" xml:"limit" form:"limit" query:"limit"` // Offset is the number of items to skip. Offset int `json:"offset" xml:"offset" form:"offset" query:"limit"` // Search is the search term to filter the results. Search string `json:"search" xml:"search" form:"search" query:"limit"` // Sort is the sorting order. Sort string `json:"sort,omitempty" xml:"sort" form:"sort" query:"limit"` // 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 ¶ added in v0.1.48
func NewPagination[R any]() Pagination[R]
NewPagination returns a new pagination.
func (*Pagination[R]) GetLimit ¶ added in v0.1.48
func (p *Pagination[R]) GetLimit() int
GetLimit returns the limit.
func (*Pagination[R]) GetOffset ¶ added in v0.1.48
func (p *Pagination[R]) GetOffset() int
GetOffset returns the page.
func (*Pagination[R]) GetRows ¶ added in v0.1.48
func (p *Pagination[R]) GetRows() []*R
GetRows returns the rows as pointers.
func (*Pagination[R]) GetSort ¶ added in v0.1.48
func (p *Pagination[R]) GetSort() string
GetSort returns the sort.
func (*Pagination[R]) GetTotalRows ¶ added in v0.1.48
func (p *Pagination[R]) GetTotalRows() int
GetTotalRows returns the total rows.
type SigningKeyGroup ¶ added in v0.1.48
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" gorm:"foreignKey:ID;polymorphic:Owner;polymorphicValue:signing_key_group"`
// 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()" xml:"id" params:"id"`
// Name is the name of the system.
Name string `json:"name" gorm:"unique" xml:"name" form:"name" validate:"required,min=3,max=128"`
// Description is the description of the system.
Description string `json:"description" form:"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" validate:"-"`
// OperatorID is the operator ID that is associated with the system.
OperatorID uuid.UUID `json:"operator_id" form:"operator_id" validate:"required,uuid"`
// Tags are the tags associated with the environment
Tags []Tag `json:"tags" gorm:"many2many:system_tags;"`
// 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 ¶ added in v0.1.48
type Tag struct {
// ID ...
ID uuid.UUID `json:"id" gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
// Name is the tag name.
Name string `json:"name" gorm:"uniqueIndex:idx_name_value"`
// Value is the tag value.
Value string `json:"value" gorm:"uniqueIndex:idx_name_value"`
// CreatedAt ...
CreatedAt time.Time `json:"created_at"`
// UpdatedAt ...
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt ...
DeletedAt gorm.DeletedAt `json:"deleted_at"`
}
Tag ...
type Team ¶
type Team struct {
// ID is the unique identifier of the team.
ID uuid.UUID `json:"id" gorm:"primaryKey;unique;type:uuid;column:id;default:gen_random_uuid()"`
// Name is the name of the team.
Name string `json:"name" validate:"required,alphanum,min=3,max=128"`
// Description is the description of the team.
Description string `json:"description" validate:"max=1024"`
// CreatedAt is the creation time of the team.
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is the update time of the team.
UpdatedAt time.Time `json:"updated_at"`
// DeletedAt is the deletion time of the team.
DeletedAt gorm.DeletedAt `json:"deleted_at"`
}
Team is a model for storing the team.
type Token ¶ added in v0.1.48
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.48
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:user"`
// 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"`
// UserLimits is the user limits.
UserLimits UserLimits `json:"limits"`
// 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.48
Credentials returns the user's credentials.
type UserLimits ¶ added in v0.1.48
type UserLimits struct {
// UserID is the user identifier.
UserID uuid.UUID `json:"user_id"`
// MaxSubscriptions is the maximum number of subscriptions the user can have.
MaxSubscriptions int `json:"max_subscriptions"`
// MaxJWTLiftime is the maximum payload size the user can have.
MaxJWTLiftime time.Duration `json:"jwt_lifetime"`
// MaxPayloadSize is the maximum payload size the user can have.
MaxPayloadSize int `json:"max_payload_size"`
// MaxDataRate is the maximum data rate the user can have.
MaxDataRate int `json:"max_data_rate"`
}
UserLimits ...