handler

package
v0.0.0-...-4b24d4f Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CatalogHandler

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

func NewCatalogHandler

func NewCatalogHandler(s store.CatalogStore) *CatalogHandler

func (*CatalogHandler) CreateCatalog

func (h *CatalogHandler) CreateCatalog(ctx echo.Context) error

CreateCatalog godoc

@Summary		Create a catalog
@Description	Create a catalog with the given title
@Tags			Catalog
@Accept			json
@Produce		json
@Param			catalog	body		createCatalogRequest	true	"Catalog to add"
@Success		201		{object}	catalogIdResponse
@Failure		401		{object}	api.Error
@Failure		422		{object}	api.Error
@Failure		500		{object}	api.Error
@Router			/catalog [post]

func (*CatalogHandler) CreateControl

func (h *CatalogHandler) CreateControl(ctx echo.Context) error

CreateControl godoc

@Summary		Create a control
@Description	Create a control with the given title
@Tags			Catalog
@Accept			json
@Produce		json
@Param			id		path		string					true	"Catalog ID"
@Param			control	body		createControlRequest	true	"Control to add"
@Success		201		{object}	catalogIdResponse
@Failure		401		{object}	api.Error
@Failure		422		{object}	api.Error
@Failure		500		{object}	api.Error
@Router			/catalog/{id}/controls [post]

func (*CatalogHandler) DeleteCatalog

func (h *CatalogHandler) DeleteCatalog(ctx echo.Context) error

DeleteCatalog godoc

@Summary		Delete a catalog
@Description	Delete a specific catalog by its ID
@Tags			Catalog
@Accept			json
@Produce		json
@Param			id	path		string	true	"Catalog ID"
@Success		200	{object}	map[string]string
@Failure		401	{object}	api.Error
@Failure		404	{object}	api.Error
@Failure		500	{object}	api.Error
@Router			/catalog/{id} [delete]

func (*CatalogHandler) GetCatalog

func (h *CatalogHandler) GetCatalog(ctx echo.Context) error

GetCatalog godoc

@Summary		Get a catalog
@Description	Get a specific catalog by its ID
@Tags			Catalog
@Accept			json
@Produce		json
@Param			id	path		string	true	"Catalog ID"
@Success		200	{object}	domain.Catalog
@Failure		401	{object}	api.Error
@Failure		404	{object}	api.Error
@Failure		500	{object}	api.Error
@Router			/catalog/{id} [get]

func (*CatalogHandler) GetControl

func (h *CatalogHandler) GetControl(ctx echo.Context) error

GetControl godoc

@Summary		Get a control
@Description	Get a specific control by its ID
@Tags			Catalog
@Accept			json
@Produce		json
@Param			id			path		string	true	"Catalog ID"
@Param			controlId	path		string	true	"Control ID"
@Success		200			{object}	domain.Control
@Failure		401			{object}	api.Error
@Failure		404			{object}	api.Error
@Failure		500			{object}	api.Error
@Router			/catalog/{id}/controls/{controlId} [get]

func (*CatalogHandler) Register

func (h *CatalogHandler) Register(api *echo.Group)

func (*CatalogHandler) UpdateCatalog

func (h *CatalogHandler) UpdateCatalog(ctx echo.Context) error

UpdateCatalog godoc

@Summary Update a catalog @Description Update a specific catalog by its ID @Tags Catalog @Accept json @Produce json @Param id path string true "Catalog ID" @Param catalog body UpdateCatalogRequest true "Catalog to update" @Success 200 {object} domain.Catalog @Failure 401 {object} api.Error @Failure 422 {object} api.Error @Failure 500 {object} api.Error @Router /catalog/{id} [patch]

func (*CatalogHandler) UpdateControl

func (h *CatalogHandler) UpdateControl(ctx echo.Context) error

UpdateControl godoc

