212 lines
5.0 KiB
Go
212 lines
5.0 KiB
Go
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
package assets
|
|
|
|
// This file was generated by the swagger tool.
|
|
// Editing this file might prove futile when you re-run the swagger generate command
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-openapi/errors"
|
|
"github.com/go-openapi/runtime"
|
|
"github.com/go-openapi/runtime/middleware"
|
|
"github.com/go-openapi/swag"
|
|
"github.com/go-openapi/validate"
|
|
|
|
strfmt "github.com/go-openapi/strfmt"
|
|
)
|
|
|
|
// NewGetAssetsParams creates a new GetAssetsParams object
|
|
// with the default values initialized.
|
|
func NewGetAssetsParams() GetAssetsParams {
|
|
|
|
var (
|
|
// initialize parameters with default values
|
|
|
|
pageDefault = int64(1)
|
|
perPageDefault = int64(200)
|
|
sortDefault = string("id")
|
|
)
|
|
|
|
return GetAssetsParams{
|
|
Page: &pageDefault,
|
|
|
|
PerPage: &perPageDefault,
|
|
|
|
Sort: &sortDefault,
|
|
}
|
|
}
|
|
|
|
// GetAssetsParams contains all the bound params for the get assets operation
|
|
// typically these are obtained from a http.Request
|
|
//
|
|
// swagger:parameters GetAssets
|
|
type GetAssetsParams struct {
|
|
|
|
// HTTP Request Object
|
|
HTTPRequest *http.Request `json:"-"`
|
|
|
|
/*Page number
|
|
Minimum: 1
|
|
In: query
|
|
Default: 1
|
|
*/
|
|
Page *int64
|
|
/*Items per page
|
|
Maximum: 200
|
|
Minimum: 1
|
|
In: query
|
|
Default: 200
|
|
*/
|
|
PerPage *int64
|
|
/*Sorting column
|
|
In: query
|
|
Default: "id"
|
|
*/
|
|
Sort *string
|
|
}
|
|
|
|
// BindRequest 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.
|
|
//
|
|
// To ensure default values, the struct must have been initialized with NewGetAssetsParams() beforehand.
|
|
func (o *GetAssetsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
|
var res []error
|
|
|
|
o.HTTPRequest = r
|
|
|
|
qs := runtime.Values(r.URL.Query())
|
|
|
|
qPage, qhkPage, _ := qs.GetOK("page")
|
|
if err := o.bindPage(qPage, qhkPage, route.Formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
qPerPage, qhkPerPage, _ := qs.GetOK("per_page")
|
|
if err := o.bindPerPage(qPerPage, qhkPerPage, route.Formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
qSort, qhkSort, _ := qs.GetOK("sort")
|
|
if err := o.bindSort(qSort, qhkSort, route.Formats); err != nil {
|
|
res = append(res, err)
|
|
}
|
|
|
|
if len(res) > 0 {
|
|
return errors.CompositeValidationError(res...)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// bindPage binds and validates parameter Page from query.
|
|
func (o *GetAssetsParams) bindPage(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
|
var raw string
|
|
if len(rawData) > 0 {
|
|
raw = rawData[len(rawData)-1]
|
|
}
|
|
|
|
// Required: false
|
|
// AllowEmptyValue: false
|
|
if raw == "" { // empty values pass all other validations
|
|
// Default values have been previously initialized by NewGetAssetsParams()
|
|
return nil
|
|
}
|
|
|
|
value, err := swag.ConvertInt64(raw)
|
|
if err != nil {
|
|
return errors.InvalidType("page", "query", "int64", raw)
|
|
}
|
|
o.Page = &value
|
|
|
|
if err := o.validatePage(formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// validatePage carries on validations for parameter Page
|
|
func (o *GetAssetsParams) validatePage(formats strfmt.Registry) error {
|
|
|
|
if err := validate.MinimumInt("page", "query", int64(*o.Page), 1, false); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// bindPerPage binds and validates parameter PerPage from query.
|
|
func (o *GetAssetsParams) bindPerPage(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
|
var raw string
|
|
if len(rawData) > 0 {
|
|
raw = rawData[len(rawData)-1]
|
|
}
|
|
|
|
// Required: false
|
|
// AllowEmptyValue: false
|
|
if raw == "" { // empty values pass all other validations
|
|
// Default values have been previously initialized by NewGetAssetsParams()
|
|
return nil
|
|
}
|
|
|
|
value, err := swag.ConvertInt64(raw)
|
|
if err != nil {
|
|
return errors.InvalidType("per_page", "query", "int64", raw)
|
|
}
|
|
o.PerPage = &value
|
|
|
|
if err := o.validatePerPage(formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// validatePerPage carries on validations for parameter PerPage
|
|
func (o *GetAssetsParams) validatePerPage(formats strfmt.Registry) error {
|
|
|
|
if err := validate.MinimumInt("per_page", "query", int64(*o.PerPage), 1, false); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := validate.MaximumInt("per_page", "query", int64(*o.PerPage), 200, false); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// bindSort binds and validates parameter Sort from query.
|
|
func (o *GetAssetsParams) bindSort(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
|
var raw string
|
|
if len(rawData) > 0 {
|
|
raw = rawData[len(rawData)-1]
|
|
}
|
|
|
|
// Required: false
|
|
// AllowEmptyValue: false
|
|
if raw == "" { // empty values pass all other validations
|
|
// Default values have been previously initialized by NewGetAssetsParams()
|
|
return nil
|
|
}
|
|
|
|
o.Sort = &raw
|
|
|
|
if err := o.validateSort(formats); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// validateSort carries on validations for parameter Sort
|
|
func (o *GetAssetsParams) validateSort(formats strfmt.Registry) error {
|
|
|
|
if err := validate.Enum("sort", "query", *o.Sort, []interface{}{"id", "id:asc", "id:desc", "uid", "uid:asc", "uid:desc", "serialnr", "serialnr:asc", "serialnr:desc"}); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|