scanopy

package
v0.99.12 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package scanopy implements the Scanopy network topology discovery provider.

Index

Constants

View Source
const (
	ID          = "scanopy"
	EndpointKey = "endpoint"
	APIKeyKey   = "api_key"
)

Variables

This section is empty.

Functions

func LimitOf

func LimitOf(n int) *int

LimitOf returns a Limit pointer for ListParams.

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

func NewScanopy(endpoint, apiKey string) *Scanopy

NewScanopy creates a Scanopy client with Bearer user API key auth. Returns nil when endpoint is empty.

func (*Scanopy) GetHost

func (s *Scanopy) GetHost(ctx context.Context, id string) (*Host, error)

GetHost returns a single host by ID (includes children by default).

func (*Scanopy) GetVersion

func (s *Scanopy) GetVersion(ctx context.Context) (*VersionInfo, error)

GetVersion returns API and server versions from GET /api/version.

func (*Scanopy) Health

func (s *Scanopy) Health(ctx context.Context) error

Health reports whether GET /api/version succeeds.

func (*Scanopy) ListDaemons

func (s *Scanopy) ListDaemons(ctx context.Context, params ListParams) (*Page[Daemon], error)

ListDaemons returns scanning daemons.

func (*Scanopy) ListHosts

func (s *Scanopy) ListHosts(ctx context.Context, params ListParams) (*Page[Host], error)

ListHosts returns hosts, optionally filtered by network, search, or staleness.

func (*Scanopy) ListNetworks

func (s *Scanopy) ListNetworks(ctx context.Context, params ListParams) (*Page[Network], error)

ListNetworks returns networks the API key can access.

func (*Scanopy) ListServices

func (s *Scanopy) ListServices(ctx context.Context, params ListParams) (*Page[Service], error)

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.

Jump to

Keyboard shortcuts

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