api

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIHandler

type APIHandler struct {
	// contains filtered or unexported fields
}

func NewAPIHandler

func NewAPIHandler(d *daemon.Daemon) *APIHandler

func (*APIHandler) CreateSpammer

func (ah *APIHandler) CreateSpammer(w http.ResponseWriter, r *http.Request)

CreateSpammer godoc @Id createSpammer @Summary Create a new spammer @Tags Spammer @Description Creates a new spammer with the given configuration @Accept json @Produce json @Param request body CreateSpammerRequest true "Spammer configuration" @Success 200 {object} int64 "Spammer ID" @Failure 400 {string} string "Invalid request" @Failure 500 {string} string "Server Error" @Router /api/spammer [post]

func (*APIHandler) DeleteSpammer

func (ah *APIHandler) DeleteSpammer(w http.ResponseWriter, r *http.Request)

DeleteSpammer godoc @Id deleteSpammer @Summary Delete a spammer @Tags Spammer @Description Deletes a spammer and stops it if running @Param id path int true "Spammer ID" @Success 200 "Success" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Failure 500 {string} string "Server Error" @Router /api/spammer/{id} [delete]

func (*APIHandler) ExportSpammers added in v1.1.5

func (ah *APIHandler) ExportSpammers(w http.ResponseWriter, r *http.Request)

ExportSpammers godoc @Id exportSpammers @Summary Export spammers to YAML @Tags Spammer @Description Exports specified spammers or all spammers to YAML format @Accept json @Produce text/plain @Param request body ExportSpammersRequest false "Spammer IDs to export (optional)" @Success 200 {string} string "YAML configuration" @Failure 400 {string} string "Invalid request" @Failure 500 {string} string "Server Error" @Router /api/spammers/export [post]

func (*APIHandler) GetClients added in v1.1.5

func (ah *APIHandler) GetClients(w http.ResponseWriter, r *http.Request)

GetClients godoc @Id getClients @Summary Get all clients @Tags Client @Description Returns a list of all clients with their details @Produce json @Success 200 {array} ClientEntry "Success" @Router /api/clients [get]

func (*APIHandler) GetGraphsDashboard added in v1.1.6

func (ah *APIHandler) GetGraphsDashboard(w http.ResponseWriter, r *http.Request)

@Summary Get graphs dashboard data @Tags Graphs @Description Returns comprehensive graphs data for the dashboard including all spammers, totals, and time-series data @Produce json @Success 200 {object} GraphsDashboardResponse "Success" @Failure 500 {string} string "Server Error" @Router /api/graphs/dashboard [get]

func (*APIHandler) GetScenarioConfig

func (ah *APIHandler) GetScenarioConfig(w http.ResponseWriter, r *http.Request)

GetScenarioConfig godoc @Id getScenarioConfig @Summary Get scenario configuration @Tags Scenario @Description Returns the default configuration for a specific scenario @Produce text/plain @Param name path string true "Scenario name" @Success 200 {string} string "YAML configuration" @Failure 404 {string} string "Scenario not found" @Failure 500 {string} string "Server Error" @Router /api/scenarios/{name}/config [get]

func (*APIHandler) GetScenarios

func (ah *APIHandler) GetScenarios(w http.ResponseWriter, r *http.Request)

GetScenarios godoc @Id getScenarios @Summary Get all scenarios @Tags Scenario @Description Returns a list of all scenarios @Produce json @Success 200 {array} ScenarioEntries "Success" @Failure 400 {string} string "Failure" @Failure 500 {string} string "Server Error" @Router /api/scenarios [get]

func (*APIHandler) GetSpammerDetails

func (ah *APIHandler) GetSpammerDetails(w http.ResponseWriter, r *http.Request)

GetSpammerDetails godoc @Id getSpammerDetails @Summary Get spammer details @Tags Spammer @Description Returns detailed information about a specific spammer @Produce json @Param id path int true "Spammer ID" @Success 200 {object} SpammerDetails "Success" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Router /api/spammer/{id} [get]