@Summary		Update a control
@Description	Update a specific control by its ID
@Tags			Catalog
@Accept			json
@Produce		json
@Param			id			path		string					true	"Catalog ID"
@Param			controlId	path		string					true	"Control ID"
@Param			control		body		UpdateControlRequest	true	"Control to update"
@Success		200			{object}	domain.Control
@Failure		401			{object}	api.Error
@Failure		422			{object}	api.Error
@Failure		500			{object}	api.Error
@Router			/catalog/{id}/controls/{controlId} [put]

type CreateSSPRequest

type CreateSSPRequest struct {
	Title string `json:"title" yaml:"title" validate:"required"`
}

createSSPRequest defines the request payload for method CreateSSP

type GenericDataListResponse

type GenericDataListResponse[T any] struct {
	// Items from the list response
	Data []T `json:"data" yaml:"data"`
}

type GenericDataResponse

type GenericDataResponse[T any] struct {
	// Items from the list response
	Data T `json:"data" yaml:"data"`
}

type Handler

type Handler interface {
	Register(api *echo.Group)
}

type MetadataHandler

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

func NewMetadataHandler

func NewMetadataHandler(s *service.MetadataService) *MetadataHandler

func (*MetadataHandler) AttachMetadata

func (h *MetadataHandler) AttachMetadata(c echo.Context) error

AttachMetadata godoc

@Summary		Attaches metadata to a specific revision
@Description	This method attaches metadata to a specific revision.
@Tags			Metadata
@Accept			json
@Produce		json
@Param			revision	body		attachMetadataRequest	true	"Revision that will be attached"
@Success		200			{string}	string					"OK"
@Failure		400			{object}	api.Error				"Bad Request: Error binding the request"
@Failure		404			{object}	api.Error				"Object not found"
@Failure		500			{object}	api.Error				"Internal Server Error"
@Router			/metadata/revisions [post]

func (*MetadataHandler) Register

func (h *MetadataHandler) Register(group *echo.Group)

type PlanHandler

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

func NewPlanHandler

func NewPlanHandler(l *zap.SugaredLogger, s *service.PlanService) *PlanHandler

func (*PlanHandler) ActivatePlan

func (h *PlanHandler) ActivatePlan(ctx echo.Context) error

ActivatePlan activates a plan with the given ID.

@Summary		Activate a plan
@Description	Activate a plan by its ID. If the plan is already active, no action will be taken.
@Tags			Plan
@Accept			json
@Produce		json
@Param			id	path	string	true	"Plan ID"
@Success		204
@Failure		500	{object}	api.Error	"Internal server error. The plan could not be activated."
@Router			/plan/{id}/activate [put]

func (*PlanHandler) CreateActivity

func (h *PlanHandler) CreateActivity(ctx echo.Context) error

CreateActivity godoc

@Summary		Create activity
@Description	This function is used to create an activity for a given task.
@Tags			Plan
@Accept			json
@Produce		json
@Param			id			path		int						true	"Plan ID"
@Param			taskId		path		int						true	"Task ID"
@Param			activity	body		createActivityRequest	true	"Activity"
@Success		201			{object}	idResponse
@Failure		404			{object}	api.Error
@Failure		500			{object}	api.Error	"Internal server error"
@Router			/plan/{id}/tasks/{taskId}/activities [post]

func (*PlanHandler) CreatePlan

func (h *PlanHandler) CreatePlan(ctx echo.Context) error

CreatePlan godoc

@Summary		Create a plan
@Description	Creates a new plan in the system
@Tags			Plan
@Accept			json
@Produce		json
@Param			plan	body		createPlanRequest	true	"Plan to add"
@Success		201		{object}	idResponse
@Failure		401		{object}	api.Error
@Failure		422		{object}	api.Error
@Failure		500		{object}	api.Error
@Router			/plan [post]

func (*PlanHandler) CreateTask

func (h *PlanHandler) CreateTask(ctx echo.Context) error

CreateTask godoc

