mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-01-03 12:53:08 +01:00
Release catalyst
This commit is contained in:
87
generated/restapi/operations/jobs/get_job_parameters.go
Normal file
87
generated/restapi/operations/jobs/get_job_parameters.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package jobs
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// GetJobEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func GetJobEndpoint(handler func(ctx context.Context, params *GetJobParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewGetJobParams()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetJobParams creates a new GetJobParams object
|
||||
// with the default values initialized.
|
||||
func NewGetJobParams() *GetJobParams {
|
||||
var ()
|
||||
return &GetJobParams{}
|
||||
}
|
||||
|
||||
// GetJobParams contains all the bound params for the get job operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters getJob
|
||||
type GetJobParams struct {
|
||||
|
||||
/*Job 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 *GetJobParams) 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 *GetJobParams) bindID(rawData []string, hasKey bool) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
o.ID = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
55
generated/restapi/operations/jobs/list_jobs_parameters.go
Normal file
55
generated/restapi/operations/jobs/list_jobs_parameters.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package jobs
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// ListJobsEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func ListJobsEndpoint(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewListJobsParams creates a new ListJobsParams object
|
||||
// with the default values initialized.
|
||||
func NewListJobsParams() *ListJobsParams {
|
||||
var ()
|
||||
return &ListJobsParams{}
|
||||
}
|
||||
|
||||
// ListJobsParams contains all the bound params for the list jobs operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters listJobs
|
||||
type ListJobsParams 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 *ListJobsParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
90
generated/restapi/operations/jobs/run_job_parameters.go
Normal file
90
generated/restapi/operations/jobs/run_job_parameters.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package jobs
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// RunJobEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func RunJobEndpoint(handler func(ctx context.Context, params *RunJobParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewRunJobParams()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewRunJobParams creates a new RunJobParams object
|
||||
// with the default values initialized.
|
||||
func NewRunJobParams() *RunJobParams {
|
||||
var ()
|
||||
return &RunJobParams{}
|
||||
}
|
||||
|
||||
// RunJobParams contains all the bound params for the run job operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters runJob
|
||||
type RunJobParams struct {
|
||||
|
||||
/*New job
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Job *models.JobForm
|
||||
}
|
||||
|
||||
// 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 *RunJobParams) ReadRequest(ctx *gin.Context) error {
|
||||
var res []error
|
||||
|
||||
if runtime.HasBody(ctx.Request) {
|
||||
var body models.JobForm
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("job", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("job", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Job = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("job", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
111
generated/restapi/operations/jobs/update_job_parameters.go
Normal file
111
generated/restapi/operations/jobs/update_job_parameters.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package jobs
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// UpdateJobEndpoint executes the core logic of the related
|
||||
// route endpoint.
|
||||
func UpdateJobEndpoint(handler func(ctx context.Context, params *UpdateJobParams) *api.Response) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
// generate params from request
|
||||
params := NewUpdateJobParams()
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NewUpdateJobParams creates a new UpdateJobParams object
|
||||
// with the default values initialized.
|
||||
func NewUpdateJobParams() *UpdateJobParams {
|
||||
var ()
|
||||
return &UpdateJobParams{}
|
||||
}
|
||||
|
||||
// UpdateJobParams contains all the bound params for the update job operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters updateJob
|
||||
type UpdateJobParams struct {
|
||||
|
||||
/*Job ID
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
ID string
|
||||
/*Job object that needs to be added
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Job *models.Job
|
||||
}
|
||||
|
||||
// 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 *UpdateJobParams) 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.Job
|
||||
if err := ctx.BindJSON(&body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("job", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("job", "body", "", err))
|
||||
}
|
||||
|
||||
} else {
|
||||
o.Job = &body
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("job", "body", ""))
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *UpdateJobParams) 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