github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/user/get_current_user_info_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package user 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 // GetCurrentUserInfoReader is a Reader for the GetCurrentUserInfo structure. 19 type GetCurrentUserInfoReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *GetCurrentUserInfoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewGetCurrentUserInfoOK() 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 := NewGetCurrentUserInfoUnauthorized() 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 := NewGetCurrentUserInfoInternalServerError() 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 // NewGetCurrentUserInfoOK creates a GetCurrentUserInfoOK with default headers values 50 func NewGetCurrentUserInfoOK() *GetCurrentUserInfoOK { 51 return &GetCurrentUserInfoOK{} 52 } 53 54 /* 55 GetCurrentUserInfoOK describes a response with status code 200, with default header values. 56 57 Get current user information successfully. 58 */ 59 type GetCurrentUserInfoOK struct { 60 Payload *models.UserResp 61 } 62 63 // IsSuccess returns true when this get current user info o k response has a 2xx status code 64 func (o *GetCurrentUserInfoOK) IsSuccess() bool { 65 return true 66 } 67 68 // IsRedirect returns true when this get current user info o k response has a 3xx status code 69 func (o *GetCurrentUserInfoOK) IsRedirect() bool { 70 return false 71 } 72 73 // IsClientError returns true when this get current user info o k response has a 4xx status code 74 func (o *GetCurrentUserInfoOK) IsClientError() bool { 75 return false 76 } 77 78 // IsServerError returns true when this get current user info o k response has a 5xx status code 79 func (o *GetCurrentUserInfoOK) IsServerError() bool { 80 return false 81 } 82 83 // IsCode returns true when this get current user info o k response a status code equal to that given 84 func (o *GetCurrentUserInfoOK) IsCode(code int) bool { 85 return code == 200 86 } 87 88 func (o *GetCurrentUserInfoOK) Error() string { 89 return fmt.Sprintf("[GET /users/current][%d] getCurrentUserInfoOK %+v", 200, o.Payload) 90 } 91 92 func (o *GetCurrentUserInfoOK) String() string { 93 return fmt.Sprintf("[GET /users/current][%d] getCurrentUserInfoOK %+v", 200, o.Payload) 94 } 95 96 func (o *GetCurrentUserInfoOK) GetPayload() *models.UserResp { 97 return o.Payload 98 } 99 100 func (o *GetCurrentUserInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 101 102 o.Payload = new(models.UserResp) 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 // NewGetCurrentUserInfoUnauthorized creates a GetCurrentUserInfoUnauthorized with default headers values 113 func NewGetCurrentUserInfoUnauthorized() *GetCurrentUserInfoUnauthorized { 114 return &GetCurrentUserInfoUnauthorized{} 115 } 116 117 /* 118 GetCurrentUserInfoUnauthorized describes a response with status code 401, with default header values. 119 120 Unauthorized 121 */ 122 type GetCurrentUserInfoUnauthorized 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 current user info unauthorized response has a 2xx status code 132 func (o *GetCurrentUserInfoUnauthorized) IsSuccess() bool { 133 return false 134 } 135 136 // IsRedirect returns true when this get current user info unauthorized response has a 3xx status code 137 func (o *GetCurrentUserInfoUnauthorized) IsRedirect() bool { 138 return false 139 } 140 141 // IsClientError returns true when this get current user info unauthorized response has a 4xx status code 142 func (o *GetCurrentUserInfoUnauthorized) IsClientError() bool { 143 return true 144 } 145 146 // IsServerError returns true when this get current user info unauthorized response has a 5xx status code 147 func (o *GetCurrentUserInfoUnauthorized) IsServerError() bool { 148 return false 149 } 150 151 // IsCode returns true when this get current user info unauthorized response a status code equal to that given 152 func (o *GetCurrentUserInfoUnauthorized) IsCode(code int) bool { 153 return code == 401 154 } 155 156 func (o *GetCurrentUserInfoUnauthorized) Error() string { 157 return fmt.Sprintf("[GET /users/current][%d] getCurrentUserInfoUnauthorized %+v", 401, o.Payload) 158 } 159 160 func (o *GetCurrentUserInfoUnauthorized) String() string { 161 return fmt.Sprintf("[GET /users/current][%d] getCurrentUserInfoUnauthorized %+v", 401, o.Payload) 162 } 163 164 func (o *GetCurrentUserInfoUnauthorized) GetPayload() *models.Errors { 165 return o.Payload 166 } 167 168 func (o *GetCurrentUserInfoUnauthorized) 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 // NewGetCurrentUserInfoInternalServerError creates a GetCurrentUserInfoInternalServerError with default headers values 188 func NewGetCurrentUserInfoInternalServerError() *GetCurrentUserInfoInternalServerError { 189 return &GetCurrentUserInfoInternalServerError{} 190 } 191 192 /* 193 GetCurrentUserInfoInternalServerError describes a response with status code 500, with default header values. 194 195 Internal server error 196 */ 197 type GetCurrentUserInfoInternalServerError 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 current user info internal server error response has a 2xx status code 207 func (o *GetCurrentUserInfoInternalServerError) IsSuccess() bool { 208 return false 209 } 210 211 // IsRedirect returns true when this get current user info internal server error response has a 3xx status code 212 func (o *GetCurrentUserInfoInternalServerError) IsRedirect() bool { 213 return false 214 } 215 216 // IsClientError returns true when this get current user info internal server error response has a 4xx status code 217 func (o *GetCurrentUserInfoInternalServerError) IsClientError() bool { 218 return false 219 } 220 221 // IsServerError returns true when this get current user info internal server error response has a 5xx status code 222 func (o *GetCurrentUserInfoInternalServerError) IsServerError() bool { 223 return true 224 } 225 226 // IsCode returns true when this get current user info internal server error response a status code equal to that given 227 func (o *GetCurrentUserInfoInternalServerError) IsCode(code int) bool { 228 return code == 500 229 } 230 231 func (o *GetCurrentUserInfoInternalServerError) Error() string { 232 return fmt.Sprintf("[GET /users/current][%d] getCurrentUserInfoInternalServerError %+v", 500, o.Payload) 233 } 234 235 func (o *GetCurrentUserInfoInternalServerError) String() string { 236 return fmt.Sprintf("[GET /users/current][%d] getCurrentUserInfoInternalServerError %+v", 500, o.Payload) 237 } 238 239 func (o *GetCurrentUserInfoInternalServerError) GetPayload() *models.Errors { 240 return o.Payload 241 } 242 243 func (o *GetCurrentUserInfoInternalServerError) 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 }