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

package operations

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

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

	"github.com/bloomberg/goldpinger/v3/pkg/models"
)

// CheckAllPodsReader is a Reader for the CheckAllPods structure.
type CheckAllPodsReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *CheckAllPodsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewCheckAllPodsOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	default:
		return nil, runtime.NewAPIError("[GET /check_all] checkAllPods", response, response.Code())
	}
}

// NewCheckAllPodsOK creates a CheckAllPodsOK with default headers values
func NewCheckAllPodsOK() *CheckAllPodsOK {
	return &CheckAllPodsOK{}
}

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

Success, return response
*/
type CheckAllPodsOK struct {
	Payload *models.CheckAllResults
}

// IsSuccess returns true when this check all pods o k response has a 2xx status code
func (o *CheckAllPodsOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this check all pods o k response has a 3xx status code
func (o *CheckAllPodsOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this check all pods o k response has a 4xx status code
func (o *CheckAllPodsOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this check all pods o k response has a 5xx status code
func (o *CheckAllPodsOK) IsServerError() bool {
	return false
}

// IsCode returns true when this check all pods o k response a status code equal to that given
func (o *CheckAllPodsOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the check all pods o k response
func (o *CheckAllPodsOK) Code() int {
	return 200
}

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

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

func (o *CheckAllPodsOK) GetPayload() *models.CheckAllResults {
	return o.Payload
}

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

	o.Payload = new(models.CheckAllResults)

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

	return nil
}
