go-kimai/models/task_query.go

335 lines
7.6 KiB
Go
Raw Permalink Normal View History

2023-01-14 14:14:06 +00:00
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"encoding/json"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// TaskQuery task query
//
// swagger:model TaskQuery
type TaskQuery struct {
// Array of activity IDs
// Required: true
Activities []int64 `json:"activities"`
// Array of customer IDs
// Required: true
Customers []int64 `json:"customers"`
// The order for returned items
// Required: true
// Enum: [ASC DESC]
Order *string `json:"order"`
// order by
// Required: true
// Enum: [title customer project activity description status user begin end team]
OrderBy *string `json:"orderBy"`
// Page number. Default: 1
Page int64 `json:"page,omitempty"`
// page size
// Enum: [10 15 20 25 30 35 40 45 50 60 70 80 90 100 125 150 175 200 250 300 350 400 450 500]
PageSize float64 `json:"pageSize,omitempty"`
// Array of project IDs
// Required: true
Projects []int64 `json:"projects"`
// search term
SearchTerm string `json:"searchTerm,omitempty"`
// status
Status []string `json:"status"`
// Comma separated list of tags
Tags string `json:"tags,omitempty"`
// Array of team IDs
Teams []int64 `json:"teams"`
// Array of user IDs
Users []int64 `json:"users"`
}
// Validate validates this task query
func (m *TaskQuery) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateActivities(formats); err != nil {
res = append(res, err)
}
if err := m.validateCustomers(formats); err != nil {
res = append(res, err)
}
if err := m.validateOrder(formats); err != nil {
res = append(res, err)
}
if err := m.validateOrderBy(formats); err != nil {
res = append(res, err)
}
if err := m.validatePageSize(formats); err != nil {
res = append(res, err)
}
if err := m.validateProjects(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *TaskQuery) validateActivities(formats strfmt.Registry) error {
if err := validate.Required("activities", "body", m.Activities); err != nil {
return err
}
return nil
}
func (m *TaskQuery) validateCustomers(formats strfmt.Registry) error {
if err := validate.Required("customers", "body", m.Customers); err != nil {
return err
}
return nil
}
var taskQueryTypeOrderPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["ASC","DESC"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
taskQueryTypeOrderPropEnum = append(taskQueryTypeOrderPropEnum, v)
}
}
const (
// TaskQueryOrderASC captures enum value "ASC"
TaskQueryOrderASC string = "ASC"
// TaskQueryOrderDESC captures enum value "DESC"
TaskQueryOrderDESC string = "DESC"
)
// prop value enum
func (m *TaskQuery) validateOrderEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, taskQueryTypeOrderPropEnum, true); err != nil {
return err
}
return nil
}
func (m *TaskQuery) validateOrder(formats strfmt.Registry) error {
if err := validate.Required("order", "body", m.Order); err != nil {
return err
}
// value enum
if err := m.validateOrderEnum("order", "body", *m.Order); err != nil {
return err
}
return nil
}
var taskQueryTypeOrderByPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["title","customer","project","activity","description","status","user","begin","end","team"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
taskQueryTypeOrderByPropEnum = append(taskQueryTypeOrderByPropEnum, v)
}
}
const (
// TaskQueryOrderByTitle captures enum value "title"
TaskQueryOrderByTitle string = "title"
// TaskQueryOrderByCustomer captures enum value "customer"
TaskQueryOrderByCustomer string = "customer"
// TaskQueryOrderByProject captures enum value "project"
TaskQueryOrderByProject string = "project"
// TaskQueryOrderByActivity captures enum value "activity"
TaskQueryOrderByActivity string = "activity"
// TaskQueryOrderByDescription captures enum value "description"
TaskQueryOrderByDescription string = "description"
// TaskQueryOrderByStatus captures enum value "status"
TaskQueryOrderByStatus string = "status"
// TaskQueryOrderByUser captures enum value "user"
TaskQueryOrderByUser string = "user"
// TaskQueryOrderByBegin captures enum value "begin"
TaskQueryOrderByBegin string = "begin"
// TaskQueryOrderByEnd captures enum value "end"
TaskQueryOrderByEnd string = "end"
// TaskQueryOrderByTeam captures enum value "team"
TaskQueryOrderByTeam string = "team"
)
// prop value enum
func (m *TaskQuery) validateOrderByEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, taskQueryTypeOrderByPropEnum, true); err != nil {
return err
}
return nil
}
func (m *TaskQuery) validateOrderBy(formats strfmt.Registry) error {
if err := validate.Required("orderBy", "body", m.OrderBy); err != nil {
return err
}
// value enum
if err := m.validateOrderByEnum("orderBy", "body", *m.OrderBy); err != nil {
return err
}
return nil
}
var taskQueryTypePageSizePropEnum []interface{}
func init() {
var res []float64
if err := json.Unmarshal([]byte(`[10,15,20,25,30,35,40,45,50,60,70,80,90,100,125,150,175,200,250,300,350,400,450,500]`), &res); err != nil {
panic(err)
}
for _, v := range res {
taskQueryTypePageSizePropEnum = append(taskQueryTypePageSizePropEnum, v)
}
}
// prop value enum
func (m *TaskQuery) validatePageSizeEnum(path, location string, value float64) error {
if err := validate.EnumCase(path, location, value, taskQueryTypePageSizePropEnum, true); err != nil {
return err
}
return nil
}
func (m *TaskQuery) validatePageSize(formats strfmt.Registry) error {
if swag.IsZero(m.PageSize) { // not required
return nil
}
// value enum
if err := m.validatePageSizeEnum("pageSize", "body", m.PageSize); err != nil {
return err
}
return nil
}
func (m *TaskQuery) validateProjects(formats strfmt.Registry) error {
if err := validate.Required("projects", "body", m.Projects); err != nil {
return err
}
return nil
}
var taskQueryStatusItemsEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["pending","progress","closed"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
taskQueryStatusItemsEnum = append(taskQueryStatusItemsEnum, v)
}
}
func (m *TaskQuery) validateStatusItemsEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, taskQueryStatusItemsEnum, true); err != nil {
return err
}
return nil
}
func (m *TaskQuery) validateStatus(formats strfmt.Registry) error {
if swag.IsZero(m.Status) { // not required
return nil
}
for i := 0; i < len(m.Status); i++ {
// value enum
if err := m.validateStatusItemsEnum("status"+"."+strconv.Itoa(i), "body", m.Status[i]); err != nil {
return err
}
}
return nil
}
// ContextValidate validates this task query based on context it is used
func (m *TaskQuery) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *TaskQuery) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *TaskQuery) UnmarshalBinary(b []byte) error {
var res TaskQuery
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}