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

package a_bit_of_everything

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

// ABitOfEverythingServiceCreateNestedBodyOneofReader is a Reader for the ABitOfEverythingServiceCreateNestedBodyOneof structure.
type ABitOfEverythingServiceCreateNestedBodyOneofReader struct {
	formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *ABitOfEverythingServiceCreateNestedBodyOneofReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (any, error) {
	switch response.Code() {
	case 200:
		result := NewABitOfEverythingServiceCreateNestedBodyOneofOK()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return result, nil
	case 403:
		result := NewABitOfEverythingServiceCreateNestedBodyOneofForbidden()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 404:
		result := NewABitOfEverythingServiceCreateNestedBodyOneofNotFound()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 418:
		result := NewABitOfEverythingServiceCreateNestedBodyOneofIMATeapot()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	case 500:
		result := NewABitOfEverythingServiceCreateNestedBodyOneofInternalServerError()
		if err := result.readResponse(response, consumer, o.formats); err != nil {
			return nil, err
		}
		return nil, result
	default:
		result := NewABitOfEverythingServiceCreateNestedBodyOneofDefault(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
	}
}

// NewABitOfEverythingServiceCreateNestedBodyOneofOK creates a ABitOfEverythingServiceCreateNestedBodyOneofOK with default headers values
func NewABitOfEverythingServiceCreateNestedBodyOneofOK() *ABitOfEverythingServiceCreateNestedBodyOneofOK {
	return &ABitOfEverythingServiceCreateNestedBodyOneofOK{}
}

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

A successful response.
*/
type ABitOfEverythingServiceCreateNestedBodyOneofOK struct {
	Payload *models.ExamplepbNestedBodyOneof
}

// IsSuccess returns true when this a bit of everything service create nested body oneof o k response has a 2xx status code
func (o *ABitOfEverythingServiceCreateNestedBodyOneofOK) IsSuccess() bool {
	return true
}

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

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

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

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

// Code gets the status code for the a bit of everything service create nested body oneof o k response
func (o *ABitOfEverythingServiceCreateNestedBodyOneofOK) Code() int {
	return 200
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofOK) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofOK %s", 200, payload)
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofOK) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofOK %s", 200, payload)
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofOK) GetPayload() *models.ExamplepbNestedBodyOneof {
	return o.Payload
}

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

	o.Payload = new(models.ExamplepbNestedBodyOneof)

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

	return nil
}

// NewABitOfEverythingServiceCreateNestedBodyOneofForbidden creates a ABitOfEverythingServiceCreateNestedBodyOneofForbidden with default headers values
func NewABitOfEverythingServiceCreateNestedBodyOneofForbidden() *ABitOfEverythingServiceCreateNestedBodyOneofForbidden {
	return &ABitOfEverythingServiceCreateNestedBodyOneofForbidden{}
}

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

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

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

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

// IsClientError returns true when this a bit of everything service create nested body oneof forbidden response has a 4xx status code
func (o *ABitOfEverythingServiceCreateNestedBodyOneofForbidden) IsClientError() bool {
	return true
}

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

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

// Code gets the status code for the a bit of everything service create nested body oneof forbidden response
func (o *ABitOfEverythingServiceCreateNestedBodyOneofForbidden) Code() int {
	return 403
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofForbidden) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofForbidden %s", 403, payload)
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofForbidden) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofForbidden %s", 403, payload)
}

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

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

// NewABitOfEverythingServiceCreateNestedBodyOneofNotFound creates a ABitOfEverythingServiceCreateNestedBodyOneofNotFound with default headers values
func NewABitOfEverythingServiceCreateNestedBodyOneofNotFound() *ABitOfEverythingServiceCreateNestedBodyOneofNotFound {
	return &ABitOfEverythingServiceCreateNestedBodyOneofNotFound{}
}

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

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

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

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

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

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

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

// Code gets the status code for the a bit of everything service create nested body oneof not found response
func (o *ABitOfEverythingServiceCreateNestedBodyOneofNotFound) Code() int {
	return 404
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofNotFound) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofNotFound %s", 404, payload)
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofNotFound) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofNotFound %s", 404, payload)
}

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

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

// NewABitOfEverythingServiceCreateNestedBodyOneofIMATeapot creates a ABitOfEverythingServiceCreateNestedBodyOneofIMATeapot with default headers values
func NewABitOfEverythingServiceCreateNestedBodyOneofIMATeapot() *ABitOfEverythingServiceCreateNestedBodyOneofIMATeapot {
	return &ABitOfEverythingServiceCreateNestedBodyOneofIMATeapot{}
}

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

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

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

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

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

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

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

// Code gets the status code for the a bit of everything service create nested body oneof i m a teapot response
func (o *ABitOfEverythingServiceCreateNestedBodyOneofIMATeapot) Code() int {
	return 418
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofIMATeapot) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofIMATeapot %s", 418, payload)
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofIMATeapot) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofIMATeapot %s", 418, payload)
}

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

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

// NewABitOfEverythingServiceCreateNestedBodyOneofInternalServerError creates a ABitOfEverythingServiceCreateNestedBodyOneofInternalServerError with default headers values
func NewABitOfEverythingServiceCreateNestedBodyOneofInternalServerError() *ABitOfEverythingServiceCreateNestedBodyOneofInternalServerError {
	return &ABitOfEverythingServiceCreateNestedBodyOneofInternalServerError{}
}

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

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

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

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

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

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

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

// Code gets the status code for the a bit of everything service create nested body oneof internal server error response
func (o *ABitOfEverythingServiceCreateNestedBodyOneofInternalServerError) Code() int {
	return 500
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofInternalServerError) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofInternalServerError %s", 500, payload)
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofInternalServerError) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] aBitOfEverythingServiceCreateNestedBodyOneofInternalServerError %s", 500, payload)
}

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

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

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

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

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

	Payload *models.GoogleRPCStatus
}

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

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

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

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

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

// Code gets the status code for the a bit of everything service create nested body oneof default response
func (o *ABitOfEverythingServiceCreateNestedBodyOneofDefault) Code() int {
	return o._statusCode
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofDefault) Error() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] ABitOfEverythingService_CreateNestedBodyOneof default %s", o._statusCode, payload)
}

func (o *ABitOfEverythingServiceCreateNestedBodyOneofDefault) String() string {
	payload, _ := json.Marshal(o.Payload)
	return fmt.Sprintf("[POST /v1/example/a_bit_of_everything/nested_body_oneof][%d] ABitOfEverythingService_CreateNestedBodyOneof default %s", o._statusCode, payload)
}

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

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