schema

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PostureCheckAttrValues = map[Attribute][]string{
	ClientLocation: {"any_valid_iso_country_codes"},
	ClientVersion:  {"any_valid_semantic_version"},
	OS:             {"linux", "darwin", "windows", "ios", "android"},
	OSVersion:      {"any_valid_semantic_version"},
	OSFamily:       {"linux-debian", "linux-redhat", "linux-suse", "linux-arch", "linux-gentoo", "linux-other", "darwin", "windows", "ios", "android"},
	KernelVersion:  {"any_valid_semantic_version"},
	AutoUpdate:     {"true", "false"},
}
View Source
var PostureCheckAttrValuesMap = map[Attribute]map[string]struct{}{
	ClientLocation: {
		"any_valid_iso_country_codes": {},
	},
	ClientVersion: {
		"any_valid_semantic_version": {},
	},
	OS: {
		"linux":   {},
		"darwin":  {},
		"windows": {},
		"ios":     {},
		"android": {},
	},
	OSVersion: {
		"any_valid_semantic_version": {},
	},
	OSFamily: {
		"linux-debian": {},
		"linux-redhat": {},
		"linux-suse":   {},
		"linux-arch":   {},
		"linux-gentoo": {},
		"linux-other":  {},
		"darwin":       {},
		"windows":      {},
		"ios":          {},
		"android":      {},
	},
	KernelVersion: {
		"any_valid_semantic_version": {},
	},
	AutoUpdate: {
		"true":  {},
		"false": {},
	},
}

Functions

func ListModels

func ListModels() []interface{}

ListModels lists all the models in this schema.

Types

type Attribute added in v1.4.0

type Attribute string
const (
	OS             Attribute = "os"
	OSVersion      Attribute = "os_version"
	OSFamily       Attribute = "os_family"
	KernelVersion  Attribute = "kernel_version"
	AutoUpdate     Attribute = "auto_update"
	ClientVersion  Attribute = "client_version"
	ClientLocation Attribute = "client_location"
)

type Egress

type Egress struct {
	ID           string                      `gorm:"primaryKey" json:"id"`
	Name         string                      `gorm:"name" json:"name"`
	Network      string                      `gorm:"network" json:"network"`
	Description  string                      `gorm:"description" json:"description"`
	Nodes        datatypes.JSONMap           `gorm:"nodes" json:"nodes"`
	Tags         datatypes.JSONMap           `gorm:"tags" json:"tags"`
	Range        string                      `gorm:"range" json:"range"`
	Mode         models.EgressNATMode        `gorm:"mode;default:direct_nat" json:"mode"`
	VirtualRange string                      `gorm:"virtual_range" json:"virtual_range"`
	DomainAns    datatypes.JSONSlice[string] `gorm:"domain_ans" json:"domain_ans"`
	Domain       string                      `gorm:"domain" json:"domain"`
	Nat          bool                        `gorm:"nat" json:"nat"`
	//IsInetGw    bool              `gorm:"is_inet_gw" json:"is_internet_gateway"`
	Status    bool      `gorm:"status" json:"status"`
	CreatedBy string    `gorm:"created_by" json:"created_by"`
	CreatedAt time.Time `gorm:"created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"updated_at" json:"updated_at"`
}

func (*Egress) Count added in v1.1.0

func (e *Egress) Count(ctx context.Context) (int, error)

func (*Egress) Create

func (e *Egress) Create(ctx context.Context) error

func (*Egress) Delete

func (e *Egress) Delete(ctx context.Context) error

func (*Egress) DoesEgressRouteExists added in v1.1.0

func (e *Egress) DoesEgressRouteExists(ctx context.Context) error

func (*Egress) Get

func (e *Egress) Get(ctx context.Context) error

func (*Egress) List added in v1.4.0

func (e *Egress) List(ctx context.Context) (egs []Egress, err error)

func (*Egress) ListByNetwork

func (e *Egress) ListByNetwork(ctx context.Context) (egs []Egress, err error)

func (*Egress) ResetDomain added in v1.2.0

func (e *Egress) ResetDomain(ctx context.Context) error

func (*Egress) ResetMode added in v1.5.0

func (e *Egress) ResetMode(ctx context.Context) error

func (*Egress) ResetRange added in v1.2.0

func (e *Egress) ResetRange(ctx context.Context) error

func (*Egress) ResetVirtualRange added in v1.5.0

func (e *Egress) ResetVirtualRange(ctx context.Context) error

func (*Egress) Table

func (e *Egress) Table() string

func (*Egress) Update

func (e *Egress) Update(ctx context.Context) error

func (*Egress) UpdateEgressStatus

func (e *Egress) UpdateEgressStatus(ctx context.Context) error

