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

package echo_rpc

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

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

	"github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/abe/models"
)

// ABitOfEverythingServiceEchoReader is a Reader for the ABitOfEverythingServiceEcho structure.
type ABitOfEverythingServiceEchoReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *ABitOfEverythingServiceEchoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewABitOfEverythingServiceEchoOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewABitOfEverythingServiceEchoForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewABitOfEverythingServiceEchoNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 418:
		result := NewABitOfEverythingServiceEchoIMATeapot()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewABitOfEverythingServiceEchoInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewABitOfEverythingServiceEchoServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		result := NewABitOfEverythingServiceEchoDefault(response.Code())
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		if response.Code()/100 == 2 {
			return result, nil
		}
		return nil, result
	}
}

// NewABitOfEverythingServiceEchoOK creates a ABitOfEverythingServiceEchoOK with default headers values
func NewABitOfEverythingServiceEchoOK() *ABitOfEverythingServiceEchoOK {
	return &ABitOfEverythingServiceEchoOK{}
}

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

A successful response.
*/
type ABitOfEverythingServiceEchoOK struct {
	Payload *models.SubStringMessage
}

// IsSuccess returns true when this a bit of everything service echo o k response has a 2xx status code
func (o *ABitOfEverythingServiceEchoOK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this a bit of everything service echo o k response has a 3xx status code
func (o *ABitOfEverythingServiceEchoOK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service echo o k response has a 4xx status code
func (o *ABitOfEverythingServiceEchoOK) IsClientError() bool {
	return false
}

// IsServerError returns true when this a bit of everything service echo o k response has a 5xx status code
func (o *ABitOfEverythingServiceEchoOK) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service echo o k response a status code equal to that given
func (o *ABitOfEverythingServiceEchoOK) IsCode(code int) bool {
	return code == 200
}

// Code gets the status code for the a bit of everything service echo o k response
func (o *ABitOfEverythingServiceEchoOK) Code() int {
	return 200
}

func (o *ABitOfEverythingServiceEchoOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoOK %s", 200, payload)
}

func (o *ABitOfEverythingServiceEchoOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoOK %s", 200, payload)
}

func (o *ABitOfEverythingServiceEchoOK) GetPayload() *models.SubStringMessage {
	return o.Payload
}

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

	o.Payload = new(models.SubStringMessage)

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

	return nil
}

// NewABitOfEverythingServiceEchoForbidden creates a ABitOfEverythingServiceEchoForbidden with default headers values
func NewABitOfEverythingServiceEchoForbidden() *ABitOfEverythingServiceEchoForbidden {
	return &ABitOfEverythingServiceEchoForbidden{}
}

/*
ABitOfEverythingServiceEchoForbidden describes a response with status code 403, with default header values.

Returned when the user does not have permission to access the resource.
*/
type ABitOfEverythingServiceEchoForbidden struct {
	Payload any
}

// IsSuccess returns true when this a bit of everything service echo forbidden response has a 2xx status code
func (o *ABitOfEverythingServiceEchoForbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service echo forbidden response has a 3xx status code
func (o *ABitOfEverythingServiceEchoForbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service echo forbidden response has a 4xx status code
func (o *ABitOfEverythingServiceEchoForbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this a bit of everything service echo forbidden response has a 5xx status code
func (o *ABitOfEverythingServiceEchoForbidden) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service echo forbidden response a status code equal to that given
func (o *ABitOfEverythingServiceEchoForbidden) IsCode(code int) bool {
	return code == 403
}

// Code gets the status code for the a bit of everything service echo forbidden response
func (o *ABitOfEverythingServiceEchoForbidden) Code() int {
	return 403
}

func (o *ABitOfEverythingServiceEchoForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoForbidden %s", 403, payload)
}

func (o *ABitOfEverythingServiceEchoForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoForbidden %s", 403, payload)
}

func (o *ABitOfEverythingServiceEchoForbidden) GetPayload() any {
	return o.Payload
}

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

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

	return nil
}

// NewABitOfEverythingServiceEchoNotFound creates a ABitOfEverythingServiceEchoNotFound with default headers values
func NewABitOfEverythingServiceEchoNotFound() *ABitOfEverythingServiceEchoNotFound {
	return &ABitOfEverythingServiceEchoNotFound{}
}

/*
ABitOfEverythingServiceEchoNotFound describes a response with status code 404, with default header values.

Returned when the resource does not exist.
*/
type ABitOfEverythingServiceEchoNotFound struct {
	Payload int64
}

// IsSuccess returns true when this a bit of everything service echo not found response has a 2xx status code
func (o *ABitOfEverythingServiceEchoNotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service echo not found response has a 3xx status code
func (o *ABitOfEverythingServiceEchoNotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service echo not found response has a 4xx status code
func (o *ABitOfEverythingServiceEchoNotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this a bit of everything service echo not found response has a 5xx status code
func (o *ABitOfEverythingServiceEchoNotFound) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service echo not found response a status code equal to that given
func (o *ABitOfEverythingServiceEchoNotFound) IsCode(code int) bool {
	return code == 404
}

// Code gets the status code for the a bit of everything service echo not found response
func (o *ABitOfEverythingServiceEchoNotFound) Code() int {
	return 404
}

func (o *ABitOfEverythingServiceEchoNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoNotFound %s", 404, payload)
}

func (o *ABitOfEverythingServiceEchoNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoNotFound %s", 404, payload)
}

func (o *ABitOfEverythingServiceEchoNotFound) GetPayload() int64 {
	return o.Payload
}

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

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

	return nil
}

// NewABitOfEverythingServiceEchoIMATeapot creates a ABitOfEverythingServiceEchoIMATeapot with default headers values
func NewABitOfEverythingServiceEchoIMATeapot() *ABitOfEverythingServiceEchoIMATeapot {
	return &ABitOfEverythingServiceEchoIMATeapot{}
}

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

I'm a teapot.
*/
type ABitOfEverythingServiceEchoIMATeapot struct {
	Payload models.ExamplepbNumericEnum
}

// IsSuccess returns true when this a bit of everything service echo i m a teapot response has a 2xx status code
func (o *ABitOfEverythingServiceEchoIMATeapot) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service echo i m a teapot response has a 3xx status code
func (o *ABitOfEverythingServiceEchoIMATeapot) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service echo i m a teapot response has a 4xx status code
func (o *ABitOfEverythingServiceEchoIMATeapot) IsClientError() bool {
	return true
}

// IsServerError returns true when this a bit of everything service echo i m a teapot response has a 5xx status code
func (o *ABitOfEverythingServiceEchoIMATeapot) IsServerError() bool {
	return false
}

// IsCode returns true when this a bit of everything service echo i m a teapot response a status code equal to that given
func (o *ABitOfEverythingServiceEchoIMATeapot) IsCode(code int) bool {
	return code == 418
}

// Code gets the status code for the a bit of everything service echo i m a teapot response
func (o *ABitOfEverythingServiceEchoIMATeapot) Code() int {
	return 418
}

func (o *ABitOfEverythingServiceEchoIMATeapot) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoIMATeapot %s", 418, payload)
}

func (o *ABitOfEverythingServiceEchoIMATeapot) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoIMATeapot %s", 418, payload)
}

func (o *ABitOfEverythingServiceEchoIMATeapot) GetPayload() models.ExamplepbNumericEnum {
	return o.Payload
}

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

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

	return nil
}

// NewABitOfEverythingServiceEchoInternalServerError creates a ABitOfEverythingServiceEchoInternalServerError with default headers values
func NewABitOfEverythingServiceEchoInternalServerError() *ABitOfEverythingServiceEchoInternalServerError {
	return &ABitOfEverythingServiceEchoInternalServerError{}
}

/*
ABitOfEverythingServiceEchoInternalServerError describes a response with status code 500, with default header values.

Server error
*/
type ABitOfEverythingServiceEchoInternalServerError struct {
	Payload *models.ExamplepbErrorResponse
}

// IsSuccess returns true when this a bit of everything service echo internal server error response has a 2xx status code
func (o *ABitOfEverythingServiceEchoInternalServerError) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service echo internal server error response has a 3xx status code
func (o *ABitOfEverythingServiceEchoInternalServerError) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service echo internal server error response has a 4xx status code
func (o *ABitOfEverythingServiceEchoInternalServerError) IsClientError() bool {
	return false
}

// IsServerError returns true when this a bit of everything service echo internal server error response has a 5xx status code
func (o *ABitOfEverythingServiceEchoInternalServerError) IsServerError() bool {
	return true
}

// IsCode returns true when this a bit of everything service echo internal server error response a status code equal to that given
func (o *ABitOfEverythingServiceEchoInternalServerError) IsCode(code int) bool {
	return code == 500
}

// Code gets the status code for the a bit of everything service echo internal server error response
func (o *ABitOfEverythingServiceEchoInternalServerError) Code() int {
	return 500
}

func (o *ABitOfEverythingServiceEchoInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoInternalServerError %s", 500, payload)
}

func (o *ABitOfEverythingServiceEchoInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoInternalServerError %s", 500, payload)
}

func (o *ABitOfEverythingServiceEchoInternalServerError) GetPayload() *models.ExamplepbErrorResponse {
	return o.Payload
}

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

	o.Payload = new(models.ExamplepbErrorResponse)

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

	return nil
}

// NewABitOfEverythingServiceEchoServiceUnavailable creates a ABitOfEverythingServiceEchoServiceUnavailable with default headers values
func NewABitOfEverythingServiceEchoServiceUnavailable() *ABitOfEverythingServiceEchoServiceUnavailable {
	return &ABitOfEverythingServiceEchoServiceUnavailable{}
}

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

Returned when the resource is temporarily unavailable.
*/
type ABitOfEverythingServiceEchoServiceUnavailable struct {
	Payload any
}

// IsSuccess returns true when this a bit of everything service echo service unavailable response has a 2xx status code
func (o *ABitOfEverythingServiceEchoServiceUnavailable) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this a bit of everything service echo service unavailable response has a 3xx status code
func (o *ABitOfEverythingServiceEchoServiceUnavailable) IsRedirect() bool {
	return false
}

// IsClientError returns true when this a bit of everything service echo service unavailable response has a 4xx status code
func (o *ABitOfEverythingServiceEchoServiceUnavailable) IsClientError() bool {
	return false
}

// IsServerError returns true when this a bit of everything service echo service unavailable response has a 5xx status code
func (o *ABitOfEverythingServiceEchoServiceUnavailable) IsServerError() bool {
	return true
}

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

// Code gets the status code for the a bit of everything service echo service unavailable response
func (o *ABitOfEverythingServiceEchoServiceUnavailable) Code() int {
	return 503
}

func (o *ABitOfEverythingServiceEchoServiceUnavailable) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoServiceUnavailable %s", 503, payload)
}

