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