func (*Egress) UpdateNatStatus

func (e *Egress) UpdateNatStatus(ctx context.Context) error

type Event

type Event struct {
	ID          string           `gorm:"primaryKey" json:"id"`
	Action      models.Action    `gorm:"action" json:"action"`
	Source      datatypes.JSON   `gorm:"source" json:"source"`
	Origin      models.Origin    `gorm:"origin" json:"origin"`
	Target      datatypes.JSON   `gorm:"target" json:"target"`
	NetworkID   models.NetworkID `gorm:"network_id" json:"network_id"`
	TriggeredBy string           `gorm:"triggered_by" json:"triggered_by"`
	Diff        datatypes.JSON   `gorm:"diff" json:"diff"`
	TimeStamp   time.Time        `gorm:"time_stamp" json:"time_stamp"`
}

func (*Event) Create

func (a *Event) Create(ctx context.Context) error

func (*Event) DeleteOldEvents

func (a *Event) DeleteOldEvents(ctx context.Context, retentionDays int) error

func (*Event) Get

func (a *Event) Get(ctx context.Context) error

func (*Event) List

func (a *Event) List(ctx context.Context, from, to time.Time) (ats []Event, err error)

func (*Event) ListByNetwork

func (a *Event) ListByNetwork(ctx context.Context, from, to time.Time) (ats []Event, err error)

func (*Event) ListByUser

func (a *Event) ListByUser(ctx context.Context, from, to time.Time) (ats []Event, err error)

func (*Event) ListByUserAndNetwork

func (a *Event) ListByUserAndNetwork(ctx context.Context, from, to time.Time) (ats []Event, err error)

func (*Event) Update

func (a *Event) Update(ctx context.Context) error

type JITGrant added in v1.5.0

type JITGrant struct {
	ID        string    `gorm:"primaryKey" json:"id"`
	NetworkID string    `gorm:"network_id" json:"network_id"`
	UserID    string    `gorm:"user_id" json:"user_id"`
	RequestID string    `gorm:"request_id" json:"request_id"`
	GrantedAt time.Time `gorm:"granted_at" json:"granted_at"`
	ExpiresAt time.Time `gorm:"expires_at" json:"expires_at"`
}

func (*JITGrant) Create added in v1.5.0

func (g *JITGrant) Create(ctx context.Context) error

func (*JITGrant) Delete added in v1.5.0

func (g *JITGrant) Delete(ctx context.Context) error

func (*JITGrant) Get added in v1.5.0

func (g *JITGrant) Get(ctx context.Context) error

func (*JITGrant) GetActiveByUserAndNetwork added in v1.5.0

func (g *JITGrant) GetActiveByUserAndNetwork(ctx context.Context) (*JITGrant, error)

func (*JITGrant) GetByRequestID added in v1.5.0

func (g *JITGrant) GetByRequestID(ctx context.Context) (*JITGrant, error)

func (*JITGrant) ListActiveByNetwork added in v1.5.0

func (g *JITGrant) ListActiveByNetwork(ctx context.Context) ([]JITGrant, error)

func (*JITGrant) ListByUserAndNetwork added in v1.5.0

func (g *JITGrant) ListByUserAndNetwork(ctx context.Context) ([]JITGrant, error)

func (*JITGrant) ListExpired added in v1.5.0

func (g *JITGrant) ListExpired(ctx context.Context) ([]JITGrant, error)

func (*JITGrant) Table added in v1.5.0

func (g *JITGrant) Table() string

type JITRequest added in v1.5.0

type JITRequest struct {
	ID            string    `gorm:"primaryKey" json:"id"`
	NetworkID     string    `gorm:"network_id" json:"network_id"`
	UserID        string    `gorm:"user_id" json:"user_id"`
	UserName      string    `gorm:"user_name" json:"user_name"`
	Reason        string    `gorm:"reason" json:"reason"`
	Status        string    `gorm:"status" json:"status"` // pending, approved, denied, expired
	RevokedAt     time.Time `gorm:"revoked_at" json:"revoked_at"`
	RequestedAt   time.Time `gorm:"requested_at" json:"requested_at"`
	ApprovedAt    time.Time `gorm:"approved_at" json:"approved_at,omitempty"`
	ApprovedBy    string    `gorm:"approved_by" json:"approved_by,omitempty"`
	DurationHours int       `gorm:"duration_hours" json:"duration_hours,omitempty"`
	ExpiresAt     time.Time `gorm:"expires_at" json:"expires_at,omitempty"`
}

func (*JITRequest) CountByNetwork added in v1.5.0

func (r *JITRequest) CountByNetwork(ctx context.Context) (int64, error)

func (*JITRequest) CountByStatusAndNetwork added in v1.5.0

