github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/statistic/get_statistic_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package statistic 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/goharbor/go-client/pkg/sdk/v2.0/models" 16 ) 17 18 // GetStatisticReader is a Reader for the GetStatistic structure. 19 type GetStatisticReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *GetStatisticReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewGetStatisticOK() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 401: 33 result := NewGetStatisticUnauthorized() 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 return nil, result 38 case 500: 39 result := NewGetStatisticInternalServerError() 40 if err := result.readResponse(response, consumer, o.formats); err != nil { 41 return nil, err 42 } 43 return nil, result 44 default: 45 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 46 } 47 } 48 49 // NewGetStatisticOK creates a GetStatisticOK with default headers values 50 func NewGetStatisticOK() *GetStatisticOK { 51 return &GetStatisticOK{} 52 } 53 54 /* 55 GetStatisticOK describes a response with status code 200, with default header values. 56 57 The statistic information 58 */ 59 type GetStatisticOK struct { 60 Payload *models.Statistic 61 } 62 63 // IsSuccess returns true when this get statistic o k response has a 2xx status code 64 func (o *GetStatisticOK) IsSuccess() bool { 65 return true 66 } 67 68 // IsRedirect returns true when this get statistic o k response has a 3xx status code 69 func (o *GetStatisticOK) IsRedirect() bool { 70 return false 71 } 72 73 // IsClientError returns true when this get statistic o k response has a 4xx status code 74 func (o *GetStatisticOK) IsClientError() bool { 75 return false 76 } 77 78 // IsServerError returns true when this get statistic o k response has a 5xx status code 79 func (o *GetStatisticOK) IsServerError() bool { 80 return false 81 } 82 83 // IsCode returns true when this get statistic o k response a status code equal to that given 84 func (o *GetStatisticOK) IsCode(code int) bool { 85 return code == 200 86 } 87 88 func (o *GetStatisticOK) Error() string { 89 return fmt.Sprintf("[GET /statistics][%d] getStatisticOK %+v", 200, o.Payload) 90 } 91 92 func (o *GetStatisticOK) String() string { 93 return fmt.Sprintf("[GET /statistics][%d] getStatisticOK %+v", 200, o.Payload) 94 } 95 96 func (o *GetStatisticOK) GetPayload() *models.Statistic { 97 return o.Payload 98 } 99 100 func (o *GetStatisticOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 101 102 o.Payload = new(models.Statistic) 103 104 // response payload 105 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 106 return err 107 } 108 109 return nil 110 } 111 112 // NewGetStatisticUnauthorized creates a GetStatisticUnauthorized with default headers values 113 func NewGetStatisticUnauthorized() *GetStatisticUnauthorized { 114 return &GetStatisticUnauthorized{} 115 } 116 117 /* 118 GetStatisticUnauthorized describes a response with status code 401, with default header values. 119 120 Unauthorized 121 */ 122 type GetStatisticUnauthorized struct { 123 124 /* The ID of the corresponding request for the response 125 */ 126 XRequestID string 127 128 Payload *models.Errors 129 } 130 131 // IsSuccess returns true when this get statistic unauthorized response has a 2xx status code 132 func (o *GetStatisticUnauthorized) IsSuccess() bool { 133 return false 134 } 135 136 // IsRedirect returns true when this get statistic unauthorized response has a 3xx status code 137 func (o *GetStatisticUnauthorized) IsRedirect() bool { 138 return false 139 } 140 141 // IsClientError returns true when this get statistic unauthorized response has a 4xx status code 142 func (o *GetStatisticUnauthorized) IsClientError() bool { 143 return true 144 } 145 146 // IsServerError returns true when this get statistic unauthorized response has a 5xx status code 147 func (o *GetStatisticUnauthorized) IsServerError() bool { 148 return false 149 } 150 151 // IsCode returns true when this get statistic unauthorized response a status code equal to that given 152 func (o *GetStatisticUnauthorized) IsCode(code int) bool { 153 return code == 401 154 } 155 156 func (o *GetStatisticUnauthorized) Error() string { 157 return fmt.Sprintf("[GET /statistics][%d] getStatisticUnauthorized %+v", 401, o.Payload) 158 } 159 160 func (o *GetStatisticUnauthorized) String() string { 161 return fmt.Sprintf("[GET /statistics][%d] getStatisticUnauthorized %+v", 401, o.Payload) 162 } 163 164 func (o *GetStatisticUnauthorized) GetPayload() *models.Errors { 165 return o.Payload 166 } 167 168 func (o *GetStatisticUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 169 170 // hydrates response header X-Request-Id 171 hdrXRequestID := response.GetHeader("X-Request-Id") 172 173 if hdrXRequestID != "" { 174 o.XRequestID = hdrXRequestID 175 } 176 177 o.Payload = new(models.Errors) 178 179 // response payload 180 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 181 return err 182 } 183 184 return nil 185 } 186 187 // NewGetStatisticInternalServerError creates a GetStatisticInternalServerError with default headers values 188 func NewGetStatisticInternalServerError() *GetStatisticInternalServerError { 189 return &GetStatisticInternalServerError{} 190 } 191 192 /* 193 GetStatisticInternalServerError describes a response with status code 500, with default header values. 194 195 Internal server error 196 */ 197 type GetStatisticInternalServerError struct { 198 199 /* The ID of the corresponding request for the response 200 */ 201 XRequestID string 202 203 Payload *models.Errors 204 } 205 206 // IsSuccess returns true when this get statistic internal server error response has a 2xx status code 207 func (o *GetStatisticInternalServerError) IsSuccess() bool { 208 return false 209 } 210 211 // IsRedirect returns true when this get statistic internal server error response has a 3xx status code 212 func (o *GetStatisticInternalServerError) IsRedirect() bool { 213 return false 214 } 215 216 // IsClientError returns true when this get statistic internal server error response has a 4xx status code 217 func (o *GetStatisticInternalServerError) IsClientError() bool { 218 return false 219 } 220 221 // IsServerError returns true when this get statistic internal server error response has a 5xx status code 222 func (o *GetStatisticInternalServerError) IsServerError() bool { 223 return true 224 } 225 226 // IsCode returns true when this get statistic internal server error response a status code equal to that given 227 func (o *GetStatisticInternalServerError) IsCode(code int) bool { 228 return code == 500 229 } 230 231 func (o *GetStatisticInternalServerError) Error() string { 232 return fmt.Sprintf("[GET /statistics][%d] getStatisticInternalServerError %+v", 500, o.Payload) 233 } 234 235 func (o *GetStatisticInternalServerError) String() string { 236 return fmt.Sprintf("[GET /statistics][%d] getStatisticInternalServerError %+v", 500, o.Payload) 237 } 238 239 func (o *GetStatisticInternalServerError) GetPayload() *models.Errors { 240 return o.Payload 241 } 242 243 func (o *GetStatisticInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 244 245 // hydrates response header X-Request-Id 246 hdrXRequestID := response.GetHeader("X-Request-Id") 247 248 if hdrXRequestID != "" { 249 o.XRequestID = hdrXRequestID 250 } 251 252 o.Payload = new(models.Errors) 253 254 // response payload 255 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 256 return err 257 } 258 259 return nil 260 }