models

package
v3.0.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalNode = &Node{
	ID:          0,
	Name:        "LocalNode",
	PublicHost:  "127.0.0.1",
	PrivateHost: "127.0.0.1",
	PublicPort:  8080,
	PrivatePort: 8080,
	SFTPPort:    5657,
}

Functions

This section is empty.

Types

type ChangeMultipleSettings

type ChangeMultipleSettings map[string]interface{} //@name ChangeMultipleSettings

type ChangeUserSetting

type ChangeUserSetting struct {
	Value string `json:"value"`

} //@name UserSetting

type Client

type Client struct {
	ID                 uint   `gorm:"PRIMARY_KEY,AUTO_INCREMEMT" json:"-"`
	ClientId           string `gorm:"NOT NULL;uniqueIndex" json:"client_id"`
	HashedClientSecret string `gorm:"column:client_secret;NOT NULL" json:"-"`

	ClientSecret string `gorm:"-" json:"client_secret"`

	UserId uint  `gorm:"NOT NULL" json:"-"`
	User   *User `json:"-"`

	Name        string `gorm:"column:name;NOT NULL;size:100;default\"\"" json:"name"`
	Description string `gorm:"column:description;NOT NULL;size:4000;default:\"\"" json:"description"`
}

func (*Client) BeforeSave

func (c *Client) BeforeSave(*gorm.DB) error

func (*Client) IsValid

func (c *Client) IsValid() (err error)

func (*Client) SetClientSecret

func (c *Client) SetClientSecret(secret string) error

func (*Client) ValidateSecret

func (c *Client) ValidateSecret(secret string) bool

type CreateServerResponse

type CreateServerResponse struct {
	Id string `json:"id"`

} //@name CreatedServerId

type Deployment

type Deployment struct {
	ClientId     string `json:"clientId"`
	ClientSecret string `json:"clientSecret"`
	PublicKey    string `json:"publicKey"`

} //@name NodeDeploymentConfig

type GetServerResponse

type GetServerResponse struct {
	Server *ServerView     `json:"server"`
	Perms  *PermissionView `json:"permissions"`

} //@name GetServer

type Node

