Documentation
¶
Overview ¶
Package api provides functionality for interacting with the Mist API and managing local configuration, cache, and validation.
Index ¶
- Variables
- func BoolPtr(b bool) *bool
- func ClearCache(cacheType string)
- func ClearCacheForSite(siteID string, cacheType string)
- func EnsureSiteCache(ctx context.Context, orgID string) error
- func Float64Ptr(f float64) *float64
- func GetDeviceTypeFromMap(data map[string]interface{}) string
- func GetSchemaDirectory(configDir string) string
- func GetSiteNameByID(siteID string) (string, bool)
- func InitializeDeviceCache()
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func IsCacheIntegrityCompromised() bool
- func MultiLevelSort[T any](items []T, config SortConfig[T]) []T
- func SetClient(client Client)
- func StringFromInt(i int) string
- func StringPtr(s string) *string
- func ValidateCacheData(cacheData interface{}, schemaDir string) (bool, error)
- func ValidateCacheFile(filePath string, schemaDir string) (bool, error)
- func ValidateInventoryFile(filePath string, schemaDir string) (bool, error)
- func ValidateSiteConfigFile(filePath string, schemaDir string) (bool, error)
- func WrapOutputWithWarning(output string) string
- type AP
- type APConfig
- type APDevice
- func (ap *APDevice) FromConfigMap(data map[string]interface{}) error
- func (ap *APDevice) FromMap(data map[string]interface{}) error
- func (ap *APDevice) GetBleConfig() map[string]interface{}
- func (ap *APDevice) GetForSite() *bool
- func (ap *APDevice) GetHeight() *float64
- func (ap *APDevice) GetIotConfig() map[string]interface{}
- func (ap *APDevice) GetLocation() *[]float64
- func (ap *APDevice) GetLocked() *bool
- func (ap *APDevice) GetMapID() *string
- func (ap *APDevice) GetOrientation() *int
- func (ap *APDevice) GetRadioConfig() map[string]interface{}
- func (ap *APDevice) GetX() *float64
- func (ap *APDevice) GetY() *float64
- func (ap *APDevice) ToConfigMap() map[string]interface{}
- func (ap *APDevice) ToMap() map[string]interface{}
- type APDeviceInterface
- type BandConfig
- type BaseDevice
- func (bd *BaseDevice) FromConfigMap(data map[string]interface{}) error
- func (bd *BaseDevice) FromMap(data map[string]interface{}) error
- func (bd *BaseDevice) GetDeviceProfileID() *string
- func (bd *BaseDevice) GetID() *string
- func (bd *BaseDevice) GetMAC() *string
- func (bd *BaseDevice) GetMagic() *string
- func (bd *BaseDevice) GetModel() *string
- func (bd *BaseDevice) GetName() *string
- func (bd *BaseDevice) GetOrgID() *string
- func (bd *BaseDevice) GetSerial() *string
- func (bd *BaseDevice) GetSiteID() *string
- func (bd *BaseDevice) GetType() *string
- func (bd *BaseDevice) ToConfigMap() map[string]interface{}
- func (bd *BaseDevice) ToMap() map[string]interface{}
- type Cache
- type CacheAccessor
- type CacheAccessorImpl
- func (ca *CacheAccessorImpl) GetAPByMAC(mac string) (*APDevice, error)
- func (ca *CacheAccessorImpl) GetAPByName(name string) (*APDevice, error)
- func (ca *CacheAccessorImpl) GetAPConfigByMAC(mac string) (*APConfig, error)
- func (ca *CacheAccessorImpl) GetAPConfigByName(name string) (*APConfig, error)
- func (ca *CacheAccessorImpl) GetAPsBySite(siteID string) ([]*APDevice, error)
- func (ca *CacheAccessorImpl) GetAllAPConfigs() ([]*APConfig, error)
- func (ca *CacheAccessorImpl) GetAllAPs() ([]*APDevice, error)
- func (ca *CacheAccessorImpl) GetAllDeviceProfileDetails() ([]*map[string]any, error)
- func (ca *CacheAccessorImpl) GetAllDeviceProfiles() ([]*DeviceProfile, error)
- func (ca *CacheAccessorImpl) GetAllGWTemplates() ([]*MistGatewayTemplate, error)
- func (ca *CacheAccessorImpl) GetAllGatewayConfigs() ([]*GatewayConfig, error)
- func (ca *CacheAccessorImpl) GetAllGateways() ([]*MistGatewayDevice, error)
- func (ca *CacheAccessorImpl) GetAllNetworks() ([]*MistNetwork, error)
- func (ca *CacheAccessorImpl) GetAllOrgWLANs() ([]*MistWLAN, error)
- func (ca *CacheAccessorImpl) GetAllOrgs() ([]*OrgStats, error)
- func (ca *CacheAccessorImpl) GetAllRFTemplates() ([]*MistRFTemplate, error)
- func (ca *CacheAccessorImpl) GetAllSiteSettings() ([]*SiteSetting, error)
- func (ca *CacheAccessorImpl) GetAllSiteWLANs() (map[string][]*MistWLAN, error)
- func (ca *CacheAccessorImpl) GetAllSites() ([]*MistSite, error)
- func (ca *CacheAccessorImpl) GetAllSwitchConfigs() ([]*SwitchConfig, error)
- func (ca *CacheAccessorImpl) GetAllSwitches() ([]*MistSwitchDevice, error)
- func (ca *CacheAccessorImpl) GetAllWLANTemplates() ([]*MistWLANTemplate, error)
- func (ca *CacheAccessorImpl) GetCacheStats() (map[string]any, error)
- func (ca *CacheAccessorImpl) GetDeviceProfileByID(id string) (*DeviceProfile, error)
- func (ca *CacheAccessorImpl) GetDeviceProfileByName(name string) (*DeviceProfile, error)
- func (ca *CacheAccessorImpl) GetDeviceProfileDetailByID(id string) (*map[string]any, error)
- func (ca *CacheAccessorImpl) GetDeviceProfileDetailByName(name string) (*map[string]any, error)
- func (ca *CacheAccessorImpl) GetDeviceProfilesByType(deviceType string) ([]*DeviceProfile, error)
- func (ca *CacheAccessorImpl) GetGWTemplateByID(id string) (*MistGatewayTemplate, error)
- func (ca *CacheAccessorImpl) GetGWTemplateByName(name string) (*MistGatewayTemplate, error)
- func (ca *CacheAccessorImpl) GetGatewayByMAC(mac string) (*MistGatewayDevice, error)
- func (ca *CacheAccessorImpl) GetGatewayByName(name string) (*MistGatewayDevice, error)
- func (ca *CacheAccessorImpl) GetGatewayConfigByMAC(mac string) (*GatewayConfig, error)
- func (ca *CacheAccessorImpl) GetGatewayConfigByName(name string) (*GatewayConfig, error)
- func (ca *CacheAccessorImpl) GetGatewaysBySite(siteID string) ([]*MistGatewayDevice, error)
- func (ca *CacheAccessorImpl) GetManager() *CacheManager
- func (ca *CacheAccessorImpl) GetNetworkByID(id string) (*MistNetwork, error)
- func (ca *CacheAccessorImpl) GetNetworkByName(name string) (*MistNetwork, error)
- func (ca *CacheAccessorImpl) GetOrgByID(id string) (*OrgStats, error)
- func (ca *CacheAccessorImpl) GetOrgByName(name string) (*OrgStats, error)
- func (ca *CacheAccessorImpl) GetOrgWLANByID(id string) (*MistWLAN, error)
- func (ca *CacheAccessorImpl) GetOrgWLANByName(name string) (*MistWLAN, error)
- func (ca *CacheAccessorImpl) GetRFTemplateByID(id string) (*MistRFTemplate, error)
- func (ca *CacheAccessorImpl) GetRFTemplateByName(name string) (*MistRFTemplate, error)
- func (ca *CacheAccessorImpl) GetSiteByID(id string) (*MistSite, error)
- func (ca *CacheAccessorImpl) GetSiteByName(name string) (*MistSite, error)
- func (ca *CacheAccessorImpl) GetSiteSettingByID(id string) (*SiteSetting, error)
- func (ca *CacheAccessorImpl) GetSiteSettingBySiteID(siteID string) (*SiteSetting, error)
- func (ca *CacheAccessorImpl) GetSiteWLANByID(siteID, id string) (*MistWLAN, error)
- func (ca *CacheAccessorImpl) GetSiteWLANByName(siteID, name string) (*MistWLAN, error)
- func (ca *CacheAccessorImpl) GetSiteWLANs(siteID string) ([]*MistWLAN, error)
- func (ca *CacheAccessorImpl) GetSwitchByMAC(mac string) (*MistSwitchDevice, error)
- func (ca *CacheAccessorImpl) GetSwitchByName(name string) (*MistSwitchDevice, error)
- func (ca *CacheAccessorImpl) GetSwitchConfigByMAC(mac string) (*SwitchConfig, error)
- func (ca *CacheAccessorImpl) GetSwitchConfigByName(name string) (*SwitchConfig, error)
- func (ca *CacheAccessorImpl) GetSwitchesBySite(siteID string) ([]*MistSwitchDevice, error)
- func (ca *CacheAccessorImpl) GetWLANTemplateByID(id string) (*MistWLANTemplate, error)
- func (ca *CacheAccessorImpl) GetWLANTemplateByName(name string) (*MistWLANTemplate, error)
- func (ca *CacheAccessorImpl) IsInitialized() bool
- func (ca *CacheAccessorImpl) NeedsRebuild() bool
- type CacheIndexes
- type CacheManager
- func (cm *CacheManager) GetCache() (*Cache, error)
- func (cm *CacheManager) GetCacheStats() (map[string]any, error)
- func (cm *CacheManager) GetIndexes() (*CacheIndexes, error)
- func (cm *CacheManager) Initialize() error
- func (cm *CacheManager) InitializeWithOptions(forceRecreate bool) error
- func (cm *CacheManager) ReadCache(fn func(*Cache) error) error
- func (cm *CacheManager) ReadIndexes(fn func(*CacheIndexes) error) error
- func (cm *CacheManager) ReplaceCache(newCache *Cache) error
- func (cm *CacheManager) SaveCache() error
- type CacheMetadata
- type CacheVerificationStatus
- type Cacher
- type Client
- type ClientOption
- func WithCacheDirectory(cacheDir string) ClientOption
- func WithCacheTTL(ttl time.Duration) ClientOption
- func WithDebug(debug bool) ClientOption
- func WithDryRun(dryRun bool) ClientOption
- func WithHTTPClient(httpClient *http.Client) ClientOption
- func WithInventory(inventoryPath string) ClientOption
- func WithRateLimit(limit int, duration time.Duration) ClientOption
- func WithResultsLimit(limit int) ClientOption
- type ClientTokenValidator
- type Config
- type Device
- type DeviceCache
- func (c *DeviceCache) AddDevice(device UnifiedDevice)
- func (c *DeviceCache) Clear()
- func (c *DeviceCache) Count() int
- func (c *DeviceCache) CountBySite() map[string]int
- func (c *DeviceCache) CountByType() map[string]int
- func (c *DeviceCache) GetAllDevices() []UnifiedDevice
- func (c *DeviceCache) GetCacheStats() (hits, misses int64, hitRate float64)
- func (c *DeviceCache) GetDeviceByMAC(mac string) (UnifiedDevice, bool)
- func (c *DeviceCache) GetDeviceByName(name string) (UnifiedDevice, bool)
- func (c *DeviceCache) GetDevicesBySite(siteID string) []UnifiedDevice
- func (c *DeviceCache) GetDevicesBySiteAndType(siteID, deviceType string) []UnifiedDevice
- func (c *DeviceCache) GetDevicesByType(deviceType string) []UnifiedDevice
- func (c *DeviceCache) MergeDeviceInfo(device UnifiedDevice)
- func (c *DeviceCache) RemoveDevice(mac string)
- type DeviceConfig
- type DeviceConfigResponse
- type DeviceInfo
- type DeviceLookupOptions
- type DeviceMarshaler
- type DeviceProfile
- func (dp *DeviceProfile) FromMap(data map[string]interface{}) error
- func (dp *DeviceProfile) GetCreatedTime() *float64
- func (dp *DeviceProfile) GetForSite() *bool
- func (dp *DeviceProfile) GetID() *string
- func (dp *DeviceProfile) GetModifiedTime() *float64
- func (dp *DeviceProfile) GetName() *string
- func (dp *DeviceProfile) GetOrgID() *string
- func (dp *DeviceProfile) GetSiteID() *string
- func (dp *DeviceProfile) GetType() *string
- func (dp *DeviceProfile) ToMap() map[string]interface{}
- type DeviceProfileAP
- type DeviceProfileAssignResult
- type DeviceProfileGateway
- type DeviceProfileMarshaler
- type DeviceProfileSwitch
- type GatewayConfig
- type GatewayDeviceInterface
- type InventoryAssignResponse
- type InventoryConfig
- type InventoryItem
- type InventoryMarshaler
- type LatLng
- type MistDeviceMacPort
- type MistGatewayDevice
- func (gw *MistGatewayDevice) FromConfigMap(data map[string]interface{}) error
- func (gw *MistGatewayDevice) FromMap(data map[string]interface{}) error
- func (gw *MistGatewayDevice) GetIP() *string
- func (gw *MistGatewayDevice) GetLANConfig() map[string]interface{}
- func (gw *MistGatewayDevice) GetMgmtIntf() *string
- func (gw *MistGatewayDevice) GetSecurityConfig() map[string]interface{}
- func (gw *MistGatewayDevice) GetVPNConfig() map[string]interface{}
- func (gw *MistGatewayDevice) GetVersion() *string
- func (gw *MistGatewayDevice) GetWANConfig() map[string]interface{}
- func (gw *MistGatewayDevice) ToConfigMap() map[string]interface{}
- func (gw *MistGatewayDevice) ToMap() map[string]interface{}
- type MistGatewayTemplate
- type MistInventoryItem
- func (i *MistInventoryItem) FromConfigMap(data map[string]interface{}) error
- func (i *MistInventoryItem) FromMap(data map[string]interface{}) error
- func (i *MistInventoryItem) GetID() string
- func (i *MistInventoryItem) GetMAC() string
- func (i *MistInventoryItem) GetRaw() map[string]interface{}
- func (i *MistInventoryItem) GetType() string
- func (i *MistInventoryItem) SetRaw(data map[string]interface{})
- func (i *MistInventoryItem) ToConfigMap() map[string]interface{}
- func (i *MistInventoryItem) ToMap() map[string]interface{}
- type MistLatLng
- type MistNetwork
- type MistRFTemplate
- type MistSite
- func (s *MistSite) FromConfigMap(data map[string]interface{}) error
- func (s *MistSite) FromMap(data map[string]interface{}) error
- func (s *MistSite) FromMapEnhanced(data map[string]interface{}) error
- func (s *MistSite) GetID() string
- func (s *MistSite) GetName() string
- func (s *MistSite) GetRaw() map[string]interface{}
- func (s *MistSite) SetRaw(data map[string]interface{})
- func (s *MistSite) ToConfigMap() map[string]interface{}
- func (s *MistSite) ToMap() map[string]interface{}
- func (s *MistSite) ToMapEnhanced() map[string]interface{}
- type MistSwitchDevice
- func (sw *MistSwitchDevice) FromConfigMap(data map[string]interface{}) error
- func (sw *MistSwitchDevice) FromMap(data map[string]interface{}) error
- func (sw *MistSwitchDevice) GetIP() *string
- func (sw *MistSwitchDevice) GetIPConfig() map[string]interface{}
- func (sw *MistSwitchDevice) GetManaged() *bool
- func (sw *MistSwitchDevice) GetNetworks() map[string]interface{}
- func (sw *MistSwitchDevice) GetPort() *int
- func (sw *MistSwitchDevice) GetPortConfig() map[string]interface{}
- func (sw *MistSwitchDevice) GetRole() *string
- func (sw *MistSwitchDevice) GetRouterID() *string
- func (sw *MistSwitchDevice) GetVersion() *string
- func (sw *MistSwitchDevice) ToConfigMap() map[string]interface{}
- func (sw *MistSwitchDevice) ToMap() map[string]interface{}
- type MistWLAN
- type MistWLANTemplate
- type MistWiredClient
- func (w *MistWiredClient) FromMap(data map[string]interface{}) error
- func (w *MistWiredClient) GetMAC() string
- func (w *MistWiredClient) GetOrgID() string
- func (w *MistWiredClient) GetRaw() map[string]interface{}
- func (w *MistWiredClient) GetSiteID() string
- func (w *MistWiredClient) SetRaw(data map[string]interface{})
- func (w *MistWiredClient) ToMap() map[string]interface{}
- type MistWiredClientResponse
- type MistWirelessClient
- func (w *MistWirelessClient) FromMap(data map[string]interface{}) error
- func (w *MistWirelessClient) GetMAC() string
- func (w *MistWirelessClient) GetOrgID() string
- func (w *MistWirelessClient) GetRaw() map[string]interface{}
- func (w *MistWirelessClient) GetSiteID() string
- func (w *MistWirelessClient) SetRaw(data map[string]interface{})
- func (w *MistWirelessClient) ToMap() map[string]interface{}
- type MistWirelessClientResponse
- type MockClient
- func (m *MockClient) AddInventoryItem(item InventoryItem)
- func (m *MockClient) AddMockAP(ap AP)
- func (m *MockClient) AddMockSite(site Site)
- func (m *MockClient) AssignDevice(ctx context.Context, orgID string, siteID string, mac string) (*UnifiedDevice, error)
- func (m *MockClient) AssignDeviceProfile(ctx context.Context, orgID string, profileID string, macs []string) (*DeviceProfileAssignResult, error)
- func (m *MockClient) AssignDevicesToSite(ctx context.Context, orgID string, siteID string, macs []string, ...) error
- func (m *MockClient) AssignInventoryItemsToSite(ctx context.Context, orgID string, siteID string, itemMACs []string) error
- func (m *MockClient) BatchGetDeviceConfigs(ctx context.Context, devices []DeviceInfo) (map[string]*DeviceConfig, map[string]error)
- func (m *MockClient) ClaimInventoryItem(ctx context.Context, orgID string, claimCodes []string) ([]*MistInventoryItem, error)
- func (m *MockClient) Close() error
- func (m *MockClient) CreateMistSite(ctx context.Context, site *MistSite) (*MistSite, error)
- func (m *MockClient) CreateSite(ctx context.Context, site *MistSite) (*MistSite, error)
- func (m *MockClient) DeleteDevicesFromSite(_ context.Context, _ []string) error
- func (m *MockClient) DeleteMistSite(ctx context.Context, siteID string) error
- func (m *MockClient) DeleteSite(ctx context.Context, siteID string) error
- func (m *MockClient) DeleteSiteByName(ctx context.Context, siteName string) error
- func (m *MockClient) DeleteSiteByNameNew(ctx context.Context, siteName string) error
- func (m *MockClient) ForceRebuildCache(_ context.Context) error
- func (m *MockClient) GetAPBySerialOrMAC(_ context.Context, siteID, serial, mac string) (*AP, error)
- func (m *MockClient) GetAPConfig(ctx context.Context, siteID, deviceID string) (*APConfig, error)
- func (m *MockClient) GetAPIUserInfo(ctx context.Context) (*SelfResponse, error)
- func (m *MockClient) GetCacheAccessor() CacheAccessor
- func (m *MockClient) GetConfigDirectory() string
- func (m *MockClient) GetDeviceByID(ctx context.Context, siteID, deviceID string) (*UnifiedDevice, error)
- func (m *MockClient) GetDeviceByMAC(ctx context.Context, mac string) (*UnifiedDevice, error)
- func (m *MockClient) GetDeviceByName(ctx context.Context, siteID, name string) (*UnifiedDevice, error)
- func (m *MockClient) GetDeviceCache() *DeviceCache
- func (m *MockClient) GetDeviceConfig(ctx context.Context, siteID, deviceID string) (*DeviceConfigResponse, error)
- func (m *MockClient) GetDeviceProfile(ctx context.Context, orgID string, profileID string) (*DeviceProfile, error)
- func (m *MockClient) GetDeviceProfileByName(ctx context.Context, orgID string, name string, profileType string) (*DeviceProfile, error)
- func (m *MockClient) GetDeviceProfiles(ctx context.Context, orgID string, profileType string) ([]DeviceProfile, error)
- func (m *MockClient) GetDevices(ctx context.Context, siteID string, deviceType string) ([]UnifiedDevice, error)
- func (m *MockClient) GetDevicesByType(ctx context.Context, siteID string, deviceType string) ([]UnifiedDevice, error)
- func (m *MockClient) GetGatewayConfig(ctx context.Context, siteID, deviceID string) (*GatewayConfig, error)
- func (m *MockClient) GetGatewayTemplates(_ context.Context, orgID string) ([]MistGatewayTemplate, error)
- func (m *MockClient) GetInventory(ctx context.Context, orgID string, deviceType string) ([]*MistInventoryItem, error)
- func (m *MockClient) GetInventoryConfig(_ string) (*InventoryConfig, error)
- func (m *MockClient) GetInventoryItem(ctx context.Context, orgID string, itemID string) (*MistInventoryItem, error)
- func (m *MockClient) GetInventoryItemByMAC(ctx context.Context, orgID string, macAddress string) (*MistInventoryItem, error)
- func (m *MockClient) GetMistSite(ctx context.Context, siteID string) (*MistSite, error)
- func (m *MockClient) GetNetworks(_ context.Context, orgID string) ([]MistNetwork, error)
- func (m *MockClient) GetOrgName(_ string) (string, bool)
- func (m *MockClient) GetOrgStats(_ context.Context, orgID string) (*OrgStats, error)
- func (m *MockClient) GetRFTemplates(_ context.Context, orgID string) ([]MistRFTemplate, error)
- func (m *MockClient) GetRawDeviceJSON(_ context.Context, siteID, deviceID string) (string, error)
- func (m *MockClient) GetSchemaDirectory() string
- func (m *MockClient) GetSite(ctx context.Context, siteID string) (*MistSite, error)
- func (m *MockClient) GetSiteByIdentifier(ctx context.Context, siteIdentifier string) (*MistSite, error)
- func (m *MockClient) GetSiteByIdentifierNew(ctx context.Context, siteIdentifier string) (*MistSite, error)
- func (m *MockClient) GetSiteByName(ctx context.Context, name, orgID string) (*MistSite, error)
- func (m *MockClient) GetSiteName(siteID string) (string, bool)
- func (m *MockClient) GetSiteSetting(_ context.Context, siteID string) (*SiteSetting, error)
- func (m *MockClient) GetSiteWLANs(_ context.Context, siteID string) ([]MistWLAN, error)
- func (m *MockClient) GetSites(ctx context.Context, orgID string) ([]*MistSite, error)
- func (m *MockClient) GetSitesNew(ctx context.Context, orgID string) ([]*MistSite, error)
- func (m *MockClient) GetSwitchConfig(ctx context.Context, siteID, deviceID string) (*SwitchConfig, error)
- func (m *MockClient) GetWLANTemplates(_ context.Context, orgID string) ([]MistWLANTemplate, error)
- func (m *MockClient) GetWLANs(_ context.Context, orgID string) ([]MistWLAN, error)
- func (m *MockClient) LookupSiteByID(siteID string, options ...SiteLookupOptions) (Site, bool, error)
- func (m *MockClient) LookupSiteByIdentifier(identifier string, options ...SiteLookupOptions) (Site, bool, error)
- func (m *MockClient) LookupSiteByName(siteName string, options ...SiteLookupOptions) (Site, bool, error)
- func (m *MockClient) PopulateDeviceCacheForSite(_ context.Context, _ string, _ string) error
- func (m *MockClient) QueryDeviceExtensive(_ context.Context, _, _ string) error
- func (m *MockClient) ReleaseInventoryItem(ctx context.Context, orgID string, itemIDs []string) error
- func (m *MockClient) SearchWiredClients(ctx context.Context, orgID string, text string) (*MistWiredClientResponse, error)
- func (m *MockClient) SearchWirelessClients(ctx context.Context, orgID string, text string) (*MistWirelessClientResponse, error)
- func (m *MockClient) SetDebug(debug bool)
- func (m *MockClient) SetRateLimit(limit int, duration time.Duration)
- func (m *MockClient) SetResultsLimit(limit int)
- func (m *MockClient) UnassignDevice(ctx context.Context, orgID string, _ string, deviceID string) error
- func (m *MockClient) UnassignDeviceProfiles(ctx context.Context, orgID string, profileID string, macs []string) error
- func (m *MockClient) UnassignDevicesFromSite(ctx context.Context, orgID string, macs []string) error
- func (m *MockClient) UnassignInventoryItemsFromMistSite(ctx context.Context, orgID string, itemMACs []string) error
- func (m *MockClient) UnassignInventoryItemsFromSite(ctx context.Context, orgID string, itemMACs []string) error
- func (m *MockClient) UpdateCacheForTypes(_ context.Context, _ []string, _ []string) error
- func (m *MockClient) UpdateDevice(ctx context.Context, siteID string, deviceID string, device *UnifiedDevice) (*UnifiedDevice, error)
- func (m *MockClient) UpdateDeviceNew(ctx context.Context, siteID string, deviceID string, device *UnifiedDevice) (*UnifiedDevice, error)
- func (m *MockClient) UpdateInventoryItem(ctx context.Context, orgID string, itemID string, item *MistInventoryItem) (*MistInventoryItem, error)
- func (m *MockClient) UpdateMistSite(ctx context.Context, siteID string, site *MistSite) (*MistSite, error)
- func (m *MockClient) UpdateSite(ctx context.Context, siteID string, site *MistSite) (*MistSite, error)
- func (m *MockClient) UpdateSiteByName(ctx context.Context, siteName string, site *MistSite) (*MistSite, error)
- func (m *MockClient) UpdateSiteByNameNew(ctx context.Context, siteName string, site *MistSite) (*MistSite, error)
- func (m *MockClient) ValidateAPIToken(ctx context.Context) (*SelfResponse, error)
- type OrgData
- type OrgStats
- type OrgStatsSLE
- type OrgStatsSLEUserMinutes
- type Privilege
- type RadioConfig
- type RadioConfigBand
- type RadioConfigBand5
- type RadioConfigBand6
- type RadioConfigBand24
- type SchemaType
- type SchemaValidator
- type SearchClientMarshaler
- type SelfResponse
- type Site
- type SiteLookupOptions
- type SiteMarshaler
- type SiteSetting
- type SortConfig
- type SortField
- type SwitchConfig
- type SwitchDeviceInterface
- type UUID
- type UnifiedCache
- func (uc *UnifiedCache) Clear() error
- func (uc *UnifiedCache) GetAllSites() ([]*MistSite, error)
- func (uc *UnifiedCache) GetConfigs(orgID, deviceType string) ([]any, error)
- func (uc *UnifiedCache) GetDevice(mac string) (*UnifiedDevice, error)
- func (uc *UnifiedCache) GetDevicesByType(siteID, deviceType string) ([]UnifiedDevice, error)
- func (uc *UnifiedCache) GetInventory(deviceType string) ([]any, error)
- func (uc *UnifiedCache) GetMetadata() *CacheMetadata
- func (uc *UnifiedCache) GetOrgData(orgID string) (*OrgData, error)
- func (uc *UnifiedCache) GetPath() string
- func (uc *UnifiedCache) GetProfiles(profileType string) ([]any, error)
- func (uc *UnifiedCache) GetSite(identifier string) (*MistSite, error)
- func (uc *UnifiedCache) IsDirty() bool
- func (uc *UnifiedCache) Load() error
- func (uc *UnifiedCache) MarkDirty()
- func (uc *UnifiedCache) MergeConfigs(orgID, deviceType string, configs []any) error
- func (uc *UnifiedCache) Save() error
- func (uc *UnifiedCache) SetOrgData(orgID string, data *OrgData) error
- func (uc *UnifiedCache) UpdateConfigs(orgID, deviceType string, configs []any) error
- func (uc *UnifiedCache) UpdateDevice(device *UnifiedDevice) error
- func (uc *UnifiedCache) UpdateInventory(deviceType string, items []any) error
- func (uc *UnifiedCache) UpdateMetadata(_ *CacheMetadata)
- func (uc *UnifiedCache) UpdateProfiles(profileType string, profiles []any) error
- func (uc *UnifiedCache) UpdateSite(site *MistSite) error
- type UnifiedDevice
- func ConvertFromRawMap(rawData map[string]interface{}) (*UnifiedDevice, error)
- func MergeDeviceData(base UnifiedDevice, update UnifiedDevice) UnifiedDevice
- func NewUnifiedDeviceFromMap(data map[string]interface{}) (*UnifiedDevice, error)
- func NewUnifiedDeviceFromType(deviceType string) *UnifiedDevice
- func (ud *UnifiedDevice) FromConfigMap(data map[string]interface{}) error
- func (ud *UnifiedDevice) FromMap(data map[string]interface{}) error
- func (ud *UnifiedDevice) GetDeviceProfileID() *string
- func (ud *UnifiedDevice) GetID() *string
- func (ud *UnifiedDevice) GetMAC() *string
- func (ud *UnifiedDevice) GetMagic() *string
- func (ud *UnifiedDevice) GetModel() *string
- func (ud *UnifiedDevice) GetName() *string
- func (ud *UnifiedDevice) GetOrgID() *string
- func (ud *UnifiedDevice) GetSerial() *string
- func (ud *UnifiedDevice) GetSiteID() *string
- func (ud *UnifiedDevice) GetType() *string
- func (ud *UnifiedDevice) ToConfigMap() map[string]interface{}
- func (ud *UnifiedDevice) ToMap() map[string]interface{}
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("not found: resource does not exist")
ErrNotFound is a sentinel error for resource not found
ErrUnauthorized is a sentinel error for unauthorized requests
Functions ¶
func ClearCache ¶
func ClearCache(cacheType string)
ClearCache clears specific cache types or all caches cacheType can be:
- "all" - clears everything
- "inventory" - clears all inventory caches
- "inventory-ap", "inventory-switch", "inventory-gateway" - clears specific inventory type
- "configs" - clears all device config caches
- "configs-ap", "configs-switch", "configs-gateway" - clears specific device config type
- "devices" - clears device cache (alias for configs)
func ClearCacheForSite ¶
ClearCacheForSite clears cache entries for a specific site
func EnsureSiteCache ¶
EnsureSiteCache ensures that the site cache is populated for the given org ID
func GetDeviceTypeFromMap ¶
GetDeviceTypeFromMap determines device type from raw API data
func GetSchemaDirectory ¶
GetSchemaDirectory returns the directory containing the schema files.
The schema files are stored in a 'schemas' subdirectory of the main configuration directory by default, but can be overridden in the config file with the "files.schemas" setting. This function constructs the path to this directory.
Schema files follow a naming convention: - cache-schema.json: Defines the structure for cache files - site-config-schema.json: Defines the structure for site configuration files - inventory-schema.json: Defines the structure for inventory files
The schemas are in JSON Schema format (draft-07) and define the structure, required fields, and valid values for all JSON files used by the application.
Note: This function is for backward compatibility. Always prefer to use client.GetSchemaDirectory() when a client object is available.
func GetSiteNameByID ¶
GetSiteNameByID retrieves a site name from the global client cache
func InitializeDeviceCache ¶
func InitializeDeviceCache()
InitializeDeviceCache initializes the global device cache
func IsCacheIntegrityCompromised ¶
func IsCacheIntegrityCompromised() bool
IsCacheIntegrityCompromised returns whether cache integrity is compromised
func MultiLevelSort ¶
func MultiLevelSort[T any](items []T, config SortConfig[T]) []T
MultiLevelSort performs generic multi-level natural sorting on any slice The sorting is stable and uses natural ordering for strings Empty values are placed at the end of their respective groups when EmptyLast is true
func ValidateCacheData ¶
ValidateCacheData validates cache data against the cache schema.
This function is similar to ValidateCacheFile but operates on an in-memory data structure instead of a file. This is particularly useful when validating cache data before saving it to a file, or when validating dynamically generated cache content.
The validation ensures that the data structure follows all requirements defined in the cache schema, including: - Proper versioning (version 1.0) - Required sections (sites, inventory) - Properly formatted device entries with required fields - Normalized MAC addresses as keys
func ValidateCacheFile ¶
ValidateCacheFile validates a cache file against the cache schema.
The cache schema defines the structure for storing sites, inventory, and device profiles. It enforces requirements like normalized MAC address formats as keys for devices, proper site name formats, and required fields like the 'magic' field which is critical for device identification in the API.
The cache file is central to the application's operation, as it stores all data retrieved from the API to minimize API calls and provide offline functionality.
func ValidateInventoryFile ¶
ValidateInventoryFile validates an inventory file against the inventory schema.
The inventory file tracks devices that are available for assignment to sites. It organizes devices by type (ap, switch, gateway) and indexes them by normalized MAC addresses.
Key validations include: - Required 'magic' field for all devices - Proper MAC address formatting - Target site assignments with proper site name format - Required fields like name, model, etc.
This validation ensures that the inventory accurately represents available devices and can be used for assignments to sites.
func ValidateSiteConfigFile ¶
ValidateSiteConfigFile validates a site configuration file against the site config schema.
Site configuration files define the desired state for sites and their associated devices. They follow a structure where devices are organized by type (ap, switch, gateway) and indexed by normalized MAC addresses.
The schema enforces: - Proper site naming convention - Required 'magic' field for all devices - Consistent structure for all device types (ap, switch, gateway) - Required site_config section with name, country_code, timezone, etc.
This validation is critical to ensure that site configurations can be properly applied to the Mist API.
func WrapOutputWithWarning ¶
WrapOutputWithWarning prefixes each line with a warning indicator if cache integrity is compromised
Types ¶
type AP ¶
type AP struct {
// Id is the unique identifier for the AP
Id *UUID `json:"id,omitempty"`
// Name is the name of the AP
Name *string `json:"name,omitempty"`
// Serial is the serial number of the AP
Serial *string `json:"serial,omitempty"`
// Mac is the MAC address of the AP
Mac *string `json:"mac,omitempty"`
// Magic is the claim code for the device
Magic *string `json:"magic,omitempty"`
// Model is the AP model
Model *string `json:"model,omitempty"`
// HwRev is the hardware revision of the AP
HwRev *string `json:"hw_rev,omitempty"`
// Type is the AP type
Type *string `json:"type,omitempty"`
// Tags are labels applied to the AP
Tags *[]string `json:"tags,omitempty"`
// Notes are additional information about the AP
Notes *string `json:"notes,omitempty"`
// SiteId is the ID of the site the AP belongs to
SiteId *UUID `json:"site_id,omitempty"`
// OrgId is the ID of the organization
OrgId *string `json:"org_id,omitempty"`
// Location of the AP [latitude, longitude]
Location *[]float64 `json:"location,omitempty"`
// Orientation of the AP in degrees
Orientation *int `json:"orientation,omitempty"`
// Status of the AP (connected, disconnected, etc.)
Status *string `json:"status,omitempty"`
// Connected indicates if the device is connected
Connected *bool `json:"connected,omitempty"`
// Led indicates whether LED is enabled on the AP
Led *bool `json:"led,omitempty"`
// MapID is the map the AP is placed on
MapID *string `json:"map_id,omitempty"`
// TagUUID is the tag UUID
TagUUID *string `json:"tag_uuid,omitempty"`
// TagID is the tag ID
TagID *int `json:"tag_id,omitempty"`
// EvpnScope is the EVPN scope
EvpnScope *string `json:"evpn_scope,omitempty"`
// EvpntopoID is the EVPN topology ID
EvpntopoID *string `json:"evpntopo_id,omitempty"`
// StIPBase is the ST IP base
StIPBase *string `json:"st_ip_base,omitempty"`
// BundledMac is the bundled MAC address
BundledMac *string `json:"bundled_mac,omitempty"`
// CreatedTime is when the AP was created
CreatedTime *int64 `json:"created_time,omitempty"`
// ModifiedTime is when the AP was last modified
ModifiedTime *int64 `json:"modified_time,omitempty"`
// SKU is the stock keeping unit
SKU *string `json:"sku,omitempty"`
// DeviceProfileId is the deviceprofile ID if assigned, null if not assigned
DeviceProfileId *string `json:"deviceprofile_id,omitempty"`
// Band24 is the 2.4GHz radio configuration (legacy)
Band24 *BandConfig `json:"band_24,omitempty"`
// Band5 is the 5GHz radio configuration (legacy)
Band5 *BandConfig `json:"band_5,omitempty"`
// LastSeen is the last time the AP was seen by the Mist cloud
LastSeen *time.Time `json:"last_seen,omitempty"`
// RadioConfig contains the radio configuration
RadioConfig *RadioConfig `json:"radio_config,omitempty"`
}
AP represents a Mist access point
func ConvertToAPSlice ¶
func ConvertToAPSlice(devices []UnifiedDevice) []AP
ConvertToAPSlice converts a slice of UnifiedDevice structs to AP structs
type APConfig ¶
type APConfig = APDevice
APConfig represents an AP device configuration This uses the same structure as APDevice since configs follow the same schema
type APDevice ¶
type APDevice struct {
BaseDevice
// AP-specific typed fields for frequently used configurations
// Position and orientation
Location *[]float64 `json:"location,omitempty"`
Orientation *int `json:"orientation,omitempty"`
MapID *string `json:"map_id,omitempty"`
Height *float64 `json:"height,omitempty"`
X *float64 `json:"x,omitempty"`
Y *float64 `json:"y,omitempty"`
// Site and locking
ForSite *bool `json:"for_site,omitempty"`
Locked *bool `json:"locked,omitempty"`
// Hardware configuration - common fields with typed access
Led *bool `json:"led,omitempty"`
DisableEth1 *bool `json:"disable_eth1,omitempty"`
DisableEth2 *bool `json:"disable_eth2,omitempty"`
DisableEth3 *bool `json:"disable_eth3,omitempty"`
DisableModule *bool `json:"disable_module,omitempty"`
PoEPassthrough *bool `json:"poe_passthrough,omitempty"`
// Complex configuration stored as maps for flexibility and evolution
RadioConfig map[string]interface{} `json:"radio_config,omitempty"`
BleConfig map[string]interface{} `json:"ble_config,omitempty"`
IotConfig map[string]interface{} `json:"iot_config,omitempty"`
IPConfig map[string]interface{} `json:"ip_config,omitempty"`
MeshConfig map[string]interface{} `json:"mesh,omitempty"`
PortConfig map[string]interface{} `json:"port_config,omitempty"`
UplinkPortConfig map[string]interface{} `json:"uplink_port_config,omitempty"`
LedConfig map[string]interface{} `json:"led_config,omitempty"`
AeroscoutConfig map[string]interface{} `json:"aeroscout,omitempty"`
CentrakConfig map[string]interface{} `json:"centrak,omitempty"`
ClientBridgeConfig map[string]interface{} `json:"client_bridge,omitempty"`
EslConfig map[string]interface{} `json:"esl_config,omitempty"`
PwrConfig map[string]interface{} `json:"pwr_config,omitempty"`
UsbConfig map[string]interface{} `json:"usb_config,omitempty"`
// Additional config for unknown fields
AdditionalConfig map[string]interface{} `json:"-"`
}
APDevice represents a Mist access point with complete data preservation
func NewAPDeviceFromMap ¶
NewAPDeviceFromMap creates a new APDevice from API response data
func (*APDevice) FromConfigMap ¶
FromConfigMap populates AP device from configuration map (from config files)
func (*APDevice) GetBleConfig ¶
func (*APDevice) GetForSite ¶
func (*APDevice) GetIotConfig ¶
func (*APDevice) GetLocation ¶
Implement APDeviceInterface
func (*APDevice) GetOrientation ¶
func (*APDevice) GetRadioConfig ¶
func (*APDevice) ToConfigMap ¶
ToConfigMap converts AP device to configuration map (for config files)
type APDeviceInterface ¶
type APDeviceInterface interface {
DeviceMarshaler
GetLocation() *[]float64
GetOrientation() *int
GetMapID() *string
GetHeight() *float64
GetX() *float64
GetY() *float64
GetForSite() *bool
GetLocked() *bool
GetRadioConfig() map[string]interface{}
GetBleConfig() map[string]interface{}
GetIotConfig() map[string]interface{}
}
APDeviceInterface defines the interface for AP device operations. Note: The "Interface" suffix is retained because there is a struct named APDevice.
type BandConfig ¶
type BandConfig struct {
// Disabled indicates whether the radio is disabled
Disabled *bool `json:"disabled,omitempty"`
// Channel is the channel number
Channel *int `json:"channel,omitempty"`
// TxPower is the transmission power in dBm
TxPower *int `json:"tx_power,omitempty"`
}
BandConfig represents radio configuration for a specific band
type BaseDevice ¶
type BaseDevice struct {
// Core identification
ID *string `json:"id,omitempty"`
MAC *string `json:"mac,omitempty"`
Serial *string `json:"serial,omitempty"`
Name *string `json:"name,omitempty"`
Model *string `json:"model,omitempty"`
Type *string `json:"type,omitempty"`
Magic *string `json:"magic,omitempty"`
HwRev *string `json:"hw_rev,omitempty"`
SKU *string `json:"sku,omitempty"`
// Metadata
SiteID *string `json:"site_id,omitempty"`
OrgID *string `json:"org_id,omitempty"`
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
DeviceProfileID *string `json:"deviceprofile_id,omitempty"`
// Status
Connected *bool `json:"connected,omitempty"`
Adopted *bool `json:"adopted,omitempty"`
Hostname *string `json:"hostname,omitempty"`
Notes *string `json:"notes,omitempty"`
JSI *bool `json:"jsi,omitempty"`
// Basic config
Tags *[]string `json:"tags,omitempty"`
// Additional configuration for any unmapped fields
AdditionalConfig map[string]interface{} `json:"-"`
}
BaseDevice represents the core device fields with bidirectional data handling
func (*BaseDevice) FromConfigMap ¶
func (bd *BaseDevice) FromConfigMap(data map[string]interface{}) error
FromConfigMap populates device from configuration map (from config files)
func (*BaseDevice) FromMap ¶
func (bd *BaseDevice) FromMap(data map[string]interface{}) error
FromMap populates the BaseDevice from API response data
func (*BaseDevice) GetDeviceProfileID ¶
func (bd *BaseDevice) GetDeviceProfileID() *string
func (*BaseDevice) GetID ¶
func (bd *BaseDevice) GetID() *string
Implement DeviceMarshaler for BaseDevice
func (*BaseDevice) GetMAC ¶
func (bd *BaseDevice) GetMAC() *string
func (*BaseDevice) GetMagic ¶
func (bd *BaseDevice) GetMagic() *string
func (*BaseDevice) GetModel ¶
func (bd *BaseDevice) GetModel() *string
func (*BaseDevice) GetName ¶
func (bd *BaseDevice) GetName() *string
func (*BaseDevice) GetOrgID ¶
func (bd *BaseDevice) GetOrgID() *string
func (*BaseDevice) GetSerial ¶
func (bd *BaseDevice) GetSerial() *string
func (*BaseDevice) GetSiteID ¶
func (bd *BaseDevice) GetSiteID() *string
func (*BaseDevice) GetType ¶
func (bd *BaseDevice) GetType() *string
func (*BaseDevice) ToConfigMap ¶
func (bd *BaseDevice) ToConfigMap() map[string]interface{}
ToConfigMap converts device to configuration map (for config files)
func (*BaseDevice) ToMap ¶
func (bd *BaseDevice) ToMap() map[string]interface{}
ToMap converts the BaseDevice to a map for API operations
type Cache ¶
type Cache struct {
Version int `json:"version"`
Orgs map[string]*OrgData `json:"orgs"` // [orgID]*OrgData
}
Cache represents the new unified cache structure with orgs at top level
type CacheAccessor ¶
type CacheAccessor interface {
// Organizations
GetOrgByName(name string) (*OrgStats, error)
GetOrgByID(id string) (*OrgStats, error)
GetAllOrgs() ([]*OrgStats, error)
// Sites
GetSiteByName(name string) (*MistSite, error)
GetSiteByID(id string) (*MistSite, error)
GetAllSites() ([]*MistSite, error)
// Site Settings
GetSiteSettingBySiteID(siteID string) (*SiteSetting, error)
GetSiteSettingByID(id string) (*SiteSetting, error)
GetAllSiteSettings() ([]*SiteSetting, error)
// Templates
GetRFTemplateByName(name string) (*MistRFTemplate, error)
GetRFTemplateByID(id string) (*MistRFTemplate, error)
GetAllRFTemplates() ([]*MistRFTemplate, error)
GetGWTemplateByName(name string) (*MistGatewayTemplate, error)
GetGWTemplateByID(id string) (*MistGatewayTemplate, error)
GetAllGWTemplates() ([]*MistGatewayTemplate, error)
GetWLANTemplateByName(name string) (*MistWLANTemplate, error)
GetWLANTemplateByID(id string) (*MistWLANTemplate, error)
GetAllWLANTemplates() ([]*MistWLANTemplate, error)
// Networks
GetNetworkByName(name string) (*MistNetwork, error)
GetNetworkByID(id string) (*MistNetwork, error)
GetAllNetworks() ([]*MistNetwork, error)
// WLANs
GetOrgWLANByName(name string) (*MistWLAN, error)
GetOrgWLANByID(id string) (*MistWLAN, error)
GetAllOrgWLANs() ([]*MistWLAN, error)
GetSiteWLANByName(siteID, name string) (*MistWLAN, error)
GetSiteWLANByID(siteID, id string) (*MistWLAN, error)
GetSiteWLANs(siteID string) ([]*MistWLAN, error)
GetAllSiteWLANs() (map[string][]*MistWLAN, error)
// Devices
GetAPByMAC(mac string) (*APDevice, error)
GetAPByName(name string) (*APDevice, error)
GetAPsBySite(siteID string) ([]*APDevice, error)
GetAllAPs() ([]*APDevice, error)
GetSwitchByMAC(mac string) (*MistSwitchDevice, error)
GetSwitchByName(name string) (*MistSwitchDevice, error)
GetSwitchesBySite(siteID string) ([]*MistSwitchDevice, error)
GetAllSwitches() ([]*MistSwitchDevice, error)
GetGatewayByMAC(mac string) (*MistGatewayDevice, error)
GetGatewayByName(name string) (*MistGatewayDevice, error)
GetGatewaysBySite(siteID string) ([]*MistGatewayDevice, error)
GetAllGateways() ([]*MistGatewayDevice, error)
// Device Profiles
GetDeviceProfileByName(name string) (*DeviceProfile, error)
GetDeviceProfileByID(id string) (*DeviceProfile, error)
GetDeviceProfilesByType(deviceType string) ([]*DeviceProfile, error)
GetAllDeviceProfiles() ([]*DeviceProfile, error)
// Device Profile Details (full details from individual API calls)
GetDeviceProfileDetailByName(name string) (*map[string]any, error)
GetDeviceProfileDetailByID(id string) (*map[string]any, error)
GetAllDeviceProfileDetails() ([]*map[string]any, error)
// Device Configurations
GetAPConfigByMAC(mac string) (*APConfig, error)
GetAPConfigByName(name string) (*APConfig, error)
GetAllAPConfigs() ([]*APConfig, error)
GetSwitchConfigByMAC(mac string) (*SwitchConfig, error)
GetSwitchConfigByName(name string) (*SwitchConfig, error)
GetAllSwitchConfigs() ([]*SwitchConfig, error)
GetGatewayConfigByMAC(mac string) (*GatewayConfig, error)
GetGatewayConfigByName(name string) (*GatewayConfig, error)
GetAllGatewayConfigs() ([]*GatewayConfig, error)
// Utility methods
GetCacheStats() (map[string]any, error)
IsInitialized() bool
NeedsRebuild() bool
GetManager() *CacheManager
}
CacheAccessor provides O(1) lookup methods for all cached data
func GetGlobalCacheAccessor ¶
func GetGlobalCacheAccessor() CacheAccessor
GetGlobalCacheAccessor returns the global singleton cache accessor
func NewCacheAccessor ¶
func NewCacheAccessor(cachePath string) CacheAccessor
NewCacheAccessor creates a new cache accessor with the given cache path
type CacheAccessorImpl ¶
type CacheAccessorImpl struct {
// contains filtered or unexported fields
}
CacheAccessorImpl implements the CacheAccessor interface
func (*CacheAccessorImpl) GetAPByMAC ¶
func (ca *CacheAccessorImpl) GetAPByMAC(mac string) (*APDevice, error)
GetAPByMAC retrieves an AP by MAC address with O(1) lookup
func (*CacheAccessorImpl) GetAPByName ¶
func (ca *CacheAccessorImpl) GetAPByName(name string) (*APDevice, error)
GetAPByName retrieves an AP by name with O(1) lookup
func (*CacheAccessorImpl) GetAPConfigByMAC ¶
func (ca *CacheAccessorImpl) GetAPConfigByMAC(mac string) (*APConfig, error)
GetAPConfigByMAC retrieves an AP config by MAC address with O(1) lookup
func (*CacheAccessorImpl) GetAPConfigByName ¶
func (ca *CacheAccessorImpl) GetAPConfigByName(name string) (*APConfig, error)
GetAPConfigByName retrieves an AP config by name with O(1) lookup
func (*CacheAccessorImpl) GetAPsBySite ¶
func (ca *CacheAccessorImpl) GetAPsBySite(siteID string) ([]*APDevice, error)
GetAPsBySite retrieves all APs for a specific site with O(1) lookup
func (*CacheAccessorImpl) GetAllAPConfigs ¶
func (ca *CacheAccessorImpl) GetAllAPConfigs() ([]*APConfig, error)
GetAllAPConfigs returns all AP configurations
func (*CacheAccessorImpl) GetAllAPs ¶
func (ca *CacheAccessorImpl) GetAllAPs() ([]*APDevice, error)
GetAllAPs returns all APs
func (*CacheAccessorImpl) GetAllDeviceProfileDetails ¶
func (ca *CacheAccessorImpl) GetAllDeviceProfileDetails() ([]*map[string]any, error)
GetAllDeviceProfileDetails returns all device profile details
func (*CacheAccessorImpl) GetAllDeviceProfiles ¶
func (ca *CacheAccessorImpl) GetAllDeviceProfiles() ([]*DeviceProfile, error)
GetAllDeviceProfiles returns all device profiles
func (*CacheAccessorImpl) GetAllGWTemplates ¶
func (ca *CacheAccessorImpl) GetAllGWTemplates() ([]*MistGatewayTemplate, error)
GetAllGWTemplates returns all gateway templates
func (*CacheAccessorImpl) GetAllGatewayConfigs ¶
func (ca *CacheAccessorImpl) GetAllGatewayConfigs() ([]*GatewayConfig, error)
GetAllGatewayConfigs returns all gateway configurations
func (*CacheAccessorImpl) GetAllGateways ¶
func (ca *CacheAccessorImpl) GetAllGateways() ([]*MistGatewayDevice, error)
GetAllGateways returns all gateways
func (*CacheAccessorImpl) GetAllNetworks ¶
func (ca *CacheAccessorImpl) GetAllNetworks() ([]*MistNetwork, error)
GetAllNetworks returns all networks
func (*CacheAccessorImpl) GetAllOrgWLANs ¶
func (ca *CacheAccessorImpl) GetAllOrgWLANs() ([]*MistWLAN, error)
GetAllOrgWLANs returns all org-level WLANs
func (*CacheAccessorImpl) GetAllOrgs ¶
func (ca *CacheAccessorImpl) GetAllOrgs() ([]*OrgStats, error)
GetAllOrgs returns all organizations
func (*CacheAccessorImpl) GetAllRFTemplates ¶
func (ca *CacheAccessorImpl) GetAllRFTemplates() ([]*MistRFTemplate, error)
GetAllRFTemplates returns all RF templates
func (*CacheAccessorImpl) GetAllSiteSettings ¶
func (ca *CacheAccessorImpl) GetAllSiteSettings() ([]*SiteSetting, error)
GetAllSiteSettings returns all site settings
func (*CacheAccessorImpl) GetAllSiteWLANs ¶
func (ca *CacheAccessorImpl) GetAllSiteWLANs() (map[string][]*MistWLAN, error)
GetAllSiteWLANs returns all site-level WLANs grouped by site
func (*CacheAccessorImpl) GetAllSites ¶
func (ca *CacheAccessorImpl) GetAllSites() ([]*MistSite, error)
GetAllSites returns all sites
func (*CacheAccessorImpl) GetAllSwitchConfigs ¶
func (ca *CacheAccessorImpl) GetAllSwitchConfigs() ([]*SwitchConfig, error)
GetAllSwitchConfigs returns all switch configurations
func (*CacheAccessorImpl) GetAllSwitches ¶
func (ca *CacheAccessorImpl) GetAllSwitches() ([]*MistSwitchDevice, error)
GetAllSwitches returns all switches
func (*CacheAccessorImpl) GetAllWLANTemplates ¶
func (ca *CacheAccessorImpl) GetAllWLANTemplates() ([]*MistWLANTemplate, error)
GetAllWLANTemplates returns all WLAN templates
func (*CacheAccessorImpl) GetCacheStats ¶
func (ca *CacheAccessorImpl) GetCacheStats() (map[string]any, error)
GetCacheStats returns cache statistics
func (*CacheAccessorImpl) GetDeviceProfileByID ¶
func (ca *CacheAccessorImpl) GetDeviceProfileByID(id string) (*DeviceProfile, error)
GetDeviceProfileByID retrieves a device profile by ID with O(1) lookup
func (*CacheAccessorImpl) GetDeviceProfileByName ¶
func (ca *CacheAccessorImpl) GetDeviceProfileByName(name string) (*DeviceProfile, error)
GetDeviceProfileByName retrieves a device profile by name with O(1) lookup
func (*CacheAccessorImpl) GetDeviceProfileDetailByID ¶
func (ca *CacheAccessorImpl) GetDeviceProfileDetailByID(id string) (*map[string]any, error)
GetDeviceProfileDetailByID retrieves device profile details by ID with O(1) lookup
func (*CacheAccessorImpl) GetDeviceProfileDetailByName ¶
func (ca *CacheAccessorImpl) GetDeviceProfileDetailByName(name string) (*map[string]any, error)
GetDeviceProfileDetailByName retrieves device profile details by name with O(1) lookup
func (*CacheAccessorImpl) GetDeviceProfilesByType ¶
func (ca *CacheAccessorImpl) GetDeviceProfilesByType(deviceType string) ([]*DeviceProfile, error)
GetDeviceProfilesByType retrieves device profiles filtered by type
func (*CacheAccessorImpl) GetGWTemplateByID ¶
func (ca *CacheAccessorImpl) GetGWTemplateByID(id string) (*MistGatewayTemplate, error)
GetGWTemplateByID retrieves a gateway template by ID with O(1) lookup
func (*CacheAccessorImpl) GetGWTemplateByName ¶
func (ca *CacheAccessorImpl) GetGWTemplateByName(name string) (*MistGatewayTemplate, error)
GetGWTemplateByName retrieves a gateway template by name with O(1) lookup
func (*CacheAccessorImpl) GetGatewayByMAC ¶
func (ca *CacheAccessorImpl) GetGatewayByMAC(mac string) (*MistGatewayDevice, error)
GetGatewayByMAC retrieves a gateway by MAC address with O(1) lookup
func (*CacheAccessorImpl) GetGatewayByName ¶
func (ca *CacheAccessorImpl) GetGatewayByName(name string) (*MistGatewayDevice, error)
GetGatewayByName retrieves a gateway by name with O(1) lookup
func (*CacheAccessorImpl) GetGatewayConfigByMAC ¶
func (ca *CacheAccessorImpl) GetGatewayConfigByMAC(mac string) (*GatewayConfig, error)
GetGatewayConfigByMAC retrieves a gateway config by MAC address with O(1) lookup
func (*CacheAccessorImpl) GetGatewayConfigByName ¶
func (ca *CacheAccessorImpl) GetGatewayConfigByName(name string) (*GatewayConfig, error)
GetGatewayConfigByName retrieves a gateway config by name with O(1) lookup
func (*CacheAccessorImpl) GetGatewaysBySite ¶
func (ca *CacheAccessorImpl) GetGatewaysBySite(siteID string) ([]*MistGatewayDevice, error)
GetGatewaysBySite retrieves all gateways for a specific site with O(1) lookup
func (*CacheAccessorImpl) GetManager ¶
func (ca *CacheAccessorImpl) GetManager() *CacheManager
GetManager returns the underlying cache manager
func (*CacheAccessorImpl) GetNetworkByID ¶
func (ca *CacheAccessorImpl) GetNetworkByID(id string) (*MistNetwork, error)
GetNetworkByID retrieves a network by ID with O(1) lookup
func (*CacheAccessorImpl) GetNetworkByName ¶
func (ca *CacheAccessorImpl) GetNetworkByName(name string) (*MistNetwork, error)
GetNetworkByName retrieves a network by name with O(1) lookup
func (*CacheAccessorImpl) GetOrgByID ¶
func (ca *CacheAccessorImpl) GetOrgByID(id string) (*OrgStats, error)
GetOrgByID retrieves an organization by ID with O(1) lookup
func (*CacheAccessorImpl) GetOrgByName ¶
func (ca *CacheAccessorImpl) GetOrgByName(name string) (*OrgStats, error)
GetOrgByName retrieves an organization by name with O(1) lookup
func (*CacheAccessorImpl) GetOrgWLANByID ¶
func (ca *CacheAccessorImpl) GetOrgWLANByID(id string) (*MistWLAN, error)
GetOrgWLANByID retrieves an org-level WLAN by ID with O(1) lookup
func (*CacheAccessorImpl) GetOrgWLANByName ¶
func (ca *CacheAccessorImpl) GetOrgWLANByName(name string) (*MistWLAN, error)
GetOrgWLANByName retrieves an org-level WLAN by name with O(1) lookup
func (*CacheAccessorImpl) GetRFTemplateByID ¶
func (ca *CacheAccessorImpl) GetRFTemplateByID(id string) (*MistRFTemplate, error)
GetRFTemplateByID retrieves an RF template by ID with O(1) lookup
func (*CacheAccessorImpl) GetRFTemplateByName ¶
func (ca *CacheAccessorImpl) GetRFTemplateByName(name string) (*MistRFTemplate, error)
GetRFTemplateByName retrieves an RF template by name with O(1) lookup
func (*CacheAccessorImpl) GetSiteByID ¶
func (ca *CacheAccessorImpl) GetSiteByID(id string) (*MistSite, error)
GetSiteByID retrieves a site by ID with O(1) lookup
func (*CacheAccessorImpl) GetSiteByName ¶
func (ca *CacheAccessorImpl) GetSiteByName(name string) (*MistSite, error)
GetSiteByName retrieves a site by name with O(1) lookup
func (*CacheAccessorImpl) GetSiteSettingByID ¶
func (ca *CacheAccessorImpl) GetSiteSettingByID(id string) (*SiteSetting, error)
GetSiteSettingByID retrieves a site setting by ID with O(1) lookup
func (*CacheAccessorImpl) GetSiteSettingBySiteID ¶
func (ca *CacheAccessorImpl) GetSiteSettingBySiteID(siteID string) (*SiteSetting, error)
GetSiteSettingBySiteID retrieves a site setting by site ID with O(1) lookup
func (*CacheAccessorImpl) GetSiteWLANByID ¶
func (ca *CacheAccessorImpl) GetSiteWLANByID(siteID, id string) (*MistWLAN, error)
GetSiteWLANByID retrieves a site-level WLAN by ID with O(1) lookup
func (*CacheAccessorImpl) GetSiteWLANByName ¶
func (ca *CacheAccessorImpl) GetSiteWLANByName(siteID, name string) (*MistWLAN, error)
GetSiteWLANByName retrieves a site-level WLAN by name with O(1) lookup
func (*CacheAccessorImpl) GetSiteWLANs ¶
func (ca *CacheAccessorImpl) GetSiteWLANs(siteID string) ([]*MistWLAN, error)
GetSiteWLANs returns all WLANs for a specific site
func (*CacheAccessorImpl) GetSwitchByMAC ¶
func (ca *CacheAccessorImpl) GetSwitchByMAC(mac string) (*MistSwitchDevice, error)
GetSwitchByMAC retrieves a switch by MAC address with O(1) lookup
func (*CacheAccessorImpl) GetSwitchByName ¶
func (ca *CacheAccessorImpl) GetSwitchByName(name string) (*MistSwitchDevice, error)
GetSwitchByName retrieves a switch by name with O(1) lookup
func (*CacheAccessorImpl) GetSwitchConfigByMAC ¶
func (ca *CacheAccessorImpl) GetSwitchConfigByMAC(mac string) (*SwitchConfig, error)
GetSwitchConfigByMAC retrieves a switch config by MAC address with O(1) lookup
func (*CacheAccessorImpl) GetSwitchConfigByName ¶
func (ca *CacheAccessorImpl) GetSwitchConfigByName(name string) (*SwitchConfig, error)
GetSwitchConfigByName retrieves a switch config by name with O(1) lookup
func (*CacheAccessorImpl) GetSwitchesBySite ¶
func (ca *CacheAccessorImpl) GetSwitchesBySite(siteID string) ([]*MistSwitchDevice, error)
GetSwitchesBySite retrieves all switches for a specific site with O(1) lookup
func (*CacheAccessorImpl) GetWLANTemplateByID ¶
func (ca *CacheAccessorImpl) GetWLANTemplateByID(id string) (*MistWLANTemplate, error)
GetWLANTemplateByID retrieves a WLAN template by ID with O(1) lookup
func (*CacheAccessorImpl) GetWLANTemplateByName ¶
func (ca *CacheAccessorImpl) GetWLANTemplateByName(name string) (*MistWLANTemplate, error)
GetWLANTemplateByName retrieves a WLAN template by name with O(1) lookup
func (*CacheAccessorImpl) IsInitialized ¶
func (ca *CacheAccessorImpl) IsInitialized() bool
IsInitialized checks if the cache is initialized
func (*CacheAccessorImpl) NeedsRebuild ¶
func (ca *CacheAccessorImpl) NeedsRebuild() bool
NeedsRebuild checks if the cache needs to be rebuilt
type CacheIndexes ¶
type CacheIndexes struct {
// Organizations
OrgsByName map[string]*OrgStats
OrgsByID map[string]*OrgStats
// Sites
SitesByName map[string]*MistSite
SitesByID map[string]*MistSite
// Site Settings
SiteSettingsBySiteID map[string]*SiteSetting
SiteSettingsByID map[string]*SiteSetting
// Templates
RFTemplatesByName map[string]*MistRFTemplate
RFTemplatesByID map[string]*MistRFTemplate
GWTemplatesByName map[string]*MistGatewayTemplate
GWTemplatesByID map[string]*MistGatewayTemplate
WLANTemplatesByName map[string]*MistWLANTemplate
WLANTemplatesByID map[string]*MistWLANTemplate
// Networks
NetworksByName map[string]*MistNetwork
NetworksByID map[string]*MistNetwork
// WLANs
OrgWLANsByName map[string]*MistWLAN
OrgWLANsByID map[string]*MistWLAN
SiteWLANsByName map[string]map[string]*MistWLAN // [siteID][name]
SiteWLANsByID map[string]map[string]*MistWLAN // [siteID][id]
// Devices - using normalized MAC addresses as keys
APsByName map[string]*APDevice
APsByMAC map[string]*APDevice
APsBySite map[string][]*APDevice
SwitchesByName map[string]*MistSwitchDevice
SwitchesByMAC map[string]*MistSwitchDevice
SwitchesBySite map[string][]*MistSwitchDevice
GatewaysByName map[string]*MistGatewayDevice
GatewaysByMAC map[string]*MistGatewayDevice
GatewaysBySite map[string][]*MistGatewayDevice
// Device Profiles
DeviceProfilesByName map[string]*DeviceProfile
DeviceProfilesByID map[string]*DeviceProfile
// Device Profile Details (full details from individual API calls)
DeviceProfileDetailsByName map[string]*map[string]interface{}
DeviceProfileDetailsByID map[string]*map[string]interface{}
// Device Configurations
APConfigsByName map[string]*APConfig
APConfigsByMAC map[string]*APConfig
SwitchConfigsByName map[string]*SwitchConfig
SwitchConfigsByMAC map[string]*SwitchConfig
GatewayConfigsByName map[string]*GatewayConfig
GatewayConfigsByMAC map[string]*GatewayConfig
}
CacheIndexes provides O(1) lookup indexes for all cached data
func NewCacheIndexes ¶
func NewCacheIndexes() *CacheIndexes
NewCacheIndexes creates and initializes a new CacheIndexes struct
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager manages the unified cache system
func NewCacheManager ¶
func NewCacheManager(cachePath string) *CacheManager
NewCacheManager creates a new cache manager instance
func (*CacheManager) GetCache ¶
func (cm *CacheManager) GetCache() (*Cache, error)
GetCache returns a pointer to the internal cache for reading.
WARNING: The returned pointer provides direct access to internal state. Callers MUST NOT modify the returned cache or any data within it. For thread-safe access when performing multiple reads, use ReadCache instead. The read lock is only held during this method call, not while using the pointer.
func (*CacheManager) GetCacheStats ¶
func (cm *CacheManager) GetCacheStats() (map[string]any, error)
GetCacheStats returns statistics about the cache
func (*CacheManager) GetIndexes ¶
func (cm *CacheManager) GetIndexes() (*CacheIndexes, error)
GetIndexes returns a pointer to the internal cache indexes for reading.
WARNING: The returned pointer provides direct access to internal state. Callers MUST NOT modify the returned indexes or any data within them. For thread-safe access when performing multiple reads, use ReadIndexes instead. The read lock is only held during this method call, not while using the pointer.
func (*CacheManager) Initialize ¶
func (cm *CacheManager) Initialize() error
Initialize loads the cache from disk and builds indexes
func (*CacheManager) InitializeWithOptions ¶
func (cm *CacheManager) InitializeWithOptions(forceRecreate bool) error
InitializeWithOptions loads the cache with optional force mode that skips integrity checks
func (*CacheManager) ReadCache ¶
func (cm *CacheManager) ReadCache(fn func(*Cache) error) error
ReadCache provides thread-safe read access to the cache. The callback function is executed while holding the read lock, ensuring consistent reads even during concurrent writes. Use this method when performing multiple related reads that must be consistent.
func (*CacheManager) ReadIndexes ¶
func (cm *CacheManager) ReadIndexes(fn func(*CacheIndexes) error) error
ReadIndexes provides thread-safe read access to the cache indexes. The callback function is executed while holding the read lock, ensuring consistent reads even during concurrent writes.
func (*CacheManager) ReplaceCache ¶
func (cm *CacheManager) ReplaceCache(newCache *Cache) error
ReplaceCache atomically replaces the entire cache and rebuilds indexes
func (*CacheManager) SaveCache ¶
func (cm *CacheManager) SaveCache() error
SaveCache saves the current cache to disk
type CacheMetadata ¶
type CacheMetadata struct {
Created time.Time `json:"created"`
OrgID string `json:"org_id"`
SitesCount int `json:"sites_count"`
DevicesCount int `json:"devices_count"`
Version string `json:"version"`
Expired bool `json:"expired,omitempty"`
NeedsRebuild bool `json:"needs_rebuild,omitempty"`
}
CacheMetadata contains metadata about the cache
type CacheVerificationStatus ¶
type CacheVerificationStatus int
CacheVerificationStatus represents the status of cache verification
const ( CacheOK CacheVerificationStatus = iota CacheCorrupted CacheOutOfDate CacheFailed )
func VerifyCacheIntegrity ¶
func VerifyCacheIntegrity(_ context.Context, client Client, orgID string) (CacheVerificationStatus, error)
VerifyCacheIntegrity verifies the integrity of the cache system with retry logic This ensures proper initialization timing and prevents false negatives
type Cacher ¶
type Cacher interface {
// Core operations
Load() error
Save() error
Clear() error
// Data access (unified methods)
GetOrgData(orgID string) (*OrgData, error)
SetOrgData(orgID string, data *OrgData) error
// Site operations
GetSite(identifier string) (*MistSite, error)
GetAllSites() ([]*MistSite, error)
UpdateSite(site *MistSite) error
// Device operations
GetDevice(mac string) (*UnifiedDevice, error)
GetDevicesByType(siteID, deviceType string) ([]UnifiedDevice, error)
UpdateDevice(device *UnifiedDevice) error
// Config operations
GetConfigs(orgID, deviceType string) ([]interface{}, error)
UpdateConfigs(orgID, deviceType string, configs []interface{}) error
MergeConfigs(orgID, deviceType string, configs []interface{}) error
// Inventory operations
GetInventory(deviceType string) ([]interface{}, error)
UpdateInventory(deviceType string, items []interface{}) error
// Profile operations
GetProfiles(profileType string) ([]interface{}, error)
UpdateProfiles(profileType string, profiles []interface{}) error
// Metadata
GetMetadata() *CacheMetadata
UpdateMetadata(metadata *CacheMetadata)
// State management
IsDirty() bool
MarkDirty()
GetPath() string
}
Cacher defines the unified interface for all cache operations. It abstracts cache storage, retrieval, and management across different implementations.
type Client ¶
type Client interface {
// Organizations
GetOrgStats(ctx context.Context, orgID string) (*OrgStats, error)
// Sites
GetSiteName(siteID string) (string, bool)
GetOrgName(orgID string) (string, bool)
GetSites(ctx context.Context, orgID string) ([]*MistSite, error)
GetSite(ctx context.Context, siteID string) (*MistSite, error)
GetSiteByName(ctx context.Context, name, orgID string) (*MistSite, error)
GetSiteByIdentifier(ctx context.Context, siteIdentifier string) (*MistSite, error)
CreateSite(ctx context.Context, site *MistSite) (*MistSite, error)
UpdateSite(ctx context.Context, siteID string, site *MistSite) (*MistSite, error)
UpdateSiteByName(ctx context.Context, siteName string, site *MistSite) (*MistSite, error)
DeleteSite(ctx context.Context, siteID string) error
DeleteSiteByName(ctx context.Context, siteName string) error
// Site Settings
GetSiteSetting(ctx context.Context, siteID string) (*SiteSetting, error)
// Devices API
GetDevices(ctx context.Context, siteID string, deviceType string) ([]UnifiedDevice, error)
GetDeviceByMAC(ctx context.Context, mac string) (*UnifiedDevice, error)
GetDeviceByID(ctx context.Context, siteID, deviceID string) (*UnifiedDevice, error)
GetDeviceByName(ctx context.Context, siteID, name string) (*UnifiedDevice, error)
GetDevicesByType(ctx context.Context, siteID string, deviceType string) ([]UnifiedDevice, error)
UpdateDevice(ctx context.Context, siteID string, deviceID string, device *UnifiedDevice) (*UnifiedDevice, error)
AssignDevice(ctx context.Context, orgID string, siteID string, mac string) (*UnifiedDevice, error)
UnassignDevice(ctx context.Context, orgID string, siteID string, deviceID string) error
AssignDevicesToSite(ctx context.Context, orgID string, siteID string, macs []string, noReassign bool) error
UnassignDevicesFromSite(ctx context.Context, orgID string, macs []string) error
// Inventory API
DeleteDevicesFromSite(ctx context.Context, macs []string) error
GetInventoryConfig(inventoryPath string) (*InventoryConfig, error)
GetInventory(ctx context.Context, orgID string, deviceType string) ([]*MistInventoryItem, error)
GetInventoryItem(ctx context.Context, orgID string, itemID string) (*MistInventoryItem, error)
GetInventoryItemByMAC(ctx context.Context, orgID string, macAddress string) (*MistInventoryItem, error)
UpdateInventoryItem(ctx context.Context, orgID string, itemID string, item *MistInventoryItem) (*MistInventoryItem, error)
ClaimInventoryItem(ctx context.Context, orgID string, claimCodes []string) ([]*MistInventoryItem, error)
ReleaseInventoryItem(ctx context.Context, orgID string, itemIDs []string) error
AssignInventoryItemsToSite(ctx context.Context, orgID string, siteID string, itemMACs []string) error
UnassignInventoryItemsFromSite(ctx context.Context, orgID string, itemMACs []string) error
// Cache Management
ForceRebuildCache(ctx context.Context) error
UpdateCacheForTypes(ctx context.Context, deviceTypes []string, siteNames []string) error
PopulateDeviceCacheForSite(ctx context.Context, siteID string, deviceType string) error
// Device Profiles
GetDeviceProfiles(ctx context.Context, orgID string, profileType string) ([]DeviceProfile, error)
GetDeviceProfile(ctx context.Context, orgID string, profileID string) (*DeviceProfile, error)
GetDeviceProfileByName(ctx context.Context, orgID string, name string, profileType string) (*DeviceProfile, error)
AssignDeviceProfile(ctx context.Context, orgID string, profileID string, macs []string) (*DeviceProfileAssignResult, error)
UnassignDeviceProfiles(ctx context.Context, orgID string, profileID string, macs []string) error
// Templates and Networks
GetRFTemplates(ctx context.Context, orgID string) ([]MistRFTemplate, error)
GetGatewayTemplates(ctx context.Context, orgID string) ([]MistGatewayTemplate, error)
GetWLANTemplates(ctx context.Context, orgID string) ([]MistWLANTemplate, error)
GetNetworks(ctx context.Context, orgID string) ([]MistNetwork, error)
GetWLANs(ctx context.Context, orgID string) ([]MistWLAN, error)
GetSiteWLANs(ctx context.Context, siteID string) ([]MistWLAN, error)
// Configuration
SetRateLimit(limit int, duration time.Duration)
SetResultsLimit(limit int)
SetDebug(debug bool)
// Lifecycle
Close() error // Release resources; call when client is no longer needed
// Authentication & User Info
ValidateAPIToken(ctx context.Context) (*SelfResponse, error)
GetAPIUserInfo(ctx context.Context) (*SelfResponse, error)
// Returns the configuration directory where settings files are stored
GetConfigDirectory() string
// Returns the schema directory where JSON schema files are stored
GetSchemaDirectory() string
// Cache operations
GetCacheAccessor() CacheAccessor
GetDeviceCache() *DeviceCache
// Raw data operations for detail view
GetRawDeviceJSON(ctx context.Context, siteID, deviceID string) (string, error)
// Device extensive information query
QueryDeviceExtensive(ctx context.Context, siteID, deviceID string) error
// AP-specific methods for backward compatibility
GetAPBySerialOrMAC(ctx context.Context, siteID, serial, mac string) (*AP, error)
// Search API
SearchWiredClients(ctx context.Context, orgID string, text string) (*MistWiredClientResponse, error)
SearchWirelessClients(ctx context.Context, orgID string, text string) (*MistWirelessClientResponse, error)
// Device Configuration API
GetDeviceConfig(ctx context.Context, siteID, deviceID string) (*DeviceConfigResponse, error)
GetAPConfig(ctx context.Context, siteID, deviceID string) (*APConfig, error)
GetSwitchConfig(ctx context.Context, siteID, deviceID string) (*SwitchConfig, error)
GetGatewayConfig(ctx context.Context, siteID, deviceID string) (*GatewayConfig, error)
BatchGetDeviceConfigs(ctx context.Context, devices []DeviceInfo) (map[string]*DeviceConfig, map[string]error)
// contains filtered or unexported methods
}
Client is the interface for Mist API operations
func NewClientWithOptions ¶
func NewClientWithOptions(apiToken, baseURL, orgID string, options ...ClientOption) Client
NewClientWithOptions creates a new client with the provided options
func NewMockClient ¶
NewMockClient creates a new mock implementation of the Mist client
type ClientOption ¶
type ClientOption func(*mistClient)
ClientOption defines functional options for the client
func WithCacheDirectory ¶
func WithCacheDirectory(cacheDir string) ClientOption
WithCacheDirectory configures the cache directory path
func WithCacheTTL ¶
func WithCacheTTL(ttl time.Duration) ClientOption
WithCacheTTL sets the cache TTL
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient sets a custom HTTP client
func WithInventory ¶
func WithInventory(inventoryPath string) ClientOption
WithInventory configures an inventory file path
func WithRateLimit ¶
func WithRateLimit(limit int, duration time.Duration) ClientOption
WithRateLimit sets rate limiting
func WithResultsLimit ¶
func WithResultsLimit(limit int) ClientOption
WithResultsLimit sets the results limit for pagination
type ClientTokenValidator ¶
type ClientTokenValidator struct{}
ClientTokenValidator implements the encryption.TokenValidator interface using the Mist API client for token validation
func NewClientTokenValidator ¶
func NewClientTokenValidator() *ClientTokenValidator
NewClientTokenValidator creates a new ClientTokenValidator
func (*ClientTokenValidator) ValidateToken ¶
func (v *ClientTokenValidator) ValidateToken(ctx context.Context, apiBaseURL, token string) (*encryption.TokenValidationResult, error)
ValidateToken validates an API token by making a request to the Mist API This follows the requirements in encryption.txt: 1. GET /api/v1/self with token in Authorization header 2. Check for 200 response and proper content-type 3. Extract user and org information from response
type Config ¶
type Config struct {
BaseURL string
APIToken string
Organization string
Timeout time.Duration
Debug bool
RateLimit int // Requests per minute (0 = no limit)
RateDuration time.Duration // Duration for rate limiting
CacheTTL time.Duration // Cache TTL (0 = default 5 minutes)
ResultsLimit int // Maximum results per API call
HTTPClient *http.Client // Custom HTTP client
MaxRetries int // Maximum number of retry attempts (0 = no retries)
RetryBackoff time.Duration // Initial backoff duration for retries (0 = default 250ms)
LocalCache string // Path to local cache file for ID mappings
OrgID string // Organization ID for cache operations
Inventory string // Path to inventory file
DryRun bool // When true, don't make actual changes via API
}
Config holds API credentials and options
type Device ¶
type Device struct {
// Core fields from InventoryItem
Id *UUID `json:"id,omitempty"`
Mac *string `json:"mac,omitempty"`
Serial *string `json:"serial,omitempty"`
Name *string `json:"name,omitempty"`
Model *string `json:"model,omitempty"`
SKU *string `json:"sku,omitempty"`
HwRev *string `json:"hw_rev,omitempty"`
Type *string `json:"type,omitempty"`
Magic *string `json:"magic,omitempty"`
Hostname *string `json:"hostname,omitempty"`
JSI *bool `json:"jsi,omitempty"`
OrgId *string `json:"org_id,omitempty"`
SiteId *string `json:"site_id,omitempty"`
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
Connected *bool `json:"connected,omitempty"`
Adopted *bool `json:"adopted,omitempty"`
// AP-specific fields
Location *[]float64 `json:"location,omitempty"`
Orientation *int `json:"orientation,omitempty"`
Status *string `json:"status,omitempty"`
Led *bool `json:"led,omitempty"`
MapID *string `json:"map_id,omitempty"`
RadioConfig interface{} `json:"radio_config,omitempty"`
Notes *string `json:"notes,omitempty"`
TagUUID *string `json:"tag_uuid,omitempty"`
TagID *int `json:"tag_id,omitempty"`
EvpnScope *string `json:"evpn_scope,omitempty"`
EvpntopoID *string `json:"evpntopo_id,omitempty"`
StIPBase *string `json:"st_ip_base,omitempty"`
BundledMac *string `json:"bundled_mac,omitempty"`
DeviceProfileId *string `json:"deviceprofile_id,omitempty"`
// Switch-specific fields
IP *string `json:"ip,omitempty"`
Port *int `json:"port,omitempty"`
Version *string `json:"version,omitempty"`
// Gateway-specific fields
MgmtIntf *string `json:"mgmt_intf,omitempty"`
// Additional device configuration - varies by device type
Config map[string]interface{} `json:"config,omitempty"`
}
Device represents a universal device in the Mist system This type is used to handle all device types (AP, Switch, Gateway) uniformly
type DeviceCache ¶
type DeviceCache struct {
// Primary storage: all devices by MAC address
Devices map[string]UnifiedDevice // MAC -> UnifiedDevice
// Indexes for quick lookups
SiteIndex map[string][]string // SiteID -> []MAC
TypeIndex map[string][]string // DeviceType -> []MAC
NameIndex map[string]string // Name -> MAC
// Cache management
LastUpdated time.Time
// contains filtered or unexported fields
}
DeviceCache structure with proper indexing using new bidirectional data handling
func (*DeviceCache) AddDevice ¶
func (c *DeviceCache) AddDevice(device UnifiedDevice)
AddDevice adds or updates a device in the cache
func (*DeviceCache) Count ¶
func (c *DeviceCache) Count() int
Count returns the total number of devices in the cache
func (*DeviceCache) CountBySite ¶
func (c *DeviceCache) CountBySite() map[string]int
CountBySite returns the number of devices for each site
func (*DeviceCache) CountByType ¶
func (c *DeviceCache) CountByType() map[string]int
CountByType returns the number of devices of each type
func (*DeviceCache) GetAllDevices ¶
func (c *DeviceCache) GetAllDevices() []UnifiedDevice
GetAllDevices returns all devices in the cache
func (*DeviceCache) GetCacheStats ¶
func (c *DeviceCache) GetCacheStats() (hits, misses int64, hitRate float64)
GetCacheStats returns cache performance statistics
func (*DeviceCache) GetDeviceByMAC ¶
func (c *DeviceCache) GetDeviceByMAC(mac string) (UnifiedDevice, bool)
GetDeviceByMAC retrieves a device by MAC address
func (*DeviceCache) GetDeviceByName ¶
func (c *DeviceCache) GetDeviceByName(name string) (UnifiedDevice, bool)
GetDeviceByName retrieves a device by name
func (*DeviceCache) GetDevicesBySite ¶
func (c *DeviceCache) GetDevicesBySite(siteID string) []UnifiedDevice
GetDevicesBySite retrieves all devices for a site
func (*DeviceCache) GetDevicesBySiteAndType ¶
func (c *DeviceCache) GetDevicesBySiteAndType(siteID, deviceType string) []UnifiedDevice
GetDevicesBySiteAndType retrieves all devices for a site of a specific type
func (*DeviceCache) GetDevicesByType ¶
func (c *DeviceCache) GetDevicesByType(deviceType string) []UnifiedDevice
GetDevicesByType retrieves all devices of a specific type
func (*DeviceCache) MergeDeviceInfo ¶
func (c *DeviceCache) MergeDeviceInfo(device UnifiedDevice)
MergeDeviceInfo merges new device information with existing data
func (*DeviceCache) RemoveDevice ¶
func (c *DeviceCache) RemoveDevice(mac string)
RemoveDevice removes a device from the cache
type DeviceConfig ¶
type DeviceConfig struct {
// The actual device configuration data stored as interface{}
// to support AP, Switch, and Gateway configs
Data interface{} `json:"data"`
// Device type for runtime type assertion
Type string `json:"type"`
// Common fields for indexing
ID string `json:"id"`
Name string `json:"name"`
MAC string `json:"mac"`
SiteID string `json:"site_id"`
}
DeviceConfig represents a device configuration retrieved from the API It's a wrapper that can hold any device type configuration
type DeviceConfigResponse ¶
type DeviceConfigResponse struct {
// Raw JSON data from the API
Raw map[string]interface{}
}
DeviceConfigResponse represents the API response for a device configuration
func (*DeviceConfigResponse) ToDeviceConfig ¶
func (r *DeviceConfigResponse) ToDeviceConfig() (*DeviceConfig, error)
ToDeviceConfig converts the raw response to a typed DeviceConfig
type DeviceInfo ¶
DeviceInfo contains the minimal information needed to fetch a device config
type DeviceLookupOptions ¶
type DeviceLookupOptions struct {
// Context for API calls
Ctx context.Context
// SiteID is the ID of the site to search in (optional)
SiteID string
// OrgID is the ID of the organization to search in (optional)
OrgID string
// DeviceType filters the lookup to a specific device type (ap, switch, gateway)
DeviceType string
// SearchOrder determines where to look first (cache, api, or both)
// Default is both, starting with cache
SearchOrder string
}
DeviceLookupOptions contains options for device lookup operations
func DefaultDeviceLookupOptions ¶
func DefaultDeviceLookupOptions() DeviceLookupOptions
DefaultDeviceLookupOptions returns the default options for device lookup
type DeviceMarshaler ¶
type DeviceMarshaler interface {
GetID() *string
GetMAC() *string
GetSerial() *string
GetName() *string
GetModel() *string
GetType() *string
GetMagic() *string
GetSiteID() *string
GetOrgID() *string
GetDeviceProfileID() *string
ToMap() map[string]interface{}
FromMap(data map[string]interface{}) error
ToConfigMap() map[string]interface{}
FromConfigMap(data map[string]interface{}) error
}
DeviceMarshaler defines the common interface for bidirectional device data transformation. It provides type-safe access to core device fields and marshaling operations.
type DeviceProfile ¶
type DeviceProfile struct {
// Core fields present in all device profile types
// ID is the unique identifier for the device profile
ID *string `json:"id,omitempty"`
// Name is the name of the device profile
Name *string `json:"name,omitempty"`
// Type is the device type this profile applies to (ap, switch, gateway)
Type *string `json:"type,omitempty"`
// OrgID is the organization ID
OrgID *string `json:"org_id,omitempty"`
// CreatedTime is when the object has been created, in epoch
CreatedTime *float64 `json:"created_time,omitempty"`
// ModifiedTime is when the object has been modified for the last time, in epoch
ModifiedTime *float64 `json:"modified_time,omitempty"`
// ForSite indicates if this is a site-level profile
ForSite *bool `json:"for_site,omitempty"`
// SiteID is the site ID if this is a site-level profile
SiteID *string `json:"site_id,omitempty"`
// Additional configuration for any unmapped fields
AdditionalConfig map[string]interface{} `json:"-"`
}
DeviceProfile represents a Mist device profile with core fields This serves as the base structure for all device profile types
func SortDeviceProfiles ¶
func SortDeviceProfiles(profiles []*DeviceProfile) []*DeviceProfile
SortDeviceProfiles sorts device profiles by name
func (*DeviceProfile) FromMap ¶
func (dp *DeviceProfile) FromMap(data map[string]interface{}) error
FromMap populates the device profile from a map
func (*DeviceProfile) GetCreatedTime ¶
func (dp *DeviceProfile) GetCreatedTime() *float64
func (*DeviceProfile) GetForSite ¶
func (dp *DeviceProfile) GetForSite() *bool
func (*DeviceProfile) GetID ¶
func (dp *DeviceProfile) GetID() *string
Implement the interface for the base DeviceProfile
func (*DeviceProfile) GetModifiedTime ¶
func (dp *DeviceProfile) GetModifiedTime() *float64
func (*DeviceProfile) GetName ¶
func (dp *DeviceProfile) GetName() *string
func (*DeviceProfile) GetOrgID ¶
func (dp *DeviceProfile) GetOrgID() *string
func (*DeviceProfile) GetSiteID ¶
func (dp *DeviceProfile) GetSiteID() *string
func (*DeviceProfile) GetType ¶
func (dp *DeviceProfile) GetType() *string
func (*DeviceProfile) ToMap ¶
func (dp *DeviceProfile) ToMap() map[string]interface{}
ToMap converts the device profile to a map for API operations
type DeviceProfileAP ¶
type DeviceProfileAP struct {
DeviceProfile
// AP-specific configuration fields
Aeroscout map[string]interface{} `json:"aeroscout,omitempty"`
BleConfig map[string]interface{} `json:"ble_config,omitempty"`
DisableEth1 *bool `json:"disable_eth1,omitempty"`
DisableEth2 *bool `json:"disable_eth2,omitempty"`
DisableEth3 *bool `json:"disable_eth3,omitempty"`
DisableModule *bool `json:"disable_module,omitempty"`
EslConfig map[string]interface{} `json:"esl_config,omitempty"`
Height *float64 `json:"height,omitempty"`
IotConfig map[string]interface{} `json:"iot_config,omitempty"`
IPConfig map[string]interface{} `json:"ip_config,omitempty"`
LacpConfig map[string]interface{} `json:"lacp_config,omitempty"`
Led map[string]interface{} `json:"led,omitempty"`
MapID *string `json:"map_id,omitempty"`
Mesh map[string]interface{} `json:"mesh,omitempty"`
Notes *string `json:"notes,omitempty"`
NtpServers []string `json:"ntp_servers,omitempty"`
Orientation *int `json:"orientation,omitempty"`
PoePassthrough *bool `json:"poe_passthrough,omitempty"`
X *float64 `json:"x,omitempty"`
Y *float64 `json:"y,omitempty"`
// Additional AP-specific fields from schema and API response
RadioConfig map[string]interface{} `json:"radio_config,omitempty"`
SwitchConfig map[string]interface{} `json:"switch_config,omitempty"`
UsbConfig map[string]interface{} `json:"usb_config,omitempty"`
UplinkPortConfig map[string]interface{} `json:"uplink_port_config,omitempty"`
Vars map[string]string `json:"vars,omitempty"`
PortConfig map[string]interface{} `json:"port_config,omitempty"`
PwrConfig map[string]interface{} `json:"pwr_config,omitempty"`
Centrak map[string]interface{} `json:"centrak,omitempty"`
// Additional fields that may be present
AdditionalConfig map[string]interface{} `json:"-"`
}
DeviceProfileAP represents the complete AP device profile structure
func (*DeviceProfileAP) FromMap ¶
func (dp *DeviceProfileAP) FromMap(data map[string]interface{}) error
FromMap populates the DeviceProfileAP from a map
func (*DeviceProfileAP) ToMap ¶
func (dp *DeviceProfileAP) ToMap() map[string]interface{}
ToMap converts the DeviceProfileAP to a map
type DeviceProfileAssignResult ¶
type DeviceProfileAssignResult struct {
// Success contains the list of MAC addresses that were successfully assigned
Success []string `json:"success,omitempty"`
// Errors contains any errors that occurred during assignment
Errors map[string]string `json:"errors,omitempty"`
}
DeviceProfileAssignResult represents the result of assigning a device profile
type DeviceProfileGateway ¶
type DeviceProfileGateway struct {
DeviceProfile
// Gateway-specific configuration fields
AdditionalConfigCmds []string `json:"additional_config_cmds,omitempty"`
BgpConfig map[string]map[string]interface{} `json:"bgp_config,omitempty"`
DhcpdConfig map[string]interface{} `json:"dhcpd_config,omitempty"`
DnsOverride *bool `json:"dnsOverride,omitempty"`
DnsServers []string `json:"dns_servers,omitempty"`
DnsSuffix []string `json:"dns_suffix,omitempty"`
ExtraRoutes map[string]map[string]interface{} `json:"extra_routes,omitempty"`
ExtraRoutes6 map[string]map[string]interface{} `json:"extra_routes6,omitempty"`
GatewayMatching map[string]interface{} `json:"gateway_matching,omitempty"`
IdpProfiles map[string]map[string]interface{} `json:"idp_profiles,omitempty"`
IPConfigs map[string]map[string]interface{} `json:"ip_configs,omitempty"`
NtpOverride *bool `json:"ntpOverride,omitempty"`
NtpServers []string `json:"ntp_servers,omitempty"`
PathPreferences map[string]map[string]interface{} `json:"path_preferences,omitempty"`
PortConfig map[string]map[string]interface{} `json:"port_config,omitempty"`
ServicePolicies []map[string]interface{} `json:"service_policies,omitempty"`
// Additional Gateway-specific fields from schema
Networks []map[string]interface{} `json:"networks,omitempty"`
OobIPConfig map[string]interface{} `json:"oob_ip_config,omitempty"`
RouterID *string `json:"router_id,omitempty"`
RoutingPolicies map[string]map[string]interface{} `json:"routing_policies,omitempty"`
TunnelConfigs map[string]map[string]interface{} `json:"tunnel_configs,omitempty"`
TunnelProviderOptions map[string]interface{} `json:"tunnel_provider_options,omitempty"`
VrfConfig map[string]interface{} `json:"vrf_config,omitempty"`
VrfInstances map[string]map[string]interface{} `json:"vrf_instances,omitempty"`
// Additional fields that may be present
AdditionalConfig map[string]interface{} `json:"-"`
}
DeviceProfileGateway represents the complete Gateway device profile structure
func (*DeviceProfileGateway) FromMap ¶
func (dp *DeviceProfileGateway) FromMap(data map[string]interface{}) error
FromMap populates the DeviceProfileGateway from a map
func (*DeviceProfileGateway) ToMap ¶
func (dp *DeviceProfileGateway) ToMap() map[string]interface{}
ToMap converts the DeviceProfileGateway to a map
type DeviceProfileMarshaler ¶
type DeviceProfileMarshaler interface {
GetID() *string
GetName() *string
GetType() *string
GetOrgID() *string
GetCreatedTime() *float64
GetModifiedTime() *float64
GetForSite() *bool
GetSiteID() *string
ToMap() map[string]interface{}
FromMap(data map[string]interface{}) error
}
DeviceProfileMarshaler defines the common interface for bidirectional device profile data transformation between API representations and structured types.
func NewDeviceProfileFromType ¶
func NewDeviceProfileFromType(profileType string) DeviceProfileMarshaler
NewDeviceProfileFromType creates a specific device profile type based on the type string
type DeviceProfileSwitch ¶
type DeviceProfileSwitch struct {
DeviceProfile
// Switch-specific configuration fields
AclPolicies []map[string]interface{} `json:"acl_policies,omitempty"`
AclTags map[string]map[string]interface{} `json:"acl_tags,omitempty"`
AdditionalConfigCmds []string `json:"additional_config_cmds,omitempty"`
AggregateRoutes map[string]map[string]interface{} `json:"aggregate_routes,omitempty"`
AggregateRoutes6 map[string]map[string]interface{} `json:"aggregate_routes6,omitempty"`
DhcpSnooping map[string]interface{} `json:"dhcp_snooping,omitempty"`
DhcpdConfig map[string]interface{} `json:"dhcpd_config,omitempty"`
DnsServers []string `json:"dns_servers,omitempty"`
DnsSuffix []string `json:"dns_suffix,omitempty"`
EvpnConfig map[string]interface{} `json:"evpn_config,omitempty"`
ExtraRoutes map[string]map[string]interface{} `json:"extra_routes,omitempty"`
ExtraRoutes6 map[string]map[string]interface{} `json:"extra_routes6,omitempty"`
IPConfig map[string]interface{} `json:"ip_config,omitempty"`
IotConfig map[string]map[string]interface{} `json:"iot_config,omitempty"`
MistNac map[string]interface{} `json:"mist_nac,omitempty"`
Networks map[string]map[string]interface{} `json:"networks,omitempty"`
NtpServers []string `json:"ntp_servers,omitempty"`
OobIPConfig map[string]interface{} `json:"oob_ip_config,omitempty"`
OspfAreas map[string]map[string]interface{} `json:"ospf_areas,omitempty"`
OtherIPConfigs map[string]map[string]interface{} `json:"other_ip_configs,omitempty"`
PortConfig map[string]map[string]interface{} `json:"port_config,omitempty"`
PortMirroring map[string]map[string]interface{} `json:"port_mirroring,omitempty"`
PortUsages map[string]map[string]interface{} `json:"port_usages,omitempty"`
RadiusConfig map[string]interface{} `json:"radius_config,omitempty"`
RemoteSyslog map[string]interface{} `json:"remote_syslog,omitempty"`
SnmpConfig map[string]interface{} `json:"snmp_config,omitempty"`
StpConfig map[string]interface{} `json:"stp_config,omitempty"`
SwitchMgmt map[string]interface{} `json:"switch_mgmt,omitempty"`
UseRouterIDAsSourceIP *bool `json:"use_router_id_as_source_ip,omitempty"`
VrfConfig map[string]interface{} `json:"vrf_config,omitempty"`
VrfInstances map[string]map[string]interface{} `json:"vrf_instances,omitempty"`
VrrpConfig map[string]interface{} `json:"vrrp_config,omitempty"`
// Additional fields that may be present
AdditionalConfig map[string]interface{} `json:"-"`
}
DeviceProfileSwitch represents the complete Switch device profile structure
func (*DeviceProfileSwitch) FromMap ¶
func (dp *DeviceProfileSwitch) FromMap(data map[string]interface{}) error
FromMap populates the DeviceProfileSwitch from a map
func (*DeviceProfileSwitch) ToMap ¶
func (dp *DeviceProfileSwitch) ToMap() map[string]interface{}
ToMap converts the DeviceProfileSwitch to a map
type GatewayConfig ¶
type GatewayConfig = MistGatewayDevice
GatewayConfig represents a Gateway device configuration This uses the same structure as MistGatewayDevice since configs follow the same schema
type GatewayDeviceInterface ¶
type GatewayDeviceInterface interface {
DeviceMarshaler
GetMgmtIntf() *string
GetVersion() *string
GetIP() *string
GetWANConfig() map[string]interface{}
GetLANConfig() map[string]interface{}
GetSecurityConfig() map[string]interface{}
GetVPNConfig() map[string]interface{}
}
GatewayDeviceInterface defines the interface for gateway device operations. Note: The "Interface" suffix is retained because there is a struct named MistGatewayDevice.
type InventoryAssignResponse ¶
type InventoryAssignResponse struct {
// Op is the operation performed (assign, unassign)
Op string `json:"op,omitempty"`
// Success is the list of MAC addresses that were successfully processed
Success []string `json:"success,omitempty"`
// Error is the list of MAC addresses that failed to be processed
Error []string `json:"error,omitempty"`
// Reason contains the error reasons for each failed MAC address
Reason []string `json:"reason,omitempty"`
}
InventoryAssignResponse represents the response from an inventory assign operation
type InventoryConfig ¶
type InventoryConfig struct {
Version int `json:"version"`
Metadata struct {
Description string `json:"description"`
} `json:"metadata"`
Config struct {
Inventory struct {
AP []string `json:"ap"`
Switch []string `json:"switch"`
Gateway []string `json:"gateway"`
} `json:"inventory"`
} `json:"config"`
AvailableFields struct {
AP []string `json:"ap,omitempty"`
Switch []string `json:"switch,omitempty"`
Gateway []string `json:"gateway,omitempty"`
} `json:"available_fields,omitempty"`
}
InventoryConfig represents the structure of the inventory configuration file
type InventoryItem ¶
type InventoryItem struct {
// Id is the unique identifier for the device
Id *UUID `json:"id,omitempty"`
// Mac is the MAC address of the device
Mac *string `json:"mac,omitempty"`
// Serial is the serial number of the device
Serial *string `json:"serial,omitempty"`
// Model is the device model
Model *string `json:"model,omitempty"`
// SKU is the stock keeping unit
SKU *string `json:"sku,omitempty"`
// HwRev is the device hardware revision number
HwRev *string `json:"hw_rev,omitempty"`
// Type is the device type (ap, switch, gateway)
Type *string `json:"type,omitempty"`
// Magic is the device claim code
Magic *string `json:"magic,omitempty"`
// Name is the device name if configured
Name *string `json:"name,omitempty"`
// Hostname is the hostname reported by the device
Hostname *string `json:"hostname,omitempty"`
// JSI indicates if the device is JSI
JSI *bool `json:"jsi,omitempty"`
// Virtual Chassis fields
ChassisMac *string `json:"chassis_mac,omitempty"`
ChassisSerial *string `json:"chassis_serial,omitempty"`
VcMac *string `json:"vc_mac,omitempty"`
// OrgId is the organization ID
OrgId *UUID `json:"org_id,omitempty"`
// SiteId is the site ID if assigned, null if not assigned
SiteId *UUID `json:"site_id,omitempty"`
// CreatedTime is the inventory created time, in epoch
CreatedTime *int64 `json:"created_time,omitempty"`
// ModifiedTime is the inventory last modified time, in epoch
ModifiedTime *int64 `json:"modified_time,omitempty"`
// DeviceProfileId is the deviceprofile ID if assigned, null if not assigned
DeviceProfileId *string `json:"deviceprofile_id,omitempty"`
// Connected indicates whether the device is connected
Connected *bool `json:"connected,omitempty"`
// Adopted indicates whether the switch/gateway is adopted
Adopted *bool `json:"adopted,omitempty"`
}
InventoryItem represents a device in the Mist inventory
func ConvertInventoryItemFromNew ¶
func ConvertInventoryItemFromNew(newItem *MistInventoryItem) InventoryItem
ConvertInventoryItemFromNew converts an MistInventoryItem back to legacy InventoryItem
func SortInventory ¶
func SortInventory(items []InventoryItem) []InventoryItem
SortInventory sorts inventory items using natural sorting with priority: name, hostname, type, MAC
type InventoryMarshaler ¶
type InventoryMarshaler interface {
GetID() string
GetMAC() string
GetType() string
ToMap() map[string]interface{}
FromMap(data map[string]interface{}) error
ToConfigMap() map[string]interface{}
FromConfigMap(data map[string]interface{}) error
GetRaw() map[string]interface{}
SetRaw(data map[string]interface{})
}
InventoryMarshaler defines the interface for bidirectional inventory data transformation between API representations and structured types.
type LatLng ¶
type LatLng struct {
// Lat is the latitude
Lat float64 `json:"lat"`
// Lng is the longitude
Lng float64 `json:"lng"`
}
LatLng represents geographical coordinates
type MistDeviceMacPort ¶
type MistDeviceMacPort struct {
DeviceMAC *string `json:"device_mac,omitempty"`
PortID *string `json:"port_id,omitempty"`
Start *string `json:"start,omitempty"`
When *string `json:"when,omitempty"`
IP *string `json:"ip,omitempty"`
IP6 *string `json:"ip6,omitempty"`
VLAN *int `json:"vlan,omitempty"`
PortParent *string `json:"port_parent,omitempty"`
Node *string `json:"node,omitempty"`
// Additional flexible configuration stored as maps
AdditionalConfig map[string]interface{} `json:"-"`
// Raw contains the complete API response data for full preservation
Raw map[string]interface{} `json:"-"`
}
MistDeviceMacPort represents a port connection in the wired client API response with bidirectional handling
func (*MistDeviceMacPort) FromMap ¶
func (d *MistDeviceMacPort) FromMap(data map[string]interface{}) error
FromMap populates the device MAC port from a map representation
func (*MistDeviceMacPort) ToMap ¶
func (d *MistDeviceMacPort) ToMap() map[string]interface{}
ToMap converts the device MAC port to a map representation
type MistGatewayDevice ¶
type MistGatewayDevice struct {
BaseDevice
// Gateway-specific typed fields for frequently used configurations
MgmtIntf *string `json:"mgmt_intf,omitempty"`
Version *string `json:"version,omitempty"`
IP *string `json:"ip,omitempty"`
// Complex configuration stored as maps for flexibility and evolution
WANConfig map[string]interface{} `json:"wan_config,omitempty"`
LANConfig map[string]interface{} `json:"lan_config,omitempty"`
SecurityConfig map[string]interface{} `json:"security_config,omitempty"`
VPNConfig map[string]interface{} `json:"vpn_config,omitempty"`
RoutingConfig map[string]interface{} `json:"routing_config,omitempty"`
FirewallConfig map[string]interface{} `json:"firewall_config,omitempty"`
NATConfig map[string]interface{} `json:"nat_config,omitempty"`
QosConfig map[string]interface{} `json:"qos_config,omitempty"`
DhcpConfig map[string]interface{} `json:"dhcp_config,omitempty"`
DnsConfig map[string]interface{} `json:"dns_config,omitempty"`
NtpConfig map[string]interface{} `json:"ntp_config,omitempty"`
SnmpConfig map[string]interface{} `json:"snmp_config,omitempty"`
SyslogConfig map[string]interface{} `json:"syslog_config,omitempty"`
TunnelConfig map[string]interface{} `json:"tunnel_config,omitempty"`
ClusterConfig map[string]interface{} `json:"cluster_config,omitempty"`
PortConfig map[string]interface{} `json:"port_config,omitempty"`
// Additional config for unknown fields
AdditionalConfig map[string]interface{} `json:"-"`
}
MistGatewayDevice represents a Mist gateway with complete data preservation
func NewGatewayDeviceFromMap ¶
func NewGatewayDeviceFromMap(data map[string]interface{}) (*MistGatewayDevice, error)
NewGatewayDeviceFromMap creates a new MistGatewayDevice from API response data
func (*MistGatewayDevice) FromConfigMap ¶
func (gw *MistGatewayDevice) FromConfigMap(data map[string]interface{}) error
FromConfigMap populates gateway device from configuration map (from config files)
func (*MistGatewayDevice) FromMap ¶
func (gw *MistGatewayDevice) FromMap(data map[string]interface{}) error
FromMap populates the MistGatewayDevice from API response data
func (*MistGatewayDevice) GetIP ¶
func (gw *MistGatewayDevice) GetIP() *string
func (*MistGatewayDevice) GetLANConfig ¶
func (gw *MistGatewayDevice) GetLANConfig() map[string]interface{}
func (*MistGatewayDevice) GetMgmtIntf ¶
func (gw *MistGatewayDevice) GetMgmtIntf() *string
Implement GatewayDeviceInterface
func (*MistGatewayDevice) GetSecurityConfig ¶
func (gw *MistGatewayDevice) GetSecurityConfig() map[string]interface{}
func (*MistGatewayDevice) GetVPNConfig ¶
func (gw *MistGatewayDevice) GetVPNConfig() map[string]interface{}
func (*MistGatewayDevice) GetVersion ¶
func (gw *MistGatewayDevice) GetVersion() *string
func (*MistGatewayDevice) GetWANConfig ¶
func (gw *MistGatewayDevice) GetWANConfig() map[string]interface{}
func (*MistGatewayDevice) ToConfigMap ¶
func (gw *MistGatewayDevice) ToConfigMap() map[string]interface{}
ToConfigMap converts gateway device to configuration map (for config files)
func (*MistGatewayDevice) ToMap ¶
func (gw *MistGatewayDevice) ToMap() map[string]interface{}
ToMap converts the MistGatewayDevice to a map for API operations
type MistGatewayTemplate ¶
type MistGatewayTemplate struct {
// Core fields
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
OrgID *string `json:"org_id,omitempty"`
Type *string `json:"type,omitempty"`
// Network configuration
Networks *map[string]interface{} `json:"networks,omitempty"`
PortConfig *map[string]interface{} `json:"port_config,omitempty"`
// Advanced gateway settings
BGPConfig *map[string]interface{} `json:"bgp_config,omitempty"`
VRFConfig *map[string]interface{} `json:"vrf_config,omitempty"`
RoutingConfig *map[string]interface{} `json:"routing_config,omitempty"`
// Metadata
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
// Additional configuration not covered by struct fields
AdditionalConfig map[string]interface{} `json:"-"`
}
MistGatewayTemplate represents a gateway template with bidirectional data handling
func (*MistGatewayTemplate) FromMap ¶
func (gw *MistGatewayTemplate) FromMap(data map[string]interface{}) error
MistGatewayTemplate FromMap and ToMap methods
func (*MistGatewayTemplate) ToMap ¶
func (gw *MistGatewayTemplate) ToMap() map[string]interface{}
type MistInventoryItem ¶
type MistInventoryItem struct {
// Core identification fields
ID *string `json:"id,omitempty"`
MAC *string `json:"mac,omitempty"`
Serial *string `json:"serial,omitempty"`
Name *string `json:"name,omitempty"`
Model *string `json:"model,omitempty"`
SKU *string `json:"sku,omitempty"`
HwRev *string `json:"hw_rev,omitempty"`
Type *string `json:"type,omitempty"`
Magic *string `json:"magic,omitempty"`
// Network and system fields
Hostname *string `json:"hostname,omitempty"`
JSI *bool `json:"jsi,omitempty"`
// Virtual Chassis fields
ChassisMac *string `json:"chassis_mac,omitempty"`
ChassisSerial *string `json:"chassis_serial,omitempty"`
VcMac *string `json:"vc_mac,omitempty"`
// Organization and site assignment
OrgID *string `json:"org_id,omitempty"`
SiteID *string `json:"site_id,omitempty"`
DeviceProfileID *string `json:"deviceprofile_id,omitempty"`
// Status fields (read-only, not included in config)
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
Connected *bool `json:"connected,omitempty"`
Adopted *bool `json:"adopted,omitempty"`
// Additional flexible configuration stored as maps
AdditionalConfig map[string]interface{} `json:"-"`
// Raw contains the complete API response data for full preservation
Raw map[string]interface{} `json:"-"`
}
MistInventoryItem represents a Mist inventory item with bidirectional data handling
func ConvertInventoryItemToNew ¶
func ConvertInventoryItemToNew(oldItem InventoryItem) *MistInventoryItem
ConvertInventoryItemToNew converts a legacy InventoryItem to MistInventoryItem
func NewInventoryItemFromConfigMap ¶
func NewInventoryItemFromConfigMap(data map[string]interface{}) (*MistInventoryItem, error)
NewInventoryItemFromConfigMap creates a new inventory item from a configuration map
func NewInventoryItemFromMap ¶
func NewInventoryItemFromMap(data map[string]interface{}) (*MistInventoryItem, error)
NewInventoryItemFromMap creates a new inventory item from a map representation
func (*MistInventoryItem) FromConfigMap ¶
func (i *MistInventoryItem) FromConfigMap(data map[string]interface{}) error
FromConfigMap populates the inventory item from a configuration map (excludes status fields)
func (*MistInventoryItem) FromMap ¶
func (i *MistInventoryItem) FromMap(data map[string]interface{}) error
FromMap populates the inventory item from a map representation (e.g., from API response)
func (*MistInventoryItem) GetID ¶
func (i *MistInventoryItem) GetID() string
GetID returns the inventory item ID as a string
func (*MistInventoryItem) GetMAC ¶
func (i *MistInventoryItem) GetMAC() string
GetMAC returns the inventory item MAC address, normalized
func (*MistInventoryItem) GetRaw ¶
func (i *MistInventoryItem) GetRaw() map[string]interface{}
GetRaw returns the raw API data
func (*MistInventoryItem) GetType ¶
func (i *MistInventoryItem) GetType() string
GetType returns the inventory item type
func (*MistInventoryItem) SetRaw ¶
func (i *MistInventoryItem) SetRaw(data map[string]interface{})
SetRaw sets the raw API data
func (*MistInventoryItem) ToConfigMap ¶
func (i *MistInventoryItem) ToConfigMap() map[string]interface{}
ToConfigMap converts the inventory item to a map suitable for configuration files (excludes status fields)
func (*MistInventoryItem) ToMap ¶
func (i *MistInventoryItem) ToMap() map[string]interface{}
ToMap converts the inventory item to a map representation suitable for API requests
type MistLatLng ¶
MistLatLng represents latitude/longitude coordinates with bidirectional handling
type MistNetwork ¶
type MistNetwork struct {
// Core fields
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
OrgID *string `json:"org_id,omitempty"`
// Network configuration
VlanID *int `json:"vlan_id,omitempty"`
Subnet *string `json:"subnet,omitempty"`
Gateway *string `json:"gateway,omitempty"`
Subnet6 *string `json:"subnet6,omitempty"`
Gateway6 *string `json:"gateway6,omitempty"`
// Access control
InternalAccess *bool `json:"internal_access,omitempty"`
InternetAccess *bool `json:"internet_access,omitempty"`
Isolation *bool `json:"isolation,omitempty"`
// Advanced settings
Multicast *bool `json:"multicast,omitempty"`
Tenants *[]string `json:"tenants,omitempty"`
// Metadata
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
// Additional configuration not covered by struct fields
AdditionalConfig map[string]interface{} `json:"-"`
}
MistNetwork represents an organization network with bidirectional data handling
func (*MistNetwork) FromMap ¶
func (n *MistNetwork) FromMap(data map[string]interface{}) error
MistNetwork FromMap and ToMap methods
func (*MistNetwork) ToMap ¶
func (n *MistNetwork) ToMap() map[string]interface{}
type MistRFTemplate ¶
type MistRFTemplate struct {
// Core fields
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
OrgID *string `json:"org_id,omitempty"`
// Antenna gain settings
AntGain24 *int `json:"ant_gain_24,omitempty"`
AntGain5 *int `json:"ant_gain_5,omitempty"`
AntGain6 *int `json:"ant_gain_6,omitempty"`
// Radio band configurations (complex objects from schema)
Band24 map[string]interface{} `json:"band_24,omitempty"`
Band24Usage *string `json:"band_24_usage,omitempty"`
Band5 map[string]interface{} `json:"band_5,omitempty"`
Band5On24Radio map[string]interface{} `json:"band_5_on_24_radio,omitempty"`
Band6 map[string]interface{} `json:"band_6,omitempty"`
// Settings
CountryCode *string `json:"country_code,omitempty"`
ForSite *bool `json:"for_site,omitempty"`
ScanningEnabled *bool `json:"scanning_enabled,omitempty"`
// Model-specific configurations
ModelSpecific map[string]interface{} `json:"model_specific,omitempty"`
// Metadata
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
}
MistRFTemplate represents an RF template with complete API response data
func (*MistRFTemplate) FromMap ¶
func (rf *MistRFTemplate) FromMap(data map[string]interface{}) error
MistRFTemplate FromMap and ToMap methods
func (*MistRFTemplate) ToMap ¶
func (rf *MistRFTemplate) ToMap() map[string]interface{}
type MistSite ¶
type MistSite struct {
// Core site fields with typed access
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Address *string `json:"address,omitempty"`
CountryCode *string `json:"country_code,omitempty"`
Timezone *string `json:"timezone,omitempty"`
Notes *string `json:"notes,omitempty"`
Latlng *MistLatLng `json:"latlng,omitempty"`
// Status fields (read-only, not included in config)
CreatedTime *float64 `json:"created_time,omitempty"`
ModifiedTime *float64 `json:"modified_time,omitempty"`
OrgID *string `json:"org_id,omitempty"`
// Template IDs from site.json schema
AlarmTemplateID *string `json:"alarmtemplate_id,omitempty"`
APTemplateID *string `json:"aptemplate_id,omitempty"`
GatewayTemplateID *string `json:"gatewaytemplate_id,omitempty"`
NetworkTemplateID *string `json:"networktemplate_id,omitempty"`
RFTemplateID *string `json:"rftemplate_id,omitempty"`
SecPolicyID *string `json:"secpolicy_id,omitempty"`
SiteTemplateID *string `json:"sitetemplate_id,omitempty"`
// Site groups and variables
SiteGroupIDs *[]string `json:"sitegroup_ids,omitempty"`
Vars map[string]interface{} `json:"vars,omitempty"`
// Complex configuration objects (stored as maps to preserve exact API structure)
Setting map[string]interface{} `json:"setting,omitempty"`
SLE map[string]interface{} `json:"sle,omitempty"`
Stats map[string]interface{} `json:"stats,omitempty"`
AutoUpgrade map[string]interface{} `json:"auto_upgrade,omitempty"`
Engage map[string]interface{} `json:"engage,omitempty"`
EvpnOptions map[string]interface{} `json:"evpn_options,omitempty"`
Rogue map[string]interface{} `json:"rogue,omitempty"`
WanVNA map[string]interface{} `json:"wan_vna,omitempty"`
SkyATP map[string]interface{} `json:"skyatp,omitempty"`
WiredVNA map[string]interface{} `json:"wiredvna,omitempty"`
// Simple limit fields and additional properties
MSPID *string `json:"msp_id,omitempty"`
WlanLimitDown *int `json:"wlan_limit_down,omitempty"`
WlanLimitUp *int `json:"wlan_limit_up,omitempty"`
ManagedAPDeviceLimit *int `json:"managed_ap_device_limit,omitempty"`
ManagedOtherDeviceLimit *int `json:"managed_other_device_limit,omitempty"`
WxTagIDs *[]string `json:"wxtag_ids,omitempty"`
WxTunnelID *string `json:"wxtunnel_id,omitempty"`
TzOffset *int `json:"tzoffset,omitempty"`
// Additional configuration for any unmapped fields
AdditionalConfig map[string]interface{} `json:"-"`
}
MistSite represents a Mist site with bidirectional data handling
func ConvertSiteToNew ¶
ConvertSiteToNew converts a legacy Site to MistSite
func NewSiteFromConfigMap ¶
NewSiteFromConfigMap creates a new site from a configuration map
func NewSiteFromMap ¶
NewSiteFromMap creates a new site from a map representation
func SortSitesNew ¶
SortSitesNew sorts a slice of new sites using natural sorting by name
func (*MistSite) FromConfigMap ¶
FromConfigMap populates the site from a configuration map (excludes status fields)
func (*MistSite) FromMap ¶
FromMap populates the site from a map representation (e.g., from API response)
func (*MistSite) FromMapEnhanced ¶
MistSite FromMap - enhanced to map all fields from site.json schema
func (*MistSite) ToConfigMap ¶
ToConfigMap converts the site to a map suitable for configuration files (excludes status fields)
func (*MistSite) ToMapEnhanced ¶
ToMapEnhanced converts the MistSite to a complete map preserving all API fields
type MistSwitchDevice ¶
type MistSwitchDevice struct {
BaseDevice
// Switch-specific typed fields for frequently used configurations
IP *string `json:"ip,omitempty"`
Port *int `json:"port,omitempty"`
Version *string `json:"version,omitempty"`
Role *string `json:"role,omitempty"`
Managed *bool `json:"managed,omitempty"`
RouterID *string `json:"router_id,omitempty"`
// Complex configuration stored as maps for flexibility and evolution
PortConfig map[string]interface{} `json:"port_config,omitempty"`
Networks map[string]interface{} `json:"networks,omitempty"`
IPConfig map[string]interface{} `json:"ip_config,omitempty"`
OobIPConfig map[string]interface{} `json:"oob_ip_config,omitempty"`
StpConfig map[string]interface{} `json:"stp_config,omitempty"`
VlanConfig map[string]interface{} `json:"vlan_config,omitempty"`
L2Config map[string]interface{} `json:"l2_config,omitempty"`
L3Config map[string]interface{} `json:"l3_config,omitempty"`
RoutingConfig map[string]interface{} `json:"routing_config,omitempty"`
SecurityConfig map[string]interface{} `json:"security_config,omitempty"`
QosConfig map[string]interface{} `json:"qos_config,omitempty"`
SnmpConfig map[string]interface{} `json:"snmp_config,omitempty"`
SyslogConfig map[string]interface{} `json:"syslog_config,omitempty"`
NtpConfig map[string]interface{} `json:"ntp_config,omitempty"`
DnsConfig map[string]interface{} `json:"dns_config,omitempty"`
// Additional config for unknown fields
AdditionalConfig map[string]interface{} `json:"-"`
}
MistSwitchDevice represents a Mist switch with complete data preservation
func NewSwitchDeviceFromMap ¶
func NewSwitchDeviceFromMap(data map[string]interface{}) (*MistSwitchDevice, error)
NewSwitchDeviceFromMap creates a new MistSwitchDevice from API response data
func (*MistSwitchDevice) FromConfigMap ¶
func (sw *MistSwitchDevice) FromConfigMap(data map[string]interface{}) error
FromConfigMap populates switch device from configuration map (from config files)
func (*MistSwitchDevice) FromMap ¶
func (sw *MistSwitchDevice) FromMap(data map[string]interface{}) error
FromMap populates the MistSwitchDevice from API response data
func (*MistSwitchDevice) GetIP ¶
func (sw *MistSwitchDevice) GetIP() *string
Implement SwitchDeviceInterface
func (*MistSwitchDevice) GetIPConfig ¶
func (sw *MistSwitchDevice) GetIPConfig() map[string]interface{}
func (*MistSwitchDevice) GetManaged ¶
func (sw *MistSwitchDevice) GetManaged() *bool
func (*MistSwitchDevice) GetNetworks ¶
func (sw *MistSwitchDevice) GetNetworks() map[string]interface{}
func (*MistSwitchDevice) GetPort ¶
func (sw *MistSwitchDevice) GetPort() *int
func (*MistSwitchDevice) GetPortConfig ¶
func (sw *MistSwitchDevice) GetPortConfig() map[string]interface{}
func (*MistSwitchDevice) GetRole ¶
func (sw *MistSwitchDevice) GetRole() *string
func (*MistSwitchDevice) GetRouterID ¶
func (sw *MistSwitchDevice) GetRouterID() *string
func (*MistSwitchDevice) GetVersion ¶
func (sw *MistSwitchDevice) GetVersion() *string
func (*MistSwitchDevice) ToConfigMap ¶
func (sw *MistSwitchDevice) ToConfigMap() map[string]interface{}
ToConfigMap converts switch device to configuration map (for config files)
func (*MistSwitchDevice) ToMap ¶
func (sw *MistSwitchDevice) ToMap() map[string]interface{}
ToMap converts the MistSwitchDevice to a map for API operations
type MistWLAN ¶
type MistWLAN struct {
// Core fields
ID *string `json:"id,omitempty"`
SSID *string `json:"ssid,omitempty"`
OrgID *string `json:"org_id,omitempty"`
SiteID *string `json:"site_id,omitempty"`
// Network settings
VlanID *int `json:"vlan_id,omitempty"`
Interface *string `json:"interface,omitempty"`
Isolation *bool `json:"isolation,omitempty"`
// Authentication
Auth struct {
Type *string `json:"type,omitempty"`
PSK *string `json:"psk,omitempty"`
KeyIdx *int `json:"key_idx,omitempty"`
Keys *[]string `json:"keys,omitempty"`
Enterprise *struct {
Radius *struct {
Host *string `json:"host,omitempty"`
Port *int `json:"port,omitempty"`
Secret *string `json:"secret,omitempty"`
} `json:"radius,omitempty"`
} `json:"enterprise,omitempty"`
} `json:"auth,omitempty"`
// Quality of Service
QoS struct {
Class *string `json:"class,omitempty"`
} `json:"qos,omitempty"`
// Advanced settings
Band *string `json:"band,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Hidden *bool `json:"hidden,omitempty"`
ApplyTo *[]string `json:"apply_to,omitempty"`
// Metadata
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
// Additional configuration not covered by struct fields
AdditionalConfig map[string]interface{} `json:"-"`
}
MistWLAN represents a WLAN with bidirectional data handling
type MistWLANTemplate ¶
type MistWLANTemplate struct {
// Core fields
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
OrgID *string `json:"org_id,omitempty"`
// Template settings
SSID *string `json:"ssid,omitempty"`
VlanID *int `json:"vlan_id,omitempty"`
Interface *string `json:"interface,omitempty"`
// Authentication template
Auth *map[string]interface{} `json:"auth,omitempty"`
// QoS template
QoS *map[string]interface{} `json:"qos,omitempty"`
// Advanced settings
Band *string `json:"band,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Hidden *bool `json:"hidden,omitempty"`
// Metadata
CreatedTime *int64 `json:"created_time,omitempty"`
ModifiedTime *int64 `json:"modified_time,omitempty"`
// Additional configuration not covered by struct fields
AdditionalConfig map[string]interface{} `json:"-"`
}
MistWLANTemplate represents a WLAN template with bidirectional data handling
func (*MistWLANTemplate) FromMap ¶
func (wt *MistWLANTemplate) FromMap(data map[string]interface{}) error
MistWLANTemplate FromMap and ToMap methods
func (*MistWLANTemplate) ToMap ¶
func (wt *MistWLANTemplate) ToMap() map[string]interface{}
type MistWiredClient ¶
type MistWiredClient struct {
// Core identification fields
OrgID *string `json:"org_id,omitempty"`
SiteID *string `json:"site_id,omitempty"`
ClientMAC *string `json:"client_mac,omitempty"`
MAC *string `json:"mac,omitempty"`
// Timestamp and session information
Timestamp *float64 `json:"timestamp,omitempty"`
// Device and port information
DeviceMacPort []*MistDeviceMacPort `json:"device_mac_port,omitempty"`
DeviceMAC []string `json:"device_mac,omitempty"`
PortID []string `json:"port_id,omitempty"`
// Network information
IP []string `json:"ip,omitempty"`
IP6 []string `json:"ip6,omitempty"`
VLAN []int `json:"vlan,omitempty"`
Hostname []string `json:"hostname,omitempty"`
Username []string `json:"username,omitempty"`
// Authentication and security
AuthState *string `json:"auth_state,omitempty"`
AuthMethod *string `json:"auth_method,omitempty"`
RandomMAC *bool `json:"random_mac,omitempty"`
// Device characteristics
Manufacture *string `json:"manufacture,omitempty"`
// Last known information
LastVLANName *string `json:"last_vlan_name,omitempty"`
LastVLAN *int `json:"last_vlan,omitempty"`
LastPortID *string `json:"last_port_id,omitempty"`
LastHostname *string `json:"last_hostname,omitempty"`
LastIP *string `json:"last_ip,omitempty"`
LastIP6 *string `json:"last_ip6,omitempty"`
LastDeviceMAC *string `json:"last_device_mac,omitempty"`
// Additional flexible configuration stored as maps
AdditionalConfig map[string]interface{} `json:"-"`
// Raw contains the complete API response data for full preservation
Raw map[string]interface{} `json:"-"`
}
MistWiredClient represents a Mist wired client with bidirectional data handling
func NewWiredClientFromMap ¶
func NewWiredClientFromMap(data map[string]interface{}) (*MistWiredClient, error)
NewWiredClientFromMap creates a new wired client from a map representation
func (*MistWiredClient) FromMap ¶
func (w *MistWiredClient) FromMap(data map[string]interface{}) error
FromMap populates the wired client from a map representation
func (*MistWiredClient) GetMAC ¶
func (w *MistWiredClient) GetMAC() string
GetMAC returns the wired client MAC address, normalized
func (*MistWiredClient) GetOrgID ¶
func (w *MistWiredClient) GetOrgID() string
GetOrgID returns the wired client organization ID
func (*MistWiredClient) GetRaw ¶
func (w *MistWiredClient) GetRaw() map[string]interface{}
GetRaw returns the raw API data
func (*MistWiredClient) GetSiteID ¶
func (w *MistWiredClient) GetSiteID() string
GetSiteID returns the wired client site ID
func (*MistWiredClient) SetRaw ¶
func (w *MistWiredClient) SetRaw(data map[string]interface{})
SetRaw sets the raw API data
func (*MistWiredClient) ToMap ¶
func (w *MistWiredClient) ToMap() map[string]interface{}
ToMap converts the wired client to a map representation
type MistWiredClientResponse ¶
type MistWiredClientResponse struct {
Results []*MistWiredClient `json:"results,omitempty"`
Limit *int `json:"limit,omitempty"`
Start *int64 `json:"start,omitempty"`
End *int64 `json:"end,omitempty"`
Total *int `json:"total,omitempty"`
// Raw contains the complete API response data for full preservation
Raw map[string]interface{} `json:"-"`
}
MistWiredClientResponse represents the full response from the wired client search API with bidirectional handling
type MistWirelessClient ¶
type MistWirelessClient struct {
// Core identification fields
OrgID *string `json:"org_id,omitempty"`
SiteID *string `json:"site_id,omitempty"`
SiteIDs []string `json:"site_ids,omitempty"`
MAC *string `json:"mac,omitempty"`
// Timestamp and session information
Timestamp *float64 `json:"timestamp,omitempty"`
// Access Point and network information
AP []string `json:"ap,omitempty"`
IP []string `json:"ip,omitempty"`
Hostname []string `json:"hostname,omitempty"`
WLANID []string `json:"wlan_id,omitempty"`
SSID []string `json:"ssid,omitempty"`
VLAN []int `json:"vlan,omitempty"`
// Device information
Model []string `json:"model,omitempty"`
Device []string `json:"device,omitempty"`
OS []string `json:"os,omitempty"`
OSVersion []string `json:"os_version,omitempty"`
Username []string `json:"username,omitempty"`
Firmware []string `json:"firmware,omitempty"`
SDKVersion []string `json:"sdk_version,omitempty"`
AppVersion []string `json:"app_version,omitempty"`
// Device characteristics
Manufacture *string `json:"mfg,omitempty"`
Hardware *string `json:"hardware,omitempty"`
// Connection characteristics
RandomMAC *bool `json:"random_mac,omitempty"`
Ftc *bool `json:"ftc,omitempty"`
Band *string `json:"band,omitempty"`
Protocol *string `json:"protocol,omitempty"`
// PSK information
PskID []string `json:"psk_id,omitempty"`
PskName []string `json:"psk_name,omitempty"`
// Last known information
LastAP *string `json:"last_ap,omitempty"`
LastIP *string `json:"last_ip,omitempty"`
LastHostname *string `json:"last_hostname,omitempty"`
LastWLANID *string `json:"last_wlan_id,omitempty"`
LastSSID *string `json:"last_ssid,omitempty"`
LastModel *string `json:"last_model,omitempty"`
LastDevice *string `json:"last_device,omitempty"`
LastOS *string `json:"last_os,omitempty"`
LastOSVersion *string `json:"last_os_version,omitempty"`
LastFirmware *string `json:"last_firmware,omitempty"`
LastVLAN *int `json:"last_vlan,omitempty"`
// Additional flexible configuration stored as maps
AdditionalConfig map[string]interface{} `json:"-"`
// Raw contains the complete API response data for full preservation
Raw map[string]interface{} `json:"-"`
}
MistWirelessClient represents a Mist wireless client with bidirectional data handling
func NewWirelessClientFromMap ¶
func NewWirelessClientFromMap(data map[string]interface{}) (*MistWirelessClient, error)
NewWirelessClientFromMap creates a new wireless client from a map representation
func (*MistWirelessClient) FromMap ¶
func (w *MistWirelessClient) FromMap(data map[string]interface{}) error
FromMap populates the wireless client from a map representation
func (*MistWirelessClient) GetMAC ¶
func (w *MistWirelessClient) GetMAC() string
GetMAC returns the wireless client MAC address, normalized
func (*MistWirelessClient) GetOrgID ¶
func (w *MistWirelessClient) GetOrgID() string
GetOrgID returns the wireless client organization ID
func (*MistWirelessClient) GetRaw ¶
func (w *MistWirelessClient) GetRaw() map[string]interface{}
GetRaw returns the raw API data
func (*MistWirelessClient) GetSiteID ¶
func (w *MistWirelessClient) GetSiteID() string
GetSiteID returns the wireless client site ID
func (*MistWirelessClient) SetRaw ¶
func (w *MistWirelessClient) SetRaw(data map[string]interface{})
SetRaw sets the raw API data
func (*MistWirelessClient) ToMap ¶
func (w *MistWirelessClient) ToMap() map[string]interface{}
ToMap converts the wireless client to a map representation
type MistWirelessClientResponse ¶
type MistWirelessClientResponse struct {
Results []*MistWirelessClient `json:"results,omitempty"`
Limit *int `json:"limit,omitempty"`
Start *int64 `json:"start,omitempty"`
End *int64 `json:"end,omitempty"`
Total *int `json:"total,omitempty"`
// Raw contains the complete API response data for full preservation
Raw map[string]interface{} `json:"-"`
}
MistWirelessClientResponse represents the full response from the wireless client search API with bidirectional handling
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock implementation of the Client interface for testing purposes. It simulates API responses without making actual HTTP requests to the Mist API.
func (*MockClient) AddInventoryItem ¶
func (m *MockClient) AddInventoryItem(item InventoryItem)
AddInventoryItem adds an inventory item to the mock client's inventory
func (*MockClient) AddMockAP ¶
func (m *MockClient) AddMockAP(ap AP)
AddMockAP adds a mock AP for testing
func (*MockClient) AddMockSite ¶
func (m *MockClient) AddMockSite(site Site)
AddMockSite adds a mock site for testing
func (*MockClient) AssignDevice ¶
func (m *MockClient) AssignDevice(ctx context.Context, orgID string, siteID string, mac string) (*UnifiedDevice, error)
AssignDevice assigns a device using the new bidirectional pattern
func (*MockClient) AssignDeviceProfile ¶
func (m *MockClient) AssignDeviceProfile(ctx context.Context, orgID string, profileID string, macs []string) (*DeviceProfileAssignResult, error)
AssignDeviceProfile assigns a device profile to a list of devices
func (*MockClient) AssignDevicesToSite ¶
func (m *MockClient) AssignDevicesToSite(ctx context.Context, orgID string, siteID string, macs []string, noReassign bool) error
AssignDevicesToSite assigns multiple devices using the new bidirectional pattern
func (*MockClient) AssignInventoryItemsToSite ¶
func (m *MockClient) AssignInventoryItemsToSite(ctx context.Context, orgID string, siteID string, itemMACs []string) error
AssignInventoryItemsToSite assigns inventory items to a site
func (*MockClient) BatchGetDeviceConfigs ¶
func (m *MockClient) BatchGetDeviceConfigs(ctx context.Context, devices []DeviceInfo) (map[string]*DeviceConfig, map[string]error)
BatchGetDeviceConfigs retrieves configurations for multiple devices (mock implementation)
func (*MockClient) ClaimInventoryItem ¶
func (m *MockClient) ClaimInventoryItem(ctx context.Context, orgID string, claimCodes []string) ([]*MistInventoryItem, error)
ClaimInventoryItem claims inventory items using claim codes
func (*MockClient) Close ¶
func (m *MockClient) Close() error
Close releases resources used by the mock client
func (*MockClient) CreateMistSite ¶
CreateMistSite creates a new site using the new bidirectional format
func (*MockClient) CreateSite ¶
CreateSite creates a new site
func (*MockClient) DeleteDevicesFromSite ¶
func (m *MockClient) DeleteDevicesFromSite(_ context.Context, _ []string) error
DeleteDevicesFromSite deletes devices from a site
func (*MockClient) DeleteMistSite ¶
func (m *MockClient) DeleteMistSite(ctx context.Context, siteID string) error
DeleteMistSite deletes a site by ID using the new bidirectional format
func (*MockClient) DeleteSite ¶
func (m *MockClient) DeleteSite(ctx context.Context, siteID string) error
DeleteSite deletes a site
func (*MockClient) DeleteSiteByName ¶
func (m *MockClient) DeleteSiteByName(ctx context.Context, siteName string) error
DeleteSiteByName deletes a site by name
func (*MockClient) DeleteSiteByNameNew ¶
func (m *MockClient) DeleteSiteByNameNew(ctx context.Context, siteName string) error
DeleteSiteByNameNew deletes a site by name using the new bidirectional format
func (*MockClient) ForceRebuildCache ¶
func (m *MockClient) ForceRebuildCache(_ context.Context) error
ForceRebuildCache forces a rebuild of the cache
func (*MockClient) GetAPBySerialOrMAC ¶
GetAPBySerialOrMAC retrieves an AP by serial number or MAC address
func (*MockClient) GetAPConfig ¶
GetAPConfig retrieves the configuration for a specific AP device (mock implementation)
func (*MockClient) GetAPIUserInfo ¶
func (m *MockClient) GetAPIUserInfo(ctx context.Context) (*SelfResponse, error)
GetAPIUserInfo retrieves information about the current API user
func (*MockClient) GetCacheAccessor ¶
func (m *MockClient) GetCacheAccessor() CacheAccessor
GetCacheAccessor returns a mock cache accessor
func (*MockClient) GetConfigDirectory ¶
func (m *MockClient) GetConfigDirectory() string
GetConfigDirectory returns the configuration directory
func (*MockClient) GetDeviceByID ¶
func (m *MockClient) GetDeviceByID(ctx context.Context, siteID, deviceID string) (*UnifiedDevice, error)
GetDeviceByID retrieves a device by ID using the new bidirectional pattern
func (*MockClient) GetDeviceByMAC ¶
func (m *MockClient) GetDeviceByMAC(ctx context.Context, mac string) (*UnifiedDevice, error)
GetDeviceByMAC retrieves a device by MAC using the new bidirectional pattern
func (*MockClient) GetDeviceByName ¶
func (m *MockClient) GetDeviceByName(ctx context.Context, siteID, name string) (*UnifiedDevice, error)
GetDeviceByName retrieves a device by name using the new bidirectional pattern
func (*MockClient) GetDeviceCache ¶
func (m *MockClient) GetDeviceCache() *DeviceCache
GetDeviceCache returns the device cache instance
func (*MockClient) GetDeviceConfig ¶
func (m *MockClient) GetDeviceConfig(ctx context.Context, siteID, deviceID string) (*DeviceConfigResponse, error)
GetDeviceConfig retrieves the configuration for a specific device (mock implementation)
func (*MockClient) GetDeviceProfile ¶
func (m *MockClient) GetDeviceProfile(ctx context.Context, orgID string, profileID string) (*DeviceProfile, error)
GetDeviceProfile retrieves a specific device profile by ID
func (*MockClient) GetDeviceProfileByName ¶
func (m *MockClient) GetDeviceProfileByName(ctx context.Context, orgID string, name string, profileType string) (*DeviceProfile, error)
GetDeviceProfileByName retrieves a device profile by name and type
func (*MockClient) GetDeviceProfiles ¶
func (m *MockClient) GetDeviceProfiles(ctx context.Context, orgID string, profileType string) ([]DeviceProfile, error)
GetDeviceProfiles retrieves all device profiles of a specific type
func (*MockClient) GetDevices ¶
func (m *MockClient) GetDevices(ctx context.Context, siteID string, deviceType string) ([]UnifiedDevice, error)
GetDevices retrieves devices using the new bidirectional pattern
func (*MockClient) GetDevicesByType ¶
func (m *MockClient) GetDevicesByType(ctx context.Context, siteID string, deviceType string) ([]UnifiedDevice, error)
GetDevicesByType retrieves devices by type using the new bidirectional pattern
func (*MockClient) GetGatewayConfig ¶
func (m *MockClient) GetGatewayConfig(ctx context.Context, siteID, deviceID string) (*GatewayConfig, error)
GetGatewayConfig retrieves the configuration for a specific Gateway device (mock implementation)
func (*MockClient) GetGatewayTemplates ¶
func (m *MockClient) GetGatewayTemplates(_ context.Context, orgID string) ([]MistGatewayTemplate, error)
GetGatewayTemplates returns mock gateway templates
func (*MockClient) GetInventory ¶
func (m *MockClient) GetInventory(ctx context.Context, orgID string, deviceType string) ([]*MistInventoryItem, error)
GetInventory retrieves inventory items using the new bidirectional pattern
func (*MockClient) GetInventoryConfig ¶
func (m *MockClient) GetInventoryConfig(_ string) (*InventoryConfig, error)
GetInventoryConfig retrieves the inventory configuration from the specified path
func (*MockClient) GetInventoryItem ¶
func (m *MockClient) GetInventoryItem(ctx context.Context, orgID string, itemID string) (*MistInventoryItem, error)
GetInventoryItem retrieves a specific inventory item by ID
func (*MockClient) GetInventoryItemByMAC ¶
func (m *MockClient) GetInventoryItemByMAC(ctx context.Context, orgID string, macAddress string) (*MistInventoryItem, error)
GetInventoryItemByMAC retrieves an inventory item by MAC address
func (*MockClient) GetMistSite ¶
GetMistSite retrieves a site by ID using the new bidirectional format
func (*MockClient) GetNetworks ¶
func (m *MockClient) GetNetworks(_ context.Context, orgID string) ([]MistNetwork, error)
GetNetworks returns mock networks
func (*MockClient) GetOrgName ¶
func (m *MockClient) GetOrgName(_ string) (string, bool)
GetOrgName gets an organization name by ID
func (*MockClient) GetOrgStats ¶
GetOrgStats retrieves organization statistics for the mock client
func (*MockClient) GetRFTemplates ¶
func (m *MockClient) GetRFTemplates(_ context.Context, orgID string) ([]MistRFTemplate, error)
GetRFTemplates returns mock RF templates
func (*MockClient) GetRawDeviceJSON ¶
GetRawDeviceJSON retrieves the raw JSON for a device
func (*MockClient) GetSchemaDirectory ¶
func (m *MockClient) GetSchemaDirectory() string
GetSchemaDirectory returns the schema directory
func (*MockClient) GetSiteByIdentifier ¶
func (m *MockClient) GetSiteByIdentifier(ctx context.Context, siteIdentifier string) (*MistSite, error)
GetSiteByIdentifier delegates to GetSiteByIdentifierNew for interface compatibility
func (*MockClient) GetSiteByIdentifierNew ¶
func (m *MockClient) GetSiteByIdentifierNew(ctx context.Context, siteIdentifier string) (*MistSite, error)
GetSiteByIdentifierNew retrieves a site by ID or name using the new bidirectional format
func (*MockClient) GetSiteByName ¶
GetSiteByName retrieves a site by name using the new bidirectional format
func (*MockClient) GetSiteName ¶
func (m *MockClient) GetSiteName(siteID string) (string, bool)
GetSiteName gets a site name by ID
func (*MockClient) GetSiteSetting ¶
func (m *MockClient) GetSiteSetting(_ context.Context, siteID string) (*SiteSetting, error)
GetSiteSetting retrieves site setting by site ID (mock implementation)
func (*MockClient) GetSiteWLANs ¶
GetSiteWLANs returns mock site-level WLANs
func (*MockClient) GetSitesNew ¶
GetSitesNew retrieves all sites using the new bidirectional format
func (*MockClient) GetSwitchConfig ¶
func (m *MockClient) GetSwitchConfig(ctx context.Context, siteID, deviceID string) (*SwitchConfig, error)
GetSwitchConfig retrieves the configuration for a specific Switch device (mock implementation)
func (*MockClient) GetWLANTemplates ¶
func (m *MockClient) GetWLANTemplates(_ context.Context, orgID string) ([]MistWLANTemplate, error)
GetWLANTemplates returns mock WLAN templates
func (*MockClient) LookupSiteByID ¶
func (m *MockClient) LookupSiteByID(siteID string, options ...SiteLookupOptions) (Site, bool, error)
LookupSiteByID implements the Client interface for Client
func (*MockClient) LookupSiteByIdentifier ¶
func (m *MockClient) LookupSiteByIdentifier(identifier string, options ...SiteLookupOptions) (Site, bool, error)
LookupSiteByIdentifier implements the Client interface for Client
func (*MockClient) LookupSiteByName ¶
func (m *MockClient) LookupSiteByName(siteName string, options ...SiteLookupOptions) (Site, bool, error)
LookupSiteByName implements the Client interface for Client
func (*MockClient) PopulateDeviceCacheForSite ¶
PopulateDeviceCacheForSite populates the device cache for a specific site
func (*MockClient) QueryDeviceExtensive ¶
func (m *MockClient) QueryDeviceExtensive(_ context.Context, _, _ string) error
QueryDeviceExtensive performs a detailed query on a device
func (*MockClient) ReleaseInventoryItem ¶
func (m *MockClient) ReleaseInventoryItem(ctx context.Context, orgID string, itemIDs []string) error
ReleaseInventoryItem releases inventory items from the organization
func (*MockClient) SearchWiredClients ¶
func (m *MockClient) SearchWiredClients(ctx context.Context, orgID string, text string) (*MistWiredClientResponse, error)
SearchWiredClients implements the search for wired clients with mock data using new bidirectional types
func (*MockClient) SearchWirelessClients ¶
func (m *MockClient) SearchWirelessClients(ctx context.Context, orgID string, text string) (*MistWirelessClientResponse, error)
SearchWirelessClients implements the search for wireless clients with mock data using new bidirectional types
func (*MockClient) SetDebug ¶
func (m *MockClient) SetDebug(debug bool)
SetDebug enables or disables debug mode
func (*MockClient) SetRateLimit ¶
func (m *MockClient) SetRateLimit(limit int, duration time.Duration)
SetRateLimit sets the rate limit for the client
func (*MockClient) SetResultsLimit ¶
func (m *MockClient) SetResultsLimit(limit int)
SetResultsLimit sets the results limit for pagination
func (*MockClient) UnassignDevice ¶
func (m *MockClient) UnassignDevice(ctx context.Context, orgID string, _ string, deviceID string) error
UnassignDevice unassigns a device using the new bidirectional pattern
func (*MockClient) UnassignDeviceProfiles ¶
func (m *MockClient) UnassignDeviceProfiles(ctx context.Context, orgID string, profileID string, macs []string) error
UnassignDeviceProfiles removes device profile assignments from a list of devices
func (*MockClient) UnassignDevicesFromSite ¶
func (m *MockClient) UnassignDevicesFromSite(ctx context.Context, orgID string, macs []string) error
UnassignDevicesFromSite unassigns multiple devices using the new bidirectional pattern
func (*MockClient) UnassignInventoryItemsFromMistSite ¶
func (m *MockClient) UnassignInventoryItemsFromMistSite(ctx context.Context, orgID string, itemMACs []string) error
UnassignInventoryItemsFromMistSite unassigns inventory items from their current site
func (*MockClient) UnassignInventoryItemsFromSite ¶
func (m *MockClient) UnassignInventoryItemsFromSite(ctx context.Context, orgID string, itemMACs []string) error
UnassignInventoryItemsFromSite delegates to UnassignInventoryItemsFromMistSite for interface compatibility
func (*MockClient) UpdateCacheForTypes ¶
UpdateCacheForTypes updates the cache for specific device types
func (*MockClient) UpdateDevice ¶
func (m *MockClient) UpdateDevice(ctx context.Context, siteID string, deviceID string, device *UnifiedDevice) (*UnifiedDevice, error)
UpdateDevice delegates to UpdateDeviceNew for interface compatibility
func (*MockClient) UpdateDeviceNew ¶
func (m *MockClient) UpdateDeviceNew(ctx context.Context, siteID string, deviceID string, device *UnifiedDevice) (*UnifiedDevice, error)
UpdateDeviceNew updates a device using the new bidirectional pattern
func (*MockClient) UpdateInventoryItem ¶
func (m *MockClient) UpdateInventoryItem(ctx context.Context, orgID string, itemID string, item *MistInventoryItem) (*MistInventoryItem, error)
UpdateInventoryItem updates an existing inventory item
func (*MockClient) UpdateMistSite ¶
func (m *MockClient) UpdateMistSite(ctx context.Context, siteID string, site *MistSite) (*MistSite, error)
UpdateMistSite updates an existing site using the new bidirectional format
func (*MockClient) UpdateSite ¶
func (m *MockClient) UpdateSite(ctx context.Context, siteID string, site *MistSite) (*MistSite, error)
UpdateSite delegates to UpdateMistSite for interface compatibility
func (*MockClient) UpdateSiteByName ¶
func (m *MockClient) UpdateSiteByName(ctx context.Context, siteName string, site *MistSite) (*MistSite, error)
UpdateSiteByName delegates to UpdateSiteByNameNew for interface compatibility
func (*MockClient) UpdateSiteByNameNew ¶
func (m *MockClient) UpdateSiteByNameNew(ctx context.Context, siteName string, site *MistSite) (*MistSite, error)
UpdateSiteByNameNew updates an existing site by name using the new bidirectional format
func (*MockClient) ValidateAPIToken ¶
func (m *MockClient) ValidateAPIToken(ctx context.Context) (*SelfResponse, error)
ValidateAPIToken validates the API token
type OrgData ¶
type OrgData struct {
// Organization stats from /api/v1/orgs/{org_id}/stats
OrgStats *OrgStats `json:"org_stats,omitempty"`
// All other data that was previously at top level
Sites struct {
Info []MistSite `json:"info"`
Settings []SiteSetting `json:"settings"`
} `json:"sites"`
Templates struct {
RF []MistRFTemplate `json:"rf"`
Gateway []MistGatewayTemplate `json:"gateway"`
WLAN []MistWLANTemplate `json:"wlan"`
} `json:"templates"`
Networks []MistNetwork `json:"networks"`
WLANs struct {
Org []MistWLAN `json:"org"`
Sites map[string][]MistWLAN `json:"sites"` // [siteID][]WLAN
} `json:"wlans"`
Inventory struct {
AP map[string]APDevice `json:"ap"` // MAC -> APDevice
Switch map[string]MistSwitchDevice `json:"switch"` // MAC -> SwitchDevice
Gateway map[string]MistGatewayDevice `json:"gateway"` // MAC -> GatewayDevice
} `json:"inventory"`
Profiles struct {
Devices []DeviceProfile `json:"devices"`
Details []map[string]interface{} `json:"details"`
} `json:"profiles"`
Configs struct {
AP map[string]APConfig `json:"ap"` // MAC -> APConfig
Switch map[string]SwitchConfig `json:"switch"` // MAC -> SwitchConfig
Gateway map[string]GatewayConfig `json:"gateway"` // MAC -> GatewayConfig
} `json:"configs"`
}
OrgData represents all data for a single organization
type OrgStats ¶
type OrgStats struct {
// Required fields
AlarmTemplateID *string `json:"alarmtemplate_id"`
AllowMist *bool `json:"allow_mist"`
CreatedTime *float64 `json:"created_time"`
ID *string `json:"id"`
ModifiedTime *float64 `json:"modified_time"`
MspID *string `json:"msp_id"`
Name *string `json:"name"`
NumDevices *int `json:"num_devices"`
NumDevicesConnected *int `json:"num_devices_connected"`
NumDevicesDisconnected *int `json:"num_devices_disconnected"`
NumInventory *int `json:"num_inventory"`
NumSites *int `json:"num_sites"`
OrgGroupIDs []string `json:"orggroup_ids"`
SessionExpiry *int64 `json:"session_expiry"`
SLE []*OrgStatsSLE `json:"sle"`
// Additional fields that may be present
AdditionalFields map[string]interface{} `json:"-"`
}
OrgStats represents organization statistics from /api/v1/orgs/{org_id}/stats
type OrgStatsSLE ¶
type OrgStatsSLE struct {
Path *string `json:"path"`
UserMinutes *OrgStatsSLEUserMinutes `json:"user_minutes,omitempty"`
}
OrgStatsSLE represents the SLE (Service Level Expectation) statistics
type OrgStatsSLEUserMinutes ¶
OrgStatsSLEUserMinutes represents the user minutes statistics for SLE
type Privilege ¶
type Privilege struct {
Scope string `json:"scope"`
Role string `json:"role"`
Name string `json:"name"`
OrgID string `json:"org_id"`
}
Privilege represents a user's privilege for an organization
type RadioConfig ¶
type RadioConfig struct {
// AllowRRMDisable allows the RRM to disable the radio
AllowRRMDisable *bool `json:"allow_rrm_disable,omitempty"`
// AntGain24 is the antenna gain for 2.4G
AntGain24 *float64 `json:"ant_gain_24,omitempty"`
// AntGain5 is the antenna gain for 5G
AntGain5 *float64 `json:"ant_gain_5,omitempty"`
// AntGain6 is the antenna gain for 6G
AntGain6 *float64 `json:"ant_gain_6,omitempty"`
// AntennaMode is the antenna mode for the AP
AntennaMode *string `json:"antenna_mode,omitempty"`
// Band24 is the 2.4GHz radio configuration
Band24 *RadioConfigBand24 `json:"band_24,omitempty"`
// Band24Usage configures how 2.4GHz radio is used (24, 5, 6, auto)
Band24Usage *string `json:"band_24_usage,omitempty"`
// Band5 is the 5GHz radio configuration
Band5 *RadioConfigBand5 `json:"band_5,omitempty"`
// Band5On24Radio is the 5GHz configuration for dual 5GHz APs
Band5On24Radio *RadioConfigBand5 `json:"band_5_on_24_radio,omitempty"`
// Band6 is the 6GHz radio configuration
Band6 *RadioConfigBand6 `json:"band_6,omitempty"`
// FullAutomaticRRM indicates whether to let RRM control everything
FullAutomaticRRM *bool `json:"full_automatic_rrm,omitempty"`
// IndoorUse indicates whether an outdoor AP should operate as indoor
IndoorUse *bool `json:"indoor_use,omitempty"`
// ScanningEnabled indicates whether scanning radio is enabled
ScanningEnabled *bool `json:"scanning_enabled,omitempty"`
}
RadioConfig represents the radio configuration for an AP
type RadioConfigBand ¶
type RadioConfigBand struct {
// Disabled indicates whether the radio is disabled
Disabled *bool `json:"disabled,omitempty"`
// AllowRRMDisable allows the RRM to disable the radio
AllowRRMDisable *bool `json:"allow_rrm_disable,omitempty"`
// Power is the power setting
Power *int `json:"power,omitempty"`
// Channel is the channel number
Channel *int `json:"channel,omitempty"`
// Bandwidth is the channel bandwidth
Bandwidth *int `json:"bandwidth,omitempty"`
}
For legacy compatibility
type RadioConfigBand5 ¶
type RadioConfigBand5 struct {
// Disabled indicates whether the radio is disabled
Disabled *bool `json:"disabled,omitempty"`
// AllowRRMDisable allows the RRM to disable the radio
AllowRRMDisable *bool `json:"allow_rrm_disable,omitempty"`
// AntGain is the antenna gain in dB
AntGain *float64 `json:"ant_gain,omitempty"`
// AntennaMode is the antenna mode (1x1, 2x2, 3x3, 4x4, default)
AntennaMode *string `json:"antenna_mode,omitempty"`
// Bandwidth is the channel width for the 5GHz band (20, 40, 80)
Bandwidth *string `json:"bandwidth,omitempty"`
// Channel is the primary channel for the band
Channel *int `json:"channel,omitempty"`
// Channels is a list of channels for RFTemplates
Channels *[]int `json:"channels,omitempty"`
// Power is the TX power of the radio
Power *int `json:"power,omitempty"`
// PowerMax is the maximum TX power to use when Power=0
PowerMax *int `json:"power_max,omitempty"`
// PowerMin is the minimum TX power to use when Power=0
PowerMin *int `json:"power_min,omitempty"`
// Preamble is the preamble type (auto, long, short)
Preamble *string `json:"preamble,omitempty"`
}
RadioConfigBand5 represents the radio configuration for the 5GHz band
type RadioConfigBand6 ¶
type RadioConfigBand6 struct {
// Disabled indicates whether the radio is disabled
Disabled *bool `json:"disabled,omitempty"`
// AllowRRMDisable allows the RRM to disable the radio
AllowRRMDisable *bool `json:"allow_rrm_disable,omitempty"`
// AntGain is the antenna gain in dB
AntGain *float64 `json:"ant_gain,omitempty"`
// AntennaMode is the antenna mode (1x1, 2x2, 3x3, 4x4, default)
AntennaMode *string `json:"antenna_mode,omitempty"`
// Bandwidth is the channel width for the 6GHz band (20, 40, 80, 160)
Bandwidth *string `json:"bandwidth,omitempty"`
// Channel is the primary channel for the band
Channel *int `json:"channel,omitempty"`
// Channels is a list of channels for RFTemplates
Channels *[]int `json:"channels,omitempty"`
// Power is the TX power of the radio
Power *int `json:"power,omitempty"`
// PowerMax is the maximum TX power to use when Power=0
PowerMax *int `json:"power_max,omitempty"`
// PowerMin is the minimum TX power to use when Power=0
PowerMin *int `json:"power_min,omitempty"`
// Preamble is the preamble type (auto, long, short)
Preamble *string `json:"preamble,omitempty"`
// StandardPower indicates whether to use standard-power operation with AFC
StandardPower *bool `json:"standard_power,omitempty"`
}
RadioConfigBand6 represents the radio configuration for the 6GHz band
type RadioConfigBand24 ¶
type RadioConfigBand24 struct {
// Disabled indicates whether the radio is disabled
Disabled *bool `json:"disabled,omitempty"`
// AllowRRMDisable allows the RRM to disable the radio
AllowRRMDisable *bool `json:"allow_rrm_disable,omitempty"`
// AntGain is the antenna gain in dB
AntGain *float64 `json:"ant_gain,omitempty"`
// AntennaMode is the antenna mode (1x1, 2x2, 3x3, 4x4, default)
AntennaMode *string `json:"antenna_mode,omitempty"`
// Bandwidth is the channel width for the 2.4GHz band (20, 40)
Bandwidth *string `json:"bandwidth,omitempty"`
// Channel is the primary channel for the band
Channel *int `json:"channel,omitempty"`
// Channels is a list of channels for RFTemplates
Channels *[]int `json:"channels,omitempty"`
// Power is the TX power of the radio
Power *int `json:"power,omitempty"`
// PowerMax is the maximum TX power to use when Power=0
PowerMax *int `json:"power_max,omitempty"`
// PowerMin is the minimum TX power to use when Power=0
PowerMin *int `json:"power_min,omitempty"`
// Preamble is the preamble type (auto, long, short)
Preamble *string `json:"preamble,omitempty"`
}
RadioConfigBand24 represents the radio configuration for the 2.4GHz band
type SchemaType ¶
type SchemaType string
SchemaType represents the type of schema to validate against. The application uses three main schema types: cache, site configuration, and inventory.
const ( // SchemaCache is the schema for cache validation SchemaCache SchemaType = "cache" // SchemaSiteConfig is the schema for site configuration validation SchemaSiteConfig SchemaType = "site-config" // SchemaInventory is the schema for inventory validation SchemaInventory SchemaType = "inventory" )
type SchemaValidator ¶
type SchemaValidator struct {
// contains filtered or unexported fields
}
SchemaValidator is a helper for validating various JSON files against schemas. It provides methods to validate files and data against specific schema types, handling schema loading and error formatting.
The validator loads schemas on-demand when validation is first requested and caches them for subsequent use. This approach ensures efficient validation while also providing detailed error messages for failed validations.
func NewSchemaValidator ¶
func NewSchemaValidator(schemaDir string) *SchemaValidator
NewSchemaValidator creates a new schema validator schemaDir is the directory containing the schema files
func (*SchemaValidator) ValidateData ¶
func (sv *SchemaValidator) ValidateData(schemaType SchemaType, data interface{}) (bool, error)
ValidateData validates data against the specified schema Returns true if valid, false otherwise
func (*SchemaValidator) ValidateFile ¶
func (sv *SchemaValidator) ValidateFile(schemaType SchemaType, filePath string) (bool, error)
ValidateFile validates a file against the specified schema Returns true if valid, false otherwise
type SearchClientMarshaler ¶
type SearchClientMarshaler interface {
GetMAC() string
GetOrgID() string
GetSiteID() string
ToMap() map[string]interface{}
FromMap(data map[string]interface{}) error
GetRaw() map[string]interface{}
SetRaw(data map[string]interface{})
}
SearchClientMarshaler defines the interface for bidirectional search client data transformation between API representations and structured types.
type SelfResponse ¶
type SelfResponse struct {
ID *string `json:"id,omitempty"`
Email *string `json:"email,omitempty"`
FirstName *string `json:"first_name,omitempty"`
LastName *string `json:"last_name,omitempty"`
Name string `json:"name,omitempty"`
Privileges []Privilege `json:"privileges,omitempty"`
}
SelfResponse represents the response from the /api/v1/self endpoint
type Site ¶
type Site struct {
// Id is the unique identifier for the site
Id *UUID `json:"id,omitempty"`
// Name is the name of the site
Name *string `json:"name,omitempty"`
// Address is the full address of the site
Address *string `json:"address,omitempty"`
// CountryCode is the country code for the site (for AP config generation)
CountryCode *string `json:"country_code,omitempty"`
// Timezone is the timezone of the site
Timezone *string `json:"timezone,omitempty"`
// Notes are additional information about the site
Notes *string `json:"notes,omitempty"`
// Location of the site
Latlng *LatLng `json:"latlng,omitempty"`
// CreatedTime is when the site was created
CreatedTime *float64 `json:"created_time,omitempty"`
// ModifiedTime is when the site was last modified
ModifiedTime *float64 `json:"modified_time,omitempty"`
}
Site represents a Mist site
func ConvertSiteFromNew ¶
ConvertSiteFromNew converts a MistSite back to legacy Site
type SiteLookupOptions ¶
type SiteLookupOptions struct {
// Context for API calls
Ctx context.Context
// OrgID is the ID of the organization to search in (optional)
OrgID string
// SearchOrder determines where to look first (cache, api, or both)
// Default is both, starting with cache
SearchOrder string
}
SiteLookupOptions contains options for site lookup operations
func DefaultSiteLookupOptions ¶
func DefaultSiteLookupOptions() SiteLookupOptions
DefaultSiteLookupOptions returns the default options for site lookup
type SiteMarshaler ¶
type SiteMarshaler interface {
GetID() string
GetName() string
ToMap() map[string]interface{}
FromMap(data map[string]interface{}) error
ToConfigMap() map[string]interface{}
FromConfigMap(data map[string]interface{}) error
GetRaw() map[string]interface{}
SetRaw(data map[string]interface{})
}
SiteMarshaler defines the interface for bidirectional site data transformation between API representations and structured types.
type SiteSetting ¶
type SiteSetting struct {
// Core identification fields
ID *string `json:"id,omitempty"`
SiteID *string `json:"site_id,omitempty"`
OrgID *string `json:"org_id,omitempty"`
CreatedTime *float64 `json:"created_time,omitempty"`
ModifiedTime *float64 `json:"modified_time,omitempty"`
ForSite *bool `json:"for_site,omitempty"`
// Simple configuration fields
AdditionalConfigCmds *[]string `json:"additional_config_cmds,omitempty"`
GatewayAdditionalConfigCmds *[]string `json:"gateway_additional_config_cmds,omitempty"`
APUpdownThreshold *int `json:"ap_updown_threshold,omitempty"`
AutoUpgradeLinecard *bool `json:"auto_upgrade_linecard,omitempty"`
DenylistURL *string `json:"blacklist_url,omitempty"` // Mist API field name
ConfigAutoRevert *bool `json:"config_auto_revert,omitempty"`
DefaultPortUsage *string `json:"default_port_usage,omitempty"`
DeviceUpdownThreshold *int `json:"device_updown_threshold,omitempty"`
DNSServers *[]string `json:"dns_servers,omitempty"`
DNSSuffix *[]string `json:"dns_suffix,omitempty"`
EnableUnii4 *bool `json:"enable_unii_4,omitempty"`
GatewayUpdownThreshold *int `json:"gateway_updown_threshold,omitempty"`
NTPServers *[]string `json:"ntp_servers,omitempty"`
PersistConfigOnDevice *bool `json:"persist_config_on_device,omitempty"`
RemoveExistingConfigs *bool `json:"remove_existing_configs,omitempty"`
ReportGatt *bool `json:"report_gatt,omitempty"`
SSHKeys *[]string `json:"ssh_keys,omitempty"`
SwitchUpdownThreshold *int `json:"switch_updown_threshold,omitempty"`
TrackAnonymousDevices *bool `json:"track_anonymous_devices,omitempty"`
TuntermMonitoringDisabled *bool `json:"tunterm_monitoring_disabled,omitempty"`
WatchedStationURL *string `json:"watched_station_url,omitempty"`
AllowlistURL *string `json:"whitelist_url,omitempty"` // Mist API field name
// Array fields with complex objects
ACLPolicies []map[string]interface{} `json:"acl_policies,omitempty"`
DisabledSystemDefinedPortUsages *[]string `json:"disabled_system_defined_port_usages,omitempty"`
TuntermMonitoring []map[string]interface{} `json:"tunterm_monitoring,omitempty"`
// Complex nested configuration objects (stored as maps to preserve exact API structure)
ACLTags map[string]interface{} `json:"acl_tags,omitempty"`
Analytic map[string]interface{} `json:"analytic,omitempty"`
APMatching map[string]interface{} `json:"ap_matching,omitempty"`
APPortConfig map[string]interface{} `json:"ap_port_config,omitempty"`
AutoPlacement map[string]interface{} `json:"auto_placement,omitempty"`
AutoUpgrade map[string]interface{} `json:"auto_upgrade,omitempty"`
BLEConfig map[string]interface{} `json:"ble_config,omitempty"`
ConfigPushPolicy map[string]interface{} `json:"config_push_policy,omitempty"`
CriticalURLMonitoring map[string]interface{} `json:"critical_url_monitoring,omitempty"`
DHCPSnooping map[string]interface{} `json:"dhcp_snooping,omitempty"`
Engagement map[string]interface{} `json:"engagement,omitempty"`
EVPNOptions map[string]interface{} `json:"evpn_options,omitempty"`
ExtraRoutes map[string]interface{} `json:"extra_routes,omitempty"`
ExtraRoutes6 map[string]interface{} `json:"extra_routes6,omitempty"`
Flags map[string]interface{} `json:"flags,omitempty"`
Gateway map[string]interface{} `json:"gateway,omitempty"`
GatewayMgmt map[string]interface{} `json:"gateway_mgmt,omitempty"`
JuniperSRX map[string]interface{} `json:"juniper_srx,omitempty"`
LED map[string]interface{} `json:"led,omitempty"`
Marvis map[string]interface{} `json:"marvis,omitempty"`
MistNAC map[string]interface{} `json:"mist_nac,omitempty"`
MXEdge map[string]interface{} `json:"mxedge,omitempty"`
MXEdgeMgmt map[string]interface{} `json:"mxedge_mgmt,omitempty"`
MXTunnels map[string]interface{} `json:"mxtunnels,omitempty"`
Networks map[string]interface{} `json:"networks,omitempty"`
Occupancy map[string]interface{} `json:"occupancy,omitempty"`
OSPFAreas map[string]interface{} `json:"ospf_areas,omitempty"`
PaloAltoNetworks map[string]interface{} `json:"paloalto_networks,omitempty"`
PortMirroring map[string]interface{} `json:"port_mirroring,omitempty"`
PortUsages map[string]interface{} `json:"port_usages,omitempty"`
Proxy map[string]interface{} `json:"proxy,omitempty"`
RadioConfig map[string]interface{} `json:"radio_config,omitempty"`
RadiusConfig map[string]interface{} `json:"radius_config,omitempty"`
RemoteSyslog map[string]interface{} `json:"remote_syslog,omitempty"`
Rogue map[string]interface{} `json:"rogue,omitempty"`
RTSA map[string]interface{} `json:"rtsa,omitempty"`
SimpleAlert map[string]interface{} `json:"simple_alert,omitempty"`
SkyATP map[string]interface{} `json:"skyatp,omitempty"`
SLEThresholds map[string]interface{} `json:"sle_thresholds,omitempty"`
SNMPConfig map[string]interface{} `json:"snmp_config,omitempty"`
SRXApp map[string]interface{} `json:"srx_app,omitempty"`
SSR map[string]interface{} `json:"ssr,omitempty"`
StatusPortal map[string]interface{} `json:"status_portal,omitempty"`
Switch map[string]interface{} `json:"switch,omitempty"`
SwitchMatching map[string]interface{} `json:"switch_matching,omitempty"`
SwitchMgmt map[string]interface{} `json:"switch_mgmt,omitempty"`
SyntheticTest map[string]interface{} `json:"synthetic_test,omitempty"`
TuntermMulticastConfig map[string]interface{} `json:"tunterm_multicast_config,omitempty"`
UplinkPortConfig map[string]interface{} `json:"uplink_port_config,omitempty"`
Vars map[string]interface{} `json:"vars,omitempty"`
VNA map[string]interface{} `json:"vna,omitempty"`
VRFConfig map[string]interface{} `json:"vrf_config,omitempty"`
VRFInstances map[string]interface{} `json:"vrf_instances,omitempty"`
VRRPGroups map[string]interface{} `json:"vrrp_groups,omitempty"`
VSInstance map[string]interface{} `json:"vs_instance,omitempty"`
WANVNA map[string]interface{} `json:"wan_vna,omitempty"`
WIDS map[string]interface{} `json:"wids,omitempty"`
WiFi map[string]interface{} `json:"wifi,omitempty"`
WiredVNA map[string]interface{} `json:"wired_vna,omitempty"`
ZoneOccupancyAlert map[string]interface{} `json:"zone_occupancy_alert,omitempty"`
// Additional configuration for any unmapped fields
AdditionalConfig map[string]interface{} `json:"-"`
}
SiteSetting represents a Mist site setting with comprehensive field mapping This follows the comprehensive FromMap/ToMap pattern to preserve exact API response structure
func NewSiteSettingFromMap ¶
func NewSiteSettingFromMap(data map[string]interface{}) (*SiteSetting, error)
NewSiteSettingFromMap creates a new site setting from a map representation
func (*SiteSetting) FromMap ¶
func (ss *SiteSetting) FromMap(data map[string]interface{}) error
FromMap populates the site setting from a map representation (e.g., from API response)
func (*SiteSetting) GetSiteID ¶
func (ss *SiteSetting) GetSiteID() string
GetSiteID returns the site ID
func (*SiteSetting) ToMap ¶
func (ss *SiteSetting) ToMap() map[string]interface{}
ToMap converts the site setting to a map representation suitable for API requests
type SortConfig ¶
type SortConfig[T any] struct { // Fields defines the sort fields in priority order Fields []SortField[T] // EmptyLast determines if empty values should be sorted last // Set to false to sort empty values first EmptyLast bool }
SortConfig defines the configuration for multi-level sorting
type SortField ¶
SortField defines a field extractor function for sorting
func GetStringField ¶
GetStringField creates a field extractor for simple string pointer fields
type SwitchConfig ¶
type SwitchConfig = MistSwitchDevice
SwitchConfig represents a Switch device configuration This uses the same structure as MistSwitchDevice since configs follow the same schema
type SwitchDeviceInterface ¶
type SwitchDeviceInterface interface {
DeviceMarshaler
GetIP() *string
GetPort() *int
GetVersion() *string
GetRole() *string
GetManaged() *bool
GetRouterID() *string
GetPortConfig() map[string]interface{}
GetNetworks() map[string]interface{}
GetIPConfig() map[string]interface{}
}
SwitchDeviceInterface defines the interface for switch device operations. Note: The "Interface" suffix is retained because there is a struct named MistSwitchDevice.
type UnifiedCache ¶
type UnifiedCache struct {
*CacheManager
// contains filtered or unexported fields
}
UnifiedCache implements Cacher using the existing CacheManager
func (*UnifiedCache) GetAllSites ¶
func (uc *UnifiedCache) GetAllSites() ([]*MistSite, error)
GetAllSites returns all sites
func (*UnifiedCache) GetConfigs ¶
func (uc *UnifiedCache) GetConfigs(orgID, deviceType string) ([]any, error)
GetConfigs retrieves configurations by type
func (*UnifiedCache) GetDevice ¶
func (uc *UnifiedCache) GetDevice(mac string) (*UnifiedDevice, error)
GetDevice retrieves a device by MAC address
func (*UnifiedCache) GetDevicesByType ¶
func (uc *UnifiedCache) GetDevicesByType(siteID, deviceType string) ([]UnifiedDevice, error)
GetDevicesByType retrieves devices by site and type
func (*UnifiedCache) GetInventory ¶
func (uc *UnifiedCache) GetInventory(deviceType string) ([]any, error)
GetInventory retrieves inventory items by type
func (*UnifiedCache) GetMetadata ¶
func (uc *UnifiedCache) GetMetadata() *CacheMetadata
GetMetadata returns cache metadata (deprecated - metadata now in separate file)
func (*UnifiedCache) GetOrgData ¶
func (uc *UnifiedCache) GetOrgData(orgID string) (*OrgData, error)
GetOrgData returns organization data, creating it if necessary
func (*UnifiedCache) GetPath ¶
func (uc *UnifiedCache) GetPath() string
GetPath returns the cache file path
func (*UnifiedCache) GetProfiles ¶
func (uc *UnifiedCache) GetProfiles(profileType string) ([]any, error)
GetProfiles retrieves profiles by type
func (*UnifiedCache) GetSite ¶
func (uc *UnifiedCache) GetSite(identifier string) (*MistSite, error)
GetSite retrieves a site by name or ID
func (*UnifiedCache) IsDirty ¶
func (uc *UnifiedCache) IsDirty() bool
IsDirty returns whether the cache has unsaved changes
func (*UnifiedCache) MarkDirty ¶
func (uc *UnifiedCache) MarkDirty()
MarkDirty marks the cache as having unsaved changes
func (*UnifiedCache) MergeConfigs ¶
func (uc *UnifiedCache) MergeConfigs(orgID, deviceType string, configs []any) error
MergeConfigs merges new configurations with existing ones
func (*UnifiedCache) SetOrgData ¶
func (uc *UnifiedCache) SetOrgData(orgID string, data *OrgData) error
SetOrgData sets organization data
func (*UnifiedCache) UpdateConfigs ¶
func (uc *UnifiedCache) UpdateConfigs(orgID, deviceType string, configs []any) error
UpdateConfigs replaces configurations
func (*UnifiedCache) UpdateDevice ¶
func (uc *UnifiedCache) UpdateDevice(device *UnifiedDevice) error
UpdateDevice updates or adds a device
func (*UnifiedCache) UpdateInventory ¶
func (uc *UnifiedCache) UpdateInventory(deviceType string, items []any) error
UpdateInventory updates inventory items
func (*UnifiedCache) UpdateMetadata ¶
func (uc *UnifiedCache) UpdateMetadata(_ *CacheMetadata)
UpdateMetadata updates cache metadata (deprecated - metadata now in separate file)
func (*UnifiedCache) UpdateProfiles ¶
func (uc *UnifiedCache) UpdateProfiles(profileType string, profiles []any) error
UpdateProfiles updates profiles
func (*UnifiedCache) UpdateSite ¶
func (uc *UnifiedCache) UpdateSite(site *MistSite) error
UpdateSite updates or adds a site
type UnifiedDevice ¶
type UnifiedDevice struct {
BaseDevice
// Device-specific configuration stored as maps for flexibility
// This preserves all device-specific fields while maintaining type safety for core fields
DeviceConfig map[string]interface{} `json:"device_config,omitempty"`
// Internal: not serialized, used for type identification and routing
DeviceType string `json:"-"`
}
UnifiedDevice is a universal container that can represent any device type with complete data preservation
func ConvertFromRawMap ¶
func ConvertFromRawMap(rawData map[string]interface{}) (*UnifiedDevice, error)
ConvertFromRawMap converts a raw map to a UnifiedDevice
func MergeDeviceData ¶
func MergeDeviceData(base UnifiedDevice, update UnifiedDevice) UnifiedDevice
MergeDeviceData merges data from inventory and site-specific API responses
func NewUnifiedDeviceFromMap ¶
func NewUnifiedDeviceFromMap(data map[string]interface{}) (*UnifiedDevice, error)
NewUnifiedDeviceFromMap creates a new UnifiedDevice from API response data
func NewUnifiedDeviceFromType ¶
func NewUnifiedDeviceFromType(deviceType string) *UnifiedDevice
NewUnifiedDeviceFromType creates a new UnifiedDevice with the specified device type
func (*UnifiedDevice) FromConfigMap ¶
func (ud *UnifiedDevice) FromConfigMap(data map[string]interface{}) error
FromConfigMap populates unified device from configuration map (from config files)
func (*UnifiedDevice) FromMap ¶
func (ud *UnifiedDevice) FromMap(data map[string]interface{}) error
FromMap populates the UnifiedDevice from API response data
func (*UnifiedDevice) GetDeviceProfileID ¶
func (ud *UnifiedDevice) GetDeviceProfileID() *string
func (*UnifiedDevice) GetID ¶
func (ud *UnifiedDevice) GetID() *string
Implement DeviceMarshaler for UnifiedDevice
func (*UnifiedDevice) GetMAC ¶
func (ud *UnifiedDevice) GetMAC() *string
func (*UnifiedDevice) GetMagic ¶
func (ud *UnifiedDevice) GetMagic() *string
func (*UnifiedDevice) GetModel ¶
func (ud *UnifiedDevice) GetModel() *string
func (*UnifiedDevice) GetName ¶
func (ud *UnifiedDevice) GetName() *string
func (*UnifiedDevice) GetOrgID ¶
func (ud *UnifiedDevice) GetOrgID() *string
func (*UnifiedDevice) GetSerial ¶
func (ud *UnifiedDevice) GetSerial() *string
func (*UnifiedDevice) GetSiteID ¶
func (ud *UnifiedDevice) GetSiteID() *string
func (*UnifiedDevice) GetType ¶
func (ud *UnifiedDevice) GetType() *string
func (*UnifiedDevice) ToConfigMap ¶
func (ud *UnifiedDevice) ToConfigMap() map[string]interface{}
ToConfigMap converts unified device to configuration map (for config files)
func (*UnifiedDevice) ToMap ¶
func (ud *UnifiedDevice) ToMap() map[string]interface{}
ToMap converts the UnifiedDevice to a map for API operations
Source Files
¶
- ap_device_types.go
- cache.go
- cache_accessor.go
- cache_accessor_configs.go
- cache_accessor_devices.go
- cache_accessor_org.go
- cache_accessor_templates.go
- cache_factory.go
- cache_interface.go
- cache_storage.go
- cache_storage_indexes.go
- cache_types.go
- cache_types_gw_template.go
- cache_types_network.go
- cache_types_rf_template.go
- cache_types_sites.go
- cache_types_wlan.go
- cache_types_wlan_template.go
- cache_unified.go
- cache_unified_configs.go
- cache_unified_devices.go
- cache_verification.go
- client.go
- client_ap.go
- client_config.go
- client_device.go
- client_device_common.go
- client_device_config.go
- client_device_new_methods.go
- client_device_profile.go
- client_directory.go
- client_generic.go
- client_gw_template.go
- client_http.go
- client_http_ext.go
- client_inventory.go
- client_network.go
- client_org.go
- client_rf_template.go
- client_search.go
- client_site.go
- client_validation.go
- client_validation_types.go
- client_wlan.go
- client_wlan_template.go
- device_cache.go
- device_config_types.go
- device_models.go
- device_profile_types.go
- gateway_device_types.go
- generic_sort.go
- inventory_types.go
- lookup.go
- mock_client_auth.go
- mock_client_base.go
- mock_client_cache.go
- mock_client_devices.go
- mock_client_inventory.go
- mock_client_org.go
- mock_client_profiles.go
- mock_client_search.go
- mock_client_site_lookup.go
- mock_client_sites.go
- mock_client_templates.go
- mock_client_utils.go
- org_stats_types.go
- schema_validation.go
- search_types.go
- service.go
- site_lookup.go
- site_setting_types.go
- site_types.go
- sort.go
- switch_device_types.go
- token_validator.go
- types.go
- unified_device_types.go