api

package
v1.103.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const EnvDebugMode = "PC_DEBUG_MODE"

Variables

This section is empty.

Functions

func InitRoutes

func InitRoutes(useLogger bool, handler *PcApi) *gin.Engine

InitRoutes initialize routing information

func StartHttpServerWithTCP added in v1.2.0

func StartHttpServerWithTCP(useLogger bool, address string, port int, project app.IProject) (*http.Server, error)

func StartHttpServerWithUnixSocket added in v1.2.0

func StartHttpServerWithUnixSocket(useLogger bool, unixSocket string, project app.IProject) (*http.Server, error)

func TokenAuthMiddleware added in v1.94.0

func TokenAuthMiddleware(token string) gin.HandlerFunc

TokenAuthMiddleware enforces API access using an auth token if configured.

Types

type ErrorResponse added in v1.75.0

type ErrorResponse struct {
	Error string `json:"error"`
}

type LogMessage added in v0.43.1

type LogMessage struct {
	Message     string `json:"message"`
	ProcessName string `json:"process_name"`
}

type LogsResponse added in v1.75.0

type LogsResponse struct {
	Logs []string `json:"logs"`
}

LogsResponse represents a response containing logs lines.

type NameResponse added in v1.75.0

type NameResponse struct {
	Name string `json:"name"`
}

NameResponse represents a simple response containing a process name.

type PcApi added in v0.50.0

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

func NewPcApi added in v0.50.0

func NewPcApi(project app.IProject) *PcApi

func (*PcApi) GetDependencyGraph added in v1.87.0

func (api *PcApi) GetDependencyGraph(c *gin.Context)

@Schemes @Id GetDependencyGraph @Description Returns the process dependency graph with current status @Tags Graph @Summary Get dependency graph @Produce json @Success 200 {object} types.DependencyGraph @Failure 400 {object} map[string]string @Router /graph [get]

func (*PcApi) GetNamespaces added in v1.90.0

func (api *PcApi) GetNamespaces(c *gin.Context)

@Schemes @Id GetNamespaces @Description Retrieves all unique namespaces @Tags Namespace @Summary Get all namespaces @Produce json @Success 200 {object} []string "Namespaces List" @Failure 400 {object} map[string]string @Router /namespaces [get]

func (*PcApi) GetProcess added in v0.50.0

func (api *PcApi) GetProcess(c *gin.Context)

@Schemes @Id GetProcess @Description Retrieves the given process and its status @Tags Process @Summary Get process state @Produce json @Param name path string true "Process Name" @Success 200 {object} types.ProcessState @Failure 400 {object} map[string]string @Router /process/{name} [get]

func (*PcApi) GetProcessInfo added in v0.50.0

func (api *PcApi) GetProcessInfo(c *gin.Context)

@Schemes @Id GetProcessInfo @Description Retrieves the given process and its config @Tags Process @Summary Get process config @Produce json @Param name path string true "Process Name" @Success 200 {object} types.ProcessConfig @Failure 400 {object} map[string]string @Router /process/info/{name} [get]

func (*PcApi) GetProcessLogs added in v0.50.0

func (api *PcApi) GetProcessLogs(c *gin.Context)

@Schemes @Id GetProcessLogs @Description Retrieves the process logs @Tags Process @Summary Get process logs @Produce json @Param name path string true "Process Name" @Param endOffset path int true "Offset from the end of the log" @Param limit path int true "Limit of lines to get (0 will get all the lines till the end)" @Success 200 {object} api.LogsResponse "Process Logs" @Failure 400 {object} map[string]string @Router /process/logs/{name}/{endOffset}/{limit} [get]

func (*PcApi) GetProcessPorts added in v0.55.0

func (api *PcApi) GetProcessPorts(c *gin.Context)

@Schemes @Id GetProcessPorts @Description Retrieves process open ports @Tags Process @Summary Get process ports @Produce json @Param name path string true "Process Name" @Success 200 {object} types.ProcessPorts "Process Ports" @Failure 400 {object} map[string]string @Router /process/ports/{name} [get]

func (*PcApi) GetProcesses added in v0.50.0

func (api *PcApi) GetProcesses(c *gin.Context)

