// Code generated by go-swagger; DO NOT EDIT.

package operations

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command

import (
	"context"
	"net/http"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/runtime/middleware"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
	"github.com/go-openapi/validate"
)

// GetJobErrorHandlerFunc turns a function with the right signature into a get job error handler
type GetJobErrorHandlerFunc func(GetJobErrorParams) middleware.Responder

// Handle executing the request and returning a response
func (fn GetJobErrorHandlerFunc) Handle(params GetJobErrorParams) middleware.Responder {
	return fn(params)
}

// GetJobErrorHandler interface for that can handle valid get job error params
type GetJobErrorHandler interface {
	Handle(GetJobErrorParams) middleware.Responder
}

// NewGetJobError creates a new http.Handler for the get job error operation
func NewGetJobError(ctx *middleware.Context, handler GetJobErrorHandler) *GetJobError {
	return &GetJobError{Context: ctx, Handler: handler}
}

/*
	GetJobError swagger:route POST /api/v1/jobError getJobError

GetJobError get job error API
*/
type GetJobError struct {
	Context *middleware.Context
	Handler GetJobErrorHandler
}

func (o *GetJobError) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
	route, rCtx, _ := o.Context.RouteInfo(r)
	if rCtx != nil {
		*r = *rCtx
	}
	var Params = NewGetJobErrorParams()
	if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
		o.Context.Respond(rw, r, route.Produces, route, err)
		return
	}

	res := o.Handler.Handle(Params) // actually handle the request
	o.Context.Respond(rw, r, route.Produces, route, res)

}

// GetJobErrorBody get job error body
//
// swagger:model GetJobErrorBody
type GetJobErrorBody struct {

	// job Id
	// Required: true
	JobID string `json:"jobId"`
}

// Validate validates this get job error body
func (o *GetJobErrorBody) Validate(formats strfmt.Registry) error {
	var res []error

	if err := o.validateJobID(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (o *GetJobErrorBody) validateJobID(formats strfmt.Registry) error {

	if err := validate.RequiredString("getJobErrorRequest"+"."+"jobId", "body", o.JobID); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this get job error body based on context it is used
func (o *GetJobErrorBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (o *GetJobErrorBody) MarshalBinary() ([]byte, error) {
	if o == nil {
		return nil, nil
	}
	return swag.WriteJSON(o)
}

// UnmarshalBinary interface implementation
func (o *GetJobErrorBody) UnmarshalBinary(b []byte) error {
	var res GetJobErrorBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}

// GetJobErrorOKBody get job error o k body
//
// swagger:model GetJobErrorOKBody
type GetJobErrorOKBody struct {

	// Error for job
	ErrorString string `json:"errorString,omitempty"`
}

// Validate validates this get job error o k body
func (o *GetJobErrorOKBody) Validate(formats strfmt.Registry) error {
	return nil
}

// ContextValidate validates this get job error o k body based on context it is used
func (o *GetJobErrorOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (o *GetJobErrorOKBody) MarshalBinary() ([]byte, error) {
	if o == nil {
		return nil, nil
	}
	return swag.WriteJSON(o)
}

// UnmarshalBinary interface implementation
func (o *GetJobErrorOKBody) UnmarshalBinary(b []byte) error {
	var res GetJobErrorOKBody
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*o = res
	return nil
}
