// 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 swagger generate command

import (
	"context"
	"encoding/json"
	"fmt"
	"io"
	"strconv"

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

	"github.com/fiskerinc/cloud-services/pkg/ota_api/models"
)

// GetManifestsManifestIDVehiclesReader is a Reader for the GetManifestsManifestIDVehicles structure.
type GetManifestsManifestIDVehiclesReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *GetManifestsManifestIDVehiclesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewGetManifestsManifestIDVehiclesOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewGetManifestsManifestIDVehiclesBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 401:
		result := NewGetManifestsManifestIDVehiclesUnauthorized()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewGetManifestsManifestIDVehiclesServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /manifests/{manifest_id}/vehicles] GetManifestsManifestIDVehicles", response, response.Code())
	}
}

// NewGetManifestsManifestIDVehiclesOK creates a GetManifestsManifestIDVehiclesOK with default headers values
func NewGetManifestsManifestIDVehiclesOK() *GetManifestsManifestIDVehiclesOK {
	return &GetManifestsManifestIDVehiclesOK{}
}

/*
GetManifestsManifestIDVehiclesOK describes a response with status code 200, with default header values.

list of cars
*/
type GetManifestsManifestIDVehiclesOK struct {
	Payload *GetManifestsManifestIDVehiclesOKBody
}