@Schemes @Id GetProcesses @Description Retrieves all the configured processes and their status @Tags Process @Summary Get all processes @Produce json @Success 200 {object} types.ProcessesState "Processes Status" @Failure 400 {object} map[string]string @Router /processes [get]

func (*PcApi) GetProjectName added in v1.73.0

func (api *PcApi) GetProjectName(c *gin.Context)

@Schemes @Id GetProjectName @Description Get process compose project name @Tags ProjectName @Summary Get Project Name @Produce json @Success 200 {object} api.ProjectNameResponse "Project Name" @Failure 400 {object} map[string]string @Router /project/name [get]

func (*PcApi) GetProjectState added in v0.75.0

func (api *PcApi) GetProjectState(c *gin.Context)

@Schemes @Id GetProjectState @Description Retrieves project state information @Tags Project @Summary Get project state @Produce json @Success 200 {object} types.ProjectState "Project State" @Failure 500 {object} map[string]string @Router /project/state [get]

func (*PcApi) HandleLogsStream added in v0.50.0

func (api *PcApi) HandleLogsStream(c *gin.Context)

@Schemes @Id LogsStream @Summary Stream process logs over WebSocket @Description Upgrades HTTP to WebSocket and streams JSON log messages. Each message is api.LogMessage. @Tags Process @Produce json @Param name query string true "Comma-separated process names to stream" @Param offset query int true "Offset from the end of the log" @Param follow query bool false "If true, continue streaming new lines" @Success 101 "Switching Protocols" @Failure 400 {object} api.ErrorResponse @Router /process/logs/ws [get]

func (*PcApi) IsAlive added in v0.50.0

func (api *PcApi) IsAlive(c *gin.Context)

@Schemes @Id IsAlive @Description Check if server is responding @Tags Liveness @Summary Liveness Check @Produce json @Success 200 {object} api.StatusResponse "Alive Status" @Router /live [get]

func (*PcApi) ReloadProject added in v1.34.0

func (api *PcApi) ReloadProject(c *gin.Context)

@Schemes @Id ReloadProject @Description Reload project state from config @Tags Project @Summary Reload project @Produce json @Success 200 {object} map[string]string "Update Project Status" @Success 207 {object} map[string]string "Update Project Status" @Failure 400 {object} map[string]string @Router /project/configuration [post]

func (*PcApi) RestartNamespace added in v1.90.0

func (api *PcApi) RestartNamespace(c *gin.Context)

@Schemes @Id RestartNamespace @Description Restarts the namespace @Tags Namespace @Summary Restart a namespace @Produce json @Param name path string true "Namespace Name" @Success 200 {object} api.NameResponse "Restarted Namespace Name" @Failure 400 {object} map[string]string @Router /namespace/restart/{name} [post]

func (*PcApi) RestartProcess added in v0.50.0

func (api *PcApi) RestartProcess(c *gin.Context)

@Schemes @Id RestartProcess @Description Restarts the process @Tags Process @Summary Restart a process @Produce json @Param name path string true "Process Name" @Success 200 {object} api.NameResponse "Restarted Process Name" @Failure 400 {object} map[string]string @Router /process/restart/{name} [post]

func (*PcApi) ScaleProcess added in v0.55.0

func (api *PcApi) ScaleProcess(c *gin.Context)

@Schemes @Id ScaleProcess @Description Scale a process @Tags Process @Summary Scale a process to a given replicas count @Produce json @Param name path string true "Process Name" @Param scale path int true "New amount of process replicas" @Success 200 {object} api.NameResponse "Scaled Process Name" @Failure 400 {object} map[string]string @Router /process/scale/{name}/{scale} [patch]

func (*PcApi) SendSignal added in v1.100.0

func (api *PcApi) SendSignal(c *gin.Context)

@Schemes @Id SendSignal @Description Sends a POSIX signal to the process @Tags Process @Summary Signal a process @Produce json @Param name path string true "Process Name" @Param signal path int true "Signal Number" @Success 200 {object} api.NameResponse "Signaled Process Name" @Failure 400 {object} map[string]string @Router /process/signal/{name}/{signal} [patch]

