github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/client/search/search_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package search 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 // SearchReader is a Reader for the Search structure. 19 type SearchReader struct { 20 formats strfmt.Registry 21 } 22 23 // ReadResponse reads a server response into the received o. 24 func (o *SearchReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 25 switch response.Code() { 26 case 200: 27 result := NewSearchOK() 28 if err := result.readResponse(response, consumer, o.formats); err != nil { 29 return nil, err 30 } 31 return result, nil 32 case 500: 33 result := NewSearchInternalServerError() 34 if err := result.readResponse(response, consumer, o.formats); err != nil { 35 return nil, err 36 } 37 return nil, result 38 default: 39 return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) 40 } 41 } 42 43 // NewSearchOK creates a SearchOK with default headers values 44 func NewSearchOK() *SearchOK { 45 return &SearchOK{} 46 } 47 48 /* 49 SearchOK describes a response with status code 200, with default header values. 50 51 An array of search results 52 */ 53 type SearchOK struct { 54 Payload *models.Search 55 } 56 57 // IsSuccess returns true when this search o k response has a 2xx status code 58 func (o *SearchOK) IsSuccess() bool { 59 return true 60 } 61 62 // IsRedirect returns true when this search o k response has a 3xx status code 63 func (o *SearchOK) IsRedirect() bool { 64 return false 65 } 66 67 // IsClientError returns true when this search o k response has a 4xx status code 68 func (o *SearchOK) IsClientError() bool { 69 return false 70 } 71 72 // IsServerError returns true when this search o k response has a 5xx status code 73 func (o *SearchOK) IsServerError() bool { 74 return false 75 } 76 77 // IsCode returns true when this search o k response a status code equal to that given 78 func (o *SearchOK) IsCode(code int) bool { 79 return code == 200 80 } 81 82 func (o *SearchOK) Error() string { 83 return fmt.Sprintf("[GET /search][%d] searchOK %+v", 200, o.Payload) 84 } 85 86 func (o *SearchOK) String() string { 87 return fmt.Sprintf("[GET /search][%d] searchOK %+v", 200, o.Payload) 88 } 89 90 func (o *SearchOK) GetPayload() *models.Search { 91 return o.Payload 92 } 93 94 func (o *SearchOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 95 96 o.Payload = new(models.Search) 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 // NewSearchInternalServerError creates a SearchInternalServerError with default headers values 107 func NewSearchInternalServerError() *SearchInternalServerError { 108 return &SearchInternalServerError{} 109 } 110 111 /* 112 SearchInternalServerError describes a response with status code 500, with default header values. 113 114 Internal server error 115 */ 116 type SearchInternalServerError struct { 117 118 /* The ID of the corresponding request for the response 119 */ 120 XRequestID string 121 122 Payload *models.Errors 123 } 124 125 // IsSuccess returns true when this search internal server error response has a 2xx status code 126 func (o *SearchInternalServerError) IsSuccess() bool { 127 return false 128 } 129 130 // IsRedirect returns true when this search internal server error response has a 3xx status code 131 func (o *SearchInternalServerError) IsRedirect() bool { 132 return false 133 } 134 135 // IsClientError returns true when this search internal server error response has a 4xx status code 136 func (o *SearchInternalServerError) IsClientError() bool { 137 return false 138 } 139 140 // IsServerError returns true when this search internal server error response has a 5xx status code 141 func (o *SearchInternalServerError) IsServerError() bool { 142 return true 143 } 144 145 // IsCode returns true when this search internal server error response a status code equal to that given 146 func (o *SearchInternalServerError) IsCode(code int) bool { 147 return code == 500 148 } 149 150 func (o *SearchInternalServerError) Error() string { 151 return fmt.Sprintf("[GET /search][%d] searchInternalServerError %+v", 500, o.Payload) 152 } 153 154 func (o *SearchInternalServerError) String() string { 155 return fmt.Sprintf("[GET /search][%d] searchInternalServerError %+v", 500, o.Payload) 156 } 157 158 func (o *SearchInternalServerError) GetPayload() *models.Errors { 159 return o.Payload 160 } 161 162 func (o *SearchInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 163 164 // hydrates response header X-Request-Id 165 hdrXRequestID := response.GetHeader("X-Request-Id") 166 167 if hdrXRequestID != "" { 168 o.XRequestID = hdrXRequestID 169 } 170 171 o.Payload = new(models.Errors) 172 173 // response payload 174 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 175 return err 176 } 177 178 return nil 179 }