func (o *ABitOfEverythingServiceEchoServiceUnavailable) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] aBitOfEverythingServiceEchoServiceUnavailable %s", 503, payload)
}

func (o *ABitOfEverythingServiceEchoServiceUnavailable) GetPayload() any {
	return o.Payload
}

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

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

	return nil
}

// NewABitOfEverythingServiceEchoDefault creates a ABitOfEverythingServiceEchoDefault with default headers values
func NewABitOfEverythingServiceEchoDefault(code int) *ABitOfEverythingServiceEchoDefault {
	return &ABitOfEverythingServiceEchoDefault{
		_statusCode: code,
	}
}

/*
ABitOfEverythingServiceEchoDefault describes a response with status code -1, with default header values.

An unexpected error response.
*/
type ABitOfEverythingServiceEchoDefault struct {
	_statusCode int

	Payload *models.GoogleRPCStatus
}

// IsSuccess returns true when this a bit of everything service echo default response has a 2xx status code
func (o *ABitOfEverythingServiceEchoDefault) IsSuccess() bool {
	return o._statusCode/100 == 2
}

// IsRedirect returns true when this a bit of everything service echo default response has a 3xx status code
func (o *ABitOfEverythingServiceEchoDefault) IsRedirect() bool {
	return o._statusCode/100 == 3
}