func (r *JITRequest) CountByStatusAndNetwork(ctx context.Context, status string) (int64, error)

func (*JITRequest) Create added in v1.5.0

func (r *JITRequest) Create(ctx context.Context) error

func (*JITRequest) Delete added in v1.5.0

func (r *JITRequest) Delete(ctx context.Context) error

func (*JITRequest) Get added in v1.5.0

func (r *JITRequest) Get(ctx context.Context) error

func (*JITRequest) ListByNetwork added in v1.5.0

func (r *JITRequest) ListByNetwork(ctx context.Context) ([]JITRequest, error)

func (*JITRequest) ListByStatusAndNetwork added in v1.5.0

func (r *JITRequest) ListByStatusAndNetwork(ctx context.Context, status string) ([]JITRequest, error)

func (*JITRequest) ListByUserAndNetwork added in v1.5.0

func (r *JITRequest) ListByUserAndNetwork(ctx context.Context) ([]JITRequest, error)

func (*JITRequest) ListPendingByNetwork added in v1.5.0

func (r *JITRequest) ListPendingByNetwork(ctx context.Context) ([]JITRequest, error)

func (*JITRequest) Table added in v1.5.0

func (r *JITRequest) Table() string

func (*JITRequest) Update added in v1.5.0

func (r *JITRequest) Update(ctx context.Context) error

type Job

type Job struct {
	ID        string `gorm:"primaryKey"`
	CreatedAt time.Time
}

Job represents a task that netmaker server wants to do.

Ideally, a jobs table should have details about its type, status, who initiated it, etc. But, for now, the table only contains records of jobs that have been done, so that it is easier to prevent a task from being executed again.

func (*Job) Create

func (j *Job) Create(ctx context.Context) error

Create creates a job record in the jobs table.

func (*Job) Get

func (j *Job) Get(ctx context.Context) error

Get returns a job record with the given Job.ID.

type Nameserver added in v1.1.0

type Nameserver struct {
	ID          string                                `gorm:"primaryKey" json:"id"`
	Name        string                                `gorm:"name" json:"name"`
	NetworkID   string                                `gorm:"network_id" json:"network_id"`
	Description string                                `gorm:"description" json:"description"`
	Default     bool                                  `gorm:"column:default" json:"default"`
	Fallback    bool                                  `gorm:"fallback" json:"fallback"`
	Servers     datatypes.JSONSlice[string]           `gorm:"servers" json:"servers"`
	MatchAll    bool                                  `gorm:"match_all" json:"match_all"`
	Domains     datatypes.JSONSlice[NameserverDomain] `gorm:"domains" json:"domains"`
	// TODO: deprecate
	MatchDomains datatypes.JSONSlice[string] `gorm:"match_domains" json:"match_domains"`
	Tags         datatypes.JSONMap           `gorm:"tags" json:"tags"`
	Nodes        datatypes.JSONMap           `gorm:"nodes" json:"nodes"`
	Status       bool                        `gorm:"status" json:"status"`
	CreatedBy    string                      `gorm:"created_by" json:"created_by"`
	CreatedAt    time.Time                   `gorm:"created_at" json:"created_at"`
	UpdatedAt    time.Time                   `gorm:"updated_at" json:"updated_at"`
}

func (*Nameserver) Create added in v1.1.0

func (ns *Nameserver) Create(ctx context.Context) error

func (*Nameserver) Delete added in v1.1.0

func (ns *Nameserver) Delete(ctx context.Context) error

func (*Nameserver) DeleteByNetwork added in v1.4.0

func (ns *Nameserver) DeleteByNetwork(ctx context.Context) error

func (*Nameserver) Get added in v1.1.0

func (ns *Nameserver) Get(ctx context.Context) error

func (*Nameserver) ListByNetwork added in v1.1.0

func (ns *Nameserver) ListByNetwork(ctx context.Context) (dnsli []Nameserver, err error)

func (*Nameserver) Update added in v1.1.0

func (ns *Nameserver) Update(ctx context.Context) error

func (*Nameserver) UpdateFallback added in v1.4.0

func (ns *Nameserver) UpdateFallback(ctx context.Context) error

func (*Nameserver) UpdateMatchAll added in v1.1.0

func (ns *Nameserver) UpdateMatchAll(ctx context.Context) error

func (*Nameserver) UpdateStatus added in v1.1.0

func (ns *Nameserver) UpdateStatus(ctx context.Context) error

type NameserverDomain added in v1.2.0

type NameserverDomain struct {
	Domain         string `json:"domain"`
	IsSearchDomain bool   `json:"is_search_domain"`
}

type PendingHost added in v1.1.0

