khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame^] | 1 | // Code generated by Thrift Compiler (0.14.1). DO NOT EDIT. |
| 2 | |
| 3 | package baggage |
| 4 | |
| 5 | import( |
| 6 | "bytes" |
| 7 | "context" |
| 8 | "fmt" |
| 9 | "time" |
| 10 | "github.com/uber/jaeger-client-go/thrift" |
| 11 | ) |
| 12 | |
| 13 | // (needed to ensure safety because of naive import list construction.) |
| 14 | var _ = thrift.ZERO |
| 15 | var _ = fmt.Printf |
| 16 | var _ = context.Background |
| 17 | var _ = time.Now |
| 18 | var _ = bytes.Equal |
| 19 | |
| 20 | // Attributes: |
| 21 | // - BaggageKey |
| 22 | // - MaxValueLength |
| 23 | type BaggageRestriction struct { |
| 24 | BaggageKey string `thrift:"baggageKey,1,required" db:"baggageKey" json:"baggageKey"` |
| 25 | MaxValueLength int32 `thrift:"maxValueLength,2,required" db:"maxValueLength" json:"maxValueLength"` |
| 26 | } |
| 27 | |
| 28 | func NewBaggageRestriction() *BaggageRestriction { |
| 29 | return &BaggageRestriction{} |
| 30 | } |
| 31 | |
| 32 | |
| 33 | func (p *BaggageRestriction) GetBaggageKey() string { |
| 34 | return p.BaggageKey |
| 35 | } |
| 36 | |
| 37 | func (p *BaggageRestriction) GetMaxValueLength() int32 { |
| 38 | return p.MaxValueLength |
| 39 | } |
| 40 | func (p *BaggageRestriction) Read(ctx context.Context, iprot thrift.TProtocol) error { |
| 41 | if _, err := iprot.ReadStructBegin(ctx); err != nil { |
| 42 | return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) |
| 43 | } |
| 44 | |
| 45 | var issetBaggageKey bool = false; |
| 46 | var issetMaxValueLength bool = false; |
| 47 | |
| 48 | for { |
| 49 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) |
| 50 | if err != nil { |
| 51 | return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) |
| 52 | } |
| 53 | if fieldTypeId == thrift.STOP { break; } |
| 54 | switch fieldId { |
| 55 | case 1: |
| 56 | if fieldTypeId == thrift.STRING { |
| 57 | if err := p.ReadField1(ctx, iprot); err != nil { |
| 58 | return err |
| 59 | } |
| 60 | issetBaggageKey = true |
| 61 | } else { |
| 62 | if err := iprot.Skip(ctx, fieldTypeId); err != nil { |
| 63 | return err |
| 64 | } |
| 65 | } |
| 66 | case 2: |
| 67 | if fieldTypeId == thrift.I32 { |
| 68 | if err := p.ReadField2(ctx, iprot); err != nil { |
| 69 | return err |
| 70 | } |
| 71 | issetMaxValueLength = true |
| 72 | } else { |
| 73 | if err := iprot.Skip(ctx, fieldTypeId); err != nil { |
| 74 | return err |
| 75 | } |
| 76 | } |
| 77 | default: |
| 78 | if err := iprot.Skip(ctx, fieldTypeId); err != nil { |
| 79 | return err |
| 80 | } |
| 81 | } |
| 82 | if err := iprot.ReadFieldEnd(ctx); err != nil { |
| 83 | return err |
| 84 | } |
| 85 | } |
| 86 | if err := iprot.ReadStructEnd(ctx); err != nil { |
| 87 | return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) |
| 88 | } |
| 89 | if !issetBaggageKey{ |
| 90 | return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field BaggageKey is not set")); |
| 91 | } |
| 92 | if !issetMaxValueLength{ |
| 93 | return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field MaxValueLength is not set")); |
| 94 | } |
| 95 | return nil |
| 96 | } |
| 97 | |
| 98 | func (p *BaggageRestriction) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { |
| 99 | if v, err := iprot.ReadString(ctx); err != nil { |
| 100 | return thrift.PrependError("error reading field 1: ", err) |
| 101 | } else { |
| 102 | p.BaggageKey = v |
| 103 | } |
| 104 | return nil |
| 105 | } |
| 106 | |
| 107 | func (p *BaggageRestriction) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { |
| 108 | if v, err := iprot.ReadI32(ctx); err != nil { |
| 109 | return thrift.PrependError("error reading field 2: ", err) |
| 110 | } else { |
| 111 | p.MaxValueLength = v |
| 112 | } |
| 113 | return nil |
| 114 | } |
| 115 | |
| 116 | func (p *BaggageRestriction) Write(ctx context.Context, oprot thrift.TProtocol) error { |
| 117 | if err := oprot.WriteStructBegin(ctx, "BaggageRestriction"); err != nil { |
| 118 | return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } |
| 119 | if p != nil { |
| 120 | if err := p.writeField1(ctx, oprot); err != nil { return err } |
| 121 | if err := p.writeField2(ctx, oprot); err != nil { return err } |
| 122 | } |
| 123 | if err := oprot.WriteFieldStop(ctx); err != nil { |
| 124 | return thrift.PrependError("write field stop error: ", err) } |
| 125 | if err := oprot.WriteStructEnd(ctx); err != nil { |
| 126 | return thrift.PrependError("write struct stop error: ", err) } |
| 127 | return nil |
| 128 | } |
| 129 | |
| 130 | func (p *BaggageRestriction) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { |
| 131 | if err := oprot.WriteFieldBegin(ctx, "baggageKey", thrift.STRING, 1); err != nil { |
| 132 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:baggageKey: ", p), err) } |
| 133 | if err := oprot.WriteString(ctx, string(p.BaggageKey)); err != nil { |
| 134 | return thrift.PrependError(fmt.Sprintf("%T.baggageKey (1) field write error: ", p), err) } |
| 135 | if err := oprot.WriteFieldEnd(ctx); err != nil { |
| 136 | return thrift.PrependError(fmt.Sprintf("%T write field end error 1:baggageKey: ", p), err) } |
| 137 | return err |
| 138 | } |
| 139 | |
| 140 | func (p *BaggageRestriction) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { |
| 141 | if err := oprot.WriteFieldBegin(ctx, "maxValueLength", thrift.I32, 2); err != nil { |
| 142 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:maxValueLength: ", p), err) } |
| 143 | if err := oprot.WriteI32(ctx, int32(p.MaxValueLength)); err != nil { |
| 144 | return thrift.PrependError(fmt.Sprintf("%T.maxValueLength (2) field write error: ", p), err) } |
| 145 | if err := oprot.WriteFieldEnd(ctx); err != nil { |
| 146 | return thrift.PrependError(fmt.Sprintf("%T write field end error 2:maxValueLength: ", p), err) } |
| 147 | return err |
| 148 | } |
| 149 | |
| 150 | func (p *BaggageRestriction) Equals(other *BaggageRestriction) bool { |
| 151 | if p == other { |
| 152 | return true |
| 153 | } else if p == nil || other == nil { |
| 154 | return false |
| 155 | } |
| 156 | if p.BaggageKey != other.BaggageKey { return false } |
| 157 | if p.MaxValueLength != other.MaxValueLength { return false } |
| 158 | return true |
| 159 | } |
| 160 | |
| 161 | func (p *BaggageRestriction) String() string { |
| 162 | if p == nil { |
| 163 | return "<nil>" |
| 164 | } |
| 165 | return fmt.Sprintf("BaggageRestriction(%+v)", *p) |
| 166 | } |
| 167 | |
| 168 | type BaggageRestrictionManager interface { |
| 169 | // getBaggageRestrictions retrieves the baggage restrictions for a specific service. |
| 170 | // Usually, baggageRestrictions apply to all services however there may be situations |
| 171 | // where a baggageKey might only be allowed to be set by a specific service. |
| 172 | // |
| 173 | // Parameters: |
| 174 | // - ServiceName |
| 175 | GetBaggageRestrictions(ctx context.Context, serviceName string) (_r []*BaggageRestriction, _err error) |
| 176 | } |
| 177 | |
| 178 | type BaggageRestrictionManagerClient struct { |
| 179 | c thrift.TClient |
| 180 | meta thrift.ResponseMeta |
| 181 | } |
| 182 | |
| 183 | func NewBaggageRestrictionManagerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BaggageRestrictionManagerClient { |
| 184 | return &BaggageRestrictionManagerClient{ |
| 185 | c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | func NewBaggageRestrictionManagerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BaggageRestrictionManagerClient { |
| 190 | return &BaggageRestrictionManagerClient{ |
| 191 | c: thrift.NewTStandardClient(iprot, oprot), |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | func NewBaggageRestrictionManagerClient(c thrift.TClient) *BaggageRestrictionManagerClient { |
| 196 | return &BaggageRestrictionManagerClient{ |
| 197 | c: c, |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | func (p *BaggageRestrictionManagerClient) Client_() thrift.TClient { |
| 202 | return p.c |
| 203 | } |
| 204 | |
| 205 | func (p *BaggageRestrictionManagerClient) LastResponseMeta_() thrift.ResponseMeta { |
| 206 | return p.meta |
| 207 | } |
| 208 | |
| 209 | func (p *BaggageRestrictionManagerClient) SetLastResponseMeta_(meta thrift.ResponseMeta) { |
| 210 | p.meta = meta |
| 211 | } |
| 212 | |
| 213 | // getBaggageRestrictions retrieves the baggage restrictions for a specific service. |
| 214 | // Usually, baggageRestrictions apply to all services however there may be situations |
| 215 | // where a baggageKey might only be allowed to be set by a specific service. |
| 216 | // |
| 217 | // Parameters: |
| 218 | // - ServiceName |
| 219 | func (p *BaggageRestrictionManagerClient) GetBaggageRestrictions(ctx context.Context, serviceName string) (_r []*BaggageRestriction, _err error) { |
| 220 | var _args0 BaggageRestrictionManagerGetBaggageRestrictionsArgs |
| 221 | _args0.ServiceName = serviceName |
| 222 | var _result2 BaggageRestrictionManagerGetBaggageRestrictionsResult |
| 223 | var _meta1 thrift.ResponseMeta |
| 224 | _meta1, _err = p.Client_().Call(ctx, "getBaggageRestrictions", &_args0, &_result2) |
| 225 | p.SetLastResponseMeta_(_meta1) |
| 226 | if _err != nil { |
| 227 | return |
| 228 | } |
| 229 | return _result2.GetSuccess(), nil |
| 230 | } |
| 231 | |
| 232 | type BaggageRestrictionManagerProcessor struct { |
| 233 | processorMap map[string]thrift.TProcessorFunction |
| 234 | handler BaggageRestrictionManager |
| 235 | } |
| 236 | |
| 237 | func (p *BaggageRestrictionManagerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { |
| 238 | p.processorMap[key] = processor |
| 239 | } |
| 240 | |
| 241 | func (p *BaggageRestrictionManagerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { |
| 242 | processor, ok = p.processorMap[key] |
| 243 | return processor, ok |
| 244 | } |
| 245 | |
| 246 | func (p *BaggageRestrictionManagerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { |
| 247 | return p.processorMap |
| 248 | } |
| 249 | |
| 250 | func NewBaggageRestrictionManagerProcessor(handler BaggageRestrictionManager) *BaggageRestrictionManagerProcessor { |
| 251 | |
| 252 | self3 := &BaggageRestrictionManagerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} |
| 253 | self3.processorMap["getBaggageRestrictions"] = &baggageRestrictionManagerProcessorGetBaggageRestrictions{handler:handler} |
| 254 | return self3 |
| 255 | } |
| 256 | |
| 257 | func (p *BaggageRestrictionManagerProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { |
| 258 | name, _, seqId, err2 := iprot.ReadMessageBegin(ctx) |
| 259 | if err2 != nil { return false, thrift.WrapTException(err2) } |
| 260 | if processor, ok := p.GetProcessorFunction(name); ok { |
| 261 | return processor.Process(ctx, seqId, iprot, oprot) |
| 262 | } |
| 263 | iprot.Skip(ctx, thrift.STRUCT) |
| 264 | iprot.ReadMessageEnd(ctx) |
| 265 | x4 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) |
| 266 | oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) |
| 267 | x4.Write(ctx, oprot) |
| 268 | oprot.WriteMessageEnd(ctx) |
| 269 | oprot.Flush(ctx) |
| 270 | return false, x4 |
| 271 | |
| 272 | } |
| 273 | |
| 274 | type baggageRestrictionManagerProcessorGetBaggageRestrictions struct { |
| 275 | handler BaggageRestrictionManager |
| 276 | } |
| 277 | |
| 278 | func (p *baggageRestrictionManagerProcessorGetBaggageRestrictions) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { |
| 279 | args := BaggageRestrictionManagerGetBaggageRestrictionsArgs{} |
| 280 | var err2 error |
| 281 | if err2 = args.Read(ctx, iprot); err2 != nil { |
| 282 | iprot.ReadMessageEnd(ctx) |
| 283 | x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) |
| 284 | oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.EXCEPTION, seqId) |
| 285 | x.Write(ctx, oprot) |
| 286 | oprot.WriteMessageEnd(ctx) |
| 287 | oprot.Flush(ctx) |
| 288 | return false, thrift.WrapTException(err2) |
| 289 | } |
| 290 | iprot.ReadMessageEnd(ctx) |
| 291 | |
| 292 | tickerCancel := func() {} |
| 293 | // Start a goroutine to do server side connectivity check. |
| 294 | if thrift.ServerConnectivityCheckInterval > 0 { |
| 295 | var cancel context.CancelFunc |
| 296 | ctx, cancel = context.WithCancel(ctx) |
| 297 | defer cancel() |
| 298 | var tickerCtx context.Context |
| 299 | tickerCtx, tickerCancel = context.WithCancel(context.Background()) |
| 300 | defer tickerCancel() |
| 301 | go func(ctx context.Context, cancel context.CancelFunc) { |
| 302 | ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) |
| 303 | defer ticker.Stop() |
| 304 | for { |
| 305 | select { |
| 306 | case <-ctx.Done(): |
| 307 | return |
| 308 | case <-ticker.C: |
| 309 | if !iprot.Transport().IsOpen() { |
| 310 | cancel() |
| 311 | return |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | }(tickerCtx, cancel) |
| 316 | } |
| 317 | |
| 318 | result := BaggageRestrictionManagerGetBaggageRestrictionsResult{} |
| 319 | var retval []*BaggageRestriction |
| 320 | if retval, err2 = p.handler.GetBaggageRestrictions(ctx, args.ServiceName); err2 != nil { |
| 321 | tickerCancel() |
| 322 | if err2 == thrift.ErrAbandonRequest { |
| 323 | return false, thrift.WrapTException(err2) |
| 324 | } |
| 325 | x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getBaggageRestrictions: " + err2.Error()) |
| 326 | oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.EXCEPTION, seqId) |
| 327 | x.Write(ctx, oprot) |
| 328 | oprot.WriteMessageEnd(ctx) |
| 329 | oprot.Flush(ctx) |
| 330 | return true, thrift.WrapTException(err2) |
| 331 | } else { |
| 332 | result.Success = retval |
| 333 | } |
| 334 | tickerCancel() |
| 335 | if err2 = oprot.WriteMessageBegin(ctx, "getBaggageRestrictions", thrift.REPLY, seqId); err2 != nil { |
| 336 | err = thrift.WrapTException(err2) |
| 337 | } |
| 338 | if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { |
| 339 | err = thrift.WrapTException(err2) |
| 340 | } |
| 341 | if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { |
| 342 | err = thrift.WrapTException(err2) |
| 343 | } |
| 344 | if err2 = oprot.Flush(ctx); err == nil && err2 != nil { |
| 345 | err = thrift.WrapTException(err2) |
| 346 | } |
| 347 | if err != nil { |
| 348 | return |
| 349 | } |
| 350 | return true, err |
| 351 | } |
| 352 | |
| 353 | |
| 354 | // HELPER FUNCTIONS AND STRUCTURES |
| 355 | |
| 356 | // Attributes: |
| 357 | // - ServiceName |
| 358 | type BaggageRestrictionManagerGetBaggageRestrictionsArgs struct { |
| 359 | ServiceName string `thrift:"serviceName,1" db:"serviceName" json:"serviceName"` |
| 360 | } |
| 361 | |
| 362 | func NewBaggageRestrictionManagerGetBaggageRestrictionsArgs() *BaggageRestrictionManagerGetBaggageRestrictionsArgs { |
| 363 | return &BaggageRestrictionManagerGetBaggageRestrictionsArgs{} |
| 364 | } |
| 365 | |
| 366 | |
| 367 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) GetServiceName() string { |
| 368 | return p.ServiceName |
| 369 | } |
| 370 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { |
| 371 | if _, err := iprot.ReadStructBegin(ctx); err != nil { |
| 372 | return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) |
| 373 | } |
| 374 | |
| 375 | |
| 376 | for { |
| 377 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) |
| 378 | if err != nil { |
| 379 | return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) |
| 380 | } |
| 381 | if fieldTypeId == thrift.STOP { break; } |
| 382 | switch fieldId { |
| 383 | case 1: |
| 384 | if fieldTypeId == thrift.STRING { |
| 385 | if err := p.ReadField1(ctx, iprot); err != nil { |
| 386 | return err |
| 387 | } |
| 388 | } else { |
| 389 | if err := iprot.Skip(ctx, fieldTypeId); err != nil { |
| 390 | return err |
| 391 | } |
| 392 | } |
| 393 | default: |
| 394 | if err := iprot.Skip(ctx, fieldTypeId); err != nil { |
| 395 | return err |
| 396 | } |
| 397 | } |
| 398 | if err := iprot.ReadFieldEnd(ctx); err != nil { |
| 399 | return err |
| 400 | } |
| 401 | } |
| 402 | if err := iprot.ReadStructEnd(ctx); err != nil { |
| 403 | return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) |
| 404 | } |
| 405 | return nil |
| 406 | } |
| 407 | |
| 408 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { |
| 409 | if v, err := iprot.ReadString(ctx); err != nil { |
| 410 | return thrift.PrependError("error reading field 1: ", err) |
| 411 | } else { |
| 412 | p.ServiceName = v |
| 413 | } |
| 414 | return nil |
| 415 | } |
| 416 | |
| 417 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { |
| 418 | if err := oprot.WriteStructBegin(ctx, "getBaggageRestrictions_args"); err != nil { |
| 419 | return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } |
| 420 | if p != nil { |
| 421 | if err := p.writeField1(ctx, oprot); err != nil { return err } |
| 422 | } |
| 423 | if err := oprot.WriteFieldStop(ctx); err != nil { |
| 424 | return thrift.PrependError("write field stop error: ", err) } |
| 425 | if err := oprot.WriteStructEnd(ctx); err != nil { |
| 426 | return thrift.PrependError("write struct stop error: ", err) } |
| 427 | return nil |
| 428 | } |
| 429 | |
| 430 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { |
| 431 | if err := oprot.WriteFieldBegin(ctx, "serviceName", thrift.STRING, 1); err != nil { |
| 432 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:serviceName: ", p), err) } |
| 433 | if err := oprot.WriteString(ctx, string(p.ServiceName)); err != nil { |
| 434 | return thrift.PrependError(fmt.Sprintf("%T.serviceName (1) field write error: ", p), err) } |
| 435 | if err := oprot.WriteFieldEnd(ctx); err != nil { |
| 436 | return thrift.PrependError(fmt.Sprintf("%T write field end error 1:serviceName: ", p), err) } |
| 437 | return err |
| 438 | } |
| 439 | |
| 440 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) String() string { |
| 441 | if p == nil { |
| 442 | return "<nil>" |
| 443 | } |
| 444 | return fmt.Sprintf("BaggageRestrictionManagerGetBaggageRestrictionsArgs(%+v)", *p) |
| 445 | } |
| 446 | |
| 447 | // Attributes: |
| 448 | // - Success |
| 449 | type BaggageRestrictionManagerGetBaggageRestrictionsResult struct { |
| 450 | Success []*BaggageRestriction `thrift:"success,0" db:"success" json:"success,omitempty"` |
| 451 | } |
| 452 | |
| 453 | func NewBaggageRestrictionManagerGetBaggageRestrictionsResult() *BaggageRestrictionManagerGetBaggageRestrictionsResult { |
| 454 | return &BaggageRestrictionManagerGetBaggageRestrictionsResult{} |
| 455 | } |
| 456 | |
| 457 | var BaggageRestrictionManagerGetBaggageRestrictionsResult_Success_DEFAULT []*BaggageRestriction |
| 458 | |
| 459 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) GetSuccess() []*BaggageRestriction { |
| 460 | return p.Success |
| 461 | } |
| 462 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) IsSetSuccess() bool { |
| 463 | return p.Success != nil |
| 464 | } |
| 465 | |
| 466 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { |
| 467 | if _, err := iprot.ReadStructBegin(ctx); err != nil { |
| 468 | return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) |
| 469 | } |
| 470 | |
| 471 | |
| 472 | for { |
| 473 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) |
| 474 | if err != nil { |
| 475 | return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) |
| 476 | } |
| 477 | if fieldTypeId == thrift.STOP { break; } |
| 478 | switch fieldId { |
| 479 | case 0: |
| 480 | if fieldTypeId == thrift.LIST { |
| 481 | if err := p.ReadField0(ctx, iprot); err != nil { |
| 482 | return err |
| 483 | } |
| 484 | } else { |
| 485 | if err := iprot.Skip(ctx, fieldTypeId); err != nil { |
| 486 | return err |
| 487 | } |
| 488 | } |
| 489 | default: |
| 490 | if err := iprot.Skip(ctx, fieldTypeId); err != nil { |
| 491 | return err |
| 492 | } |
| 493 | } |
| 494 | if err := iprot.ReadFieldEnd(ctx); err != nil { |
| 495 | return err |
| 496 | } |
| 497 | } |
| 498 | if err := iprot.ReadStructEnd(ctx); err != nil { |
| 499 | return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) |
| 500 | } |
| 501 | return nil |
| 502 | } |
| 503 | |
| 504 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { |
| 505 | _, size, err := iprot.ReadListBegin(ctx) |
| 506 | if err != nil { |
| 507 | return thrift.PrependError("error reading list begin: ", err) |
| 508 | } |
| 509 | tSlice := make([]*BaggageRestriction, 0, size) |
| 510 | p.Success = tSlice |
| 511 | for i := 0; i < size; i ++ { |
| 512 | _elem5 := &BaggageRestriction{} |
| 513 | if err := _elem5.Read(ctx, iprot); err != nil { |
| 514 | return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem5), err) |
| 515 | } |
| 516 | p.Success = append(p.Success, _elem5) |
| 517 | } |
| 518 | if err := iprot.ReadListEnd(ctx); err != nil { |
| 519 | return thrift.PrependError("error reading list end: ", err) |
| 520 | } |
| 521 | return nil |
| 522 | } |
| 523 | |
| 524 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { |
| 525 | if err := oprot.WriteStructBegin(ctx, "getBaggageRestrictions_result"); err != nil { |
| 526 | return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } |
| 527 | if p != nil { |
| 528 | if err := p.writeField0(ctx, oprot); err != nil { return err } |
| 529 | } |
| 530 | if err := oprot.WriteFieldStop(ctx); err != nil { |
| 531 | return thrift.PrependError("write field stop error: ", err) } |
| 532 | if err := oprot.WriteStructEnd(ctx); err != nil { |
| 533 | return thrift.PrependError("write struct stop error: ", err) } |
| 534 | return nil |
| 535 | } |
| 536 | |
| 537 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { |
| 538 | if p.IsSetSuccess() { |
| 539 | if err := oprot.WriteFieldBegin(ctx, "success", thrift.LIST, 0); err != nil { |
| 540 | return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } |
| 541 | if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Success)); err != nil { |
| 542 | return thrift.PrependError("error writing list begin: ", err) |
| 543 | } |
| 544 | for _, v := range p.Success { |
| 545 | if err := v.Write(ctx, oprot); err != nil { |
| 546 | return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) |
| 547 | } |
| 548 | } |
| 549 | if err := oprot.WriteListEnd(ctx); err != nil { |
| 550 | return thrift.PrependError("error writing list end: ", err) |
| 551 | } |
| 552 | if err := oprot.WriteFieldEnd(ctx); err != nil { |
| 553 | return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } |
| 554 | } |
| 555 | return err |
| 556 | } |
| 557 | |
| 558 | func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) String() string { |
| 559 | if p == nil { |
| 560 | return "<nil>" |
| 561 | } |
| 562 | return fmt.Sprintf("BaggageRestrictionManagerGetBaggageRestrictionsResult(%+v)", *p) |
| 563 | } |
| 564 | |
| 565 | |