github.com/thetreep/go-swagger@v0.0.0-20240223100711-35af64f14f01/examples/stream-server/client/operations/elapse_responses.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package operations
     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  
    16  // ElapseReader is a Reader for the Elapse structure.
    17  type ElapseReader struct {
    18  	formats strfmt.Registry
    19  	writer  io.Writer
    20  }
    21  
    22  // ReadResponse reads a server response into the received o.
    23  func (o *ElapseReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    24  	switch response.Code() {
    25  	case 200:
    26  		result := NewElapseOK(o.writer)
    27  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    28  			return nil, err
    29  		}
    30  		return result, nil
    31  	case 403:
    32  		result := NewElapseForbidden()
    33  		if err := result.readResponse(response, consumer, o.formats); err != nil {
    34  			return nil, err
    35  		}
    36  		return nil, result
    37  	default:
    38  		return nil, runtime.NewAPIError("[GET /elapse/{length}] elapse", response, response.Code())
    39  	}
    40  }
    41  
    42  // NewElapseOK creates a ElapseOK with default headers values
    43  func NewElapseOK(writer io.Writer) *ElapseOK {
    44  	return &ElapseOK{
    45  
    46  		Payload: writer,
    47  	}
    48  }
    49  
    50  /*
    51  ElapseOK describes a response with status code 200, with default header values.
    52  
    53  Secondly update on remaining time
    54  */
    55  type ElapseOK struct {
    56  	Payload io.Writer
    57  }
    58  
    59  // IsSuccess returns true when this elapse o k response has a 2xx status code
    60  func (o *ElapseOK) IsSuccess() bool {
    61  	return true
    62  }
    63  
    64  // IsRedirect returns true when this elapse o k response has a 3xx status code
    65  func (o *ElapseOK) IsRedirect() bool {
    66  	return false
    67  }
    68  
    69  // IsClientError returns true when this elapse o k response has a 4xx status code
    70  func (o *ElapseOK) IsClientError() bool {
    71  	return false
    72  }
    73  
    74  // IsServerError returns true when this elapse o k response has a 5xx status code
    75  func (o *ElapseOK) IsServerError() bool {
    76  	return false
    77  }
    78  
    79  // IsCode returns true when this elapse o k response a status code equal to that given
    80  func (o *ElapseOK) IsCode(code int) bool {
    81  	return code == 200
    82  }
    83  
    84  // Code gets the status code for the elapse o k response
    85  func (o *ElapseOK) Code() int {
    86  	return 200
    87  }
    88  
    89  func (o *ElapseOK) Error() string {
    90  	return fmt.Sprintf("[GET /elapse/{length}][%d] elapseOK", 200)
    91  }
    92  
    93  func (o *ElapseOK) String() string {
    94  	return fmt.Sprintf("[GET /elapse/{length}][%d] elapseOK", 200)
    95  }
    96  
    97  func (o *ElapseOK) GetPayload() io.Writer {
    98  	return o.Payload
    99  }
   100  
   101  func (o *ElapseOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   102  
   103  	// response payload
   104  	if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
   105  		return err
   106  	}
   107  
   108  	return nil
   109  }
   110  
   111  // NewElapseForbidden creates a ElapseForbidden with default headers values
   112  func NewElapseForbidden() *ElapseForbidden {
   113  	return &ElapseForbidden{}
   114  }
   115  
   116  /*
   117  ElapseForbidden describes a response with status code 403, with default header values.
   118  
   119  Contrived - thrown when length of 11 is chosen
   120  */
   121  type ElapseForbidden struct {
   122  }
   123  
   124  // IsSuccess returns true when this elapse forbidden response has a 2xx status code
   125  func (o *ElapseForbidden) IsSuccess() bool {
   126  	return false
   127  }
   128  
   129  // IsRedirect returns true when this elapse forbidden response has a 3xx status code
   130  func (o *ElapseForbidden) IsRedirect() bool {
   131  	return false
   132  }
   133  
   134  // IsClientError returns true when this elapse forbidden response has a 4xx status code
   135  func (o *ElapseForbidden) IsClientError() bool {
   136  	return true
   137  }
   138  
   139  // IsServerError returns true when this elapse forbidden response has a 5xx status code
   140  func (o *ElapseForbidden) IsServerError() bool {
   141  	return false
   142  }
   143  
   144  // IsCode returns true when this elapse forbidden response a status code equal to that given
   145  func (o *ElapseForbidden) IsCode(code int) bool {
   146  	return code == 403
   147  }
   148  
   149  // Code gets the status code for the elapse forbidden response
   150  func (o *ElapseForbidden) Code() int {
   151  	return 403
   152  }
   153  
   154  func (o *ElapseForbidden) Error() string {
   155  	return fmt.Sprintf("[GET /elapse/{length}][%d] elapseForbidden", 403)
   156  }
   157  
   158  func (o *ElapseForbidden) String() string {
   159  	return fmt.Sprintf("[GET /elapse/{length}][%d] elapseForbidden", 403)
   160  }
   161  
   162  func (o *ElapseForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
   163  
   164  	return nil
   165  }