func (*APIHandler) GetSpammerLibraryIndex added in v1.1.6

func (ah *APIHandler) GetSpammerLibraryIndex(w http.ResponseWriter, r *http.Request)

GetSpammerLibraryIndex godoc @Id getSpammerLibraryIndex @Summary Get spammer library index @Tags SpammerLibrary @Description Returns the index of available spammer configurations from GitHub @Produce json @Success 200 {object} SpammerLibraryIndex "Success" @Failure 500 {string} string "Server Error" @Router /api/spammer-library/index [get]

func (*APIHandler) GetSpammerList

func (ah *APIHandler) GetSpammerList(w http.ResponseWriter, r *http.Request)

GetSpammerList godoc @Id getSpammerList @Summary Get all spammers @Tags Spammer @Description Returns a list of all configured spammers @Produce json @Success 200 {array} SpammerListEntry "Success" @Router /api/spammers [get]

func (*APIHandler) GetSpammerLogs

func (ah *APIHandler) GetSpammerLogs(w http.ResponseWriter, r *http.Request)

GetSpammerLogs godoc @Id getSpammerLogs @Summary Get spammer logs @Tags Spammer @Description Returns the most recent logs for a specific spammer @Produce json @Param id path int true "Spammer ID" @Success 200 {array} LogEntry "Success" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Router /api/spammer/{id}/logs [get]

func (*APIHandler) GetSpammerTimeSeries added in v1.1.6

func (ah *APIHandler) GetSpammerTimeSeries(w http.ResponseWriter, r *http.Request)

@Summary Get time-series data for a specific spammer @Tags Graphs @Description Returns detailed time-series graphs data for a specific spammer @Produce json @Param id path int true "Spammer ID" @Success 200 {object} SpammerTimeSeriesResponse "Success" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Failure 500 {string} string "Server Error" @Router /api/graphs/spammer/{id}/timeseries [get]

func (*APIHandler) GetVersion added in v1.1.6

func (ah *APIHandler) GetVersion(w http.ResponseWriter, r *http.Request)

GetVersion godoc @Id getVersion @Summary Get spamoor version @Tags Version @Description Returns the current spamoor version information @Produce json @Success 200 {object} VersionResponse "Success" @Router /api/version [get]

func (*APIHandler) ImportSpammers added in v1.1.5

func (ah *APIHandler) ImportSpammers(w http.ResponseWriter, r *http.Request)

ImportSpammers godoc @Id importSpammers @Summary Import spammers from YAML data or URL @Tags Spammer @Description Imports spammers from YAML data or URL with validation and deduplication @Accept json @Produce json @Param request body ImportSpammersRequest true "Import configuration" @Success 200 {object} daemon.ImportResult "Success" @Failure 400 {string} string "Invalid request" @Failure 500 {string} string "Server Error" @Router /api/spammers/import [post]

func (*APIHandler) PauseSpammer

func (ah *APIHandler) PauseSpammer(w http.ResponseWriter, r *http.Request)

PauseSpammer godoc @Id pauseSpammer @Summary Pause a spammer @Tags Spammer @Description Pauses a running spammer @Param id path int true "Spammer ID" @Success 200 "Success" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Failure 500 {string} string "Server Error" @Router /api/spammer/{id}/pause [post]

func (*APIHandler) ReclaimFunds added in v1.1.4

func (ah *APIHandler) ReclaimFunds(w http.ResponseWriter, r *http.Request)

ReclaimFunds godoc @Id reclaimFunds @Summary Reclaim funds from a spammer @Tags Spammer @Description Reclaims funds from a spammer's wallet pool back to the root wallet @Param id path int true "Spammer ID" @Success 200 "Success" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Failure 500 {string} string "Server Error" @Router /api/spammer/{id}/reclaim [post]

func (*APIHandler) StartSpammer

func (ah *APIHandler) StartSpammer(w http.ResponseWriter, r *http.Request)

