Documentation
¶
Index ¶
- type APIHandler
- func (ah *APIHandler) CreateSpammer(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) DeleteSpammer(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) GetScenarioConfig(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) GetScenarios(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) GetSpammerDetails(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) GetSpammerList(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) GetSpammerLogs(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) PauseSpammer(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) StartSpammer(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) StreamSpammerLogs(w http.ResponseWriter, r *http.Request)
- func (ah *APIHandler) UpdateSpammer(w http.ResponseWriter, r *http.Request)
- type CreateSpammerRequest
- type LogEntry
- type Response
- type ScenarioEntries
- type SpammerDetails
- type SpammerListEntry
- type UpdateSpammerRequest
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) 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) 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) 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) 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 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 Response ¶
type Response struct {
Data interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
Response represents a standard API response envelope
type ScenarioEntries ¶
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 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