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

// HealthzReader is a Reader for the Healthz structure.
type HealthzReader struct {
	formats strfmt.Registry
}

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

// NewHealthzOK creates a HealthzOK with default headers values
func NewHealthzOK() *HealthzOK {
	return &HealthzOK{}
}

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

Health check report
*/
type HealthzOK struct {
	Payload *models.HealthCheckResults
}

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

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

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

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

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

// Code gets the status code for the healthz o k response
func (o *HealthzOK) Code() int {
	return 200
}

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

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

func (o *HealthzOK) GetPayload() *models.HealthCheckResults {
	return o.Payload
}

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

	o.Payload = new(models.HealthCheckResults)

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

	return nil
}

// NewHealthzServiceUnavailable creates a HealthzServiceUnavailable with default headers values
func NewHealthzServiceUnavailable() *HealthzServiceUnavailable {
	return &HealthzServiceUnavailable{}
}

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

Unhealthy service
*/
type HealthzServiceUnavailable struct {
	Payload *models.HealthCheckResults
}

// IsSuccess returns true when this healthz service unavailable response has a 2xx status code
func (o *HealthzServiceUnavailable) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this healthz service unavailable response has a 3xx status code
func (o *HealthzServiceUnavailable) IsRedirect() bool {
	return false
}

// IsClientError returns true when this healthz service unavailable response has a 4xx status code
func (o *HealthzServiceUnavailable) IsClientError() bool {
	return false
}

// IsServerError returns true when this healthz service unavailable response has a 5xx status code
func (o *HealthzServiceUnavailable) IsServerError() bool {
	return true
}

// IsCode returns true when this healthz service unavailable response a status code equal to that given
func (o *HealthzServiceUnavailable) IsCode(code int) bool {
	return code == 503
}

// Code gets the status code for the healthz service unavailable response
func (o *HealthzServiceUnavailable) Code() int {
	return 503
}

func (o *HealthzServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /healthz][%d] healthzServiceUnavailable %s", 503, payload)
}

func (o *HealthzServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /healthz][%d] healthzServiceUnavailable %s", 503, payload)
}

func (o *HealthzServiceUnavailable) GetPayload() *models.HealthCheckResults {
	return o.Payload
}

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

	o.Payload = new(models.HealthCheckResults)

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

	return nil
}
