schema

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 21 Imported by: 7

Documentation

Index

Constants

View Source
const (
	EDRMatchEntraDeviceID = "entra_device_id"
	EDRMatchSerialNumber  = "serial_number"
	EDRMatchHostname      = "hostname"
)

EDR match identifiers (how a host was matched to an EDR endpoint record).

View Source
const (
	// FIREWALL_IPTABLES - indicates that iptables is the firewall in use
	FIREWALL_IPTABLES = "iptables"
	// FIREWALL_NFTABLES - indicates nftables is in use (Linux only)
	FIREWALL_NFTABLES = "nftables"
	// FIREWALL_NONE - indicates that no supported firewall in use
	FIREWALL_NONE = "none"
)
View Source
const (
	InternalKey_ServerID                        = "server_id"
	InternalKey_ServerVersion                   = "server_version"
	InternalKey_JwtSecret                       = "jwt_secret"
	InternalKey_OAuthSecret                     = "oauth_secret"
	InternalKey_MqPrivateKey                    = "mq_private_key"
	InternalKey_MqPublicKey                     = "mq_public_key"
	InternalKey_LicenseValidationPrivateKey     = "license_validation_private_key"
	InternalKey_LicenseValidationPublicKey      = "license_validation_public_key"
	InternalKey_LicenseValidationCachedResponse = "license_validation_cached_response"
	InternalKey_TelemetryLastReportedAt         = "telemetry_last_reported_at"
)
View Source
const (
	MDMMatchEntraDeviceID = "entra_device_id"
	MDMMatchSerialNumber  = "serial_number"
	MDMMatchHardwareUUID  = "hardware_uuid"
	MDMMatchHostname      = "hostname"
)

MatchedBy* identify how a host was matched to an MDM-managed device record.

View Source
const (
	// NODE_DELETE - delete node action
	NODE_DELETE = "delete"
	// NODE_IS_PENDING - node pending status
	NODE_IS_PENDING = "pending"
	// NODE_NOOP - node no op action
	NODE_NOOP = "noop"
	// NODE_FORCE_UPDATE - indicates a node should pull all changes
	NODE_FORCE_UPDATE = "force"
)
View Source
const (
	TcpProxyTLSModeSelfSigned = "selfsigned"
	TcpProxyTLSModeProxy      = "proxy"
)

TcpProxyTLSMode values (host/node). Empty defaults to selfsigned on clients.

View Source
const (
	OldRemoteAccessTagName = "remote-access-gws"
	GwTagName              = "gateways"
)
View Source
const DefaultSsoStateDuration = time.Minute * 5
View Source
const DefaultTcpProxyListenPort = 443

DefaultTcpProxyListenPort is used when TcpProxyEnabled is set with listen port <= 0.

View Source
const DefaultTenantSlug = "default"
View Source
const TcpProxyClientPortProxy = 443

TcpProxyClientPortProxy is the default client-facing WSS port published when TLS mode is proxy (external termination). Override at runtime with the TCP_PROXY_PUBLIC_PORT server environment variable.

Variables

View Source
var (
	ErrUserIdentifiersNotProvided = errors.New("user identifiers not provided")
	ErrTenantIDNotProvided        = errors.New("tenant ID not provided")
	ErrScopeNotProvided           = errors.New("scope not provided")
)
View Source
var EDRComplianceConfigKeys = []string{
	"require_agent_installed",
	"require_agent_healthy",
	"max_allowed_risk_level",
	"max_state_age_hours",
}
View Source
var (
	ErrNetworkIdentifiersNotProvided = errors.New("network identifiers not provided")
)
View Source
var (
	ErrPendingUserIdentifiersNotProvided = errors.New("pending user identifiers not provided")
)
View Source
var MDMComplianceConfigKeys = []string{
	"require_enrolled",
	"require_compliant",
	"max_state_age_hours",
}

MDMComplianceConfigKeys lists the supported keys in PostureCheck.Config when Attribute == MDMCompliance.

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"},
	MDMCompliance:  {"mdm"},
	EDRCompliance:  {"edr"},
}
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": {},
	},

	MDMCompliance: {
		"mdm": {},
	},
	EDRCompliance: {
		"edr": {},
	},
}
View Source
var RsrcTypeMap = map[RsrcType]struct{}{
	HostRsrc:           {},
	RelayRsrc:          {},
	RemoteAccessGwRsrc: {},
	ExtClientsRsrc:     {},
	InetGwRsrc:         {},
	EgressGwRsrc:       {},
	NetworkRsrc:        {},
	EnrollmentKeysRsrc: {},
	UserRsrc:           {},
	AclRsrc:            {},
	DnsRsrc:            {},
	FailOverRsrc:       {},
}

Functions

func ListModels

func ListModels() []interface{}

ListModels lists all the models in this schema.

func NormaliseTcpProxyPublicHostname added in v1.7.0

func NormaliseTcpProxyPublicHostname(raw string) (string, error)

NormaliseTcpProxyPublicHostname cleans a public hostname for WSS publish. Strips schemes/paths; rejects values that look like URLs with paths or empty hosts.

func NormaliseTcpProxyTLSMode added in v1.7.0

func NormaliseTcpProxyTLSMode(mode string) (string, error)

NormaliseTcpProxyTLSMode returns a valid mode; empty → selfsigned.

func StripTenantKey added in v1.7.0

func StripTenantKey(tenantID, storedKey string) string

StripTenantKey removes the tenant prefix added by TenantScopedKey, returning the original logical key.

func TenantScopedKey added in v1.7.0

func TenantScopedKey(tenantID, key string) string

TenantScopedKey composes the physical storage key for a tenant + logical key pair.

Types

type Acl added in v1.7.0

type Acl struct {
	ID               string                  `json:"id"`
	Default          bool                    `json:"default"`
	MetaData         string                  `json:"meta_data"`
	Name             string                  `json:"name"`
	NetworkID        NetworkID               `json:"network_id"`
	RuleType         AclPolicyType           `json:"policy_type"`
	Src              []AclPolicyTag          `json:"src_type"`
	Dst              []AclPolicyTag          `json:"dst_type"`
	Proto            Protocol                `json:"protocol"`
	ServiceType      string                  `json:"type"`
	Port             []string                `json:"ports"`
	AllowedDirection AllowedTrafficDirection `json:"allowed_traffic_direction"`
	Enabled          bool                    `json:"enabled"`
	CreatedBy        string                  `json:"created_by"`
	CreatedAt        time.Time               `json:"created_at"`
}

type AclGroupType added in v1.7.0

type AclGroupType string
const (
	UserAclID                AclGroupType = "user"
	UserGroupAclID           AclGroupType = "user-group"
	NodeTagID                AclGroupType = "tag"
	NodeID                   AclGroupType = "device"
	EgressRange              AclGroupType = "egress-range"
	EgressID                 AclGroupType = "egress-id"
	NetmakerIPAclID          AclGroupType = "ip"
	NetmakerSubNetRangeAClID AclGroupType = "ipset"
)

func (AclGroupType) String added in v1.7.0

func (g AclGroupType) String() string

type AclPolicyTag added in v1.7.0

type AclPolicyTag struct {
	ID    AclGroupType `json:"id"`
	Name  string       `json:"name"`
	Value string       `json:"value"`
}

type AclPolicyType added in v1.7.0

type AclPolicyType string
const (
	UserPolicy   AclPolicyType = "user-policy"
	DevicePolicy AclPolicyType = "device-policy"
)

type AclRecord added in v1.7.0

type AclRecord struct {
	Key       string `gorm:"primaryKey"`
	TenantID  string `gorm:"default:'';index"`
	NetworkID string
	Value     datatypes.JSONType[Acl]
}

func (*AclRecord) Count added in v1.7.0

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

func (*AclRecord) Delete added in v1.7.0

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

func (*AclRecord) DeleteAll added in v1.7.0

func (*AclRecord) DeleteAll(ctx context.Context) error

func (*AclRecord) Get added in v1.7.0

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

func (*AclRecord) List added in v1.7.0

func (*AclRecord) List(ctx context.Context) ([]AclRecord, error)

func (*AclRecord) TableName added in v1.7.0

func (*AclRecord) TableName() string

func (*AclRecord) Upsert added in v1.7.0

func (r *AclRecord) Upsert(ctx context.Context) error

type Action added in v1.5.1

type Action string
const (
	Create                               Action = "CREATE"
	Update                               Action = "UPDATE"
	Delete                               Action = "DELETE"
	DeleteAll                            Action = "DELETE_ALL"
	Login                                Action = "LOGIN"
	LogOut                               Action = "LOGOUT"
	Connect                              Action = "CONNECT"
	Sync                                 Action = "SYNC"
	RefreshKey                           Action = "REFRESH_KEY"
	RefreshAllKeys                       Action = "REFRESH_ALL_KEYS"
	SyncAll                              Action = "SYNC_ALL"
	UpgradeAll                           Action = "UPGRADE_ALL"
	Disconnect                           Action = "DISCONNECT"
	JoinHostToNet                        Action = "JOIN_HOST_TO_NETWORK"
	RemoveHostFromNet                    Action = "REMOVE_HOST_FROM_NETWORK"
	EnableMFA                            Action = "ENABLE_MFA"
	DisableMFA                           Action = "DISABLE_MFA"
	EnforceMFA                           Action = "ENFORCE_MFA"
	UnenforceMFA                         Action = "UNENFORCE_MFA"
	EnableBasicAuth                      Action = "ENABLE_BASIC_AUTH"
	DisableBasicAuth                     Action = "DISABLE_BASIC_AUTH"
	EnableTelemetry                      Action = "ENABLE_TELEMETRY"
	DisableTelemetry                     Action = "DISABLE_TELEMETRY"
	UpdateClientSettings                 Action = "UPDATE_CLIENT_SETTINGS"
	UpdateAuthenticationSecuritySettings Action = "UPDATE_AUTHENTICATION_SECURITY_SETTINGS"
	UpdateMonitoringAndDebuggingSettings Action = "UPDATE_MONITORING_AND_DEBUGGING_SETTINGS"
	UpdateSMTPSettings                   Action = "UPDATE_EMAIL_SETTINGS"
	UpdateIDPSettings                    Action = "UPDATE_IDP_SETTINGS"
	EnableFlowLogs                       Action = "ENABLE_FLOW_LOGS"
	DisableFlowLogs                      Action = "DISABLE_FLOW_LOGS"
	GatewayAssign                        Action = "GATEWAY_ASSIGN"
	GatewayUnAssign                      Action = "GATEWAY_UNASSIGN"
	JitEnable                            Action = "ENABLE_JIT"
	JitDisable                           Action = "DISABLE_JIT"
	JitRequestCreate                     Action = "CREATE_JIT_REQUEST"
	JitRequestApprove                    Action = "APPROVE_JIT_REQUEST"
	JitRequestDeny                       Action = "DENY_JIT_REQUEST"
	JitGrantRevoke                       Action = "REVOKE_JIT_GRANT"
	JitGroupsUpdate                      Action = "UPDATE_JIT_GROUPS"
	EnableUser                           Action = "ENABLE_USER"
	DisableUser                          Action = "DISABLE_USER"
	EnableAclPolicy                      Action = "ENABLE_ACL_POLICY"
	DisableAclPolicy                     Action = "DISABLE_ACL_POLICY"
	MDMVerify                            Action = "MDM_VERIFY"
	MDMSync                              Action = "MDM_SYNC"
	PostureCheckFailed                   Action = "POSTURE_CHECK_FAILED"
	TransferDeviceOwnership              Action = "TRANSFER_DEVICE_OWNERSHIP"
)