// IsClientError returns true when this a bit of everything service echo default response has a 4xx status code
func (o *ABitOfEverythingServiceEchoDefault) IsClientError() bool {
	return o._statusCode/100 == 4
}

// IsServerError returns true when this a bit of everything service echo default response has a 5xx status code
func (o *ABitOfEverythingServiceEchoDefault) IsServerError() bool {
	return o._statusCode/100 == 5
}

// IsCode returns true when this a bit of everything service echo default response a status code equal to that given
func (o *ABitOfEverythingServiceEchoDefault) IsCode(code int) bool {
	return o._statusCode == code
}

// Code gets the status code for the a bit of everything service echo default response
func (o *ABitOfEverythingServiceEchoDefault) Code() int {
	return o._statusCode
}

func (o *ABitOfEverythingServiceEchoDefault) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] ABitOfEverythingService_Echo default %s", o._statusCode, payload)
}

func (o *ABitOfEverythingServiceEchoDefault) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[GET /v1/example/a_bit_of_everything/echo/{value}][%d] ABitOfEverythingService_Echo default %s", o._statusCode, payload)
}

func (o *ABitOfEverythingServiceEchoDefault) GetPayload() *models.GoogleRPCStatus {
	return o.Payload
}

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

	o.Payload = new(models.GoogleRPCStatus)

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

	return nil
}
