// 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"
)

// ClusterHealthReader is a Reader for the ClusterHealth structure.
type ClusterHealthReader struct {
	formats strfmt.Registry
}

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

// NewClusterHealthOK creates a ClusterHealthOK with default headers values
func NewClusterHealthOK() *ClusterHealthOK {
	return &ClusterHealthOK{}
}

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

Healthy cluster
*/
type ClusterHealthOK struct {
	Payload *models.ClusterHealthResults
}

// IsSuccess returns true when this cluster health o k response has a 2xx status code
func (o *ClusterHealthOK) IsSuccess() bool {
	return true
}

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

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

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

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

// Code gets the status code for the cluster health o k response
func (o *ClusterHealthOK) Code() int {
	return 200
}

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

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

func (o *ClusterHealthOK) GetPayload() *models.ClusterHealthResults {
	return o.Payload
}

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

	o.Payload = new(models.ClusterHealthResults)

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

	return nil
}

// NewClusterHealthIMATeapot creates a ClusterHealthIMATeapot with default headers values
func NewClusterHealthIMATeapot() *ClusterHealthIMATeapot {
	return &ClusterHealthIMATeapot{}
}

/*
ClusterHealthIMATeapot describes a response with status code 418, with default header values.

Unhealthy cluster
*/
type ClusterHealthIMATeapot struct {
	Payload *models.ClusterHealthResults
}

// IsSuccess returns true when this cluster health i m a teapot response has a 2xx status code
func (o *ClusterHealthIMATeapot) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this cluster health i m a teapot response has a 3xx status code
func (o *ClusterHealthIMATeapot) IsRedirect() bool {
	return false
}

// IsClientError returns true when this cluster health i m a teapot response has a 4xx status code
func (o *ClusterHealthIMATeapot) IsClientError() bool {
	return true
}

// IsServerError returns true when this cluster health i m a teapot response has a 5xx status code
func (o *ClusterHealthIMATeapot) IsServerError() bool {
	return false
}

// IsCode returns true when this cluster health i m a teapot response a status code equal to that given
func (o *ClusterHealthIMATeapot) IsCode(code int) bool {
	return code == 418
}

// Code gets the status code for the cluster health i m a teapot response
func (o *ClusterHealthIMATeapot) Code() int {
	return 418
}

func (o *ClusterHealthIMATeapot) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /cluster_health][%d] clusterHealthIMATeapot %s", 418, payload)
}

func (o *ClusterHealthIMATeapot) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /cluster_health][%d] clusterHealthIMATeapot %s", 418, payload)
}

func (o *ClusterHealthIMATeapot) GetPayload() *models.ClusterHealthResults {
	return o.Payload
}

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

	o.Payload = new(models.ClusterHealthResults)

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

	return nil
}