type AddrPort added in v1.5.1

type AddrPort struct {
	netip.AddrPort
}

func (AddrPort) MarshalJSON added in v1.5.1

func (a AddrPort) MarshalJSON() ([]byte, error)

func (*AddrPort) Scan added in v1.5.1

func (a *AddrPort) Scan(value interface{}) error

func (*AddrPort) UnmarshalJSON added in v1.5.1

func (a *AddrPort) UnmarshalJSON(data []byte) error

func (AddrPort) Value added in v1.5.1

func (a AddrPort) Value() (driver.Value, error)

type AllowedTrafficDirection added in v1.7.0

type AllowedTrafficDirection int

AllowedTrafficDirection - allowed direction of traffic

const (
	TrafficDirectionUni AllowedTrafficDirection = iota
	TrafficDirectionBi
)

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"
	// MDMCompliance evaluates the host's posture against the MDM provider
	// configured in ServerSettings. Config payload (JSONMap):
	//   {"require_enrolled": bool, "require_compliant": bool, "max_state_age_hours": int}
	MDMCompliance Attribute = "mdm_compliance"
	// EDRCompliance evaluates the host's posture against the EDR provider.
	// Config payload (JSONMap):
	//   {"require_agent_installed": bool, "require_agent_healthy": bool,
	//    "max_allowed_risk_level": string, "max_state_age_hours": int}
	EDRCompliance Attribute = "edr_compliance"
)

type AuthType added in v1.5.1

type AuthType string
var (
	BasicAuth AuthType = "basic_auth"
	OAuth     AuthType = "oauth"
	Inherited AuthType = "inherited"
)

type CacheRecord added in v1.7.0

type CacheRecord struct {
	Key   string `gorm:"primaryKey"`
	Value datatypes.JSONType[CacheValue]
}

func (*CacheRecord) Count added in v1.7.0

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

func (*CacheRecord) Delete added in v1.7.0

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

func (*CacheRecord) Get added in v1.7.0

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

func (*CacheRecord) List added in v1.7.0

func (*CacheRecord) List(ctx context.Context) ([]CacheRecord, error)

func (*CacheRecord) TableName added in v1.7.0

func (*CacheRecord) TableName() string

func (*CacheRecord) Upsert added in v1.7.0

func (r *CacheRecord) Upsert(ctx context.Context) error

type CacheValue added in v1.7.0

type CacheValue struct {
	Scope      scope.Scope `json:"scope"`
	ScopeID    string      `json:"scope_id"`
	Network    string      `json:"network,omitempty"`
	Value      string      `json:"value"`
	Host       Host        `json:"host"`
	Pass       string      `json:"pass,omitempty"`
	User       string      `json:"user,omitempty"`
	ALL        bool        `json:"all,omitempty"`
	Expiration time.Time   `json:"expiration"`
}

CacheValue - the cache object for a network

type DNSEntry added in v1.7.0

type DNSEntry struct {
	Type     DNSEntryType `json:"type"`
	Address  string       `json:"address" validate:"omitempty,ip"`
	Address6 string       `json:"address6" validate:"omitempty,ip"`
	Name     string       `json:"name" validate:"required,name_unique,min=1,max=192,whitespace"`
	Network  string       `json:"network" validate:"network_exists"`
}

DNSEntry - a DNS entry represented as struct

type DNSEntryType added in v1.7.0

type DNSEntryType string
const (
	DNSEntryType_Node   DNSEntryType = "node"
	DNSEntryType_Custom DNSEntryType = "custom"
)

type DNSRecord added in v1.7.0

type DNSRecord struct {
	Key       string `gorm:"primaryKey"`
	TenantID  string `gorm:"default:''"`
	NetworkID string
	Value     datatypes.JSONType[DNSEntry]
}

func (*DNSRecord) Count added in v1.7.0

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

func (*DNSRecord) Delete added in v1.7.0

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

func (*DNSRecord) DeleteAll added in v1.7.0

func (*DNSRecord) DeleteAll(ctx context.Context) error

func (*DNSRecord) Get added in v1.7.0

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

func (*DNSRecord) List added in v1.7.0

func (*DNSRecord) List(ctx context.Context) ([]DNSRecord, error)

func (*DNSRecord) TableName added in v1.7.0

func (*DNSRecord) TableName() string

func (*DNSRecord) Upsert added in v1.7.0

func (r *DNSRecord) Upsert(ctx context.Context) error

type DeviceEDRState added in v1.7.0

type DeviceEDRState struct {
	HostID         string         `gorm:"primaryKey;column:host_id" json:"host_id"`
	Provider       string         `gorm:"primaryKey;column:provider" json:"provider"`
	TenantID       string         `gorm:"default:'';index" json:"tenant_id"`
	EDRDeviceID    string         `gorm:"column:edr_device_id" json:"edr_device_id"`
	MatchedBy      string         `gorm:"column:matched_by" json:"matched_by"`
	AgentInstalled bool           `gorm:"column:agent_installed" json:"agent_installed"`
	AgentHealthy   bool           `gorm:"column:agent_healthy" json:"agent_healthy"`
	RiskLevel      string         `gorm:"column:risk_level" json:"risk_level"`
	ThreatCount    int            `gorm:"column:threat_count" json:"threat_count"`
	ActiveThreats  bool           `gorm:"column:active_threats" json:"active_threats"`
	Isolated       bool           `gorm:"column:isolated" json:"isolated"`
	Contained      bool           `gorm:"column:contained" json:"contained"`
	LastSeenAt     time.Time      `gorm:"column:last_seen_at" json:"last_seen_at"`
	LastSyncedAt   time.Time      `gorm:"column:last_synced_at" json:"last_synced_at"`
	LastError      string         `gorm:"column:last_error" json:"last_error,omitempty"`
	RawVendorData  datatypes.JSON `gorm:"column:raw_vendor_data" json:"raw_vendor_data,omitempty"`
}

DeviceEDRState is the per-host snapshot of an EDR provider's view of an endpoint.

func (*DeviceEDRState) Delete added in v1.7.0

func (s *DeviceEDRState) Delete(ctx context.Context) error

func (*DeviceEDRState) DeleteAll added in v1.7.0

func (s *DeviceEDRState) DeleteAll(ctx context.Context) error

func (*DeviceEDRState) DeleteByHostID added in v1.7.0

func (s *DeviceEDRState) DeleteByHostID(ctx context.Context) error

func (*DeviceEDRState) Get added in v1.7.0

func (s *DeviceEDRState) Get(ctx context.Context) error

func (*DeviceEDRState) ListAll added in v1.7.0

func (s *DeviceEDRState) ListAll(ctx context.Context) ([]DeviceEDRState, error)

func (*DeviceEDRState) ListByHost added in v1.7.0

func (s *DeviceEDRState) ListByHost(ctx context.Context) ([]DeviceEDRState, error)

func (*DeviceEDRState) ListByProvider added in v1.7.0

func (s *DeviceEDRState) ListByProvider(ctx context.Context) ([]DeviceEDRState, error)

func (*DeviceEDRState) TableName added in v1.7.0

func (s *DeviceEDRState) TableName() string

func (*DeviceEDRState) Upsert added in v1.7.0

func (s *DeviceEDRState) Upsert(ctx context.Context) error

type DeviceMDMState added in v1.7.0

type DeviceMDMState struct {
	HostID       string    `gorm:"primaryKey;column:host_id" json:"host_id"`
	Provider     string    `gorm:"primaryKey;column:provider" json:"provider"`
	TenantID     string    `gorm:"default:'';index" json:"tenant_id"`
	MDMDeviceID  string    `gorm:"column:mdm_device_id" json:"mdm_device_id"`
	Enrolled     bool      `gorm:"column:enrolled" json:"enrolled"`
	Compliant    bool      `gorm:"column:compliant" json:"compliant"`
	MatchedBy    string    `gorm:"column:matched_by" json:"matched_by"`
	LastSyncedAt time.Time `gorm:"column:last_synced_at" json:"last_synced_at"`
	LastSeenAt   time.Time `gorm:"column:last_seen_at" json:"last_seen_at"`
	// LastError holds a stable lookup failure code (e.g. device_not_registered_in_entra).
	LastError string `gorm:"column:last_error" json:"last_error,omitempty"`
}

DeviceMDMState is the per-host snapshot of an MDM provider's view of a device. Composite PK (HostID, Provider) allows a host to carry historical state for multiple providers (e.g. after switching MDMs).

func (*DeviceMDMState) Delete added in v1.7.0

func (s *DeviceMDMState) Delete(ctx context.Context) error

Delete removes the row for (HostID, Provider).

func (*DeviceMDMState) DeleteAll added in v1.7.0

func (s *DeviceMDMState) DeleteAll(ctx context.Context) error

DeleteAll removes every MDM state row for the tenant in scope (or all rows if unscoped).

func (*DeviceMDMState) DeleteByHostID added in v1.7.0

func (s *DeviceMDMState) DeleteByHostID(ctx context.Context) error

DeleteByHostID removes all MDM state rows for a given host (used when a host is deleted).

func (*DeviceMDMState) Get added in v1.7.0

func (s *DeviceMDMState) Get(ctx context.Context) error

Get loads the row identified by (HostID, Provider).

func (*DeviceMDMState) ListAll added in v1.7.0

func (s *DeviceMDMState) ListAll(ctx context.Context) ([]DeviceMDMState, error)

ListAll returns every MDM state row.

func (*DeviceMDMState) ListByHost added in v1.7.0

func (s *DeviceMDMState) ListByHost(ctx context.Context) ([]DeviceMDMState, error)

ListByHost returns all provider states for the host in s.HostID.

func (*DeviceMDMState) ListByProvider added in v1.7.0

func (s *DeviceMDMState) ListByProvider(ctx context.Context) ([]DeviceMDMState, error)

ListByProvider returns all host states for the provider in s.Provider.

func (*DeviceMDMState) TableName added in v1.7.0

func (s *DeviceMDMState) TableName() string

func (*DeviceMDMState) Upsert added in v1.7.0

func (s *DeviceMDMState) Upsert(ctx context.Context) error

Upsert inserts the row or updates the existing one keyed by (HostID, Provider).

type Egress

type Egress struct {
	ID           string            `gorm:"primaryKey" json:"id"`
	TenantID     string            `gorm:"default:'';index" json:"tenant_id"`
	Name         string            `gorm:"name" json:"name"`
	Network      string            `gorm:"network" json:"network"`
	Description  string            `gorm:"description" json:"description"`
	Type         EgressType        `gorm:"column:egress_type;default:cidr;index" json:"type"`
	Nodes        datatypes.JSONMap `gorm:"nodes" json:"nodes"`
	Tags         datatypes.JSONMap `gorm:"tags" json:"tags"`
	Range        string            `gorm:"range" json:"range"`
	Mode         EgressNATMode     `gorm:"mode;default:direct_nat" json:"mode"`
	VirtualRange string            `gorm:"virtual_range" json:"virtual_range"`
	// Domains is the user-configured hostname list (exact or *.suffix).
	Domains datatypes.JSONSlice[string] `gorm:"domains" json:"domains"`
	// DomainAnsByDomain maps each configured domain to its resolved CIDRs.
	DomainAnsByDomain datatypes.JSONMap `gorm:"domain_ans_by_domain" json:"domain_ans_by_domain"`
	Nat               bool              `gorm:"nat" json:"nat"`
	// PresetID is the catalog id when this egress was created from a preset (empty if custom).
	PresetID  string    `gorm:"preset_id" json:"preset_id"`
	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, options ...dbtypes.Option) 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) ListAll added in v1.6.0

