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