@Summary		Creates a new task for a specific plan
@Description	This method creates a new task and adds it to a specific plan.
@Tags			Plan
@Accept			json
@Produce		json
@Param			id		path		string				true	"Plan ID"
@Param			task	body		createTaskRequest	true	"Task to add"
@Success		200		{object}	string				"Successfully added the task to the plan"
@Failure		404		{object}	api.Error			"Plan not found"
@Failure		422		{object}	api.Error			"Unprocessable Entity: Error binding the request"
@Failure		500		{object}	api.Error			"Internal Server Error"
@Router			/plan/{id}/tasks [post]

func (*PlanHandler) GetPlan

func (h *PlanHandler) GetPlan(ctx echo.Context) error

GetPlan godoc

@Summary		Fetches a plan
@Description	Fetches a plan in the system
@Tags			Plan
@Accept			json
@Produce		json
@Param			id	path		string	true	"Plan ID"
@Success		200	{object}	domain.Plan
@Failure		401	{object}	api.Error
@Failure		422	{object}	api.Error
@Failure		500	{object}	api.Error
@Router			/plan/:id [get]

func (*PlanHandler) Register

func (h *PlanHandler) Register(api *echo.Group)

func (*PlanHandler) Risks

func (h *PlanHandler) Risks(c echo.Context) error

Risks Returns the risks of the result with the given ID.

@Summary		Return the risks
@Description	Return the risks of the result with the given ID.
@Tags			Plan
@Produce		json
@Param			id			path		string	true	"Plan ID"
@Param			resultId	path		string	true	"Result ID"
@Success		200			{object}	[]domain.Risk
@Failure		500			{object}	api.Error	"Internal server error."
@Router			/plan/{id}/results/{resultId}/risks [get]

type PlansHandler

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

func NewPlansHandler

func NewPlansHandler(l *zap.SugaredLogger, s *service.PlansService) *PlansHandler

func (*PlansHandler) GetPlans

func (h *PlansHandler) GetPlans(c echo.Context) error

GetPlans godoc

@Summary		Gets plan summaries
@Description	Returns id and title of all the plans in the system
@Tags			Plan
@Accept			json
@Produce		json
@Success		200	{object}	[]domain.PlanPrecis
@Failure		500	{object}	api.Error
@Router			/plans [get]

func (*PlansHandler) Register

func (h *PlansHandler) Register(api *echo.Group)

type ResultsHandler

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

func (*ResultsHandler) GetPlanResults

func (h *ResultsHandler) GetPlanResults(c echo.Context) error

GetPlanResults godoc

@Summary		Gets a plan's results
@Description	Returns data of all the latest results for a plan
@Tags			Result
@Accept			json
@Produce		json
@Success		200	{object}	handler.GenericDataListResponse[domain.Result]
@Failure		500	{object}	api.Error
@Router			/results/plan/:plan [get]

func (*ResultsHandler) GetResult

func (h *ResultsHandler) GetResult(c echo.Context) error

GetResult godoc

@Summary		Get a result
@Description	Returns singular result
@Tags			Result
@Accept			json
@Produce		json
@Success		200	{object}	handler.GenericDataResponse[domain.Result]
@Failure		500	{object}	api.Error
@Router			/results/:id [get]

func (*ResultsHandler) GetStreamResults

func (h *ResultsHandler) GetStreamResults(c echo.Context) error

GetStreamResults godoc

@Summary		Gets a plan's results
@Description	Returns a list of all the results for a strea,data of all the latest results for a plan
@Tags			Result
@Accept			json
@Produce		json
@Success		200	{object}	handler.GenericDataListResponse[domain.Result]
@Failure		500	{object}	api.Error
@Router			/results/stream/:stream [get]

func (*ResultsHandler) Register

func (h *ResultsHandler) Register(api *echo.Group)

type SSPHandler

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

func NewSSPHandler

func NewSSPHandler(sspService *service.SSPService) *SSPHandler

func (*SSPHandler) CreateSSP

func (h *SSPHandler) CreateSSP(ctx echo.Context) error

CreateSSP godoc