func (e *Egress) ListAll(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 EgressNATMode added in v1.5.1

type EgressNATMode string
const (
	DisabledNAT EgressNATMode = "disabled"
	VirtualNAT  EgressNATMode = "virtual_nat"
	DirectNAT   EgressNATMode = "direct_nat"
)

type EgressType added in v1.7.0

type EgressType string

EgressType classifies an egress resource's routing purpose.

const (
	EgressTypeCIDR     EgressType = "cidr"
	EgressTypeDomain   EgressType = "domain"
	EgressTypeApp      EgressType = "app"
	EgressTypeInternet EgressType = "internet"
)

type EnrollmentKey added in v1.7.0

type EnrollmentKey struct {
	ID                string                      `gorm:"primaryKey" json:"id"`
	TenantID          string                      `gorm:"default:'';index" json:"tenant_id"`
	Name              string                      `json:"name"`
	Value             string                      `gorm:"uniqueIndex" json:"value"`
	Token             string                      `json:"token"`
	Default           bool                        `json:"default"`
	Unlimited         bool                        `json:"unlimited"`
	UsesRemaining     int                         `json:"uses_remaining"`
	Expiration        time.Time                   `json:"expiration"`
	Networks          datatypes.JSONSlice[string] `json:"networks"`
	Tags              datatypes.JSONSlice[string] `json:"tags"`
	GatewayID         *string                     `json:"gateway_id"`
	AutoEgress        bool                        `json:"auto_egress"`
	AutoAssignGateway bool                        `json:"auto_assign_gateway"`
	Type              EnrollmentKeyType           `json:"type"`
	CreatedBy         string                      `json:"created_by"`
	CreatedAt         time.Time                   `json:"created_at"`
	UpdatedAt         time.Time                   `json:"updated_at"`
}

func (*EnrollmentKey) Count added in v1.7.0

func (e *EnrollmentKey) Count(ctx context.Context, options ...dbtypes.Option) (int, error)

func (*EnrollmentKey) Create added in v1.7.0

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

func (*EnrollmentKey) Delete added in v1.7.0

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

func (*EnrollmentKey) DeleteAll added in v1.7.0

func (e *EnrollmentKey) DeleteAll(ctx context.Context) error

func (*EnrollmentKey) DeleteByValue added in v1.7.0

func (e *EnrollmentKey) DeleteByValue(ctx context.Context) error

func (*EnrollmentKey) Get added in v1.7.0

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

func (*EnrollmentKey) GetByValue added in v1.7.0

func (e *EnrollmentKey) GetByValue(ctx context.Context) error

func (*EnrollmentKey) ListAll added in v1.7.0

func (e *EnrollmentKey) ListAll(ctx context.Context, options ...dbtypes.Option) ([]EnrollmentKey, error)

func (*EnrollmentKey) TableName added in v1.7.0

func (e *EnrollmentKey) TableName() string

func (*EnrollmentKey) Upsert added in v1.7.0

func (e *EnrollmentKey) Upsert(ctx context.Context) error

type EnrollmentKeyType added in v1.7.0

type EnrollmentKeyType int
const (
	EnrollmentKeyType_TimedExpiry EnrollmentKeyType = iota + 1
	EnrollmentKeyType_LimitedUses
	EnrollmentKeyType_UnlimitedUses
)

type Event

type Event struct {
	ID          string         `gorm:"primaryKey" json:"id"`
	TenantID    string         `gorm:"default:'';index" json:"tenant_id"`
	Action      Action         `gorm:"action" json:"action"`
	Source      datatypes.JSON `gorm:"source" json:"source"`
	Origin      Origin         `gorm:"origin" json:"origin"`
	Target      datatypes.JSON `gorm:"target" json:"target"`
	NetworkID   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) DeleteAllForTenant added in v1.7.0

func (a *Event) DeleteAllForTenant(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) TableName added in v1.7.0

func (e *Event) TableName() string

func (*Event) Update

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

type ExtClient added in v1.7.0

type ExtClient struct {
	ClientID               string   `json:"clientid" bson:"clientid"`
	PrivateKey             string   `json:"privatekey" bson:"privatekey"`
	PublicKey              string   `json:"publickey" bson:"publickey"`
	Network                string   `json:"network" bson:"network"`
	DNS                    string   `json:"dns" bson:"dns"`
	Address                string   `json:"address" bson:"address"`
	Address6               string   `json:"address6" bson:"address6"`
	ExtraAllowedIPs        []string `json:"extraallowedips" bson:"extraallowedips"`
	AllowedIPs             []string `json:"allowed_ips"`
	IngressGatewayID       string   `json:"ingressgatewayid" bson:"ingressgatewayid"`
	IngressGatewayEndpoint string   `json:"ingressgatewayendpoint" bson:"ingressgatewayendpoint"`
	// SelectedInternetEgressID is the internet egress this config file uses for full-tunnel exit (empty = none).
	SelectedInternetEgressID          string              `json:"selected_internet_egress_id" bson:"selected_internet_egress_id"`
	LastModified                      int64               `json:"lastmodified" bson:"lastmodified" swaggertype:"primitive,integer" format:"int64"`
	Enabled                           bool                `json:"enabled" bson:"enabled"`
	OwnerID                           string              `json:"ownerid" bson:"ownerid"`
	DeniedACLs                        map[string]struct{} `json:"deniednodeacls" bson:"acls,omitempty"`
	RemoteAccessClientID              string              `json:"remote_access_client_id"`
	PostUp                            string              `json:"postup" bson:"postup"`
	PostDown                          string              `json:"postdown" bson:"postdown"`
	Tags                              map[TagID]struct{}  `json:"tags"`
	OS                                string              `json:"os"`
	OSFamily                          string              `json:"os_family" yaml:"os_family"`
	OSVersion                         string              `json:"os_version" yaml:"os_version"`
	KernelVersion                     string              `json:"kernel_version" yaml:"kernel_version"`
	ClientVersion                     string              `json:"client_version"`
	DeviceID                          string              `json:"device_id"`
	DeviceName                        string              `json:"device_name"`
	PublicEndpoint                    string              `json:"public_endpoint"`
	Country                           string              `json:"country"`
	Location                          string              `json:"location"`
	PostureChecksViolations           []Violation         `json:"posture_check_violations"`
	PostureCheckVolationSeverityLevel Severity            `json:"posture_check_violation_severity_level"`
	LastEvaluatedAt                   time.Time           `json:"last_evaluated_at"`
	JITExpiresAt                      *time.Time          `json:"jit_expires_at,omitempty" bson:"jit_expires_at,omitempty"`
	Status                            NodeStatus          `json:"status" bson:"status"`
	Mutex                             *sync.Mutex         `json:"-"`
}

ExtClient - struct for external clients

func (*ExtClient) AddressIPNet4 added in v1.7.0

func (extPeer *ExtClient) AddressIPNet4() net.IPNet

func (*ExtClient) AddressIPNet6 added in v1.7.0

func (extPeer *ExtClient) AddressIPNet6() net.IPNet

type ExtClientRecord added in v1.7.0

type ExtClientRecord struct {
	Key       string `gorm:"primaryKey"`
	TenantID  string `gorm:"default:''"`
	NetworkID string
	Value     datatypes.JSONType[ExtClient]
}

func (*ExtClientRecord) Count added in v1.7.0

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

func (*ExtClientRecord) Delete added in v1.7.0

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

func (*ExtClientRecord) DeleteAll added in v1.7.0

func (*ExtClientRecord) DeleteAll(ctx context.Context) error

func (*ExtClientRecord) Get added in v1.7.0

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

func (*ExtClientRecord) List added in v1.7.0

func (*ExtClientRecord) TableName added in v1.7.0

func (*ExtClientRecord) TableName() string

func (*ExtClientRecord) Upsert added in v1.7.0

func (r *ExtClientRecord) Upsert(ctx context.Context) error

type Host added in v1.5.1

type Host struct {
	ID                 uuid.UUID `gorm:"primaryKey" json:"id" yaml:"id"`
	TenantID           string    `gorm:"default:'';index" json:"tenant_id"`
	Verbosity          int       `json:"verbosity" yaml:"verbosity"`
	FirewallInUse      string    `json:"firewallinuse" yaml:"firewallinuse"`
	Version            string    `json:"version" yaml:"version"`
	IPForwarding       bool      `json:"ipforwarding" yaml:"ipforwarding"`
	DaemonInstalled    bool      `json:"daemoninstalled" yaml:"daemoninstalled"`
	AutoUpdate         bool      `json:"autoupdate" yaml:"autoupdate"`
	HostPass           string    `json:"hostpass" yaml:"hostpass"`
	Name               string    `json:"name" yaml:"name"`
	OS                 string    `json:"os" yaml:"os"`
	OSFamily           string    `json:"os_family" yaml:"os_family"`
	OSVersion          string    `json:"os_version" yaml:"os_version"`
	KernelVersion      string    `json:"kernel_version" yaml:"kernel_version"`
	Interface          string    `json:"interface" yaml:"interface"`
	Debug              bool      `json:"debug" yaml:"debug"`
	ListenPort         int       `json:"listenport" yaml:"listenport"`
	WgPublicListenPort int       `json:"wg_public_listen_port" yaml:"wg_public_listen_port"`
	// TcpProxyEnabled: host accepts TCP/WSS framed WG uplinks (gateway listen is host-level).
	TcpProxyEnabled bool `json:"tcp_proxy_enabled" yaml:"tcp_proxy_enabled"`
	// TcpProxyListenPort: listen port when TcpProxyEnabled (default 443 if enabled with port 0).
	TcpProxyListenPort int `json:"tcp_proxy_listen_port" yaml:"tcp_proxy_listen_port"`
	// TcpProxyTLSMode: selfsigned (default) or proxy. Empty means selfsigned.
	TcpProxyTLSMode string `json:"tcp_proxy_tls_mode" yaml:"tcp_proxy_tls_mode"`
	// TcpProxyListenAddr: optional bind address (e.g. 127.0.0.1). Empty means all interfaces (:port).
	TcpProxyListenAddr string `json:"tcp_proxy_listen_addr,omitempty" yaml:"tcp_proxy_listen_addr,omitempty"`
	// TcpProxyPublicHostname: public DNS name clients dial when TLS mode is proxy
	// (e.g. gateway.example.com). Empty falls back to EndpointIP.
	TcpProxyPublicHostname string `json:"tcp_proxy_public_hostname,omitempty" yaml:"tcp_proxy_public_hostname,omitempty"`
	// TcpProxyCertFingerprint: SHA-256 hex of the leaf cert when tls mode is selfsigned.
	TcpProxyCertFingerprint string                      `json:"tcp_proxy_cert_fingerprint,omitempty" yaml:"tcp_proxy_cert_fingerprint,omitempty"`
	MTU                     int                         `json:"mtu" yaml:"mtu"`
	PublicKey               WgKey                       `json:"publickey" yaml:"publickey"`
	MacAddress              net.HardwareAddr            `json:"macaddress" yaml:"macaddress"`
	TrafficKeyPublic        datatypes.JSONSlice[byte]   `json:"traffickeypublic" yaml:"traffickeypublic"`
	Nodes                   datatypes.JSONSlice[string] `json:"nodes" yaml:"nodes"`
	Interfaces              datatypes.JSONSlice[Iface]  `json:"interfaces" yaml:"interfaces"`
	DefaultInterface        string                      `json:"defaultinterface" yaml:"defaultinterface"`
	EndpointIP              net.IP                      `json:"endpointip" yaml:"endpointip"`
	EndpointIPv6            net.IP                      `json:"endpointipv6" yaml:"endpointipv6"`
	IsDocker                bool                        `json:"isdocker" yaml:"isdocker"`
	IsK8S                   bool                        `json:"isk8s" yaml:"isk8s"`
	IsStaticPort            bool                        `json:"isstaticport" yaml:"isstaticport"`
	IsStatic                bool                        `json:"isstatic" yaml:"isstatic"`
	IsDefault               bool                        `json:"isdefault" yaml:"isdefault"`
	DNS                     string                      `json:"dns_status" yaml:"dns_status"`
	NatType                 string                      `json:"nat_type,omitempty" yaml:"nat_type,omitempty"`
	TurnEndpoint            *AddrPort                   `json:"turn_endpoint,omitempty" yaml:"turn_endpoint,omitempty"`
	PersistentKeepalive     time.Duration               `json:"persistentkeepalive" swaggertype:"primitive,integer" format:"int64" yaml:"persistentkeepalive"`
	Location                string                      `json:"location" yaml:"location"` // Format: "lat,lon"
	CountryCode             string                      `json:"country_code" yaml:"country_code"`
	EnableFlowLogs          bool                        `json:"enable_flow_logs" yaml:"enable_flow_logs"`

	// MDM device-matching identifiers. Reported by netclient on host check-in
	// and consumed by the MDM sync worker to match a Netmaker host to its
	// upstream MDM-managed device record.
	EntraDeviceID string `json:"entra_device_id" yaml:"entra_device_id"`
	SerialNumber  string `json:"serial_number"   yaml:"serial_number"`
	HardwareUUID  string `json:"hardware_uuid"   yaml:"hardware_uuid"`

	// OwnerUsername is the Netmaker user who registered this device (desktop/netclient).
	OwnerUsername string `json:"owner_username" yaml:"owner_username"`

	CreatedAt time.Time `json:"created_at" yaml:"created_at"`
	UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
}

func (*Host) Count added in v1.5.1

func (h *Host) Count(ctx context.Context, options ...dbtypes.Option) (int, error)

func (*Host) Create added in v1.5.1

func (h *Host) Create(ctx context.Context) error

func (*Host) Delete added in v1.5.1

func (h *Host) Delete(ctx context.Context) error

func (*Host) DeleteAll added in v1.6.0

func (h *Host) DeleteAll(ctx context.Context) error

func (*Host) Get added in v1.5.1

func (h *Host) Get(ctx context.Context) error

func (*Host) ListAll added in v1.5.1

func (h *Host) ListAll(ctx context.Context, options ...dbtypes.Option) ([]Host, error)

func (*Host) SetTcpProxy added in v1.7.0

func (h *Host) SetTcpProxy(ctx context.Context) error

SetTcpProxy persists TCP proxy listen settings on the host (source of truth for gateway listen).

func (*Host) TableName added in v1.5.1

func (h *Host) TableName() string

func (*Host) Upsert added in v1.5.1

func (h *Host) Upsert(ctx context.Context) error

type Iface added in v1.5.1

type Iface struct {
	Name          string    `json:"name"`
	Address       net.IPNet `json:"address"`
	AddressString string    `json:"addressString"`
}

Iface struct for local interfaces of a node

type Integration added in v1.6.0

type Integration struct {
	ID        string         `gorm:"primaryKey" json:"id"`
	Provider  string         `gorm:"default:'';uniqueIndex:idx_integrations_provider_tenant" json:"provider"`
	TenantID  string         `gorm:"default:'';uniqueIndex:idx_integrations_provider_tenant" json:"tenant_id"`
	Type      string         `gorm:"not null" json:"type"`
	Config    datatypes.JSON `gorm:"not null" json:"config"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
}

func (*Integration) Delete added in v1.6.0

func (i *Integration) Delete(ctx context.Context) error

func (*Integration) DeleteAll added in v1.7.0

func (i *Integration) DeleteAll(ctx context.Context) error

func (*Integration) Get added in v1.6.0

func (i *Integration) Get(ctx context.Context) error

func (*Integration) ListByType added in v1.6.0

func (i *Integration) ListByType(ctx context.Context) ([]Integration, error)

func (*Integration) TableName added in v1.6.0

func (i *Integration) TableName() string

func (*Integration) Upsert added in v1.6.0

func (i *Integration) Upsert(ctx context.Context) error

type Internal added in v1.7.0

type Internal struct {
	Key      string `gorm:"primaryKey"`
	TenantID string `gorm:"default:'';index"`
	Value    string `gorm:"not null"`
}

func (*Internal) Get added in v1.7.0

func (i *Internal) Get(ctx context.Context) error

func (*Internal) Reset added in v1.7.0

func (i *Internal) Reset(ctx context.Context) error

func (*Internal) Set added in v1.7.0

func (i *Internal) Set(ctx context.Context) error

func (*Internal) TableName added in v1.7.0

func (i *Internal) TableName() string

type JITGrant added in v1.5.0

type JITGrant struct {
	ID        string    `gorm:"primaryKey" json:"id"`
	TenantID  string    `gorm:"default:'';index" json:"tenant_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) DeleteAll added in v1.7.0

func (g *JITGrant) DeleteAll(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"`
	TenantID      string    `gorm:"default:'';index" json:"tenant_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) DeleteAll added in v1.7.0

func (r *JITRequest) DeleteAll(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 Metric added in v1.7.0

type Metric struct {
	NodeName          string        `json:"node_name" bson:"node_name" yaml:"node_name"`
	Uptime            int64         `json:"uptime" bson:"uptime" yaml:"uptime" swaggertype:"primitive,integer" format:"int64"`
	TotalTime         int64         `json:"totaltime" bson:"totaltime" yaml:"totaltime" swaggertype:"primitive,integer" format:"int64"`
	Latency           int64         `json:"latency" bson:"latency" yaml:"latency" swaggertype:"primitive,integer" format:"int64"`
	TotalReceived     int64         `json:"totalreceived" bson:"totalreceived" yaml:"totalreceived" swaggertype:"primitive,integer" format:"int64"`
	LastTotalReceived int64         `json:"lasttotalreceived" bson:"lasttotalreceived" yaml:"lasttotalreceived" swaggertype:"primitive,integer" format:"int64"`
	TotalSent         int64         `json:"totalsent" bson:"totalsent" yaml:"totalsent" swaggertype:"primitive,integer" format:"int64"`
	LastTotalSent     int64         `json:"lasttotalsent" bson:"lasttotalsent" yaml:"lasttotalsent" swaggertype:"primitive,integer" format:"int64"`
	ActualUptime      time.Duration `json:"actualuptime" swaggertype:"primitive,integer" format:"int64" bson:"actualuptime" yaml:"actualuptime"`
	PercentUp         float64       `json:"percentup" bson:"percentup" yaml:"percentup"`
	Connected         bool          `json:"connected" bson:"connected" yaml:"connected"`
}

Metric - holds a metric for data between nodes

type Metrics added in v1.7.0

type Metrics struct {
	Network      string            `json:"network" bson:"network" yaml:"network"`
	NodeID       string            `json:"node_id" bson:"node_id" yaml:"node_id"`
	NodeName     string            `json:"node_name" bson:"node_name" yaml:"node_name"`
	Connectivity map[string]Metric `json:"connectivity" bson:"connectivity" yaml:"connectivity"`
	UpdatedAt    time.Time         `json:"updated_at" bson:"updated_at" yaml:"updated_at"`
}

Metrics - metrics struct

type MetricsRecord added in v1.7.0

type MetricsRecord struct {
	Key       string `gorm:"primaryKey"`
	TenantID  string `gorm:"default:'';index"`
	NetworkID string
	Value     datatypes.JSONType[Metrics]
}

func (*MetricsRecord) Count added in v1.7.0

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

func (*MetricsRecord) Delete added in v1.7.0

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

func (*MetricsRecord) DeleteAll added in v1.7.0

func (*MetricsRecord) DeleteAll(ctx context.Context) error

func (*MetricsRecord) Get added in v1.7.0

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

func (*MetricsRecord) List added in v1.7.0

func (*MetricsRecord) TableName added in v1.7.0

func (*MetricsRecord) TableName() string

func (*MetricsRecord) Upsert added in v1.7.0

func (r *MetricsRecord) Upsert(ctx context.Context) error

type Nameserver added in v1.1.0

type Nameserver struct {
	ID          string                                `gorm:"primaryKey" json:"id"`
	TenantID    string                                `gorm:"default:'';index" json:"tenant_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, options ...dbtypes.Option) error

func (*Nameserver) Get added in v1.1.0

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

func (*Nameserver) ListAll added in v1.6.0

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

func (*Nameserver) ListByNetwork added in v1.1.0

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

func (*Nameserver) TableName added in v1.7.0

func (ns *Nameserver) TableName() string

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"`
	IsADDomain     bool   `json:"is_ad_domain"`
}

type Network added in v1.5.1

type Network struct {
	ID            string `gorm:"primaryKey" json:"id"`
	TenantID      string `gorm:"default:'';uniqueIndex:udx_network_tenant_name" json:"tenant_id"`
	Name          string `gorm:"uniqueIndex:udx_network_tenant_name" json:"netid"`
	AddressRange  string `json:"addressrange"`
	AddressRange6 string `json:"addressrange6"`
	// in seconds.
	DefaultKeepAlive int                         `gorm:"default:20" json:"defaultkeepalive"`
	DefaultMTU       int32                       `gorm:"default:1280" json:"defaultmtu"`
	AutoJoin         bool                        `json:"auto_join"`
	AutoRemove       bool                        `json:"auto_remove"`
	AutoRemoveTags   datatypes.JSONSlice[string] `json:"auto_remove_tags"`
	// in minutes
	AutoRemoveThreshold         int                              `json:"auto_remove_threshold"`
	JITEnabled                  bool                             `json:"jit_enabled"`
	JITUserGroupIDs             datatypes.JSONSlice[UserGroupID] `json:"jit_user_group_ids"`
	VirtualNATPoolIPv4          string                           `json:"virtual_nat_pool_ipv4"`
	VirtualNATSitePrefixLenIPv4 int                              `json:"virtual_nat_site_prefixlen_ipv4"`
	NodesUpdatedAt              time.Time                        `json:"nodes_updated_at"`
	CreatedBy                   string                           `json:"created_by"`
	CreatedAt                   time.Time                        `json:"created_at"`
	UpdatedAt                   time.Time                        `json:"updated_at"`
}

Network schema.

NOTE: json tags are different from field names to ensure compatibility with the older model.

func (*Network) Count added in v1.5.1

func (n *Network) Count(ctx context.Context) (int, error)

func (*Network) Create added in v1.5.1

func (n *Network) Create(ctx context.Context) error

func (*Network) Delete added in v1.5.1

func (n *Network) Delete(ctx context.Context) error

func (*Network) DeleteAll added in v1.6.0

func (n *Network) DeleteAll(ctx context.Context) error

func (*Network) Get added in v1.5.1

func (n *Network) Get(ctx context.Context) error

func (*Network) ListAll added in v1.5.1

func (n *Network) ListAll(ctx context.Context) ([]Network, error)

func (*Network) TableName added in v1.5.1

func (n *Network) TableName() string

func (*Network) Update added in v1.5.1

func (n *Network) Update(ctx context.Context) error

func (*Network) UpdateNodesUpdatedAt added in v1.5.1

func (n *Network) UpdateNodesUpdatedAt(ctx context.Context) error

type NetworkID added in v1.5.1

type NetworkID string
const AllNetworks NetworkID = "all_networks"

func (NetworkID) String added in v1.5.1

func (n NetworkID) String() string

type NetworkRoles added in v1.5.1

type NetworkRoles map[NetworkID]map[UserRoleID]struct{}

type Node added in v1.6.0

type Node struct {
	ID                         string                      `gorm:"primaryKey" json:"id"`
	TenantID                   string                      `gorm:"default:'';index" json:"tenant_id"`
	HostID                     string                      `gorm:"not null;index" json:"host_id"`
	Host                       *Host                       `gorm:"foreignKey:HostID;constraint:OnDelete:CASCADE" json:"host,omitempty"`
	NetworkID                  string                      `gorm:"not null;index" json:"network_id"`
	Network                    *Network                    `gorm:"foreignKey:NetworkID;constraint:OnDelete:CASCADE" json:"network,omitempty"`
	Address                    string                      `json:"address"`
	Address6                   string                      `json:"address6"`
	Connected                  bool                        `json:"connected"`
	Action                     string                      `json:"action"`
	Status                     NodeStatus                  `json:"status"`
	PendingDelete              bool                        `json:"pending_delete"`
	AutoAssignGateway          bool                        `json:"auto_assign_gateway"`
	IsGateway                  bool                        `json:"is_gateway"`
	IsAutoRelay                string                      `json:"is_auto_relay"`
	IsInternetGateway          bool                        `json:"is_internet_gateway"`
	AdditionalGatewayEndpoints datatypes.JSONSlice[string] `json:"additional_gateway_endpoints"`
	RelayedClients             datatypes.JSONMap           `json:"relayed_clients"`
	RelayedIGWClients          datatypes.JSONMap           `json:"relayed_igw_clients"`
	RelayedByNodeID            *string                     `json:"relayed_by_node_id"`
	IsIGWClient                bool                        `json:"is_igw_client"`
	// UseTcpUplink: assigned/relayed node opts into TCP uplink to its gateway (requires host TcpProxyEnabled).
	UseTcpUplink bool `json:"use_tcp_uplink"`
	// SelectedInternetEgressID is the internet-type egress this node uses as its exit node (empty = none).
	SelectedInternetEgressID          string                                `json:"selected_internet_egress_id"`
	AutoRelayedPeers                  datatypes.JSONType[map[string]string] `json:"auto_relayed_peers"`
	Tags                              datatypes.JSONMap                     `json:"tags"`
	PostureCheckSeverity              Severity                              `json:"posture_check_severity"`
	PostureCheckLastEvaluationCycleID string                                `json:"posture_check_last_evaluation_cycle_id"`
	PostureCheckLastEvaluatedAt       time.Time                             `json:"posture_check_last_evaluated_at"`
	Metadata                          string                                `json:"metadata"`
	LastCheckIn                       time.Time                             `json:"last_check_in"`
	ExpirationDateTime                time.Time                             `json:"expiration_date_time"`
	CreatedAt                         time.Time                             `json:"created_at"`
	UpdatedAt                         time.Time                             `json:"updated_at"`
}

func (*Node) AssignGateway added in v1.6.0

func (n *Node) AssignGateway(ctx context.Context) error

func (*Node) AssignTag added in v1.6.0

func (n *Node) AssignTag(ctx context.Context, tag string, options ...dbtypes.Option) error

func (*Node) ClearGatewayIDFromEnrollmentKeys added in v1.7.0

func (n *Node) ClearGatewayIDFromEnrollmentKeys(ctx context.Context) error

func (*Node) Count added in v1.6.0

func (n *Node) Count(ctx context.Context, options ...dbtypes.Option) (int, error)

func (*Node) Create added in v1.6.0

func (n *Node) Create(ctx context.Context) error

func (*Node) Delete added in v1.6.0

func (n *Node) Delete(ctx context.Context) error

func (*Node) DeleteAll added in v1.6.0

func (n *Node) DeleteAll(ctx context.Context) error

func (*Node) DeleteViolations added in v1.6.0

func (n *Node) DeleteViolations(ctx context.Context) error

func (*Node) Exists added in v1.6.0

func (n *Node) Exists(ctx context.Context) (bool, error)

func (*Node) Get added in v1.6.0

func (n *Node) Get(ctx context.Context, options ...dbtypes.Option) error

func (*Node) GetByHostAndNetwork added in v1.6.0

func (n *Node) GetByHostAndNetwork(ctx context.Context) error

func (*Node) GetByNetworkAndAddress added in v1.6.0

func (n *Node) GetByNetworkAndAddress(ctx context.Context) error

func (*Node) GetByNetworkAndAddress6 added in v1.6.0

func (n *Node) GetByNetworkAndAddress6(ctx context.Context) error

func (*Node) ListAll added in v1.6.0

func (n *Node) ListAll(ctx context.Context, options ...dbtypes.Option) ([]Node, error)

func (*Node) ListByIDs added in v1.6.0

func (n *Node) ListByIDs(ctx context.Context, ids []string, options ...dbtypes.Option) ([]Node, error)

ListByIDs fetches nodes whose IDs are in the given slice using a single `WHERE id IN (?)` query. Returns an empty slice when ids is empty.

func (*Node) ListViolations added in v1.6.0

func (n *Node) ListViolations(ctx context.Context) ([]PostureCheckViolation, error)

func (*Node) MarkForDeletion added in v1.6.0

func (n *Node) MarkForDeletion(ctx context.Context) error

func (*Node) MarkStaleOffline added in v1.6.0

func (n *Node) MarkStaleOffline(ctx context.Context, threshold time.Time) (int64, error)

MarkStaleOffline sets status=offline for every node whose last_check_in is older than the given threshold and which is not already offline, not pending deletion, and not flagged for the delete action. Returns the number of rows updated. Issues exactly one SQL statement.

func (*Node) ResetAutoAssignGateway added in v1.6.0

func (n *Node) ResetAutoAssignGateway(ctx context.Context) error

func (*Node) ResetAutoRelayedPeers added in v1.6.0

func (n *Node) ResetAutoRelayedPeers(ctx context.Context) error

func (*Node) ResetGateway added in v1.6.0

func (n *Node) ResetGateway(ctx context.Context) error

func (*Node) SetAutoAssignGateway added in v1.6.0

func (n *Node) SetAutoAssignGateway(ctx context.Context) error

func (*Node) SetInternetGateway added in v1.6.0

func (n *Node) SetInternetGateway(ctx context.Context) error

func (*Node) SetRelayedClients added in v1.6.0

func (n *Node) SetRelayedClients(ctx context.Context) error

func (*Node) TableName added in v1.6.0

func (n *Node) TableName() string

func (*Node) UnassignGateway added in v1.6.0

func (n *Node) UnassignGateway(ctx context.Context) error

func (*Node) UnassignTag added in v1.6.0

func (n *Node) UnassignTag(ctx context.Context, tag string, options ...dbtypes.Option) error

func (*Node) Update added in v1.6.0

func (n *Node) Update(ctx context.Context) error

func (*Node) UpdateConnectedStatus added in v1.6.0

func (n *Node) UpdateConnectedStatus(ctx context.Context, options ...dbtypes.Option) error

func (*Node) UpdateLastCheckIn added in v1.6.0

func (n *Node) UpdateLastCheckIn(ctx context.Context) error

func (*Node) UpdateRelayedClients added in v1.6.0

func (n *Node) UpdateRelayedClients(ctx context.Context) error

func (*Node) UpdateRelayingNode added in v1.6.0

func (n *Node) UpdateRelayingNode(ctx context.Context) error

func (*Node) UpdateStatus added in v1.6.0

func (n *Node) UpdateStatus(ctx context.Context) error

UpdateStatus updates only the status column for a single node by ID. Lighter than Upsert: no preloads, no full row write, no association handling.

func (*Node) Upsert added in v1.6.0

func (n *Node) Upsert(ctx context.Context) error

func (*Node) UpsertViolations added in v1.6.0

func (n *Node) UpsertViolations(ctx context.Context, violations []PostureCheckViolation) error

type NodeStatus added in v1.6.0

type NodeStatus string
const (
	OnlineSt     NodeStatus = "online"
	OfflineSt    NodeStatus = "offline"
	WarningSt    NodeStatus = "warning"
	ErrorSt      NodeStatus = "error"
	UnKnown      NodeStatus = "unknown"
	Disconnected NodeStatus = "disconnected"
)

type OrgMembership added in v1.7.0

type OrgMembership struct {
	OrganizationID             string     `gorm:"primaryKey" json:"organization_id"`
	UserID                     string     `gorm:"primaryKey" json:"user_id"`
	RoleID                     UserRoleID `json:"role_id"`
	AuthType                   AuthType   `json:"auth_type"`
	ExternalIdentityProviderID string     `json:"external_identity_provider_id"`
	Password                   string     `json:"password"`
	AccountDisabled            bool       `json:"account_disabled"`
	IsMFAEnabled               bool       `json:"is_mfa_enabled"`
	TOTPSecret                 string     `json:"totp_secret"`
}

func (*OrgMembership) Create added in v1.7.0

func (o *OrgMembership) Create(ctx context.Context) error

func (*OrgMembership) Delete added in v1.7.0

func (o *OrgMembership) Delete(ctx context.Context) error

func (*OrgMembership) Get added in v1.7.0

func (o *OrgMembership) Get(ctx context.Context) error

func (*OrgMembership) GetOwner added in v1.7.0

func (o *OrgMembership) GetOwner(ctx context.Context) error

func (*OrgMembership) ListByUserID added in v1.7.0

func (o *OrgMembership) ListByUserID(ctx context.Context) ([]OrgMembership, error)

func (*OrgMembership) TableName added in v1.7.0

func (o *OrgMembership) TableName() string

func (*OrgMembership) UpdateAccountStatus added in v1.7.0

func (o *OrgMembership) UpdateAccountStatus(ctx context.Context) error

func (*OrgMembership) UpdateMFA added in v1.7.0

func (o *OrgMembership) UpdateMFA(ctx context.Context) error

func (*OrgMembership) UpdateRoleID added in v1.7.0

func (o *OrgMembership) UpdateRoleID(ctx context.Context) error

func (*OrgMembership) Upsert added in v1.7.0

func (o *OrgMembership) Upsert(ctx context.Context) error

type Organization added in v1.7.0

type Organization struct {
	ID        string    `gorm:"primaryKey"         json:"id"`
	Name      string    `gorm:"not null"           json:"name"`
	Slug      string    `gorm:"uniqueIndex;not null" json:"slug"`
	Metadata  string    `json:"metadata"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Organization) Create added in v1.7.0

func (o *Organization) Create(ctx context.Context) error

func (*Organization) CreateDefault added in v1.7.0

func (o *Organization) CreateDefault(ctx context.Context) error

func (*Organization) Delete added in v1.7.0

func (o *Organization) Delete(ctx context.Context) error

func (*Organization) Get added in v1.7.0

func (o *Organization) Get(ctx context.Context) error

func (*Organization) GetDefault added in v1.7.0

func (o *Organization) GetDefault(ctx context.Context) error

func (*Organization) ListAll added in v1.7.0

func (o *Organization) ListAll(ctx context.Context) ([]Organization, error)

func (*Organization) ListOrgsByUserID added in v1.7.0

func (o *Organization) ListOrgsByUserID(ctx context.Context, userID string) ([]Organization, error)

func (*Organization) TableName added in v1.7.0

func (o *Organization) TableName() string

func (*Organization) Update added in v1.7.0

func (o *Organization) Update(ctx context.Context) error

type OrganizationSettings added in v1.7.0

type OrganizationSettings struct {
	ID       string `gorm:"primaryKey"`
	Settings datatypes.JSONType[OrganizationSettingsData]
}

func (*OrganizationSettings) Delete added in v1.7.0

func (o *OrganizationSettings) Delete(ctx context.Context) error

func (*OrganizationSettings) Get added in v1.7.0

func (*OrganizationSettings) TableName added in v1.7.0

func (o *OrganizationSettings) TableName() string

func (*OrganizationSettings) Upsert added in v1.7.0

func (o *OrganizationSettings) Upsert(ctx context.Context) error

type OrganizationSettingsData added in v1.7.0

type OrganizationSettingsData struct {
	AuthProvider                   string `json:"auth_provider"`
	ClientID                       string `json:"client_id"`
	ClientSecret                   string `json:"client_secret"`
	OIDCIssuer                     string `json:"oidc_issuer"`
	AzureTenant                    string `json:"azure_tenant"`
	EmailSenderAddr                string `json:"email_sender_addr"`
	EmailSenderUser                string `json:"email_sender_user"`
	EmailSenderPassword            string `json:"email_sender_password"`
	SmtpHost                       string `json:"smtp_host"`
	SmtpPort                       int    `json:"smtp_port"`
	SmtpSkipTlsVerify              bool   `json:"smtp_skip_tls_verify"`
	AuditLogsRetentionPeriodInDays int    `json:"audit_logs_retention_period"`
}

type Origin added in v1.5.1

type Origin string
const (
	Dashboard Origin = "DASHBOARD"
	Api       Origin = "API"
	NMCTL     Origin = "NMCTL"
	ClientApp Origin = "CLIENT-APP"
)

type PendingHost added in v1.1.0

type PendingHost struct {
	ID            string         `gorm:"id" json:"id"`
	TenantID      string         `gorm:"default:'';index" json:"tenant_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) DeleteAll added in v1.7.0

func (p *PendingHost) DeleteAll(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)

func (*PendingHost) TableName added in v1.7.0

func (p *PendingHost) TableName() string

type PendingUser added in v1.6.0

type PendingUser struct {
	ID                         string      `gorm:"primaryKey" json:"id"`
	Scope                      scope.Scope `gorm:"default:0;uniqueIndex:udx_pending_user_scope_username" json:"scope"`
	ScopeID                    string      `gorm:"default:'';uniqueIndex:udx_pending_user_scope_username" json:"scope_id"`
	Username                   string      `gorm:"uniqueIndex:udx_pending_user_scope_username" json:"username"`
	ExternalIdentityProviderID string      `json:"external_identity_provider_id"`
	CreatedAt                  time.Time   `json:"created_at"`
}

func (*PendingUser) Create added in v1.6.0

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

func (*PendingUser) Delete added in v1.6.0

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

func (*PendingUser) DeleteAll added in v1.6.0

func (p *PendingUser) DeleteAll(ctx context.Context) error

func (*PendingUser) Exists added in v1.6.0

func (p *PendingUser) Exists(ctx context.Context) (bool, error)

func (*PendingUser) Get added in v1.6.0

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

func (*PendingUser) ListAll added in v1.6.0

func (p *PendingUser) ListAll(ctx context.Context, options ...dbtypes.Option) ([]PendingUser, error)

func (*PendingUser) TableName added in v1.6.0

func (p *PendingUser) TableName() string

type PostureCheck added in v1.4.0

type PostureCheck struct {
	ID          string                      `gorm:"primaryKey" json:"id"`
	TenantID    string                      `gorm:"default:'';index" json:"tenant_id"`
	Name        string                      `gorm:"name" json:"name"`
	NetworkID   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"`
	// Config holds attribute-specific structured options. Used by MDMCompliance
	// for {require_enrolled, require_compliant, max_state_age_hours}; null for
	// legacy attributes that rely on Values.
	Config     datatypes.JSONMap `gorm:"config" json:"config"`
	Severity   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, options ...dbtypes.Option) error

func (*PostureCheck) Get added in v1.4.0

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

func (*PostureCheck) ListAll added in v1.5.1

func (p *PostureCheck) ListAll(ctx context.Context) ([]PostureCheck, error)

func (*PostureCheck) ListByNetwork added in v1.4.0

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

func (*PostureCheck) TableName added in v1.7.0

func (p *PostureCheck) TableName() string

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 PostureCheckViolation added in v1.6.0

type PostureCheckViolation struct {
	EvaluationCycleID string    `gorm:"primaryKey;column:evaluation_cycle_id" json:"evaluation_cycle_id"`
	TenantID          string    `gorm:"default:'';index" json:"tenant_id"`
	CheckID           string    `gorm:"primaryKey;column:check_id" json:"check_id"`
	NodeID            string    `gorm:"primaryKey;column:node_id" json:"node_id"`
	Name              string    `json:"name"`
	Attribute         string    `json:"attribute"`
	Message           string    `json:"message"`
	Severity          Severity  `json:"severity"`
	EvaluatedAt       time.Time `json:"evaluated_at"`
}

func (*PostureCheckViolation) DeleteAll added in v1.7.0

func (v *PostureCheckViolation) DeleteAll(ctx context.Context) error

func (*PostureCheckViolation) TableName added in v1.6.0

func (v *PostureCheckViolation) TableName() string

type Protocol added in v1.7.0

type Protocol string

Protocol - allowed protocol

const (
	ALL  Protocol = "all"
	UDP  Protocol = "udp"
	TCP  Protocol = "tcp"
	ICMP Protocol = "icmp"
)

func (Protocol) String added in v1.7.0

func (p Protocol) String() string

type ResourceAccess added in v1.5.1

type ResourceAccess map[RsrcType]map[RsrcID]RsrcPermissionScope

type RsrcID added in v1.5.1

type RsrcID string
const (
	AllHostRsrcID            RsrcID = "all_host"
	AllRelayRsrcID           RsrcID = "all_relay"
	AllRemoteAccessGwRsrcID  RsrcID = "all_remote_access_gw"
	AllExtClientsRsrcID      RsrcID = "all_extclients"
	AllInetGwRsrcID          RsrcID = "all_inet_gw"
	AllEgressGwRsrcID        RsrcID = "all_egress"
	AllNetworkRsrcID         RsrcID = "all_network"
	AllEnrollmentKeysRsrcID  RsrcID = "all_enrollment_key"
	AllUserRsrcID            RsrcID = "all_user"
	AllDnsRsrcID             RsrcID = "all_dns"
	AllFailOverRsrcID        RsrcID = "all_fail_over"
	AllAclsRsrcID            RsrcID = "all_acl"
	AllTagsRsrcID            RsrcID = "all_tag"
	AllPostureCheckRsrcID    RsrcID = "all_posturecheck"
	AllNameserverRsrcID      RsrcID = "all_nameserver"
	AllJitAdminRsrcID        RsrcID = "all_jit_admin"
	AllJitUserRsrcID         RsrcID = "all_jit_user"
	AllUserActivityRsrcID    RsrcID = "all_user_activity"
	AllNetworkActivityRsrcID RsrcID = "all_network_activity"
	AllActivityRsrcID        RsrcID = "all_activity"
	AllTrafficFlowRsrcID     RsrcID = "all_traffic_flow"
)

func (RsrcID) String added in v1.5.1

func (rid RsrcID) String() string

type RsrcPermissionScope added in v1.5.1

type RsrcPermissionScope struct {
	Create    bool `json:"create"`
	Read      bool `json:"read"`
	Update    bool `json:"update"`
	Delete    bool `json:"delete"`
	VPNaccess bool `json:"vpn_access"`
	SelfOnly  bool `json:"self_only"`
}

type RsrcType added in v1.5.1

type RsrcType string
const (
	HostRsrc            RsrcType = "host"
	RelayRsrc           RsrcType = "relay"
	RemoteAccessGwRsrc  RsrcType = "remote_access_gw"
	GatewayRsrc         RsrcType = "gateway"
	ExtClientsRsrc      RsrcType = "extclient"
	InetGwRsrc          RsrcType = "inet_gw"
	EgressGwRsrc        RsrcType = "egress"
	NetworkRsrc         RsrcType = "network"
	EnrollmentKeysRsrc  RsrcType = "enrollment_key"
	UserRsrc            RsrcType = "user"
	AclRsrc             RsrcType = "acl"
	TagRsrc             RsrcType = "tag"
	DnsRsrc             RsrcType = "dns"
	NameserverRsrc      RsrcType = "nameserver"
	FailOverRsrc        RsrcType = "fail_over"
	MetricRsrc          RsrcType = "metric"
	PostureCheckRsrc    RsrcType = "posturecheck"
	JitAdminRsrc        RsrcType = "jit_admin"
	JitUserRsrc         RsrcType = "jit_user"
	UserActivityRsrc    RsrcType = "user_activity"
	NetworkActivityRsrc RsrcType = "network_activity"
	ActivityRsrc        RsrcType = "activity"
	TrafficFlow         RsrcType = "traffic_flow"
)

func (RsrcType) String added in v1.5.1

func (r RsrcType) String() string

type Severity added in v1.5.1

type Severity int
const (
	SeverityUnknown Severity = iota
	SeverityLow
	SeverityMedium
	SeverityHigh
	SeverityCritical
)

type SsoState added in v1.7.0

type SsoState struct {
	Scope      scope.Scope `json:"scope"`
	ScopeID    string      `json:"scope_id"`
	AppName    string      `json:"app_name"`
	Value      string      `json:"value"`
	Expiration time.Time   `json:"expiration"`
}

SsoState - holds SSO sign-in session data

func (*SsoState) IsExpired added in v1.7.0

func (s *SsoState) IsExpired() bool

type SsoStateRecord added in v1.7.0

type SsoStateRecord struct {
	Key   string `gorm:"primaryKey"`
	Value datatypes.JSONType[SsoState]
}

func (*SsoStateRecord) Count added in v1.7.0

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

func (*SsoStateRecord) Delete added in v1.7.0

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

func (*SsoStateRecord) Get added in v1.7.0

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

func (*SsoStateRecord) List added in v1.7.0

func (*SsoStateRecord) TableName added in v1.7.0

func (*SsoStateRecord) TableName() string

func (*SsoStateRecord) Upsert added in v1.7.0

func (r *SsoStateRecord) Upsert(ctx context.Context) error

type SubjectType added in v1.5.1

type SubjectType string
const (
	UserSub            SubjectType = "USER"
	UserAccessTokenSub SubjectType = "USER_ACCESS_TOKEN"
	DeviceSub          SubjectType = "DEVICE"
	NodeSub            SubjectType = "NODE"
	GatewaySub         SubjectType = "GATEWAY"
	SettingSub         SubjectType = "SETTING"
	AclSub             SubjectType = "ACL"
	TagSub             SubjectType = "TAG"
	UserRoleSub        SubjectType = "USER_ROLE"
	UserGroupSub       SubjectType = "USER_GROUP"
	UserInviteSub      SubjectType = "USER_INVITE"
	PendingUserSub     SubjectType = "PENDING_USER"
	EgressSub          SubjectType = "EGRESS"
	NetworkSub         SubjectType = "NETWORK"
	DashboardSub       SubjectType = "DASHBOARD"
	EnrollmentKeySub   SubjectType = "ENROLLMENT_KEY"
	ClientAppSub       SubjectType = "CLIENT-APP"
	NameserverSub      SubjectType = "NAMESERVER"
	PostureCheckSub    SubjectType = "POSTURE_CHECK"
	JITSub             SubjectType = "JIT"
	MDMSub             SubjectType = "MDM"
)

func (SubjectType) String added in v1.5.1

func (sub SubjectType) String() string

type Tag added in v1.7.0

type Tag struct {
	ID        TagID     `json:"id"`
	TagName   string    `json:"tag_name"`
	Network   NetworkID `json:"network"`
	ColorCode string    `json:"color_code"`
	CreatedBy string    `json:"created_by"`
	CreatedAt time.Time `json:"created_at"`
}

func (Tag) GetIDFromName added in v1.7.0

func (t Tag) GetIDFromName() string

type TagID added in v1.7.0

type TagID string

func (TagID) String added in v1.7.0

func (id TagID) String() string

type TagRecord added in v1.7.0

type TagRecord struct {
	Key       string `gorm:"primaryKey"`
	TenantID  string `gorm:"default:'';index"`
	NetworkID string
	Value     datatypes.JSONType[Tag]
}

func (*TagRecord) Count added in v1.7.0

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

func (*TagRecord) Delete added in v1.7.0

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

func (*TagRecord) DeleteAll added in v1.7.0

func (*TagRecord) DeleteAll(ctx context.Context) error

func (*TagRecord) Get added in v1.7.0

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

func (*TagRecord) List added in v1.7.0

func (*TagRecord) List(ctx context.Context) ([]TagRecord, error)

func (*TagRecord) TableName added in v1.7.0

func (*TagRecord) TableName() string

func (*TagRecord) Upsert added in v1.7.0

func (r *TagRecord) Upsert(ctx context.Context) error

type Tenant added in v1.7.0

type Tenant struct {
	ID             string    `gorm:"primaryKey"           json:"id"`
	Name           string    `gorm:"not null"             json:"name"`
	Slug           string    `gorm:"uniqueIndex;not null" json:"slug"`
	OrganizationID string    `gorm:"not null;index"       json:"organization_id"`
	Metadata       string    `json:"metadata"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

func (*Tenant) Count added in v1.7.0

func (t *Tenant) Count(ctx context.Context, options ...dbtypes.Option) (int, error)

func (*Tenant) Create added in v1.7.0

func (t *Tenant) Create(ctx context.Context) error

func (*Tenant) CreateDefault added in v1.7.0

func (t *Tenant) CreateDefault(ctx context.Context) error

func (*Tenant) Delete added in v1.7.0

func (t *Tenant) Delete(ctx context.Context) error

func (*Tenant) Get added in v1.7.0

func (t *Tenant) Get(ctx context.Context) error

func (*Tenant) GetDefault added in v1.7.0

func (t *Tenant) GetDefault(ctx context.Context) error

func (*Tenant) List added in v1.7.0

func (t *Tenant) List(ctx context.Context, options ...dbtypes.Option) ([]Tenant, error)

func (*Tenant) TableName added in v1.7.0

func (t *Tenant) TableName() string

func (*Tenant) Update added in v1.7.0

func (t *Tenant) Update(ctx context.Context) error

type TenantMembership added in v1.7.0

type TenantMembership struct {
	TenantID                   string                                       `gorm:"primaryKey" json:"tenant_id"`
	UserID                     string                                       `gorm:"primaryKey" json:"user_id"`
	RoleID                     UserRoleID                                   `json:"role_id"`
	Groups                     datatypes.JSONType[map[UserGroupID]struct{}] `json:"groups"`
	AuthType                   AuthType                                     `json:"auth_type"`
	ExternalIdentityProviderID string                                       `json:"external_identity_provider_id"`
	Password                   string                                       `json:"password"`
	AccountDisabled            bool                                         `json:"account_disabled"`
	IsMFAEnabled               bool                                         `json:"is_mfa_enabled"`
	TOTPSecret                 string                                       `json:"totp_secret"`
}

func (*TenantMembership) Create added in v1.7.0

func (t *TenantMembership) Create(ctx context.Context) error

func (*TenantMembership) Delete added in v1.7.0

func (t *TenantMembership) Delete(ctx context.Context) error

func (*TenantMembership) DeleteAllByTenantID added in v1.7.0

func (t *TenantMembership) DeleteAllByTenantID(ctx context.Context) error

func (*TenantMembership) Get added in v1.7.0

func (t *TenantMembership) Get(ctx context.Context) error

func (*TenantMembership) ListByTenantID added in v1.7.0

func (t *TenantMembership) ListByTenantID(ctx context.Context) ([]TenantMembership, error)

func (*TenantMembership) ListByUserID added in v1.7.0

func (t *TenantMembership) ListByUserID(ctx context.Context) ([]TenantMembership, error)

func (*TenantMembership) TableName added in v1.7.0

func (t *TenantMembership) TableName() string

func (*TenantMembership) UpdateAccountStatus added in v1.7.0

func (t *TenantMembership) UpdateAccountStatus(ctx context.Context) error

func (*TenantMembership) UpdateExternalIdentityProviderID added in v1.7.0

func (t *TenantMembership) UpdateExternalIdentityProviderID(ctx context.Context) error

func (*TenantMembership) UpdateGroups added in v1.7.0

func (t *TenantMembership) UpdateGroups(ctx context.Context) error

func (*TenantMembership) UpdateMFA added in v1.7.0

func (t *TenantMembership) UpdateMFA(ctx context.Context) error

func (*TenantMembership) UpdateRoleID added in v1.7.0

func (t *TenantMembership) UpdateRoleID(ctx context.Context) error

func (*TenantMembership) Upsert added in v1.7.0

func (t *TenantMembership) Upsert(ctx context.Context) error

type TenantSettings added in v1.7.0

type TenantSettings struct {
	NetclientAutoUpdate         bool     `json:"netclientautoupdate"`
	Verbosity                   int32    `json:"verbosity"`
	AuthProvider                string   `json:"authprovider"`
	OIDCIssuer                  string   `json:"oidcissuer"`
	ClientID                    string   `json:"client_id"`
	ClientSecret                string   `json:"client_secret"`
	SyncEnabled                 bool     `json:"sync_enabled"`
	GoogleAdminEmail            string   `json:"google_admin_email"`
	GoogleSACredsJson           string   `json:"google_sa_creds_json"`
	AzureTenant                 string   `json:"azure_tenant"`
	OktaOrgURL                  string   `json:"okta_org_url"`
	OktaAPIToken                string   `json:"okta_api_token"`
	UserFilters                 []string `json:"user_filters"`
	GroupFilters                []string `json:"group_filters"`
	IDPSyncInterval             string   `json:"idp_sync_interval"`
	Telemetry                   string   `json:"telemetry"`
	BasicAuth                   bool     `json:"basic_auth"`
	JwtValidityDuration         int      `json:"jwt_validity_duration"`
	JwtValidityDurationClients  int      `json:"jwt_validity_duration_clients"`
	MFAEnforced                 bool     `json:"mfa_enforced"`
	RacRestrictToSingleNetwork  bool     `json:"rac_restrict_to_single_network"`
	EndpointDetection           bool     `json:"endpoint_detection"`
	AllowedEmailDomains         string   `json:"allowed_email_domains"`
	MetricInterval              string   `json:"metric_interval"`
	MetricsPort                 int      `json:"metrics_port"`
	IPDetectionInterval         int      `json:"ip_detection_interval"`
	ManageDNS                   bool     `json:"manage_dns"`
	DefaultDomain               string   `json:"default_domain"`
	Stun                        bool     `json:"stun"`
	StunServers                 string   `json:"stun_servers"`
	PeerConnectionCheckInterval string   `json:"peer_connection_check_interval"`
	PostureCheckInterval        string   `json:"posture_check_interval"`
	CleanUpInterval             int      `json:"clean_up_interval_in_mins"`
	EnableFlowLogs              bool     `json:"enable_flow_logs"`
	// AuditLogsRetentionPeriodInDays and the Smtp/EmailSender fields below are
	// not persisted here: they live on OrganizationSettings and are
	// populated/written through logic.GetServerSettings and
	// logic.UpsertServerSettings for API backward compatibility.
	AuditLogsRetentionPeriodInDays int    `json:"audit_logs_retention_period"`
	EmailSenderAddr                string `json:"email_sender_addr"`
	EmailSenderUser                string `json:"email_sender_user"`
	EmailSenderPassword            string `json:"email_sender_password"`
	SmtpHost                       string `json:"smtp_host"`
	SmtpPort                       int    `json:"smtp_port"`
	SmtpSkipTlsVerify              bool   `json:"smtp_skip_tls_verify"`
}

type TenantSettingsRecord added in v1.7.0

type TenantSettingsRecord struct {
	Key   string `gorm:"primaryKey"`
	Value datatypes.JSONType[TenantSettings]
}

func (*TenantSettingsRecord) Count added in v1.7.0

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

func (*TenantSettingsRecord) Delete added in v1.7.0

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

func (*TenantSettingsRecord) Get added in v1.7.0

func (*TenantSettingsRecord) List added in v1.7.0

func (*TenantSettingsRecord) TableName added in v1.7.0

func (*TenantSettingsRecord) TableName() string

func (*TenantSettingsRecord) Upsert added in v1.7.0

func (r *TenantSettingsRecord) Upsert(ctx context.Context) error

type Theme added in v1.7.0

type Theme string
const (
	Dark   Theme = "dark"
	Light  Theme = "light"
	System Theme = "system"
)

type User added in v1.5.1

type User struct {
	ID                         string     `gorm:"primaryKey" json:"id"`
	Username                   string     `gorm:"unique" json:"username"`
	DisplayName                string     `json:"display_name"`
	PlatformRoleID             UserRoleID `gorm:"-" json:"platform_role_id,omitempty"`
	ExternalIdentityProviderID string     `gorm:"-" json:"external_identity_provider_id"`
	AccountDisabled            bool       `gorm:"-" json:"account_disabled"`
	AuthType                   AuthType   `gorm:"-" json:"auth_type"`
	Password                   string     `gorm:"-" json:"password"`
	IsMFAEnabled               bool       `gorm:"-" json:"is_mfa_enabled"`
	TOTPSecret                 string     `gorm:"-" json:"totp_secret"`
	EmailValidated             bool       `json:"email_validated"`
	// NOTE: json tag is different from field name to ensure compatibility with the older model.
	LastLoginAt time.Time `json:"last_login_time"`
	// NOTE: json tag is different from field name to ensure compatibility with the older model.
	UserGroups    datatypes.JSONType[map[UserGroupID]struct{}] `gorm:"-" json:"user_group_ids,omitempty"`
	Theme         Theme                                        `json:"theme"`
	TextSize      string                                       `json:"text_size"`
	ReducedMotion bool                                         `json:"reduced_motion"`
	CreatedBy     string                                       `json:"created_by"`
	CreatedAt     time.Time                                    `json:"created_at"`
	UpdatedAt     time.Time                                    `json:"updated_at"`
}

func (*User) Count added in v1.5.1

func (u *User) Count(ctx context.Context, options ...dbtypes.Option) (int, error)

func (*User) CountWithMembership added in v1.7.0

func (u *User) CountWithMembership(ctx context.Context, options ...dbtypes.Option) (int, error)

func (*User) Create added in v1.5.1

func (u *User) Create(ctx context.Context) error

func (*User) Delete added in v1.5.1

func (u *User) Delete(ctx context.Context) error

func (*User) DeleteMembership added in v1.7.0

func (u *User) DeleteMembership(ctx context.Context) error

func (*User) Get added in v1.5.1

func (u *User) Get(ctx context.Context) error

func (*User) GetByExternalID added in v1.6.0

func (u *User) GetByExternalID(ctx context.Context) error

func (*User) GetSuperAdmin added in v1.5.1

func (u *User) GetSuperAdmin(ctx context.Context) error

func (*User) GetWithMembership added in v1.7.0

func (u *User) GetWithMembership(ctx context.Context) error

func (*User) ListAll added in v1.5.1

func (u *User) ListAll(ctx context.Context, options ...dbtypes.Option) ([]User, error)

func (*User) ListAllWithMembership added in v1.7.0

func (u *User) ListAllWithMembership(ctx context.Context, options ...dbtypes.Option) ([]User, error)

func (*User) SuperAdminExists added in v1.5.1

func (u *User) SuperAdminExists(ctx context.Context) (bool, error)

func (*User) TableName added in v1.5.1

func (u *User) TableName() string

func (*User) Update added in v1.5.1

func (u *User) Update(ctx context.Context) error

func (*User) UpdateAccountStatus added in v1.5.1

func (u *User) UpdateAccountStatus(ctx context.Context) error

func (*User) UpdateMFA added in v1.5.1

func (u *User) UpdateMFA(ctx context.Context) error

func (*User) UpdateUserSettings added in v1.7.0

func (u *User) UpdateUserSettings(ctx context.Context) error

func (*User) UpsertMembership added in v1.7.0

func (u *User) UpsertMembership(ctx context.Context) error

type UserAccessToken

type UserAccessToken struct {
	ID        string    `gorm:"primaryKey" json:"id"`
	TenantID  string    `gorm:"default:'';index" json:"tenant_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) DeleteAll added in v1.7.0

func (a *UserAccessToken) DeleteAll(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) TableName added in v1.7.0

func (a *UserAccessToken) TableName() string

func (*UserAccessToken) Update

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

type UserGroup added in v1.5.1

type UserGroup struct {
	ID                         UserGroupID                      `gorm:"primaryKey" json:"id"`
	TenantID                   string                           `gorm:"default:'';index" json:"tenant_id"`
	Name                       string                           `json:"name"`
	Default                    bool                             `json:"default"`
	ExternalIdentityProviderID string                           `json:"external_identity_provider_id"`
	NetworkRoles               datatypes.JSONType[NetworkRoles] `json:"network_roles"`
	ColorCode                  string                           `json:"color_code"`
	MetaData                   string                           `json:"meta_data"`
	CreatedBy                  string                           `json:"created_by"`
	CreatedAt                  time.Time                        `json:"created_at"`
	UpdatedAt                  time.Time                        `json:"updated_at"`
}

func (*UserGroup) Count added in v1.5.1

func (u *UserGroup) Count(ctx context.Context, options ...dbtypes.Option) (int, error)

func (*UserGroup) Create added in v1.5.1

func (u *UserGroup) Create(ctx context.Context) error

func (*UserGroup) Delete added in v1.5.1

func (u *UserGroup) Delete(ctx context.Context) error

func (*UserGroup) DeleteAll added in v1.7.0

func (u *UserGroup) DeleteAll(ctx context.Context) error

func (*UserGroup) Get added in v1.5.1

func (u *UserGroup) Get(ctx context.Context) error

func (*UserGroup) GetByName added in v1.5.1

func (u *UserGroup) GetByName(ctx context.Context) error

func (*UserGroup) ListAll added in v1.5.1

func (u *UserGroup) ListAll(ctx context.Context, options ...dbtypes.Option) ([]UserGroup, error)

func (*UserGroup) TableName added in v1.5.1

func (u *UserGroup) TableName() string

func (*UserGroup) Update added in v1.5.1

func (u *UserGroup) Update(ctx context.Context) error

func (*UserGroup) Upsert added in v1.5.1

func (u *UserGroup) Upsert(ctx context.Context) error

type UserGroupID added in v1.5.1

type UserGroupID string

func ScopeUserGroupID added in v1.7.0

func ScopeUserGroupID(tenantID string, id UserGroupID) UserGroupID

func UnscopeUserGroupID added in v1.7.0

func UnscopeUserGroupID(tenantID string, id UserGroupID) UserGroupID

func (UserGroupID) String added in v1.5.1

func (g UserGroupID) String() string

type UserInvite added in v1.6.0

type UserInvite struct {
	ID             string                                       `gorm:"primaryKey" json:"id"`
	Scope          scope.Scope                                  `json:"scope"`
	ScopeID        string                                       `gorm:"default:''" json:"scope_id"`
	InviteCode     string                                       `gorm:"uniqueIndex" json:"invite_code"`
	InviteURL      string                                       `json:"invite_url"`
	Email          string                                       `json:"email"`
	PlatformRoleID string                                       `json:"platform_role_id"`
	UserGroups     datatypes.JSONType[map[UserGroupID]struct{}] `json:"user_group_ids"`
	Type           UserInviteType                               `gorm:"default:'membership'" json:"type"`
}

func (*UserInvite) Create added in v1.6.0

func (u *UserInvite) Create(ctx context.Context) error

func (*UserInvite) Delete added in v1.7.0

func (u *UserInvite) Delete(ctx context.Context) error

func (*UserInvite) DeleteAll added in v1.6.0

func (u *UserInvite) DeleteAll(ctx context.Context) error

func (*UserInvite) DeleteByEmail added in v1.6.0

func (u *UserInvite) DeleteByEmail(ctx context.Context) error

func (*UserInvite) Get added in v1.7.0

func (u *UserInvite) Get(ctx context.Context) error

func (*UserInvite) GetByEmail added in v1.6.0

func (u *UserInvite) GetByEmail(ctx context.Context) error

func (*UserInvite) GetPendingValidationInvite added in v1.7.0

func (u *UserInvite) GetPendingValidationInvite(ctx context.Context) error

func (*UserInvite) GetValidationInvite added in v1.7.0

func (u *UserInvite) GetValidationInvite(ctx context.Context) error

func (*UserInvite) ListAll added in v1.6.0

func (u *UserInvite) ListAll(ctx context.Context, options ...dbtypes.Option) ([]UserInvite, error)

func (*UserInvite) TableName added in v1.6.0

func (u *UserInvite) TableName() string

type UserInviteType added in v1.7.0

type UserInviteType string
const (
	MembershipInvite UserInviteType = "membership"
	ValidationInvite UserInviteType = "validation"
)

type UserRole added in v1.5.1

type UserRole struct {
	ID                  UserRoleID                         `gorm:"primaryKey" json:"id"`
	Name                string                             `json:"name"`
	Default             bool                               `json:"default"`
	MetaData            string                             `json:"meta_data"`
	DenyDashboardAccess bool                               `json:"deny_dashboard_access"`
	OrgGlobalAccess     bool                               `json:"org_global_access"`
	TenantGlobalAccess  bool                               `json:"tenant_global_access"`
	NetworkID           NetworkID                          `json:"network_id"`
	NetworkLevelAccess  datatypes.JSONType[ResourceAccess] `json:"network_level_access"`
	GlobalLevelAccess   datatypes.JSONType[ResourceAccess] `json:"global_level_access"`
}

func (*UserRole) Create added in v1.5.1

func (u *UserRole) Create(ctx context.Context) error

func (*UserRole) DeleteAllForNetworks added in v1.7.0

func (u *UserRole) DeleteAllForNetworks(ctx context.Context, networkIDs []string) error

func (*UserRole) DeleteNetworkRole added in v1.7.0

func (u *UserRole) DeleteNetworkRole(ctx context.Context) error

func (*UserRole) DeleteNetworkRoles added in v1.5.1

func (u *UserRole) DeleteNetworkRoles(ctx context.Context) error

func (*UserRole) GetNetworkRole added in v1.7.0

func (u *UserRole) GetNetworkRole(ctx context.Context) error

func (*UserRole) GetPlatformRole added in v1.7.0

func (u *UserRole) GetPlatformRole(ctx context.Context) error

func (*UserRole) ListNetworkRoles added in v1.5.1

func (u *UserRole) ListNetworkRoles(ctx context.Context) ([]UserRole, error)

func (*UserRole) ListPlatformRoles added in v1.5.1

func (u *UserRole) ListPlatformRoles(ctx context.Context) ([]UserRole, error)

func (*UserRole) TableName added in v1.5.1

func (u *UserRole) TableName() string

func (*UserRole) Upsert added in v1.5.1

func (u *UserRole) Upsert(ctx context.Context) error

type UserRoleID added in v1.5.1

type UserRoleID string
const (
	SuperAdminRole UserRoleID = "super-admin"
	AdminRole      UserRoleID = "admin"
	ServiceUser    UserRoleID = "service-user"
	PlatformUser   UserRoleID = "platform-user"
	Auditor        UserRoleID = "auditor"
	NetworkAdmin   UserRoleID = "network-admin"
	NetworkUser    UserRoleID = "network-user"
	OrgOwner       UserRoleID = "org-owner"
	OrgAdmin       UserRoleID = "org-admin"
)

func ScopeUserRoleID added in v1.7.0

func ScopeUserRoleID(tenantID string, id UserRoleID) UserRoleID

func UnscopeUserRoleID added in v1.7.0

func UnscopeUserRoleID(tenantID string, id UserRoleID) UserRoleID

func (UserRoleID) String added in v1.5.1

func (r UserRoleID) String() string

type Values added in v1.4.0

type Values string

type Violation added in v1.7.0

type Violation struct {
	CheckID   string   `json:"check_id"`
	Name      string   `json:"name"`
	Attribute string   `json:"attribute"`
	Message   string   `json:"message"`
	Severity  Severity `json:"severity"`
}

Violation - posture check violation data

type WgKey added in v1.5.1

type WgKey struct {
	wgtypes.Key
}

func (WgKey) MarshalJSON added in v1.5.1

func (k WgKey) MarshalJSON() ([]byte, error)

func (*WgKey) Scan added in v1.5.1

func (k *WgKey) Scan(value interface{}) error

func (*WgKey) UnmarshalJSON added in v1.5.1

func (k *WgKey) UnmarshalJSON(data []byte) error

func (WgKey) Value added in v1.5.1

func (k WgKey) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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