type Node struct {
	ID          uint   `json:"-"`
	Name        string `gorm:"size:100;UNIQUE;NOT NULL" json:"-" validate:"required,printascii"`
	PublicHost  string `gorm:"size:100;NOT NULL" json:"-" validate:"required,ip|fqdn"`
	PrivateHost string `gorm:"size:100;NOT NULL" json:"-" validate:"required,ip|fqdn"`
	PublicPort  uint16 `gorm:"DEFAULT:8080;NOT NULL" json:"-" validate:"required,min=1,max=65535,nefield=SFTPPort"`
	PrivatePort uint16 `gorm:"DEFAULT:8080;NOT NULL" json:"-" validate:"required,min=1,max=65535,nefield=SFTPPort"`
	SFTPPort    uint16 `gorm:"DEFAULT:5657;NOT NULL" json:"-" validate:"required,min=1,max=65535,nefield=PublicPort,nefield=PrivatePort"`

	Secret string `gorm:"size=36;NOT NULL" json:"-" validate:"required"`

	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

func (*Node) BeforeSave

func (n *Node) BeforeSave(*gorm.DB) (err error)

func (*Node) IsLocal

func (n *Node) IsLocal() bool

func (*Node) IsValid

func (n *Node) IsValid() (err error)

type NodeView

type NodeView struct {
	Id          uint   `json:"id"`
	Name        string `json:"name,omitempty"`
	PublicHost  string `json:"publicHost,omitempty"`
	PrivateHost string `json:"privateHost,omitempty"`
	PublicPort  uint16 `json:"publicPort,omitempty"`
	PrivatePort uint16 `json:"privatePort,omitempty"`
	SFTPPort    uint16 `json:"sftpPort,omitempty"`
	Local       bool   `json:"isLocal"`

} //@name Node

func FromNode

func FromNode(n *Node) *NodeView

func (*NodeView) CopyToModel

func (n *NodeView) CopyToModel(newModel *Node)

func (*NodeView) Valid

func (n *NodeView) Valid(allowEmpty bool) error

type NodesView

type NodesView []*NodeView //@name Nodes

func FromNodes

func FromNodes(n []*Node) *NodesView

type PermissionView

type PermissionView struct {
	ServerIdentifier string `json:"serverIdentifier,omitempty"`

	Scopes []*pufferpanel.Scope `json:"scopes"`

} //@name Permissions

func FromPermission

func FromPermission(p *Permissions) *PermissionView

type Permissions

type Permissions struct {
	ID uint `gorm:"primaryKey,autoIncrement" json:"-"`

	//owners of this permission set
	UserId *uint `json:"-"`
	User   User  `gorm:"ASSOCIATION_SAVE_REFERENCE:false" json:"-" validate:"-"`

	ClientId *uint  `json:"-"`
	Client   Client `gorm:"ASSOCIATION_SAVE_REFERENCE:false" json:"-" validate:"-"`

	//if this set is for a server, what server
	ServerIdentifier *string `json:"-"`
	Server           Server  `gorm:"ASSOCIATION_SAVE_REFERENCE:false" json:"-" validate:"-"`

	RawScopes string               `gorm:"column:scopes;NOT NULL;DEFAULT:''" json:"-" validate:"required"`
	Scopes    []*pufferpanel.Scope `gorm:"-" json:"-"`
}

func (*Permissions) AfterFind

func (p *Permissions) AfterFind(*gorm.DB) error

func (*Permissions) BeforeSave

func (p *Permissions) BeforeSave(*gorm.DB) error

func (*Permissions) ShouldDelete

func (p *Permissions) ShouldDelete() bool

type Server

type Server struct {
	Name       string `gorm:"size:40;NOT NULL" json:"-" validate:"required,printascii"`
	Identifier string `gorm:"UNIQUE;NOT NULL;primaryKey;size:8" json:"-" validate:"required,printascii"`

	RawNodeID *uint `gorm:"column:node_id" json:"-"`
	NodeID    uint  `gorm:"-" json:"-" validate:"-"`
	Node      Node  `gorm:"ASSOCIATION_SAVE_REFERENCE:false;foreignKey:RawNodeID" json:"-" validate:"-"`

	IP   string `gorm:"" json:"-" validate:"omitempty,ip|fqdn"`
	Port uint16 `gorm:"" json:"-" validate:"omitempty"`

	Type string `gorm:"NOT NULL;default='generic'" json:"-" validate:"required,printascii"`
	Icon string `gorm:"" json:"-"`

	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

func (*Server) AfterFind

func (s *Server) AfterFind(*gorm.DB) (err error)

func (*Server) BeforeSave

func (s *Server) BeforeSave(*gorm.DB) (err error)

func (*Server) IsValid

func (s *Server) IsValid() (err error)

type ServerCreation

type ServerCreation struct {
	pufferpanel.Server

	NodeId uint     `json:"node"`
	Users  []string `json:"users"`
	Name   string   `json:"name"`

} //@name CreatedServer

type ServerSearchResponse

type ServerSearchResponse struct {
	Servers []*ServerView `json:"servers"`
	*pufferpanel.Metadata

} //@name ServerSearchResults

type ServerUserView

type ServerUserView struct {
	Username string   `json:"username"`
	Scopes   []string `json:"scopes"`

} //@name ServerUser

type ServerView

type ServerView struct {
	Identifier   string           `json:"id,omitempty"`
	Name         string           `json:"name,omitempty"`
	NodeId       uint             `json:"nodeId,omitempty"`
	Node         *NodeView        `json:"node,omitempty"`
	Data         interface{}      `json:"data,omitempty"`
	Users        []ServerUserView `json:"users,omitempty"`
	IP           string           `json:"ip,omitempty"`
	Port         uint16           `json:"port,omitempty"`
	Type         string           `json:"type"`
	Icon         string           `json:"icon,omitempty"`
	CanGetStatus bool             `json:"canGetStatus,omitempty"`

} //@name ServerInfo

func FromServer

func FromServer(server *Server) *ServerView

func FromServers

func FromServers(servers []*Server) []*ServerView

func RemoveServerPrivateInfo

func RemoveServerPrivateInfo(server *ServerView) *ServerView

func RemoveServerPrivateInfoFromAll

func RemoveServerPrivateInfoFromAll(servers []*ServerView) []*ServerView

func (*ServerView) Valid

func (s *ServerView) Valid(allowEmpty bool) error

type ServerWithName

type ServerWithName struct {
	pufferpanel.Server
	Name string `json:"name"`

} //@name NamedServer

type Session

type Session struct {
	ID             uint      `gorm:"primaryKey,autoIncrement" json:"-"`
	Token          string    `gorm:"unique;size:64;not null" json:"-"`
	ExpirationTime time.Time `gorm:"not null" json:"-"`

	UserId *uint `json:"-"`
	User   User  `gorm:"ASSOCIATION_SAVE_REFERENCE:false" json:"-" validate:"-"`

	ClientId *uint  `json:"-"`
	Client   Client `gorm:"ASSOCIATION_SAVE_REFERENCE:false" json:"-" validate:"-"`

	//if this set is for a server, what server
	ServerIdentifier *string `json:"-"`
	Server           Server  `gorm:"ASSOCIATION_SAVE_REFERENCE:false" json:"-" validate:"-"`
}

type Setting

type Setting struct {
	Value interface{} `json:"value"`

} //@name Setting

type Template

type Template struct {
	pufferpanel.Server `gorm:"-"`

	Name     string `gorm:"type:varchar(100);primaryKey" json:"name"`
	RawValue string `gorm:"type:text" json:"-"`

	Readme string `gorm:"type:text" json:"readme,omitempty"`

} //@name Template

func (*Template) AfterFind

func (t *Template) AfterFind(*gorm.DB) error

func (*Template) BeforeSave

func (t *Template) BeforeSave(*gorm.DB) error

type TemplateRepo

type TemplateRepo struct {
	ID       uint   `gorm:"primaryKey" json:"id"`
	Name     string `gorm:"type:varchar(100);" json:"name"`
	Url      string `gorm:"type:text" json:"url"`
	Branch   string `gorm:"type:text" json:"branch"`
	PAT      string `json:"-"`
	Username string `json:"-"`
	Password string `json:"-"`
	SSHKey   string `json:"-"`
	IsLocal  bool   `gorm:"-" json:"isLocal"`

} //@name TemplateRepo

type User

type User struct {
	ID             uint   `json:"-"`
	Username       string `gorm:"UNIQUE;NOT NULL;size:100" json:"-" validate:"required,printascii,max=100,min=5"`
	Email          string `gorm:"UNIQUE;NOT NULL;size:255" json:"-" validate:"required,email,max=255"`
	HashedPassword string `gorm:"column:password;NOT NULL;size:200" json:"-" validate:"required,max=200"`
	OtpSecret      string `gorm:"size:32" json:"-"`
	OtpActive      bool   `gorm:"NOT NULL;DEFAULT:0" json:"-"`

	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
}

func (*User) BeforeSave

func (u *User) BeforeSave(*gorm.DB) (err error)

func (*User) IsValid

func (u *User) IsValid() (err error)

func (*User) SetPassword

func (u *User) SetPassword(pw string) error

type UserPermissionsView

type UserPermissionsView struct {
	Username string               `json:"username,omitempty"`
	Email    string               `json:"email"`
	Scopes   []*pufferpanel.Scope `json:"scopes"`
}

type UserSearch

type UserSearch struct {
	Username  string `form:"username"`
	Email     string `form:"email"`
	PageLimit uint   `form:"limit"`
	Page      uint   `form:"page"`

} //@name UserSearch

type UserSearchResponse

type UserSearchResponse struct {
	Users []*UserView `json:"users"`
	*pufferpanel.Metadata

} //@name UserSearchResponse

type UserSetting

type UserSetting struct {
	Key    string `gorm:"NOT NULL;size:100;primaryKey"`
	UserID uint   `gorm:"NOT NULL;primaryKey;AUTO_INCREMENT:false"`
	Value  string `gorm:"NOT NULL;type:text"`
}

type UserSettingView

type UserSettingView struct {
	Key   string `json:"key"`
	Value string `json:"value"`

} //@name UserSettings

func FromUserSetting

func FromUserSetting(setting *UserSetting) *UserSettingView

type UserSettingsView

type UserSettingsView []*UserSettingView

func FromUserSettings

func FromUserSettings(settings []*UserSetting) UserSettingsView

type UserView

type UserView struct {
	Id       uint   `json:"id,omitempty"`
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
	//ONLY SHOW WHEN COPYING
	Password    string `json:"password,omitempty"`
	NewPassword string `json:"newPassword,omitempty"`

} //@name User

func FromUser

func FromUser(model *User) *UserView

func FromUsers

func FromUsers(users []*User) []*UserView

func (*UserView) CopyToModel

func (model *UserView) CopyToModel(newModel *User)

func (*UserView) EmailValid

func (model *UserView) EmailValid(allowEmpty bool) error

func (*UserView) UserNameValid

func (model *UserView) UserNameValid(allowEmpty bool) error

func (*UserView) Valid

func (model *UserView) Valid(allowEmpty bool) error

Jump to

Keyboard shortcuts

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