github.com/cilium/cilium@v1.16.2/api/v1/client/ipam/post_ipam_responses.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright Authors of Cilium 4 // SPDX-License-Identifier: Apache-2.0 5 6 package ipam 7 8 // This file was generated by the swagger tool. 9 // Editing this file might prove futile when you re-run the swagger generate command 10 11 import ( 12 "fmt" 13 "io" 14 15 "github.com/go-openapi/runtime" 16 "github.com/go-openapi/strfmt" 17 18 "github.com/cilium/cilium/api/v1/models" 19 ) 20 21 // PostIpamReader is a Reader for the PostIpam structure. 22 type PostIpamReader struct { 23 formats strfmt.Registry 24 } 25 26 // ReadResponse reads a server response into the received o. 27 func (o *PostIpamReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { 28 switch response.Code() { 29 case 201: 30 result := NewPostIpamCreated() 31 if err := result.readResponse(response, consumer, o.formats); err != nil { 32 return nil, err 33 } 34 return result, nil 35 case 403: 36 result := NewPostIpamForbidden() 37 if err := result.readResponse(response, consumer, o.formats); err != nil { 38 return nil, err 39 } 40 return nil, result 41 case 502: 42 result := NewPostIpamFailure() 43 if err := result.readResponse(response, consumer, o.formats); err != nil { 44 return nil, err 45 } 46 return nil, result 47 default: 48 return nil, runtime.NewAPIError("[POST /ipam] PostIpam", response, response.Code()) 49 } 50 } 51 52 // NewPostIpamCreated creates a PostIpamCreated with default headers values 53 func NewPostIpamCreated() *PostIpamCreated { 54 return &PostIpamCreated{} 55 } 56 57 /* 58 PostIpamCreated describes a response with status code 201, with default header values. 59 60 Success 61 */ 62 type PostIpamCreated struct { 63 Payload *models.IPAMResponse 64 } 65 66 // IsSuccess returns true when this post ipam created response has a 2xx status code 67 func (o *PostIpamCreated) IsSuccess() bool { 68 return true 69 } 70 71 // IsRedirect returns true when this post ipam created response has a 3xx status code 72 func (o *PostIpamCreated) IsRedirect() bool { 73 return false 74 } 75 76 // IsClientError returns true when this post ipam created response has a 4xx status code 77 func (o *PostIpamCreated) IsClientError() bool { 78 return false 79 } 80 81 // IsServerError returns true when this post ipam created response has a 5xx status code 82 func (o *PostIpamCreated) IsServerError() bool { 83 return false 84 } 85 86 // IsCode returns true when this post ipam created response a status code equal to that given 87 func (o *PostIpamCreated) IsCode(code int) bool { 88 return code == 201 89 } 90 91 // Code gets the status code for the post ipam created response 92 func (o *PostIpamCreated) Code() int { 93 return 201 94 } 95 96 func (o *PostIpamCreated) Error() string { 97 return fmt.Sprintf("[POST /ipam][%d] postIpamCreated %+v", 201, o.Payload) 98 } 99 100 func (o *PostIpamCreated) String() string { 101 return fmt.Sprintf("[POST /ipam][%d] postIpamCreated %+v", 201, o.Payload) 102 } 103 104 func (o *PostIpamCreated) GetPayload() *models.IPAMResponse { 105 return o.Payload 106 } 107 108 func (o *PostIpamCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 109 110 o.Payload = new(models.IPAMResponse) 111 112 // response payload 113 if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { 114 return err 115 } 116 117 return nil 118 } 119 120 // NewPostIpamForbidden creates a PostIpamForbidden with default headers values 121 func NewPostIpamForbidden() *PostIpamForbidden { 122 return &PostIpamForbidden{} 123 } 124 125 /* 126 PostIpamForbidden describes a response with status code 403, with default header values. 127 128 Forbidden 129 */ 130 type PostIpamForbidden struct { 131 } 132 133 // IsSuccess returns true when this post ipam forbidden response has a 2xx status code 134 func (o *PostIpamForbidden) IsSuccess() bool { 135 return false 136 } 137 138 // IsRedirect returns true when this post ipam forbidden response has a 3xx status code 139 func (o *PostIpamForbidden) IsRedirect() bool { 140 return false 141 } 142 143 // IsClientError returns true when this post ipam forbidden response has a 4xx status code 144 func (o *PostIpamForbidden) IsClientError() bool { 145 return true 146 } 147 148 // IsServerError returns true when this post ipam forbidden response has a 5xx status code 149 func (o *PostIpamForbidden) IsServerError() bool { 150 return false 151 } 152 153 // IsCode returns true when this post ipam forbidden response a status code equal to that given 154 func (o *PostIpamForbidden) IsCode(code int) bool { 155 return code == 403 156 } 157 158 // Code gets the status code for the post ipam forbidden response 159 func (o *PostIpamForbidden) Code() int { 160 return 403 161 } 162 163 func (o *PostIpamForbidden) Error() string { 164 return fmt.Sprintf("[POST /ipam][%d] postIpamForbidden ", 403) 165 } 166 167 func (o *PostIpamForbidden) String() string { 168 return fmt.Sprintf("[POST /ipam][%d] postIpamForbidden ", 403) 169 } 170 171 func (o *PostIpamForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 172 173 return nil 174 } 175 176 // NewPostIpamFailure creates a PostIpamFailure with default headers values 177 func NewPostIpamFailure() *PostIpamFailure { 178 return &PostIpamFailure{} 179 } 180 181 /* 182 PostIpamFailure describes a response with status code 502, with default header values. 183 184 Allocation failure 185 */ 186 type PostIpamFailure struct { 187 Payload models.Error 188 } 189 190 // IsSuccess returns true when this post ipam failure response has a 2xx status code 191 func (o *PostIpamFailure) IsSuccess() bool { 192 return false 193 } 194 195 // IsRedirect returns true when this post ipam failure response has a 3xx status code 196 func (o *PostIpamFailure) IsRedirect() bool { 197 return false 198 } 199 200 // IsClientError returns true when this post ipam failure response has a 4xx status code 201 func (o *PostIpamFailure) IsClientError() bool { 202 return false 203 } 204 205 // IsServerError returns true when this post ipam failure response has a 5xx status code 206 func (o *PostIpamFailure) IsServerError() bool { 207 return true 208 } 209 210 // IsCode returns true when this post ipam failure response a status code equal to that given 211 func (o *PostIpamFailure) IsCode(code int) bool { 212 return code == 502 213 } 214 215 // Code gets the status code for the post ipam failure response 216 func (o *PostIpamFailure) Code() int { 217 return 502 218 } 219 220 func (o *PostIpamFailure) Error() string { 221 return fmt.Sprintf("[POST /ipam][%d] postIpamFailure %+v", 502, o.Payload) 222 } 223 224 func (o *PostIpamFailure) String() string { 225 return fmt.Sprintf("[POST /ipam][%d] postIpamFailure %+v", 502, o.Payload) 226 } 227 228 func (o *PostIpamFailure) GetPayload() models.Error { 229 return o.Payload 230 } 231 232 func (o *PostIpamFailure) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 233 234 // response payload 235 if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { 236 return err 237 } 238 239 return nil 240 }