@Summary		Create an SSP
@Description	Create an SSP with the given title
@Tags			SSP
@Accept			json
@Produce		json
@Param			SSP	body		CreateSSPRequest	true	"SSP to add"
@Success		201	{object}	idResponse
@Failure		401	{object}	api.Error
@Failure		422	{object}	api.Error
@Failure		500	{object}	api.Error
@Router			/ssp [post]

func (*SSPHandler) DeleteSSP

func (h *SSPHandler) DeleteSSP(ctx echo.Context) error

DeleteSSP godoc

@Summary		Delete an SSP
@Description	Delete an SSP with the given ID
@Tags			SSP
@Accept			json
@Produce		json
@Param			id	path		string	true	"SSP ID"
@Success		204	{object}	string
@Failure		404	{object}	api.Error
@Failure		500	{object}	api.Error
@Router			/ssp/{id} [delete]

func (*SSPHandler) GetSSP

func (h *SSPHandler) GetSSP(ctx echo.Context) error

GetSSP godoc

@Summary		Get an SSP by ID
@Description	Get an SSP by its ID
@Tags			SSP
@Accept			json
@Produce		json
@Param			id	path		string	true	"SSP ID"
@Success		200	{object}	domain.SystemSecurityPlan
@Failure		404	{object}	api.Error
@Failure		500	{object}	api.Error
@Router			/ssp/{id} [get]

func (*SSPHandler) ListSSP

func (h *SSPHandler) ListSSP(ctx echo.Context) error

ListSSP godoc

@Summary		List all SSPs
@Description	List all SSP
@Tags			SSP
@Accept			json
@Produce		json
@Success		200	{object}	domain.SystemSecurityPlan
@Failure		500	{object}	api.Error
@Router			/ssp [get]

func (*SSPHandler) Register

func (h *SSPHandler) Register(api *echo.Group)

func (*SSPHandler) UpdateSSP

func (h *SSPHandler) UpdateSSP(ctx echo.Context) error

UpdateSSP godoc

@Summary		Update an SSP
@Description	Update an SSP with the given ID
@Tags			SSP
@Accept			json
@Produce		json
@Param			id	path		string				true	"SSP ID"
@Param			SSP	body		UpdateSSPRequest	true	"SSP to update"
@Success		200	{object}	domain.SystemSecurityPlan
@Failure		400	{object}	api.Error
@Failure		404	{object}	api.Error
@Failure		500	{object}	api.Error
@Router			/ssp/{id} [put]

type UpdateCatalogRequest

type UpdateCatalogRequest struct {
	Uuid  domain.Uuid `json:"uuid" yaml:"uuid"`
	Title string      `json:"title" yaml:"title"`
	// Metadata   domain.Metadata   `json:"metadata" yaml:"metadata"`
	Params     []domain.Parameter `json:"params" yaml:"params"`
	Controls   []domain.Control   `json:"controlUuids" yaml:"controlUuids"`
	Groups     []domain.Uuid      `json:"groupUuids" yaml:"groupUuids"`
	BackMatter domain.BackMatter  `json:"backMatter" yaml:"backMatter"`
}

type UpdateControlRequest

type UpdateControlRequest struct {
	// Uuid     domain.Uuid        `json:"uuid" yaml:"uuid"`
	Props    []domain.Property  `json:"props,omitempty" yaml:"props,omitempty"`
	Links    []domain.Link      `json:"links,omitempty" yaml:"links,omitempty"`
	Parts    []domain.Part      `json:"parts,omitempty" yaml:"parts,omitempty"`
	Class    string             `json:"class" yaml:"class"`
	Title    string             `json:"title" yaml:"title"`
	Params   []domain.Parameter `json:"params" yaml:"params"`
	Controls []domain.Uuid      `json:"controlUuids" yaml:"controlUuids"`
}

type UpdateSSPRequest

type UpdateSSPRequest struct {
	Title       string `json:"title" yaml:"title"`
	Description string `json:"description" yaml:"description"`
}

updateSSPRequest defines the request payload for method UpdateSSP

Jump to

Keyboard shortcuts

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