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

package unannotated_echo_service

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

// UnannotatedEchoServiceEcho2Reader is a Reader for the UnannotatedEchoServiceEcho2 structure.
type UnannotatedEchoServiceEcho2Reader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *UnannotatedEchoServiceEcho2Reader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewUnannotatedEchoServiceEcho2OK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewUnannotatedEchoServiceEcho2Forbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewUnannotatedEchoServiceEcho2NotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 503:
		result := NewUnannotatedEchoServiceEcho2ServiceUnavailable()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		result := NewUnannotatedEchoServiceEcho2Default(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
	}
}

// NewUnannotatedEchoServiceEcho2OK creates a UnannotatedEchoServiceEcho2OK with default headers values
func NewUnannotatedEchoServiceEcho2OK() *UnannotatedEchoServiceEcho2OK {
	return &UnannotatedEchoServiceEcho2OK{}
}

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

A successful response.
*/
type UnannotatedEchoServiceEcho2OK struct {
	Payload *models.ExamplepbUnannotatedSimpleMessage
}

// IsSuccess returns true when this unannotated echo service echo2 o k response has a 2xx status code
func (o *UnannotatedEchoServiceEcho2OK) IsSuccess() bool {
	return true
}

// IsRedirect returns true when this unannotated echo service echo2 o k response has a 3xx status code
func (o *UnannotatedEchoServiceEcho2OK) IsRedirect() bool {
	return false
}

// IsClientError returns true when this unannotated echo service echo2 o k response has a 4xx status code
func (o *UnannotatedEchoServiceEcho2OK) IsClientError() bool {
	return false
}

// IsServerError returns true when this unannotated echo service echo2 o k response has a 5xx status code
func (o *UnannotatedEchoServiceEcho2OK) IsServerError() bool {
	return false
}

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

// Code gets the status code for the unannotated echo service echo2 o k response
func (o *UnannotatedEchoServiceEcho2OK) Code() int {
	return 200
}

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

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

func (o *UnannotatedEchoServiceEcho2OK) GetPayload() *models.ExamplepbUnannotatedSimpleMessage {
	return o.Payload
}

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

	o.Payload = new(models.ExamplepbUnannotatedSimpleMessage)

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

	return nil
}

// NewUnannotatedEchoServiceEcho2Forbidden creates a UnannotatedEchoServiceEcho2Forbidden with default headers values
func NewUnannotatedEchoServiceEcho2Forbidden() *UnannotatedEchoServiceEcho2Forbidden {
	return &UnannotatedEchoServiceEcho2Forbidden{}
}

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

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

// IsSuccess returns true when this unannotated echo service echo2 forbidden response has a 2xx status code
func (o *UnannotatedEchoServiceEcho2Forbidden) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this unannotated echo service echo2 forbidden response has a 3xx status code
func (o *UnannotatedEchoServiceEcho2Forbidden) IsRedirect() bool {
	return false
}

// IsClientError returns true when this unannotated echo service echo2 forbidden response has a 4xx status code
func (o *UnannotatedEchoServiceEcho2Forbidden) IsClientError() bool {
	return true
}

// IsServerError returns true when this unannotated echo service echo2 forbidden response has a 5xx status code
func (o *UnannotatedEchoServiceEcho2Forbidden) IsServerError() bool {
	return false
}

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

// Code gets the status code for the unannotated echo service echo2 forbidden response
func (o *UnannotatedEchoServiceEcho2Forbidden) Code() int {
	return 403
}

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

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

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

func (o *UnannotatedEchoServiceEcho2Forbidden) 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
}

// NewUnannotatedEchoServiceEcho2NotFound creates a UnannotatedEchoServiceEcho2NotFound with default headers values
func NewUnannotatedEchoServiceEcho2NotFound() *UnannotatedEchoServiceEcho2NotFound {
	return &UnannotatedEchoServiceEcho2NotFound{}
}

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

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

// IsSuccess returns true when this unannotated echo service echo2 not found response has a 2xx status code
func (o *UnannotatedEchoServiceEcho2NotFound) IsSuccess() bool {
	return false
}

// IsRedirect returns true when this unannotated echo service echo2 not found response has a 3xx status code
func (o *UnannotatedEchoServiceEcho2NotFound) IsRedirect() bool {
	return false
}

// IsClientError returns true when this unannotated echo service echo2 not found response has a 4xx status code
func (o *UnannotatedEchoServiceEcho2NotFound) IsClientError() bool {
	return true
}

// IsServerError returns true when this unannotated echo service echo2 not found response has a 5xx status code
func (o *UnannotatedEchoServiceEcho2NotFound) IsServerError() bool {
	return false
}

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

// Code gets the status code for the unannotated echo service echo2 not found response
func (o *UnannotatedEchoServiceEcho2NotFound) Code() int {
	return 404
}

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

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

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

func (o *UnannotatedEchoServiceEcho2NotFound) 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
}

// NewUnannotatedEchoServiceEcho2ServiceUnavailable creates a UnannotatedEchoServiceEcho2ServiceUnavailable with default headers values
func NewUnannotatedEchoServiceEcho2ServiceUnavailable() *UnannotatedEchoServiceEcho2ServiceUnavailable {
	return &UnannotatedEchoServiceEcho2ServiceUnavailable{}
}

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

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

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

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

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

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

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

// Code gets the status code for the unannotated echo service echo2 service unavailable response
func (o *UnannotatedEchoServiceEcho2ServiceUnavailable) Code() int {
	return 503
}

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

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

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

func (o *UnannotatedEchoServiceEcho2ServiceUnavailable) 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
}

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

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

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

	Payload *models.RPCStatus
}

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

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

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

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

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

// Code gets the status code for the unannotated echo service echo2 default response
func (o *UnannotatedEchoServiceEcho2Default) Code() int {
	return o._statusCode
}

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

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

func (o *UnannotatedEchoServiceEcho2Default) GetPayload() *models.RPCStatus {
	return o.Payload
}

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

	o.Payload = new(models.RPCStatus)

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

	return nil
}