StartSpammer godoc @Id startSpammer @Summary Start a spammer @Tags Spammer @Description Starts a specific spammer @Param id path int true "Spammer ID" @Success 200 "Success" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Failure 500 {string} string "Server Error" @Router /api/spammer/{id}/start [post]

func (*APIHandler) StreamGraphs added in v1.1.6

func (ah *APIHandler) StreamGraphs(w http.ResponseWriter, r *http.Request)

@Summary Stream real-time graphs updates @Tags Graphs @Description Provides real-time graphs updates via Server-Sent Events (SSE) @Produce text/event-stream @Success 200 {string} string "SSE stream" @Router /api/graphs/stream [get]

func (*APIHandler) StreamSpammerLogs

func (ah *APIHandler) StreamSpammerLogs(w http.ResponseWriter, r *http.Request)

StreamSpammerLogs godoc @Id streamSpammerLogs @Summary Stream spammer logs @Tags Spammer @Description Streams logs for a specific spammer using Server-Sent Events @Produce text/event-stream @Param id path int true "Spammer ID" @Param since query string false "Timestamp to start from (RFC3339Nano)" @Success 200 {string} string "SSE stream of log entries" @Failure 400 {string} string "Invalid spammer ID" @Failure 404 {string} string "Spammer not found" @Failure 500 {string} string "Streaming unsupported" @Router /api/spammer/{id}/logs/stream [get]

func (*APIHandler) UpdateClientEnabled added in v1.1.5

func (ah *APIHandler) UpdateClientEnabled(w http.ResponseWriter, r *http.Request)

UpdateClientEnabled godoc @Id updateClientEnabled @Summary Update client enabled state @Tags Client @Description Updates the enabled state for a specific client @Accept json @Param index path int true "Client index" @Param request body UpdateClientEnabledRequest true "New enabled state" @Success 200 "Success" @Failure 400 {string} string "Invalid client index" @Failure 404 {string} string "Client not found" @Router /api/client/{index}/enabled [put]

func (*APIHandler) UpdateClientGroup added in v1.1.5

func (ah *APIHandler) UpdateClientGroup(w http.ResponseWriter, r *http.Request)

UpdateClientGroup godoc @Id updateClientGroup @Summary Update client group @Tags Client @Description Updates the group(s) for a specific client. Supports both single group (backward compatibility) and multiple groups. @Accept json @Param index path int true "Client index" @Param request body UpdateClientGroupRequest true "New group name(s)" @Success 200 "Success" @Failure 400 {string} string "Invalid client index" @Failure 404 {string} string "Client not found" @Router /api/client/{index}/group [put]

func (*APIHandler) UpdateClientName added in v1.1.6

func (ah *APIHandler) UpdateClientName(w http.ResponseWriter, r *http.Request)

UpdateClientName godoc @Id updateClientName @Summary Update client name override @Tags Client @Description Updates the name override for a specific client @Accept json @Param index path int true "Client index" @Param request body UpdateClientNameRequest true "New name override" @Success 200 "Success" @Failure 400 {string} string "Invalid client index" @Failure 404 {string} string "Client not found" @Router /api/client/{index}/name [put]

func (*APIHandler) UpdateSpammer

func (ah *APIHandler) UpdateSpammer(w http.ResponseWriter, r *http.Request)

UpdateSpammer godoc @Id updateSpammer @Summary Update a spammer @Tags Spammer @Description Updates an existing spammer's configuration @Accept json @Param id path int true "Spammer ID" @Param request body UpdateSpammerRequest true "Updated configuration" @Success 200 "Success" @Failure 400 {string} string "Invalid request" @Failure 404 {string} string "Spammer not found" @Failure 500 {string} string "Server Error" @Router /api/spammer/{id} [put]

type ClientEntry added in v1.1.5

