production_plan_parameters.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Code generated by go-swagger; DO NOT EDIT.
  2. package operations
  3. // This file was generated by the swagger tool.
  4. // Editing this file might prove futile when you re-run the swagger generate command
  5. import (
  6. "context"
  7. "net/http"
  8. "github.com/go-openapi/errors"
  9. "github.com/go-openapi/runtime"
  10. "github.com/go-openapi/runtime/middleware"
  11. "github.com/go-openapi/validate"
  12. "gem-spaas-coding-challenge/models"
  13. )
  14. // NewProductionPlanParams creates a new ProductionPlanParams object
  15. // no default values defined in spec.
  16. func NewProductionPlanParams() ProductionPlanParams {
  17. return ProductionPlanParams{}
  18. }
  19. // ProductionPlanParams contains all the bound params for the production plan operation
  20. // typically these are obtained from a http.Request
  21. //
  22. // swagger:parameters ProductionPlan
  23. type ProductionPlanParams struct {
  24. // HTTP Request Object
  25. HTTPRequest *http.Request `json:"-"`
  26. /*
  27. In: body
  28. */
  29. PayloadFormat *models.Payload
  30. }
  31. // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
  32. // for simple values it will use straight method calls.
  33. //
  34. // To ensure default values, the struct must have been initialized with NewProductionPlanParams() beforehand.
  35. func (o *ProductionPlanParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
  36. var res []error
  37. o.HTTPRequest = r
  38. if runtime.HasBody(r) {
  39. defer r.Body.Close()
  40. var body models.Payload
  41. if err := route.Consumer.Consume(r.Body, &body); err != nil {
  42. res = append(res, errors.NewParseError("payloadFormat", "body", "", err))
  43. } else {
  44. // validate body object
  45. if err := body.Validate(route.Formats); err != nil {
  46. res = append(res, err)
  47. }
  48. ctx := validate.WithOperationRequest(context.Background())
  49. if err := body.ContextValidate(ctx, route.Formats); err != nil {
  50. res = append(res, err)
  51. }
  52. if len(res) == 0 {
  53. o.PayloadFormat = &body
  54. }
  55. }
  56. }
  57. if len(res) > 0 {
  58. return errors.CompositeValidationError(res...)
  59. }
  60. return nil
  61. }