Documentation
¶
Overview ¶
Package scanopy implements the Scanopy network topology discovery provider.
Index ¶
- Constants
- func LimitOf(n int) *int
- type Daemon
- type DaemonVersionStatus
- type EntitySource
- type Envelope
- type Host
- type IPAddress
- type ListParams
- type Meta
- type Network
- type Page
- type PaginationMeta
- type Port
- type Scanopy
- func (s *Scanopy) GetHost(ctx context.Context, id string) (*Host, error)
- func (s *Scanopy) GetVersion(ctx context.Context) (*VersionInfo, error)
- func (s *Scanopy) Health(ctx context.Context) error
- func (s *Scanopy) ListDaemons(ctx context.Context, params ListParams) (*Page[Daemon], error)
- func (s *Scanopy) ListHosts(ctx context.Context, params ListParams) (*Page[Host], error)
- func (s *Scanopy) ListNetworks(ctx context.Context, params ListParams) (*Page[Network], error)
- func (s *Scanopy) ListServices(ctx context.Context, params ListParams) (*Page[Service], error)
- type Service
- type VersionInfo
Constants ¶
const ( ID = "scanopy" EndpointKey = "endpoint" APIKeyKey = "api_key" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Daemon ¶
type Daemon struct {
ID string `json:"id"`
Name string `json:"name"`
NetworkID string `json:"network_id,omitzero"`
HostID string `json:"host_id,omitzero"`
Mode string `json:"mode,omitzero"`
Version string `json:"version,omitzero"`
LastSeen string `json:"last_seen,omitzero"`
IsUnreachable bool `json:"is_unreachable"`
URL string `json:"url,omitzero"`
VersionStatus *DaemonVersionStatus `json:"version_status,omitzero"`
CreatedAt string `json:"created_at,omitzero"`
UpdatedAt string `json:"updated_at,omitzero"`
}
Daemon is a scanning agent.
type DaemonVersionStatus ¶
type DaemonVersionStatus struct {
Status string `json:"status,omitzero"`
Version string `json:"version,omitzero"`
}
DaemonVersionStatus is computed daemon version health.
type EntitySource ¶
type EntitySource struct {
Type string `json:"type,omitzero"`
}
EntitySource describes how an entity was created.
type Envelope ¶
type Envelope[T any] struct { Success bool `json:"success"` Data T `json:"data"` Error string `json:"error,omitzero"` Meta Meta `json:"meta"` }
Envelope is the standard Scanopy API response wrapper.
type Host ¶
type Host struct {
ID string `json:"id"`
Name string `json:"name"`
NameSource string `json:"name_source,omitzero"`
Hostname string `json:"hostname,omitzero"`
Description string `json:"description,omitzero"`
NetworkID string `json:"network_id"`
Hidden bool `json:"hidden"`
LastSeenAt string `json:"last_seen_at,omitzero"`
Manufacturer string `json:"manufacturer,omitzero"`
Model string `json:"model,omitzero"`
ManagementURL string `json:"management_url,omitzero"`
Source EntitySource `json:"source,omitzero"`
Tags []string `json:"tags,omitzero"`
IPAddresses []IPAddress `json:"ip_addresses,omitzero"`
Ports []Port `json:"ports,omitzero"`
Services []Service `json:"services,omitzero"`
CreatedAt string `json:"created_at,omitzero"`
UpdatedAt string `json:"updated_at,omitzero"`
}
Host is a discovered or manually created network host.
type IPAddress ¶
type IPAddress struct {
ID string `json:"id"`
NetworkID string `json:"network_id,omitzero"`
HostID string `json:"host_id,omitzero"`
SubnetID string `json:"subnet_id,omitzero"`
IPAddress string `json:"ip_address"`
MACAddress string `json:"mac_address,omitzero"`
Name string `json:"name,omitzero"`
Position int `json:"position,omitzero"`
}
IPAddress is an IP assigned to a host.
type ListParams ¶
type ListParams struct {
NetworkID string
HostID string
Search string
// Limit is optional. nil omits the query (API default 50).
// Use a pointer to 0 for Scanopy "no limit".
Limit *int
Offset int
}
ListParams holds shared list/filter/pagination options.
type Meta ¶
type Meta struct {
APIVersion int `json:"api_version"`
ServerVersion string `json:"server_version"`
Pagination *PaginationMeta `json:"pagination,omitzero"`
}
Meta holds API and optional pagination metadata.
type Network ¶
type Network struct {
ID string `json:"id"`
Name string `json:"name"`
OrganizationID string `json:"organization_id,omitzero"`
StaleAfterHours *int64 `json:"stale_after_hours,omitzero"`
EffectiveStaleAfterHours int64 `json:"effective_stale_after_hours,omitzero"`
Tags []string `json:"tags,omitzero"`
CreatedAt string `json:"created_at,omitzero"`
UpdatedAt string `json:"updated_at,omitzero"`
}
Network is a Scanopy network container.
type Page ¶
type Page[T any] struct { Items []T Pagination PaginationMeta Meta Meta }
Page is a typed list result with pagination metadata.
type PaginationMeta ¶
type PaginationMeta struct {
TotalCount int64 `json:"total_count"`
Limit int `json:"limit"`
Offset int `json:"offset"`
HasMore bool `json:"has_more"`
}
PaginationMeta describes a paginated list page.
type Port ¶
type Port struct {
ID string `json:"id"`
HostID string `json:"host_id,omitzero"`
NetworkID string `json:"network_id,omitzero"`
Number int `json:"number"`
Protocol string `json:"protocol,omitzero"`
Type string `json:"type,omitzero"`
}
Port is an open port on a host.
type Scanopy ¶
type Scanopy struct {
// contains filtered or unexported fields
}
Scanopy is an HTTP client for the Scanopy REST API (/api/v1).
func GetClient ¶
func GetClient() *Scanopy
GetClient builds a Scanopy client from providers.scanopy config. Returns nil when endpoint is not configured.
func NewScanopy ¶
NewScanopy creates a Scanopy client with Bearer user API key auth. Returns nil when endpoint is empty.
func (*Scanopy) GetVersion ¶
func (s *Scanopy) GetVersion(ctx context.Context) (*VersionInfo, error)
GetVersion returns API and server versions from GET /api/version.
func (*Scanopy) ListDaemons ¶
ListDaemons returns scanning daemons.
func (*Scanopy) ListHosts ¶
ListHosts returns hosts, optionally filtered by network, search, or staleness.
func (*Scanopy) ListNetworks ¶
ListNetworks returns networks the API key can access.
func (*Scanopy) ListServices ¶
ListServices returns services, optionally filtered by network or host.
type Service ¶
type Service struct {
ID string `json:"id"`
Name string `json:"name"`
HostID string `json:"host_id,omitzero"`
NetworkID string `json:"network_id,omitzero"`
ServiceDefinition string `json:"service_definition,omitzero"`
Position int `json:"position,omitzero"`
Source EntitySource `json:"source,omitzero"`
Tags []string `json:"tags,omitzero"`
LastSeenAt string `json:"last_seen_at,omitzero"`
CreatedAt string `json:"created_at,omitzero"`
UpdatedAt string `json:"updated_at,omitzero"`
}
Service is a detected or manually added service on a host.
type VersionInfo ¶
type VersionInfo struct {
APIVersion int `json:"api_version"`
ServerVersion string `json:"server_version"`
MinCompatibleClient string `json:"min_compatible_client,omitzero"`
}
VersionInfo is returned by GET /api/version.