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

package jobs

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

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

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

	apiserver_params "github.com/cloudbase/garm/apiserver/params"
	garm_params "github.com/cloudbase/garm/params"
)

// ListJobsReader is a Reader for the ListJobs structure.
type ListJobsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *ListJobsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
	switch response.Code() {
	case 200:
		result := NewListJobsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 400:
		result := NewListJobsBadRequest()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		return nil, runtime.NewAPIError("[GET /jobs] ListJobs", response, response.Code())
	}
}

// NewListJobsOK creates a ListJobsOK with default headers values
func NewListJobsOK() *ListJobsOK {
	return &ListJobsOK{}
}

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

Jobs
*/
type ListJobsOK struct {
	Payload garm_params.Jobs
}

// IsSuccess returns true when this list jobs o k response has a 2xx status code
func (o *ListJobsOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this list jobs o k response has a 3xx status code
func (o *ListJobsOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this list jobs o k response has a 4xx status code
func (o *ListJobsOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this list jobs o k response has a 5xx status code
func (o *ListJobsOK) IsServerError() bool {
	return false
}

// IsCode returns true when this list jobs o k response a status code equal to that given
func (o *ListJobsOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the list jobs o k response
func (o *ListJobsOK) Code() int {
	return 200
}

func (o *ListJobsOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /jobs][%d] listJobsOK %s", 200, payload)
}

func (o *ListJobsOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /jobs][%d] listJobsOK %s", 200, payload)
}

func (o *ListJobsOK) GetPayload() garm_params.Jobs {
	return o.Payload
}

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

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

	return nil
}

// NewListJobsBadRequest creates a ListJobsBadRequest with default headers values
func NewListJobsBadRequest() *ListJobsBadRequest {
	return &ListJobsBadRequest{}
}

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

APIErrorResponse
*/
type ListJobsBadRequest struct {
	Payload apiserver_params.APIErrorResponse
}

// IsSuccess returns true when this list jobs bad request response has a 2xx status code
func (o *ListJobsBadRequest) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this list jobs bad request response has a 3xx status code
func (o *ListJobsBadRequest) IsRedirect() bool {
	return false
}

// IsClientError returns true when this list jobs bad request response has a 4xx status code
func (o *ListJobsBadRequest) IsClientError() bool {
	return true
}

// IsServerError returns true when this list jobs bad request response has a 5xx status code
func (o *ListJobsBadRequest) IsServerError() bool {
	return false
}

// IsCode returns true when this list jobs bad request response a status code equal to that given
func (o *ListJobsBadRequest) IsCode(code int) bool {
	return code == 400
}

// Code gets the status code for the list jobs bad request response
func (o *ListJobsBadRequest) Code() int {
	return 400
}

func (o *ListJobsBadRequest) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /jobs][%d] listJobsBadRequest %s", 400, payload)
}

func (o *ListJobsBadRequest) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /jobs][%d] listJobsBadRequest %s", 400, payload)
}

func (o *ListJobsBadRequest) GetPayload() apiserver_params.APIErrorResponse {
	return o.Payload
}

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

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

	return nil
}
