mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-04-21 10:11:50 +02:00
Release catalyst
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
package templates
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// CreateTemplateEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func CreateTemplateEndpoint(handler func(ctx context.Context, params *CreateTemplateParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewCreateTemplateParams()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewCreateTemplateParams creates a new CreateTemplateParams object
|
||||
// with the default values initialized.
|
||||
func NewCreateTemplateParams() *CreateTemplateParams {
|
||||
var ()
|
||||
return &CreateTemplateParams{}
|
||||
}
|
||||
|
||||
// CreateTemplateParams contains all the bound params for the create template operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters createTemplate
|
||||
type CreateTemplateParams struct {
|
||||
|
||||
/*New template
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Template *models.TicketTemplateForm
|
||||
}
|
||||
|
||||
// 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 *CreateTemplateParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.TicketTemplateForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("template", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("template", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Template = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("template", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package templates
|
||||
|
||||
// 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/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// DeleteTemplateEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func DeleteTemplateEndpoint(handler func(ctx context.Context, params *DeleteTemplateParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewDeleteTemplateParams()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewDeleteTemplateParams creates a new DeleteTemplateParams object
|
||||
// with the default values initialized.
|
||||
func NewDeleteTemplateParams() *DeleteTemplateParams {
|
||||
var ()
|
||||
return &DeleteTemplateParams{}
|
||||
}
|
||||
|
||||
// DeleteTemplateParams contains all the bound params for the delete template operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters deleteTemplate
|
||||
type DeleteTemplateParams struct {
|
||||
|
||||
/*Template ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID 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 *DeleteTemplateParams) 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 *DeleteTemplateParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package templates
|
||||
|
||||
// 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/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// GetTemplateEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func GetTemplateEndpoint(handler func(ctx context.Context, params *GetTemplateParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewGetTemplateParams()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetTemplateParams creates a new GetTemplateParams object
|
||||
// with the default values initialized.
|
||||
func NewGetTemplateParams() *GetTemplateParams {
|
||||
var ()
|
||||
return &GetTemplateParams{}
|
||||
}
|
||||
|
||||
// GetTemplateParams contains all the bound params for the get template operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters getTemplate
|
||||
type GetTemplateParams struct {
|
||||
|
||||
/*Template ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID 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 *GetTemplateParams) 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 *GetTemplateParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package templates
|
||||
|
||||
// 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/SecurityBrewery/catalyst/generated/restapi/api"
|
||||
)
|
||||
|
||||
// ListTemplatesEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func ListTemplatesEndpoint(handler func(ctx context.Context) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
resp := handler(ctx)
|
||||
|
||||
switch resp.Code {
|
||||
case http.StatusNoContent:
|
||||
ctx.AbortWithStatus(resp.Code)
|
||||
default:
|
||||
ctx.JSON(resp.Code, resp.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewListTemplatesParams creates a new ListTemplatesParams object
|
||||
// with the default values initialized.
|
||||
func NewListTemplatesParams() *ListTemplatesParams {
|
||||
var ()
|
||||
return &ListTemplatesParams{}
|
||||
}
|
||||
|
||||
// ListTemplatesParams contains all the bound params for the list templates operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters listTemplates
|
||||
type ListTemplatesParams struct {
|
||||
}
|
||||
|
||||
// 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 *ListTemplatesParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package templates
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// UpdateTemplateEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func UpdateTemplateEndpoint(handler func(ctx context.Context, params *UpdateTemplateParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewUpdateTemplateParams()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateTemplateParams creates a new UpdateTemplateParams object
|
||||
// with the default values initialized.
|
||||
func NewUpdateTemplateParams() *UpdateTemplateParams {
|
||||
var ()
|
||||
return &UpdateTemplateParams{}
|
||||
}
|
||||
|
||||
// UpdateTemplateParams contains all the bound params for the update template operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters updateTemplate
|
||||
type UpdateTemplateParams struct {
|
||||
|
||||
/*Template ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*Template object that needs to be added
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Template *models.TicketTemplateForm
|
||||
}
|
||||
|
||||
// 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 *UpdateTemplateParams) 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.TicketTemplateForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("template", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("template", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Template = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("template", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *UpdateTemplateParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user