github.com/jamescostian/go-swagger@v0.30.4-0.20221130163922-68364d6b567b/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("response status code does not match any response statuses defined for this endpoint in the swagger spec", 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 returns 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 returns 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 returns 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 returns 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 returns a 4xx status code 80 func (o *ElapseOK) IsCode(code int) bool { 81 return code == 200 82 } 83 84 func (o *ElapseOK) Error() string { 85 return fmt.Sprintf("[GET /elapse/{length}][%d] elapseOK %+v", 200, o.Payload) 86 } 87 88 func (o *ElapseOK) String() string { 89 return fmt.Sprintf("[GET /elapse/{length}][%d] elapseOK %+v", 200, o.Payload) 90 } 91 92 func (o *ElapseOK) GetPayload() io.Writer { 93 return o.Payload 94 } 95 96 func (o *ElapseOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 97 98 // response payload 99 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 100 return err 101 } 102 103 return nil 104 } 105 106 // NewElapseForbidden creates a ElapseForbidden with default headers values 107 func NewElapseForbidden() *ElapseForbidden { 108 return &ElapseForbidden{} 109 } 110 111 /* 112 ElapseForbidden describes a response with status code 403, with default header values. 113 114 Contrived - thrown when length of 11 is chosen 115 */ 116 type ElapseForbidden struct { 117 } 118 119 // IsSuccess returns true when this elapse forbidden response returns a 2xx status code 120 func (o *ElapseForbidden) IsSuccess() bool { 121 return false 122 } 123 124 // IsRedirect returns true when this elapse forbidden response returns a 3xx status code 125 func (o *ElapseForbidden) IsRedirect() bool { 126 return false 127 } 128 129 // IsClientError returns true when this elapse forbidden response returns a 4xx status code 130 func (o *ElapseForbidden) IsClientError() bool { 131 return true 132 } 133 134 // IsServerError returns true when this elapse forbidden response returns a 5xx status code 135 func (o *ElapseForbidden) IsServerError() bool { 136 return false 137 } 138 139 // IsCode returns true when this elapse forbidden response returns a 4xx status code 140 func (o *ElapseForbidden) IsCode(code int) bool { 141 return code == 403 142 } 143 144 func (o *ElapseForbidden) Error() string { 145 return fmt.Sprintf("[GET /elapse/{length}][%d] elapseForbidden ", 403) 146 } 147 148 func (o *ElapseForbidden) String() string { 149 return fmt.Sprintf("[GET /elapse/{length}][%d] elapseForbidden ", 403) 150 } 151 152 func (o *ElapseForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 153 154 return nil 155 }