// IsSuccess returns true when this get manifests manifest Id vehicles o k response has a 2xx status code
func (o *GetManifestsManifestIDVehiclesOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this get manifests manifest Id vehicles o k response has a 3xx status code
func (o *GetManifestsManifestIDVehiclesOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get manifests manifest Id vehicles o k response has a 4xx status code
func (o *GetManifestsManifestIDVehiclesOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this get manifests manifest Id vehicles o k response has a 5xx status code
func (o *GetManifestsManifestIDVehiclesOK) IsServerError() bool {
	return false
}

// IsCode returns true when this get manifests manifest Id vehicles o k response a status code equal to that given
func (o *GetManifestsManifestIDVehiclesOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the get manifests manifest Id vehicles o k response
func (o *GetManifestsManifestIDVehiclesOK) Code() int {
	return 200
}

func (o *GetManifestsManifestIDVehiclesOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesOK %s", 200, payload)
}

func (o *GetManifestsManifestIDVehiclesOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesOK %s", 200, payload)
}

func (o *GetManifestsManifestIDVehiclesOK) GetPayload() *GetManifestsManifestIDVehiclesOKBody {
	return o.Payload
}

func (o *GetManifestsManifestIDVehiclesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(GetManifestsManifestIDVehiclesOKBody)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

// NewGetManifestsManifestIDVehiclesBadRequest creates a GetManifestsManifestIDVehiclesBadRequest with default headers values
func NewGetManifestsManifestIDVehiclesBadRequest() *GetManifestsManifestIDVehiclesBadRequest {
	return &GetManifestsManifestIDVehiclesBadRequest{}
}

/*
GetManifestsManifestIDVehiclesBadRequest describes a response with status code 400, with default header values.

Bad request
*/
type GetManifestsManifestIDVehiclesBadRequest struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this get manifests manifest Id vehicles bad request response has a 2xx status code
func (o *GetManifestsManifestIDVehiclesBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get manifests manifest Id vehicles bad request response has a 3xx status code
func (o *GetManifestsManifestIDVehiclesBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get manifests manifest Id vehicles bad request response has a 4xx status code
func (o *GetManifestsManifestIDVehiclesBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this get manifests manifest Id vehicles bad request response has a 5xx status code
func (o *GetManifestsManifestIDVehiclesBadRequest) IsServerError() bool {
	return false
}

// IsCode returns true when this get manifests manifest Id vehicles bad request response a status code equal to that given
func (o *GetManifestsManifestIDVehiclesBadRequest) IsCode(code int) bool {
	return code == 400
}

// Code gets the status code for the get manifests manifest Id vehicles bad request response
func (o *GetManifestsManifestIDVehiclesBadRequest) Code() int {
	return 400
}

func (o *GetManifestsManifestIDVehiclesBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesBadRequest %s", 400, payload)
}

func (o *GetManifestsManifestIDVehiclesBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesBadRequest %s", 400, payload)
}

func (o *GetManifestsManifestIDVehiclesBadRequest) GetPayload() *models.CommonJSONError {
	return o.Payload
}

func (o *GetManifestsManifestIDVehiclesBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(models.CommonJSONError)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

// NewGetManifestsManifestIDVehiclesUnauthorized creates a GetManifestsManifestIDVehiclesUnauthorized with default headers values
func NewGetManifestsManifestIDVehiclesUnauthorized() *GetManifestsManifestIDVehiclesUnauthorized {
	return &GetManifestsManifestIDVehiclesUnauthorized{}
}

/*
GetManifestsManifestIDVehiclesUnauthorized describes a response with status code 401, with default header values.

Unauthorized
*/
type GetManifestsManifestIDVehiclesUnauthorized struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this get manifests manifest Id vehicles unauthorized response has a 2xx status code
func (o *GetManifestsManifestIDVehiclesUnauthorized) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get manifests manifest Id vehicles unauthorized response has a 3xx status code
func (o *GetManifestsManifestIDVehiclesUnauthorized) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get manifests manifest Id vehicles unauthorized response has a 4xx status code
func (o *GetManifestsManifestIDVehiclesUnauthorized) IsClientError() bool {
	return true
}

// IsServerError returns true when this get manifests manifest Id vehicles unauthorized response has a 5xx status code
func (o *GetManifestsManifestIDVehiclesUnauthorized) IsServerError() bool {
	return false
}

// IsCode returns true when this get manifests manifest Id vehicles unauthorized response a status code equal to that given
func (o *GetManifestsManifestIDVehiclesUnauthorized) IsCode(code int) bool {
	return code == 401
}

// Code gets the status code for the get manifests manifest Id vehicles unauthorized response
func (o *GetManifestsManifestIDVehiclesUnauthorized) Code() int {
	return 401
}

func (o *GetManifestsManifestIDVehiclesUnauthorized) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesUnauthorized %s", 401, payload)
}

func (o *GetManifestsManifestIDVehiclesUnauthorized) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesUnauthorized %s", 401, payload)
}

func (o *GetManifestsManifestIDVehiclesUnauthorized) GetPayload() *models.CommonJSONError {
	return o.Payload
}

func (o *GetManifestsManifestIDVehiclesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(models.CommonJSONError)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

// NewGetManifestsManifestIDVehiclesServiceUnavailable creates a GetManifestsManifestIDVehiclesServiceUnavailable with default headers values
func NewGetManifestsManifestIDVehiclesServiceUnavailable() *GetManifestsManifestIDVehiclesServiceUnavailable {
	return &GetManifestsManifestIDVehiclesServiceUnavailable{}
}

/*
GetManifestsManifestIDVehiclesServiceUnavailable describes a response with status code 503, with default header values.

Service unavailable
*/
type GetManifestsManifestIDVehiclesServiceUnavailable struct {
	Payload *models.CommonJSONError
}

// IsSuccess returns true when this get manifests manifest Id vehicles service unavailable response has a 2xx status code
func (o *GetManifestsManifestIDVehiclesServiceUnavailable) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this get manifests manifest Id vehicles service unavailable response has a 3xx status code
func (o *GetManifestsManifestIDVehiclesServiceUnavailable) IsRedirect() bool {
	return false
}

// IsClientError returns true when this get manifests manifest Id vehicles service unavailable response has a 4xx status code
func (o *GetManifestsManifestIDVehiclesServiceUnavailable) IsClientError() bool {
	return false
}

// IsServerError returns true when this get manifests manifest Id vehicles service unavailable response has a 5xx status code
func (o *GetManifestsManifestIDVehiclesServiceUnavailable) IsServerError() bool {
	return true
}

// IsCode returns true when this get manifests manifest Id vehicles service unavailable response a status code equal to that given
func (o *GetManifestsManifestIDVehiclesServiceUnavailable) IsCode(code int) bool {
	return code == 503
}

// Code gets the status code for the get manifests manifest Id vehicles service unavailable response
func (o *GetManifestsManifestIDVehiclesServiceUnavailable) Code() int {
	return 503
}

func (o *GetManifestsManifestIDVehiclesServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesServiceUnavailable %s", 503, payload)
}

func (o *GetManifestsManifestIDVehiclesServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /manifests/{manifest_id}/vehicles][%d] getManifestsManifestIdVehiclesServiceUnavailable %s", 503, payload)
}

func (o *GetManifestsManifestIDVehiclesServiceUnavailable) GetPayload() *models.CommonJSONError {
	return o.Payload
}

func (o *GetManifestsManifestIDVehiclesServiceUnavailable) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

	o.Payload = new(models.CommonJSONError)

	// response payload
	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}

/*
GetManifestsManifestIDVehiclesOKBody get manifests manifest ID vehicles o k body
swagger:model GetManifestsManifestIDVehiclesOKBody
*/
type GetManifestsManifestIDVehiclesOKBody struct {
	models.CommonJSONDBQueryResult

	// data
	Data []*models.CommonCar `json:"data"`
}

// UnmarshalJSON unmarshals this object from a JSON structure
func (o *GetManifestsManifestIDVehiclesOKBody) UnmarshalJSON(raw []byte) error {
	// GetManifestsManifestIDVehiclesOKBodyAO0
	var getManifestsManifestIDVehiclesOKBodyAO0 models.CommonJSONDBQueryResult
	if err := swag.ReadJSON(raw, &getManifestsManifestIDVehiclesOKBodyAO0); err != nil {
		return err
	}
	o.CommonJSONDBQueryResult = getManifestsManifestIDVehiclesOKBodyAO0

	// GetManifestsManifestIDVehiclesOKBodyAO1
	var dataGetManifestsManifestIDVehiclesOKBodyAO1 struct {
		Data []*models.CommonCar `json:"data"`
	}
	if err := swag.ReadJSON(raw, &dataGetManifestsManifestIDVehiclesOKBodyAO1); err != nil {
		return err
	}

	o.Data = dataGetManifestsManifestIDVehiclesOKBodyAO1.Data

	return nil
}

// MarshalJSON marshals this object to a JSON structure
func (o GetManifestsManifestIDVehiclesOKBody) MarshalJSON() ([]byte, error) {
	_parts := make([][]byte, 0, 2)

	getManifestsManifestIDVehiclesOKBodyAO0, err := swag.WriteJSON(o.CommonJSONDBQueryResult)
	if err != nil {
		return nil, err
	}
	_parts = append(_parts, getManifestsManifestIDVehiclesOKBodyAO0)
	var dataGetManifestsManifestIDVehiclesOKBodyAO1 struct {
		Data []*models.CommonCar `json:"data"`
	}

	dataGetManifestsManifestIDVehiclesOKBodyAO1.Data = o.Data

	jsonDataGetManifestsManifestIDVehiclesOKBodyAO1, errGetManifestsManifestIDVehiclesOKBodyAO1 := swag.WriteJSON(dataGetManifestsManifestIDVehiclesOKBodyAO1)
	if errGetManifestsManifestIDVehiclesOKBodyAO1 != nil {
		return nil, errGetManifestsManifestIDVehiclesOKBodyAO1
	}
	_parts = append(_parts, jsonDataGetManifestsManifestIDVehiclesOKBodyAO1)
	return swag.ConcatJSON(_parts...), nil
}

// Validate validates this get manifests manifest ID vehicles o k body
func (o *GetManifestsManifestIDVehiclesOKBody) Validate(formats strfmt.Registry) error {
	var res []error

	// validation for a type composition with models.CommonJSONDBQueryResult
	if err := o.CommonJSONDBQueryResult.Validate(formats); err != nil {
		res = append(res, err)
	}

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

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

func (o *GetManifestsManifestIDVehiclesOKBody) validateData(formats strfmt.Registry) error {

	if swag.IsZero(o.Data) { // not required
		return nil
	}

	for i := 0; i < len(o.Data); i++ {
		if swag.IsZero(o.Data[i]) { // not required
			continue
		}

		if o.Data[i] != nil {
			if err := o.Data[i].Validate(formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("getManifestsManifestIdVehiclesOK" + "." + "data" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("getManifestsManifestIdVehiclesOK" + "." + "data" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

// ContextValidate validate this get manifests manifest ID vehicles o k body based on the context it is used
func (o *GetManifestsManifestIDVehiclesOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	// validation for a type composition with models.CommonJSONDBQueryResult
	if err := o.CommonJSONDBQueryResult.ContextValidate(ctx, formats); err != nil {
		res = append(res, err)
	}

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

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

func (o *GetManifestsManifestIDVehiclesOKBody) contextValidateData(ctx context.Context, formats strfmt.Registry) error {

	for i := 0; i < len(o.Data); i++ {

		if o.Data[i] != nil {

			if swag.IsZero(o.Data[i]) { // not required
				return nil
			}

			if err := o.Data[i].ContextValidate(ctx, formats); err != nil {
				if ve, ok := err.(*errors.Validation); ok {
					return ve.ValidateName("getManifestsManifestIdVehiclesOK" + "." + "data" + "." + strconv.Itoa(i))
				} else if ce, ok := err.(*errors.CompositeError); ok {
					return ce.ValidateName("getManifestsManifestIdVehiclesOK" + "." + "data" + "." + strconv.Itoa(i))
				}
				return err
			}
		}

	}

	return nil
}

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

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