type ClientEntry struct {
	Index        int      `json:"index"`
	Name         string   `json:"name"`
	Group        string   `json:"group"`  // First group for backward compatibility
	Groups       []string `json:"groups"` // All groups
	Version      string   `json:"version"`
	BlockHeight  uint64   `json:"block_height"`
	IsReady      bool     `json:"ready"`
	RpcHost      string   `json:"rpc_host"`
	Enabled      bool     `json:"enabled"`
	NameOverride string   `json:"name_override,omitempty"`
}

ClientEntry represents a client in the API response

type CreateSpammerRequest

type CreateSpammerRequest struct {
	Name             string `json:"name"`
	Description      string `json:"description"`
	Scenario         string `json:"scenario"`
	Config           string `json:"config"`
	StartImmediately bool   `json:"startImmediately"`
}

CreateSpammerRequest represents the request body for creating a new spammer

type ExportSpammersRequest added in v1.1.5

type ExportSpammersRequest struct {
	SpammerIDs []int64 `json:"spammer_ids,omitempty"` // If empty, exports all spammers
}

ExportSpammersRequest represents the request body for exporting spammers

type GitHubFile added in v1.1.6

type GitHubFile struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	Sha         string `json:"sha"`
	Size        int    `json:"size"`
	URL         string `json:"url"`
	HTMLURL     string `json:"html_url"`
	GitURL      string `json:"git_url"`
	DownloadURL string `json:"download_url"`
	Type        string `json:"type"`
}

GitHubFile represents a file from GitHub API

type GraphsDashboardResponse added in v1.1.6

type GraphsDashboardResponse struct {
	TimeRange  TimeRange            `json:"range"`
	Spammers   []SpammerMetricsData `json:"spammers"`
	Totals     TotalMetricsData     `json:"totals"`
	Others     OthersMetricsData    `json:"others"`
	DataPoints []GraphsDataPoint    `json:"data"`
}

GraphsDashboardResponse represents the main dashboard graphs data

type GraphsDataPoint added in v1.1.6

type GraphsDataPoint struct {
	Timestamp        time.Time                    `json:"ts"`
	StartBlockNumber uint64                       `json:"startBlock"`
	EndBlockNumber   uint64                       `json:"endBlock"`
	BlockCount       uint64                       `json:"blocks"`
	TotalGasUsed     uint64                       `json:"totalGas"`
	OthersGasUsed    uint64                       `json:"othersGas"`
	SpammerData      map[string]*SpammerBlockData `json:"spammers"` // spammerID -> detailed data
}

GraphsDataPoint represents a single time-series data point for the graphs

type ImportSpammersRequest added in v1.1.5

type ImportSpammersRequest struct {
	Input string `json:"input"` // Can be YAML data or a URL
}

ImportSpammersRequest represents the request body for importing spammers

type LogEntry

type LogEntry struct {
	Time    string            `json:"time"`
	Level   string            `json:"level"`
	Message string            `json:"message"`
	Fields  map[string]string `json:"fields"`
}

type OthersMetricsData added in v1.1.6

type OthersMetricsData struct {
	GasUsedInWindow uint64 `json:"gasUsed"`
}

OthersMetricsData represents metrics for non-spammer transactions

type SSEState added in v1.1.6

type SSEState struct {
	// contains filtered or unexported fields
}

SSE state tracking

type ScenarioEntries

type ScenarioEntries struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

type SpammerBlockData added in v1.1.6

type SpammerBlockData struct {
	GasUsed          uint64 `json:"gas"`
	ConfirmedTxCount uint64 `json:"confirmed"`
	PendingTxCount   uint64 `json:"pending"`
	SubmittedTxCount uint64 `json:"submitted"`
}

SpammerBlockData represents a spammer's data within a time period

type SpammerDetails

type SpammerDetails struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Scenario    string `json:"scenario"`
	Config      string `json:"config"`
	Status      int    `json:"status"`
}

SpammerDetails represents detailed information about a spammer

type SpammerLibraryEntry added in v1.1.6

