mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-06-22 00:38:09 +02:00
Release catalyst
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// AddArtifactEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func AddArtifactEndpoint(handler func(ctx context.Context, params *AddArtifactParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewAddArtifactParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewAddArtifactParams creates a new AddArtifactParams object
|
||||
// with the default values initialized.
|
||||
func NewAddArtifactParams() *AddArtifactParams {
|
||||
var ()
|
||||
return &AddArtifactParams{}
|
||||
}
|
||||
|
||||
// AddArtifactParams contains all the bound params for the add artifact operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters addArtifact
|
||||
type AddArtifactParams struct {
|
||||
|
||||
/*Artifact object that needs to be added
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Artifact *models.Artifact
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *AddArtifactParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.Artifact
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("artifact", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("artifact", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Artifact = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("artifact", "body", ""))
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *AddArtifactParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// AddCommentEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func AddCommentEndpoint(handler func(ctx context.Context, params *AddCommentParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewAddCommentParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewAddCommentParams creates a new AddCommentParams object
|
||||
// with the default values initialized.
|
||||
func NewAddCommentParams() *AddCommentParams {
|
||||
var ()
|
||||
return &AddCommentParams{}
|
||||
}
|
||||
|
||||
// AddCommentParams contains all the bound params for the add comment operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters addComment
|
||||
type AddCommentParams struct {
|
||||
|
||||
/*Ticket comment
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Comment *models.CommentForm
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *AddCommentParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.CommentForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("comment", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("comment", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Comment = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("comment", "body", ""))
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *AddCommentParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// AddTicketPlaybookEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func AddTicketPlaybookEndpoint(handler func(ctx context.Context, params *AddTicketPlaybookParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewAddTicketPlaybookParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewAddTicketPlaybookParams creates a new AddTicketPlaybookParams object
|
||||
// with the default values initialized.
|
||||
func NewAddTicketPlaybookParams() *AddTicketPlaybookParams {
|
||||
var ()
|
||||
return &AddTicketPlaybookParams{}
|
||||
}
|
||||
|
||||
// AddTicketPlaybookParams contains all the bound params for the add ticket playbook operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters addTicketPlaybook
|
||||
type AddTicketPlaybookParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Ticket playbook object that needs to be added
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Playbook *models.PlaybookTemplateForm
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *AddTicketPlaybookParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.PlaybookTemplateForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("playbook", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("playbook", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Playbook = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("playbook", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *AddTicketPlaybookParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// CompleteTaskEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func CompleteTaskEndpoint(handler func(ctx context.Context, params *CompleteTaskParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewCompleteTaskParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewCompleteTaskParams creates a new CompleteTaskParams object
|
||||
// with the default values initialized.
|
||||
func NewCompleteTaskParams() *CompleteTaskParams {
|
||||
var ()
|
||||
return &CompleteTaskParams{}
|
||||
}
|
||||
|
||||
// CompleteTaskParams contains all the bound params for the complete task operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters completeTask
|
||||
type CompleteTaskParams struct {
|
||||
|
||||
/*Ticket playbook object that needs to be added
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Data interface{}
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Playbook ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
PlaybookID string
|
||||
/*Task ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
TaskID string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *CompleteTaskParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body interface{}
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("data", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("data", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Data = body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("data", "body", ""))
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rPlaybookID := []string{ctx.Param("playbookID")}
|
||||
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rTaskID := []string{ctx.Param("taskID")}
|
||||
if err := o.bindTaskID(rTaskID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *CompleteTaskParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *CompleteTaskParams) bindPlaybookID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.PlaybookID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *CompleteTaskParams) bindTaskID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.TaskID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// CreateTicketBatchEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func CreateTicketBatchEndpoint(handler func(ctx context.Context, params *CreateTicketBatchParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewCreateTicketBatchParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateTicketBatchParams creates a new CreateTicketBatchParams object
|
||||
// with the default values initialized.
|
||||
func NewCreateTicketBatchParams() *CreateTicketBatchParams {
|
||||
var ()
|
||||
return &CreateTicketBatchParams{}
|
||||
}
|
||||
|
||||
// CreateTicketBatchParams contains all the bound params for the create ticket batch operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters createTicketBatch
|
||||
type CreateTicketBatchParams struct {
|
||||
|
||||
/*New ticket
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Ticket []*models.TicketForm
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *CreateTicketBatchParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body []*models.TicketForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("ticket", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("ticket", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Ticket = body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("ticket", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// CreateTicketEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func CreateTicketEndpoint(handler func(ctx context.Context, params *CreateTicketParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewCreateTicketParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateTicketParams creates a new CreateTicketParams object
|
||||
// with the default values initialized.
|
||||
func NewCreateTicketParams() *CreateTicketParams {
|
||||
var ()
|
||||
return &CreateTicketParams{}
|
||||
}
|
||||
|
||||
// CreateTicketParams contains all the bound params for the create ticket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters createTicket
|
||||
type CreateTicketParams struct {
|
||||
|
||||
/*New ticket
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Ticket *models.TicketForm
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *CreateTicketParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.TicketForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("ticket", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("ticket", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Ticket = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("ticket", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// DeleteTicketEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func DeleteTicketEndpoint(handler func(ctx context.Context, params *DeleteTicketParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewDeleteTicketParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteTicketParams creates a new DeleteTicketParams object
|
||||
// with the default values initialized.
|
||||
func NewDeleteTicketParams() *DeleteTicketParams {
|
||||
var ()
|
||||
return &DeleteTicketParams{}
|
||||
}
|
||||
|
||||
// DeleteTicketParams contains all the bound params for the delete ticket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters deleteTicket
|
||||
type DeleteTicketParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *DeleteTicketParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *DeleteTicketParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// EnrichArtifactEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func EnrichArtifactEndpoint(handler func(ctx context.Context, params *EnrichArtifactParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewEnrichArtifactParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewEnrichArtifactParams creates a new EnrichArtifactParams object
|
||||
// with the default values initialized.
|
||||
func NewEnrichArtifactParams() *EnrichArtifactParams {
|
||||
var ()
|
||||
return &EnrichArtifactParams{}
|
||||
}
|
||||
|
||||
// EnrichArtifactParams contains all the bound params for the enrich artifact operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters enrichArtifact
|
||||
type EnrichArtifactParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Data *models.EnrichmentForm
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *EnrichArtifactParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.EnrichmentForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("data", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("data", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Data = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("data", "body", ""))
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rName := []string{ctx.Param("name")}
|
||||
if err := o.bindName(rName, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *EnrichArtifactParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *EnrichArtifactParams) bindName(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// GetArtifactEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func GetArtifactEndpoint(handler func(ctx context.Context, params *GetArtifactParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewGetArtifactParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetArtifactParams creates a new GetArtifactParams object
|
||||
// with the default values initialized.
|
||||
func NewGetArtifactParams() *GetArtifactParams {
|
||||
var ()
|
||||
return &GetArtifactParams{}
|
||||
}
|
||||
|
||||
// GetArtifactParams contains all the bound params for the get artifact operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters getArtifact
|
||||
type GetArtifactParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *GetArtifactParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rName := []string{ctx.Param("name")}
|
||||
if err := o.bindName(rName, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetArtifactParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetArtifactParams) bindName(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// GetTicketEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func GetTicketEndpoint(handler func(ctx context.Context, params *GetTicketParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewGetTicketParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetTicketParams creates a new GetTicketParams object
|
||||
// with the default values initialized.
|
||||
func NewGetTicketParams() *GetTicketParams {
|
||||
var ()
|
||||
return &GetTicketParams{}
|
||||
}
|
||||
|
||||
// GetTicketParams contains all the bound params for the get ticket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters getTicket
|
||||
type GetTicketParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *GetTicketParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *GetTicketParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// LinkFilesEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func LinkFilesEndpoint(handler func(ctx context.Context, params *LinkFilesParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewLinkFilesParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewLinkFilesParams creates a new LinkFilesParams object
|
||||
// with the default values initialized.
|
||||
func NewLinkFilesParams() *LinkFilesParams {
|
||||
var ()
|
||||
return &LinkFilesParams{}
|
||||
}
|
||||
|
||||
// LinkFilesParams contains all the bound params for the link files operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters linkFiles
|
||||
type LinkFilesParams struct {
|
||||
|
||||
/*Added files
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Files []*models.File
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *LinkFilesParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body []*models.File
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("files", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("files", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Files = body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("files", "body", ""))
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *LinkFilesParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// LinkTicketEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func LinkTicketEndpoint(handler func(ctx context.Context, params *LinkTicketParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewLinkTicketParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewLinkTicketParams creates a new LinkTicketParams object
|
||||
// with the default values initialized.
|
||||
func NewLinkTicketParams() *LinkTicketParams {
|
||||
var ()
|
||||
return &LinkTicketParams{}
|
||||
}
|
||||
|
||||
// LinkTicketParams contains all the bound params for the link ticket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters linkTicket
|
||||
type LinkTicketParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Added ticket ID
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
LinkedID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *LinkTicketParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body int64
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("linkedId", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("linkedId", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.LinkedID = body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("linkedId", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *LinkTicketParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// ListTicketsEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func ListTicketsEndpoint(handler func(ctx context.Context, params *ListTicketsParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewListTicketsParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewListTicketsParams creates a new ListTicketsParams object
|
||||
// with the default values initialized.
|
||||
func NewListTicketsParams() *ListTicketsParams {
|
||||
var (
|
||||
countDefault = int64(25)
|
||||
offsetDefault = int64(0)
|
||||
)
|
||||
return &ListTicketsParams{
|
||||
Count: &countDefault,
|
||||
|
||||
Offset: &offsetDefault,
|
||||
}
|
||||
}
|
||||
|
||||
// ListTicketsParams contains all the bound params for the list tickets operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters listTickets
|
||||
type ListTicketsParams struct {
|
||||
|
||||
/*Number of tickets
|
||||
Maximum: 100
|
||||
In: query
|
||||
Default: 25
|
||||
*/
|
||||
Count *int64
|
||||
/*Sort descending
|
||||
In: query
|
||||
*/
|
||||
Desc []bool
|
||||
/*Offset of the list
|
||||
In: query
|
||||
Default: 0
|
||||
*/
|
||||
Offset *int64
|
||||
/*Search query
|
||||
In: query
|
||||
*/
|
||||
Query *string
|
||||
/*Sort columns
|
||||
In: query
|
||||
*/
|
||||
Sort []string
|
||||
/*Ticket Type
|
||||
In: query
|
||||
*/
|
||||
Type *string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *ListTicketsParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
qs := runtime.Values(ctx.Request.URL.Query())
|
||||
|
||||
qCount, qhkCount, _ := qs.GetOK("count")
|
||||
if err := o.bindCount(qCount, qhkCount); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qDesc, qhkDesc, _ := qs.GetOK("desc")
|
||||
if err := o.bindDesc(qDesc, qhkDesc); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qOffset, qhkOffset, _ := qs.GetOK("offset")
|
||||
if err := o.bindOffset(qOffset, qhkOffset); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qQuery, qhkQuery, _ := qs.GetOK("query")
|
||||
if err := o.bindQuery(qQuery, qhkQuery); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qSort, qhkSort, _ := qs.GetOK("sort")
|
||||
if err := o.bindSort(qSort, qhkSort); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
qType, qhkType, _ := qs.GetOK("type")
|
||||
if err := o.bindType(qType, qhkType); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ListTicketsParams) bindCount(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if raw == "" { // empty values pass all other validations
|
||||
var countDefault int64 = int64(25)
|
||||
o.Count = &countDefault
|
||||
return nil
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("count", "query", "int64", raw)
|
||||
}
|
||||
o.Count = &value
|
||||
|
||||
if err := o.validateCount(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ListTicketsParams) validateCount() error {
|
||||
|
||||
if err := validate.MaximumInt("count", "query", int64(*o.Count), 100, false); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ListTicketsParams) bindDesc(rawData []string, hasKey bool) error {
|
||||
|
||||
var qvDesc string
|
||||
if len(rawData) > 0 {
|
||||
qvDesc = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
descIC := swag.SplitByFormat(qvDesc, "")
|
||||
|
||||
if len(descIC) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var descIR []bool
|
||||
for i, descIV := range descIC {
|
||||
descI, err := swag.ConvertBool(descIV)
|
||||
if err != nil {
|
||||
return errors.InvalidType(fmt.Sprintf("%s.%v", "desc", i), "query", "bool", descI)
|
||||
}
|
||||
|
||||
descIR = append(descIR, descI)
|
||||
}
|
||||
|
||||
o.Desc = descIR
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ListTicketsParams) bindOffset(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if raw == "" { // empty values pass all other validations
|
||||
var offsetDefault int64 = int64(0)
|
||||
o.Offset = &offsetDefault
|
||||
return nil
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("offset", "query", "int64", raw)
|
||||
}
|
||||
o.Offset = &value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ListTicketsParams) bindQuery(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
|
||||
o.Query = &raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ListTicketsParams) bindSort(rawData []string, hasKey bool) error {
|
||||
|
||||
var qvSort string
|
||||
if len(rawData) > 0 {
|
||||
qvSort = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
sortIC := swag.SplitByFormat(qvSort, "")
|
||||
|
||||
if len(sortIC) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var sortIR []string
|
||||
for _, sortIV := range sortIC {
|
||||
sortI := sortIV
|
||||
|
||||
sortIR = append(sortIR, sortI)
|
||||
}
|
||||
|
||||
o.Sort = sortIR
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ListTicketsParams) bindType(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
if raw == "" { // empty values pass all other validations
|
||||
return nil
|
||||
}
|
||||
|
||||
o.Type = &raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// RemoveArtifactEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func RemoveArtifactEndpoint(handler func(ctx context.Context, params *RemoveArtifactParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewRemoveArtifactParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewRemoveArtifactParams creates a new RemoveArtifactParams object
|
||||
// with the default values initialized.
|
||||
func NewRemoveArtifactParams() *RemoveArtifactParams {
|
||||
var ()
|
||||
return &RemoveArtifactParams{}
|
||||
}
|
||||
|
||||
// RemoveArtifactParams contains all the bound params for the remove artifact operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters removeArtifact
|
||||
type RemoveArtifactParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *RemoveArtifactParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rName := []string{ctx.Param("name")}
|
||||
if err := o.bindName(rName, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RemoveArtifactParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RemoveArtifactParams) bindName(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// RemoveCommentEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func RemoveCommentEndpoint(handler func(ctx context.Context, params *RemoveCommentParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewRemoveCommentParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewRemoveCommentParams creates a new RemoveCommentParams object
|
||||
// with the default values initialized.
|
||||
func NewRemoveCommentParams() *RemoveCommentParams {
|
||||
var ()
|
||||
return &RemoveCommentParams{}
|
||||
}
|
||||
|
||||
// RemoveCommentParams contains all the bound params for the remove comment operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters removeComment
|
||||
type RemoveCommentParams struct {
|
||||
|
||||
/*Comment ID to remove
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
CommentID int64
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *RemoveCommentParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rCommentID := []string{ctx.Param("commentID")}
|
||||
if err := o.bindCommentID(rCommentID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RemoveCommentParams) bindCommentID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("commentID", "path", "int64", raw)
|
||||
}
|
||||
o.CommentID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RemoveCommentParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// RemoveTicketPlaybookEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func RemoveTicketPlaybookEndpoint(handler func(ctx context.Context, params *RemoveTicketPlaybookParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewRemoveTicketPlaybookParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewRemoveTicketPlaybookParams creates a new RemoveTicketPlaybookParams object
|
||||
// with the default values initialized.
|
||||
func NewRemoveTicketPlaybookParams() *RemoveTicketPlaybookParams {
|
||||
var ()
|
||||
return &RemoveTicketPlaybookParams{}
|
||||
}
|
||||
|
||||
// RemoveTicketPlaybookParams contains all the bound params for the remove ticket playbook operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters removeTicketPlaybook
|
||||
type RemoveTicketPlaybookParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Playbook ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
PlaybookID string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *RemoveTicketPlaybookParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rPlaybookID := []string{ctx.Param("playbookID")}
|
||||
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RemoveTicketPlaybookParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RemoveTicketPlaybookParams) bindPlaybookID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.PlaybookID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// RunArtifactEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func RunArtifactEndpoint(handler func(ctx context.Context, params *RunArtifactParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewRunArtifactParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewRunArtifactParams creates a new RunArtifactParams object
|
||||
// with the default values initialized.
|
||||
func NewRunArtifactParams() *RunArtifactParams {
|
||||
var ()
|
||||
return &RunArtifactParams{}
|
||||
}
|
||||
|
||||
// RunArtifactParams contains all the bound params for the run artifact operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters runArtifact
|
||||
type RunArtifactParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Automation string
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *RunArtifactParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rAutomation := []string{ctx.Param("automation")}
|
||||
if err := o.bindAutomation(rAutomation, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rName := []string{ctx.Param("name")}
|
||||
if err := o.bindName(rName, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RunArtifactParams) bindAutomation(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.Automation = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RunArtifactParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RunArtifactParams) bindName(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// RunTaskEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func RunTaskEndpoint(handler func(ctx context.Context, params *RunTaskParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewRunTaskParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewRunTaskParams creates a new RunTaskParams object
|
||||
// with the default values initialized.
|
||||
func NewRunTaskParams() *RunTaskParams {
|
||||
var ()
|
||||
return &RunTaskParams{}
|
||||
}
|
||||
|
||||
// RunTaskParams contains all the bound params for the run task operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters runTask
|
||||
type RunTaskParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Playbook ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
PlaybookID string
|
||||
/*Task ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
TaskID string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *RunTaskParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rPlaybookID := []string{ctx.Param("playbookID")}
|
||||
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rTaskID := []string{ctx.Param("taskID")}
|
||||
if err := o.bindTaskID(rTaskID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RunTaskParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RunTaskParams) bindPlaybookID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.PlaybookID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *RunTaskParams) bindTaskID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.TaskID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// SetArtifactEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func SetArtifactEndpoint(handler func(ctx context.Context, params *SetArtifactParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewSetArtifactParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewSetArtifactParams creates a new SetArtifactParams object
|
||||
// with the default values initialized.
|
||||
func NewSetArtifactParams() *SetArtifactParams {
|
||||
var ()
|
||||
return &SetArtifactParams{}
|
||||
}
|
||||
|
||||
// SetArtifactParams contains all the bound params for the set artifact operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters setArtifact
|
||||
type SetArtifactParams struct {
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Artifact *models.Artifact
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Name string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *SetArtifactParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.Artifact
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("artifact", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("artifact", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Artifact = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("artifact", "body", ""))
|
||||
}
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rName := []string{ctx.Param("name")}
|
||||
if err := o.bindName(rName, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SetArtifactParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SetArtifactParams) bindName(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.Name = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// SetReferencesEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func SetReferencesEndpoint(handler func(ctx context.Context, params *SetReferencesParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewSetReferencesParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewSetReferencesParams creates a new SetReferencesParams object
|
||||
// with the default values initialized.
|
||||
func NewSetReferencesParams() *SetReferencesParams {
|
||||
var ()
|
||||
return &SetReferencesParams{}
|
||||
}
|
||||
|
||||
// SetReferencesParams contains all the bound params for the set references operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters setReferences
|
||||
type SetReferencesParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*All ticket references
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
References []*models.Reference
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *SetReferencesParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body []*models.Reference
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("references", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("references", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.References = body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("references", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SetReferencesParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// SetSchemaEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func SetSchemaEndpoint(handler func(ctx context.Context, params *SetSchemaParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewSetSchemaParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewSetSchemaParams creates a new SetSchemaParams object
|
||||
// with the default values initialized.
|
||||
func NewSetSchemaParams() *SetSchemaParams {
|
||||
var ()
|
||||
return &SetSchemaParams{}
|
||||
}
|
||||
|
||||
// SetSchemaParams contains all the bound params for the set schema operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters setSchema
|
||||
type SetSchemaParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*New ticket schema
|
||||
In: body
|
||||
*/
|
||||
Schema string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *SetSchemaParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body string
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
res = append(res, errors.NewParseError("schema", "body", "", err))
|
||||
} else {
|
||||
o.Schema = body
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SetSchemaParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// SetTaskEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func SetTaskEndpoint(handler func(ctx context.Context, params *SetTaskParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewSetTaskParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewSetTaskParams creates a new SetTaskParams object
|
||||
// with the default values initialized.
|
||||
func NewSetTaskParams() *SetTaskParams {
|
||||
var ()
|
||||
return &SetTaskParams{}
|
||||
}
|
||||
|
||||
// SetTaskParams contains all the bound params for the set task operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters setTask
|
||||
type SetTaskParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Playbook ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
PlaybookID string
|
||||
/*Task
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Task *models.Task
|
||||
/*Task ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
TaskID string
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *SetTaskParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rPlaybookID := []string{ctx.Param("playbookID")}
|
||||
if err := o.bindPlaybookID(rPlaybookID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.Task
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("task", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("task", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Task = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("task", "body", ""))
|
||||
}
|
||||
|
||||
rTaskID := []string{ctx.Param("taskID")}
|
||||
if err := o.bindTaskID(rTaskID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SetTaskParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SetTaskParams) bindPlaybookID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.PlaybookID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *SetTaskParams) bindTaskID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.TaskID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// UnlinkTicketEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func UnlinkTicketEndpoint(handler func(ctx context.Context, params *UnlinkTicketParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewUnlinkTicketParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewUnlinkTicketParams creates a new UnlinkTicketParams object
|
||||
// with the default values initialized.
|
||||
func NewUnlinkTicketParams() *UnlinkTicketParams {
|
||||
var ()
|
||||
return &UnlinkTicketParams{}
|
||||
}
|
||||
|
||||
// UnlinkTicketParams contains all the bound params for the unlink ticket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters unlinkTicket
|
||||
type UnlinkTicketParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Added ticket ID
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
LinkedID int64
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *UnlinkTicketParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body int64
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("linkedId", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("linkedId", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.LinkedID = body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("linkedId", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *UnlinkTicketParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package tickets
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/swag"
|
||||
|
||||
"github.com/SecurityBrewery/catalyst/generated/models"
|
||||
"github.com/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// UpdateTicketEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func UpdateTicketEndpoint(handler func(ctx context.Context, params *UpdateTicketParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewUpdateTicketParams()
|
||||
err := params.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
errObj := err.(*errors.CompositeError)
|
||||
ctx.Writer.Header().Set("Content-Type", "application/problem+json")
|
||||
ctx.JSON(int(errObj.Code()), gin.H{"error": errObj.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
resp := handler(ctx, params)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateTicketParams creates a new UpdateTicketParams object
|
||||
// with the default values initialized.
|
||||
func NewUpdateTicketParams() *UpdateTicketParams {
|
||||
var ()
|
||||
return &UpdateTicketParams{}
|
||||
}
|
||||
|
||||
// UpdateTicketParams contains all the bound params for the update ticket operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters updateTicket
|
||||
type UpdateTicketParams struct {
|
||||
|
||||
/*Ticket ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID int64
|
||||
/*Updated ticket
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Ticket *models.Ticket
|
||||
}
|
||||
|
||||
// ReadRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls
|
||||
func (o *UpdateTicketParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
rID := []string{ctx.Param("id")}
|
||||
if err := o.bindID(rID, true); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.Ticket
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("ticket", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("ticket", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Ticket = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("ticket", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *UpdateTicketParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
value, err := swag.ConvertInt64(raw)
|
||||
if err != nil {
|
||||
return errors.InvalidType("id", "path", "int64", raw)
|
||||
}
|
||||
o.ID = value
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user