api

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: MIT Imports: 12 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} Response{data=int64} "Spammer ID" @Failure 400 {object} Response "Invalid request" @Failure 500 {object} Response "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 {object} Response "Success" @Failure 400 {object} Response "Invalid spammer ID" @Failure 404 {object} Response "Spammer not found" @Failure 500 {object} Response "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 {object} Response "Invalid request" @Failure 500 {object} Response "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 {object} Response{data=[]ClientEntry} "Success" @Router /api/clients [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 {object} Response "Scenario not found" @Failure 500 {object} Response "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 {object} Response{data=[]ScenarioEntries} "Success" @Failure 400 {object} Response "Failure" @Failure 500 {object} Response "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} Response{data=SpammerDetails} "Success" @Failure 400 {object} Response "Invalid spammer ID" @Failure 404 {object} Response "Spammer not found" @Router /api/spammer/{id} [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 {object} Response{data=[]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 {object} Response{data=[]LogEntry} "Success" @Failure 400 {object} Response "Invalid spammer ID" @Failure 404 {object} Response "Spammer not found" @Router /api/spammer/{id}/logs [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} Response{data=daemon.ImportResult} "Success" @Failure 400 {object} Response "Invalid request" @Failure 500 {object} Response "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 {object} Response "Success" @Failure 400 {object} Response "Invalid spammer ID" @Failure 404 {object} Response "Spammer not found" @Failure 500 {object} Response "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 {object} Response "Success" @Failure 400 {object} Response "Invalid spammer ID" @Failure 404 {object} Response "Spammer not found" @Failure 500 {object} Response "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 {object} Response "Success" @Failure 400 {object} Response "Invalid spammer ID" @Failure 404 {object} Response "Spammer not found" @Failure 500 {object} Response "Server Error" @Router /api/spammer/{id}/start [post]

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 {object} Response "Invalid spammer ID" @Failure 404 {object} Response "Spammer not found" @Failure 500 {object} Response "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 {object} Response "Success" @Failure 400 {object} Response "Invalid client index" @Failure 404 {object} Response "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 {object} Response "Success" @Failure 400 {object} Response "Invalid client index" @Failure 404 {object} Response "Client not found" @Router /api/client/{index}/group [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 {object} Response "Success" @Failure 400 {object} Response "Invalid request" @Failure 404 {object} Response "Spammer not found" @Failure 500 {object} Response "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"`
}

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 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 Response

type Response struct {
	Data  interface{} `json:"data,omitempty"`
	Error string      `json:"error,omitempty"`
}

Response represents a standard API response envelope

type ScenarioEntries

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

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 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 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 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

Jump to

Keyboard shortcuts

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