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

// UnannotatedEchoServiceEchoNestedReader is a Reader for the UnannotatedEchoServiceEchoNested structure.
type UnannotatedEchoServiceEchoNestedReader struct {
	formats strfmt.Registry
}

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

// NewUnannotatedEchoServiceEchoNestedOK creates a UnannotatedEchoServiceEchoNestedOK with default headers values
func NewUnannotatedEchoServiceEchoNestedOK() *UnannotatedEchoServiceEchoNestedOK {
	return &UnannotatedEchoServiceEchoNestedOK{}
}

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

UnannotatedEchoServiceEchoNestedOK unannotated echo service echo nested o k
*/
type UnannotatedEchoServiceEchoNestedOK struct {
	Payload *models.ExamplepbUnannotatedNestedMessage
}

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoNestedOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] unannotatedEchoServiceEchoNestedOK %s", 200, payload)
}

func (o *UnannotatedEchoServiceEchoNestedOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] unannotatedEchoServiceEchoNestedOK %s", 200, payload)
}

func (o *UnannotatedEchoServiceEchoNestedOK) GetPayload() *models.ExamplepbUnannotatedNestedMessage {
	return o.Payload
}

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

	o.Payload = new(models.ExamplepbUnannotatedNestedMessage)

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

	return nil
}

// NewUnannotatedEchoServiceEchoNestedForbidden creates a UnannotatedEchoServiceEchoNestedForbidden with default headers values
func NewUnannotatedEchoServiceEchoNestedForbidden() *UnannotatedEchoServiceEchoNestedForbidden {
	return &UnannotatedEchoServiceEchoNestedForbidden{}
}

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

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

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoNestedForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] unannotatedEchoServiceEchoNestedForbidden %s", 403, payload)
}

func (o *UnannotatedEchoServiceEchoNestedForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] unannotatedEchoServiceEchoNestedForbidden %s", 403, payload)
}

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

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

// NewUnannotatedEchoServiceEchoNestedNotFound creates a UnannotatedEchoServiceEchoNestedNotFound with default headers values
func NewUnannotatedEchoServiceEchoNestedNotFound() *UnannotatedEchoServiceEchoNestedNotFound {
	return &UnannotatedEchoServiceEchoNestedNotFound{}
}

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

Returned when the resource does not exist.
*/
type UnannotatedEchoServiceEchoNestedNotFound struct {
	Payload string
}

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoNestedNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] unannotatedEchoServiceEchoNestedNotFound %s", 404, payload)
}

func (o *UnannotatedEchoServiceEchoNestedNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] unannotatedEchoServiceEchoNestedNotFound %s", 404, payload)
}

func (o *UnannotatedEchoServiceEchoNestedNotFound) GetPayload() string {
	return o.Payload
}

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

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

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

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

	Payload *models.RPCStatus
}

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

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

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

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

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

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

func (o *UnannotatedEchoServiceEchoNestedDefault) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] UnannotatedEchoService_EchoNested default %s", o._statusCode, payload)
}

func (o *UnannotatedEchoServiceEchoNestedDefault) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[PUT /v1/example/echo_nested][%d] UnannotatedEchoService_EchoNested default %s", o._statusCode, payload)
}

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

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