type SpammerLibraryEntry struct {
	File         string   `json:"file"`
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	Tags         []string `json:"tags"`
	SpammerCount int      `json:"spammer_count"`
	Scenarios    []string `json:"scenarios"`
	MinVersion   string   `json:"min_version,omitempty"`
}

SpammerLibraryEntry represents a spammer config from the library

type SpammerLibraryIndex added in v1.1.6

type SpammerLibraryIndex struct {
	Generated time.Time             `json:"generated"`
	Configs   []SpammerLibraryEntry `json:"configs"`
	CachedAt  time.Time             `json:"cached_at"`
	BaseURL   string                `json:"base_url"`
}

SpammerLibraryIndex represents the index of all available configs

type SpammerListEntry

type SpammerListEntry struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Scenario    string `json:"scenario"`
	Status      int    `json:"status"`
	CreatedAt   string `json:"created_at"` // RFC3339Nano formatted timestamp
}

type SpammerMetricsData added in v1.1.6

type SpammerMetricsData struct {
	ID               uint64 `json:"id"`
	Name             string `json:"name"`
	PendingTxCount   uint64 `json:"pending"`
	ConfirmedTxCount uint64 `json:"confirmed"`
	SubmittedTxCount uint64 `json:"submitted"`
	GasUsedInWindow  uint64 `json:"gasUsed"`
	LastUpdate       string `json:"updated"`
	Status           int    `json:"status"` // Running status from daemon
}

SpammerMetricsData represents metrics for a single spammer

type SpammerTimeSeriesPoint added in v1.1.6

type SpammerTimeSeriesPoint struct {
	Timestamp        time.Time `json:"timestamp"`
	BlockNumber      uint64    `json:"blockNumber"`
	GasUsed          uint64    `json:"gasUsed"`
	ConfirmedTxCount uint64    `json:"confirmedTxCount"`
	PendingTxCount   uint64    `json:"pendingTxCount"`
}

SpammerTimeSeriesPoint represents a single time-series point for a spammer

type SpammerTimeSeriesResponse added in v1.1.6

type SpammerTimeSeriesResponse struct {
	SpammerID   uint64                   `json:"spammerId"`
	SpammerName string                   `json:"spammerName"`
	TimeRange   TimeRange                `json:"timeRange"`
	DataPoints  []SpammerTimeSeriesPoint `json:"dataPoints"`
}

SpammerTimeSeriesResponse represents time-series data for a specific spammer

type TimeRange added in v1.1.6

type TimeRange struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

TimeRange represents the time range of collected metrics

type TotalMetricsData added in v1.1.6

type TotalMetricsData struct {
	PendingTxCount   uint64 `json:"pending"`
	ConfirmedTxCount uint64 `json:"confirmed"`
	SubmittedTxCount uint64 `json:"submitted"`
	GasUsedInWindow  uint64 `json:"gasUsed"`
}

TotalMetricsData represents aggregated metrics across all spammers

type UpdateClientEnabledRequest added in v1.1.5

type UpdateClientEnabledRequest struct {
	Enabled bool `json:"enabled"`
}

UpdateClientEnabledRequest represents the request body for updating a client's enabled state

type UpdateClientGroupRequest added in v1.1.5

type UpdateClientGroupRequest struct {
	Group  string   `json:"group,omitempty"`  // Single group for backward compatibility
	Groups []string `json:"groups,omitempty"` // Multiple groups
}

UpdateClientGroupRequest represents the request body for updating a client group

type UpdateClientNameRequest added in v1.1.6

type UpdateClientNameRequest struct {
	NameOverride string `json:"name_override"`
}

UpdateClientNameRequest represents the request body for updating a client's name override

type UpdateSpammerRequest

type UpdateSpammerRequest struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Config      string `json:"config"`
}

UpdateSpammerRequest represents the request body for updating a spammer

type VersionResponse added in v1.1.6

type VersionResponse struct {
	Version string `json:"version"`
	Release string `json:"release"`
}

VersionResponse represents version information

Jump to

Keyboard shortcuts

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