func (*PcApi) ShutDownProject added in v0.69.0

func (api *PcApi) ShutDownProject(c *gin.Context)

@Schemes @Id ShutDownProject @Description Shuts down the server @Tags Project @Summary Stops all the processes and the server @Produce json @Success 200 {object} api.StatusResponse "Stopped Server" @Router /project/stop [post]

func (*PcApi) StartNamespace added in v1.90.0

func (api *PcApi) StartNamespace(c *gin.Context)

@Schemes @Id StartNamespace @Description Starts the namespace @Tags Namespace @Summary Start a namespace @Produce json @Param name path string true "Namespace Name" @Success 200 {object} api.NameResponse "Started Namespace Name" @Failure 400 {object} map[string]string @Router /namespace/start/{name} [post]

func (*PcApi) StartProcess added in v0.50.0

func (api *PcApi) StartProcess(c *gin.Context)

@Schemes @Id StartProcess @Description Starts the process if the state is not 'running' or 'pending' @Tags Process @Summary Start a process @Produce json @Param name path string true "Process Name" @Success 200 {object} api.NameResponse "Started Process Name" @Failure 400 {object} map[string]string @Router /process/start/{name} [post]

func (*PcApi) StopNamespace added in v1.90.0

func (api *PcApi) StopNamespace(c *gin.Context)

@Schemes @Id StopNamespace @Description Stops the namespace @Tags Namespace @Summary Stop a namespace @Produce json @Param name path string true "Namespace Name" @Success 200 {object} api.NameResponse "Stopped Namespace Name" @Failure 400 {object} map[string]string @Router /namespace/stop/{name} [post]

func (*PcApi) StopProcess added in v0.50.0

func (api *PcApi) StopProcess(c *gin.Context)

@Schemes @Id StopProcess @Description Sends kill signal to the process @Tags Process @Summary Stop a process @Produce json @Param name path string true "Process Name" @Success 200 {object} api.NameResponse "Stopped Process Name" @Failure 400 {object} map[string]string @Router /process/stop/{name} [patch]

func (*PcApi) StopProcesses added in v0.60.0

func (api *PcApi) StopProcesses(c *gin.Context)

@Schemes @Id StopProcesses @Description Sends kill signal to the processes list @Tags Process @Summary Stop processes @Accept json

@Param []string body []string true "Processes Names"

@Produce json @Success 200 {object} map[string]string "Stopped Processes Names" @Success 207 {object} map[string]string "Stopped Processes Names" @Failure 400 {object} map[string]string @Router /processes/stop [patch]

func (*PcApi) TruncateProcessLogs added in v1.63.0

func (api *PcApi) TruncateProcessLogs(c *gin.Context)

@Schemes @Id TruncateProcessLogs @Description Truncates the process logs @Tags Process @Summary Truncate process logs @Produce json @Param name path string true "Process Name" @Success 200 {object} api.NameResponse "Truncated Process Name" @Failure 400 {object} map[string]string @Router /process/logs/{name} [delete]

func (*PcApi) UpdateProcess added in v1.34.0

func (api *PcApi) UpdateProcess(c *gin.Context)

@Schemes @Id UpdateProcess @Description Update process @Tags Process @Summary Updates process configuration @Accept json @Param process body types.ProcessConfig true "Process configuration to update" @Success 200 {object} types.ProcessConfig "Updated Process Config" @Failure 400 {object} map[string]string @Router /process [post]

func (*PcApi) UpdateProject added in v1.27.0

func (api *PcApi) UpdateProject(c *gin.Context)

@Schemes @Id UpdateProject @Description Update running project @Tags Project @Summary Updates running processes @Produce json @Success 200 {object} map[string]string "Update Project Status" @Success 207 {object} map[string]string "Update Project Status" @Failure 400 {object} map[string]string @Router /project [post]

type ProjectNameResponse added in v1.75.0

type ProjectNameResponse struct {
	ProjectName string `json:"projectName"`
}

ProjectNameResponse represents a response containing the project name.

type StatusResponse added in v1.75.0

type StatusResponse struct {
	Status string `json:"status"`
}

StatusResponse represents a simple response containing a status string.

Jump to

Keyboard shortcuts

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