type PendingHost struct {
	ID            string         `gorm:"id" json:"id"`
	HostID        string         `gorm:"host_id" json:"host_id"`
	Hostname      string         `gorm:"host_name" json:"host_name"`
	Network       string         `gorm:"network" json:"network"`
	PublicKey     string         `gorm:"public_key" json:"public_key"`
	EnrollmentKey datatypes.JSON `gorm:"enrollment_key_id" json:"enrollment_key_id"`
	OS            string         `gorm:"os" json:"os"`
	Version       string         `gorm:"version" json:"version"`
	Location      string         `gorm:"location" json:"location"` // Format: "lat,lon"
	RequestedAt   time.Time      `gorm:"requested_at" json:"requested_at"`
}

func (*PendingHost) CheckIfPendingHostExists added in v1.1.0

func (p *PendingHost) CheckIfPendingHostExists(ctx context.Context) error

func (*PendingHost) Create added in v1.1.0

func (p *PendingHost) Create(ctx context.Context) error

func (*PendingHost) Delete added in v1.1.0

func (p *PendingHost) Delete(ctx context.Context) error

func (*PendingHost) DeleteAllPendingHosts added in v1.1.0

func (p *PendingHost) DeleteAllPendingHosts(ctx context.Context) error

func (*PendingHost) Get added in v1.1.0

func (p *PendingHost) Get(ctx context.Context) error

func (*PendingHost) List added in v1.1.0

func (p *PendingHost) List(ctx context.Context) (pendingHosts []PendingHost, err error)

type PostureCheck added in v1.4.0

type PostureCheck struct {
	ID          string                      `gorm:"primaryKey" json:"id"`
	Name        string                      `gorm:"name" json:"name"`
	NetworkID   models.NetworkID            `gorm:"network_id" json:"network_id"`
	Description string                      `gorm:"description" json:"description"`
	Attribute   Attribute                   `gorm:"attribute" json:"attribute"`
	Values      datatypes.JSONSlice[string] `gorm:"values" json:"values"`
	Severity    models.Severity             `gorm:"severity" json:"severity"`
	Tags        datatypes.JSONMap           `gorm:"tags" json:"tags"`
	UserGroups  datatypes.JSONMap           `gorm:"user_groups" json:"user_groups"`
	Status      bool                        `gorm:"status" json:"status"`
	CreatedBy   string                      `gorm:"created_by" json:"created_by"`
	CreatedAt   time.Time                   `gorm:"created_at" json:"created_at"`
	UpdatedAt   time.Time                   `gorm:"updated_at" json:"updated_at"`
}

func (*PostureCheck) Create added in v1.4.0

func (p *PostureCheck) Create(ctx context.Context) error

func (*PostureCheck) Delete added in v1.4.0

func (p *PostureCheck) Delete(ctx context.Context) error

func (*PostureCheck) Get added in v1.4.0

func (p *PostureCheck) Get(ctx context.Context) error

func (*PostureCheck) ListByNetwork added in v1.4.0

func (p *PostureCheck) ListByNetwork(ctx context.Context) (pcli []PostureCheck, err error)

func (*PostureCheck) Update added in v1.4.0

func (p *PostureCheck) Update(ctx context.Context) error

func (*PostureCheck) UpdateStatus added in v1.4.0

func (p *PostureCheck) UpdateStatus(ctx context.Context) error

type UserAccessToken

type UserAccessToken struct {
	ID        string    `gorm:"primaryKey" json:"id"`
	Name      string    `json:"name"`
	UserName  string    `json:"user_name"`
	ExpiresAt time.Time `json:"expires_at"`
	LastUsed  time.Time `json:"last_used"`
	CreatedBy string    `json:"created_by"`
	CreatedAt time.Time `json:"created_at"`
}

UserAccessToken - token used to access netmaker

func (*UserAccessToken) CountByUser added in v1.0.0

func (a *UserAccessToken) CountByUser(ctx context.Context) (int, error)

func (*UserAccessToken) Create

func (a *UserAccessToken) Create(ctx context.Context) error

func (*UserAccessToken) Delete

func (a *UserAccessToken) Delete(ctx context.Context) error

func (*UserAccessToken) DeleteAllUserTokens

func (a *UserAccessToken) DeleteAllUserTokens(ctx context.Context) error

func (*UserAccessToken) Get

func (a *UserAccessToken) Get(ctx context.Context) error

func (*UserAccessToken) List

func (a *UserAccessToken) List(ctx context.Context) (ats []UserAccessToken, err error)

func (*UserAccessToken) ListByUser

func (a *UserAccessToken) ListByUser(ctx context.Context) (ats []UserAccessToken)

func (*UserAccessToken) Update

func (a *UserAccessToken) Update(ctx context.Context) error

type Values added in v1.4.0

type Values string

Jump to

Keyboard shortcuts

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