github.com/josephspurrier/go-swagger@v0.2.1-0.20221129144919-1f672a142a00/examples/todo-list/client/todos/destroy_one_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package todos
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"fmt"
    10  	"io"
    11  
    12  	"github.com/go-openapi/runtime"
    13  	"github.com/go-openapi/strfmt"
    14  
    15  	"github.com/go-swagger/go-swagger/examples/todo-list/models"
    16  )
    17  
    18  // DestroyOneReader is a Reader for the DestroyOne structure.
    19  type DestroyOneReader struct {
    20  	formats strfmt.Registry
    21  }
    22  
    23  // ReadResponse reads a server response into the received o.
    24  func (o *DestroyOneReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    25  	switch response.Code() {
    26  	case 204:
    27  		result := NewDestroyOneNoContent()
    28  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    29  			return nil, err
    30  		}
    31  		return result, nil
    32  	default:
    33  		result := NewDestroyOneDefault(response.Code())
    34  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    35  			return nil, err
    36  		}
    37  		if response.Code()/100 == 2 {
    38  			return result, nil
    39  		}
    40  		return nil, result
    41  	}
    42  }
    43  
    44  // NewDestroyOneNoContent creates a DestroyOneNoContent with default headers values
    45  func NewDestroyOneNoContent() *DestroyOneNoContent {
    46  	return &DestroyOneNoContent{}
    47  }
    48  
    49  /*
    50  	DestroyOneNoContent describes a response with status code 204, with default header values.
    51  
    52  Deleted
    53  */
    54  type DestroyOneNoContent struct {
    55  }
    56  
    57  // IsSuccess returns true when this destroy one no content response returns a 2xx status code
    58  func (o *DestroyOneNoContent) IsSuccess() bool {
    59  	return true
    60  }
    61  
    62  // IsRedirect returns true when this destroy one no content response returns a 3xx status code
    63  func (o *DestroyOneNoContent) IsRedirect() bool {
    64  	return false
    65  }
    66  
    67  // IsClientError returns true when this destroy one no content response returns a 4xx status code
    68  func (o *DestroyOneNoContent) IsClientError() bool {
    69  	return false
    70  }
    71  
    72  // IsServerError returns true when this destroy one no content response returns a 5xx status code
    73  func (o *DestroyOneNoContent) IsServerError() bool {
    74  	return false
    75  }
    76  
    77  // IsCode returns true when this destroy one no content response returns a 4xx status code
    78  func (o *DestroyOneNoContent) IsCode(code int) bool {
    79  	return code == 204
    80  }
    81  
    82  func (o *DestroyOneNoContent) Error() string {
    83  	return fmt.Sprintf("[DELETE /{id}][%d] destroyOneNoContent ", 204)
    84  }
    85  
    86  func (o *DestroyOneNoContent) String() string {
    87  	return fmt.Sprintf("[DELETE /{id}][%d] destroyOneNoContent ", 204)
    88  }
    89  
    90  func (o *DestroyOneNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
    91  
    92  	return nil
    93  }
    94  
    95  // NewDestroyOneDefault creates a DestroyOneDefault with default headers values
    96  func NewDestroyOneDefault(code int) *DestroyOneDefault {
    97  	return &DestroyOneDefault{
    98  		_statusCode: code,
    99  	}
   100  }
   101  
   102  /*
   103  	DestroyOneDefault describes a response with status code -1, with default header values.
   104  
   105  error
   106  */
   107  type DestroyOneDefault struct {
   108  	_statusCode int
   109  
   110  	Payload *models.Error
   111  }
   112  
   113  // Code gets the status code for the destroy one default response
   114  func (o *DestroyOneDefault) Code() int {
   115  	return o._statusCode
   116  }
   117  
   118  // IsSuccess returns true when this destroy one default response returns a 2xx status code
   119  func (o *DestroyOneDefault) IsSuccess() bool {
   120  	return o._statusCode/100 == 2
   121  }
   122  
   123  // IsRedirect returns true when this destroy one default response returns a 3xx status code
   124  func (o *DestroyOneDefault) IsRedirect() bool {
   125  	return o._statusCode/100 == 3
   126  }
   127  
   128  // IsClientError returns true when this destroy one default response returns a 4xx status code
   129  func (o *DestroyOneDefault) IsClientError() bool {
   130  	return o._statusCode/100 == 4
   131  }
   132  
   133  // IsServerError returns true when this destroy one default response returns a 5xx status code
   134  func (o *DestroyOneDefault) IsServerError() bool {
   135  	return o._statusCode/100 == 5
   136  }
   137  
   138  // IsCode returns true when this destroy one default response returns a 4xx status code
   139  func (o *DestroyOneDefault) IsCode(code int) bool {
   140  	return o._statusCode == code
   141  }
   142  
   143  func (o *DestroyOneDefault) Error() string {
   144  	return fmt.Sprintf("[DELETE /{id}][%d] destroyOne default  %+v", o._statusCode, o.Payload)
   145  }
   146  
   147  func (o *DestroyOneDefault) String() string {
   148  	return fmt.Sprintf("[DELETE /{id}][%d] destroyOne default  %+v", o._statusCode, o.Payload)
   149  }
   150  
   151  func (o *DestroyOneDefault) GetPayload() *models.Error {
   152  	return o.Payload
   153  }
   154  
   155  func (o *DestroyOneDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   156  
   157  	o.Payload = new(models.Error)
   158  
   159  	// response payload
   160  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   161  		return err
   162  	}
   163  
   164  	return nil
   165  }