1// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3package restjsonservice 4 5import ( 6 "bytes" 7 "fmt" 8 "io" 9 "sync" 10 "time" 11 12 "github.com/aws/aws-sdk-go/aws" 13 "github.com/aws/aws-sdk-go/aws/awserr" 14 "github.com/aws/aws-sdk-go/aws/awsutil" 15 "github.com/aws/aws-sdk-go/aws/client" 16 "github.com/aws/aws-sdk-go/aws/request" 17 "github.com/aws/aws-sdk-go/private/protocol" 18 "github.com/aws/aws-sdk-go/private/protocol/eventstream" 19 "github.com/aws/aws-sdk-go/private/protocol/eventstream/eventstreamapi" 20 "github.com/aws/aws-sdk-go/private/protocol/rest" 21 "github.com/aws/aws-sdk-go/private/protocol/restjson" 22) 23 24const opEmptyStream = "EmptyStream" 25 26// EmptyStreamRequest generates a "aws/request.Request" representing the 27// client's request for the EmptyStream operation. The "output" return 28// value will be populated with the request's response once the request completes 29// successfully. 30// 31// Use "Send" method on the returned Request to send the API call to the service. 32// the "output" return value is not valid until after Send returns without error. 33// 34// See EmptyStream for more information on using the EmptyStream 35// API call, and error handling. 36// 37// This method is useful when you want to inject custom logic or configuration 38// into the SDK's request lifecycle. Such as custom headers, or retry logic. 39// 40// 41// // Example sending a request using the EmptyStreamRequest method. 42// req, resp := client.EmptyStreamRequest(params) 43// 44// err := req.Send() 45// if err == nil { // resp is now filled 46// fmt.Println(resp) 47// } 48// 49// See also, https://docs.aws.amazon.com/goto/WebAPI/RESTJSONService-0000-00-00/EmptyStream 50func (c *RESTJSONService) EmptyStreamRequest(input *EmptyStreamInput) (req *request.Request, output *EmptyStreamOutput) { 51 op := &request.Operation{ 52 Name: opEmptyStream, 53 HTTPMethod: "POST", 54 HTTPPath: "/", 55 } 56 57 if input == nil { 58 input = &EmptyStreamInput{} 59 } 60 61 output = &EmptyStreamOutput{} 62 req = c.newRequest(op, input, output) 63 64 es := newEmptyStreamEventStream() 65 output.eventStream = es 66 67 req.Handlers.Send.Swap(client.LogHTTPResponseHandler.Name, client.LogHTTPResponseHeaderHandler) 68 req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, rest.UnmarshalHandler) 69 req.Handlers.Unmarshal.PushBack(es.runOutputStream) 70 req.Handlers.Unmarshal.PushBack(es.runOnStreamPartClose) 71 return 72} 73 74// EmptyStream API operation for REST JSON Service. 75// 76// Returns awserr.Error for service API and SDK errors. Use runtime type assertions 77// with awserr.Error's Code and Message methods to get detailed information about 78// the error. 79// 80// See the AWS API reference guide for REST JSON Service's 81// API operation EmptyStream for usage and error information. 82// See also, https://docs.aws.amazon.com/goto/WebAPI/RESTJSONService-0000-00-00/EmptyStream 83func (c *RESTJSONService) EmptyStream(input *EmptyStreamInput) (*EmptyStreamOutput, error) { 84 req, out := c.EmptyStreamRequest(input) 85 return out, req.Send() 86} 87 88// EmptyStreamWithContext is the same as EmptyStream with the addition of 89// the ability to pass a context and additional request options. 90// 91// See EmptyStream for details on how to use this API operation. 92// 93// The context must be non-nil and will be used for request cancellation. If 94// the context is nil a panic will occur. In the future the SDK may create 95// sub-contexts for http.Requests. See https://golang.org/pkg/context/ 96// for more information on using Contexts. 97func (c *RESTJSONService) EmptyStreamWithContext(ctx aws.Context, input *EmptyStreamInput, opts ...request.Option) (*EmptyStreamOutput, error) { 98 req, out := c.EmptyStreamRequest(input) 99 req.SetContext(ctx) 100 req.ApplyOptions(opts...) 101 return out, req.Send() 102} 103 104// EmptyStreamEventStream provides the event stream handling for the EmptyStream. 105type EmptyStreamEventStream struct { 106 107 // Reader is the EventStream reader for the EmptyEventStream 108 // events. This value is automatically set by the SDK when the API call is made 109 // Use this member when unit testing your code with the SDK to mock out the 110 // EventStream Reader. 111 // 112 // Must not be nil. 113 Reader EmptyEventStreamReader 114 115 outputReader io.ReadCloser 116 117 done chan struct{} 118 closeOnce sync.Once 119 err *eventstreamapi.OnceError 120} 121 122func newEmptyStreamEventStream() *EmptyStreamEventStream { 123 return &EmptyStreamEventStream{ 124 done: make(chan struct{}), 125 err: eventstreamapi.NewOnceError(), 126 } 127} 128 129func (es *EmptyStreamEventStream) runOnStreamPartClose(r *request.Request) { 130 if es.done == nil { 131 return 132 } 133 go es.waitStreamPartClose() 134 135} 136 137func (es *EmptyStreamEventStream) waitStreamPartClose() { 138 var outputErrCh <-chan struct{} 139 if v, ok := es.Reader.(interface{ ErrorSet() <-chan struct{} }); ok { 140 outputErrCh = v.ErrorSet() 141 } 142 var outputClosedCh <-chan struct{} 143 if v, ok := es.Reader.(interface{ Closed() <-chan struct{} }); ok { 144 outputClosedCh = v.Closed() 145 } 146 147 select { 148 case <-es.done: 149 case <-outputErrCh: 150 es.err.SetError(es.Reader.Err()) 151 es.Close() 152 case <-outputClosedCh: 153 if err := es.Reader.Err(); err != nil { 154 es.err.SetError(es.Reader.Err()) 155 } 156 es.Close() 157 } 158} 159 160// Events returns a channel to read events from. 161// 162// These events are: 163// 164func (es *EmptyStreamEventStream) Events() <-chan EmptyEventStreamEvent { 165 return es.Reader.Events() 166} 167 168func (es *EmptyStreamEventStream) runOutputStream(r *request.Request) { 169 var opts []func(*eventstream.Decoder) 170 if r.Config.Logger != nil && r.Config.LogLevel.Matches(aws.LogDebugWithEventStreamBody) { 171 opts = append(opts, eventstream.DecodeWithLogger(r.Config.Logger)) 172 } 173 174 unmarshalerForEvent := unmarshalerForEmptyEventStreamEvent{ 175 metadata: protocol.ResponseMetadata{ 176 StatusCode: r.HTTPResponse.StatusCode, 177 RequestID: r.RequestID, 178 }, 179 }.UnmarshalerForEventName 180 181 decoder := eventstream.NewDecoder(r.HTTPResponse.Body, opts...) 182 eventReader := eventstreamapi.NewEventReader(decoder, 183 protocol.HandlerPayloadUnmarshal{ 184 Unmarshalers: r.Handlers.UnmarshalStream, 185 }, 186 unmarshalerForEvent, 187 ) 188 189 es.outputReader = r.HTTPResponse.Body 190 es.Reader = newReadEmptyEventStream(eventReader) 191} 192 193// Close closes the stream. This will also cause the stream to be closed. 194// Close must be called when done using the stream API. Not calling Close 195// may result in resource leaks. 196// 197// You can use the closing of the Reader's Events channel to terminate your 198// application's read from the API's stream. 199// 200func (es *EmptyStreamEventStream) Close() (err error) { 201 es.closeOnce.Do(es.safeClose) 202 return es.Err() 203} 204 205func (es *EmptyStreamEventStream) safeClose() { 206 if es.done != nil { 207 close(es.done) 208 } 209 210 es.Reader.Close() 211 if es.outputReader != nil { 212 es.outputReader.Close() 213 } 214} 215 216// Err returns any error that occurred while reading or writing EventStream 217// Events from the service API's response. Returns nil if there were no errors. 218func (es *EmptyStreamEventStream) Err() error { 219 if err := es.err.Err(); err != nil { 220 return err 221 } 222 if err := es.Reader.Err(); err != nil { 223 return err 224 } 225 226 return nil 227} 228 229const opGetEventStream = "GetEventStream" 230 231// GetEventStreamRequest generates a "aws/request.Request" representing the 232// client's request for the GetEventStream operation. The "output" return 233// value will be populated with the request's response once the request completes 234// successfully. 235// 236// Use "Send" method on the returned Request to send the API call to the service. 237// the "output" return value is not valid until after Send returns without error. 238// 239// See GetEventStream for more information on using the GetEventStream 240// API call, and error handling. 241// 242// This method is useful when you want to inject custom logic or configuration 243// into the SDK's request lifecycle. Such as custom headers, or retry logic. 244// 245// 246// // Example sending a request using the GetEventStreamRequest method. 247// req, resp := client.GetEventStreamRequest(params) 248// 249// err := req.Send() 250// if err == nil { // resp is now filled 251// fmt.Println(resp) 252// } 253// 254// See also, https://docs.aws.amazon.com/goto/WebAPI/RESTJSONService-0000-00-00/GetEventStream 255func (c *RESTJSONService) GetEventStreamRequest(input *GetEventStreamInput) (req *request.Request, output *GetEventStreamOutput) { 256 op := &request.Operation{ 257 Name: opGetEventStream, 258 HTTPMethod: "POST", 259 HTTPPath: "/", 260 } 261 262 if input == nil { 263 input = &GetEventStreamInput{} 264 } 265 266 output = &GetEventStreamOutput{} 267 req = c.newRequest(op, input, output) 268 269 es := newGetEventStreamEventStream() 270 output.eventStream = es 271 272 req.Handlers.Send.Swap(client.LogHTTPResponseHandler.Name, client.LogHTTPResponseHeaderHandler) 273 req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, rest.UnmarshalHandler) 274 req.Handlers.Unmarshal.PushBack(es.runOutputStream) 275 req.Handlers.Unmarshal.PushBack(es.runOnStreamPartClose) 276 return 277} 278 279// GetEventStream API operation for REST JSON Service. 280// 281// Returns awserr.Error for service API and SDK errors. Use runtime type assertions 282// with awserr.Error's Code and Message methods to get detailed information about 283// the error. 284// 285// See the AWS API reference guide for REST JSON Service's 286// API operation GetEventStream for usage and error information. 287// See also, https://docs.aws.amazon.com/goto/WebAPI/RESTJSONService-0000-00-00/GetEventStream 288func (c *RESTJSONService) GetEventStream(input *GetEventStreamInput) (*GetEventStreamOutput, error) { 289 req, out := c.GetEventStreamRequest(input) 290 return out, req.Send() 291} 292 293// GetEventStreamWithContext is the same as GetEventStream with the addition of 294// the ability to pass a context and additional request options. 295// 296// See GetEventStream for details on how to use this API operation. 297// 298// The context must be non-nil and will be used for request cancellation. If 299// the context is nil a panic will occur. In the future the SDK may create 300// sub-contexts for http.Requests. See https://golang.org/pkg/context/ 301// for more information on using Contexts. 302func (c *RESTJSONService) GetEventStreamWithContext(ctx aws.Context, input *GetEventStreamInput, opts ...request.Option) (*GetEventStreamOutput, error) { 303 req, out := c.GetEventStreamRequest(input) 304 req.SetContext(ctx) 305 req.ApplyOptions(opts...) 306 return out, req.Send() 307} 308 309// GetEventStreamEventStream provides the event stream handling for the GetEventStream. 310type GetEventStreamEventStream struct { 311 312 // Reader is the EventStream reader for the EventStream 313 // events. This value is automatically set by the SDK when the API call is made 314 // Use this member when unit testing your code with the SDK to mock out the 315 // EventStream Reader. 316 // 317 // Must not be nil. 318 Reader EventStreamReader 319 320 outputReader io.ReadCloser 321 322 done chan struct{} 323 closeOnce sync.Once 324 err *eventstreamapi.OnceError 325} 326 327func newGetEventStreamEventStream() *GetEventStreamEventStream { 328 return &GetEventStreamEventStream{ 329 done: make(chan struct{}), 330 err: eventstreamapi.NewOnceError(), 331 } 332} 333 334func (es *GetEventStreamEventStream) runOnStreamPartClose(r *request.Request) { 335 if es.done == nil { 336 return 337 } 338 go es.waitStreamPartClose() 339 340} 341 342func (es *GetEventStreamEventStream) waitStreamPartClose() { 343 var outputErrCh <-chan struct{} 344 if v, ok := es.Reader.(interface{ ErrorSet() <-chan struct{} }); ok { 345 outputErrCh = v.ErrorSet() 346 } 347 var outputClosedCh <-chan struct{} 348 if v, ok := es.Reader.(interface{ Closed() <-chan struct{} }); ok { 349 outputClosedCh = v.Closed() 350 } 351 352 select { 353 case <-es.done: 354 case <-outputErrCh: 355 es.err.SetError(es.Reader.Err()) 356 es.Close() 357 case <-outputClosedCh: 358 if err := es.Reader.Err(); err != nil { 359 es.err.SetError(es.Reader.Err()) 360 } 361 es.Close() 362 } 363} 364 365// Events returns a channel to read events from. 366// 367// These events are: 368// 369// * EmptyEvent 370// * ExplicitPayloadEvent 371// * HeaderOnlyEvent 372// * ImplicitPayloadEvent 373// * PayloadOnlyEvent 374// * PayloadOnlyBlobEvent 375// * PayloadOnlyStringEvent 376func (es *GetEventStreamEventStream) Events() <-chan EventStreamEvent { 377 return es.Reader.Events() 378} 379 380func (es *GetEventStreamEventStream) runOutputStream(r *request.Request) { 381 var opts []func(*eventstream.Decoder) 382 if r.Config.Logger != nil && r.Config.LogLevel.Matches(aws.LogDebugWithEventStreamBody) { 383 opts = append(opts, eventstream.DecodeWithLogger(r.Config.Logger)) 384 } 385 386 unmarshalerForEvent := unmarshalerForEventStreamEvent{ 387 metadata: protocol.ResponseMetadata{ 388 StatusCode: r.HTTPResponse.StatusCode, 389 RequestID: r.RequestID, 390 }, 391 }.UnmarshalerForEventName 392 393 decoder := eventstream.NewDecoder(r.HTTPResponse.Body, opts...) 394 eventReader := eventstreamapi.NewEventReader(decoder, 395 protocol.HandlerPayloadUnmarshal{ 396 Unmarshalers: r.Handlers.UnmarshalStream, 397 }, 398 unmarshalerForEvent, 399 ) 400 401 es.outputReader = r.HTTPResponse.Body 402 es.Reader = newReadEventStream(eventReader) 403} 404 405// Close closes the stream. This will also cause the stream to be closed. 406// Close must be called when done using the stream API. Not calling Close 407// may result in resource leaks. 408// 409// You can use the closing of the Reader's Events channel to terminate your 410// application's read from the API's stream. 411// 412func (es *GetEventStreamEventStream) Close() (err error) { 413 es.closeOnce.Do(es.safeClose) 414 return es.Err() 415} 416 417func (es *GetEventStreamEventStream) safeClose() { 418 if es.done != nil { 419 close(es.done) 420 } 421 422 es.Reader.Close() 423 if es.outputReader != nil { 424 es.outputReader.Close() 425 } 426} 427 428// Err returns any error that occurred while reading or writing EventStream 429// Events from the service API's response. Returns nil if there were no errors. 430func (es *GetEventStreamEventStream) Err() error { 431 if err := es.err.Err(); err != nil { 432 return err 433 } 434 if err := es.Reader.Err(); err != nil { 435 return err 436 } 437 438 return nil 439} 440 441const opOtherOperation = "OtherOperation" 442 443// OtherOperationRequest generates a "aws/request.Request" representing the 444// client's request for the OtherOperation operation. The "output" return 445// value will be populated with the request's response once the request completes 446// successfully. 447// 448// Use "Send" method on the returned Request to send the API call to the service. 449// the "output" return value is not valid until after Send returns without error. 450// 451// See OtherOperation for more information on using the OtherOperation 452// API call, and error handling. 453// 454// This method is useful when you want to inject custom logic or configuration 455// into the SDK's request lifecycle. Such as custom headers, or retry logic. 456// 457// 458// // Example sending a request using the OtherOperationRequest method. 459// req, resp := client.OtherOperationRequest(params) 460// 461// err := req.Send() 462// if err == nil { // resp is now filled 463// fmt.Println(resp) 464// } 465// 466// See also, https://docs.aws.amazon.com/goto/WebAPI/RESTJSONService-0000-00-00/OtherOperation 467func (c *RESTJSONService) OtherOperationRequest(input *OtherOperationInput) (req *request.Request, output *OtherOperationOutput) { 468 op := &request.Operation{ 469 Name: opOtherOperation, 470 HTTPMethod: "POST", 471 HTTPPath: "/", 472 } 473 474 if input == nil { 475 input = &OtherOperationInput{} 476 } 477 478 output = &OtherOperationOutput{} 479 req = c.newRequest(op, input, output) 480 req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler) 481 return 482} 483 484// OtherOperation API operation for REST JSON Service. 485// 486// Returns awserr.Error for service API and SDK errors. Use runtime type assertions 487// with awserr.Error's Code and Message methods to get detailed information about 488// the error. 489// 490// See the AWS API reference guide for REST JSON Service's 491// API operation OtherOperation for usage and error information. 492// 493// Returned Error Types: 494// * ExceptionEvent2 495// 496// See also, https://docs.aws.amazon.com/goto/WebAPI/RESTJSONService-0000-00-00/OtherOperation 497func (c *RESTJSONService) OtherOperation(input *OtherOperationInput) (*OtherOperationOutput, error) { 498 req, out := c.OtherOperationRequest(input) 499 return out, req.Send() 500} 501 502// OtherOperationWithContext is the same as OtherOperation with the addition of 503// the ability to pass a context and additional request options. 504// 505// See OtherOperation for details on how to use this API operation. 506// 507// The context must be non-nil and will be used for request cancellation. If 508// the context is nil a panic will occur. In the future the SDK may create 509// sub-contexts for http.Requests. See https://golang.org/pkg/context/ 510// for more information on using Contexts. 511func (c *RESTJSONService) OtherOperationWithContext(ctx aws.Context, input *OtherOperationInput, opts ...request.Option) (*OtherOperationOutput, error) { 512 req, out := c.OtherOperationRequest(input) 513 req.SetContext(ctx) 514 req.ApplyOptions(opts...) 515 return out, req.Send() 516} 517 518type EmptyEvent struct { 519 _ struct{} `type:"structure"` 520} 521 522// String returns the string representation 523func (s EmptyEvent) String() string { 524 return awsutil.Prettify(s) 525} 526 527// GoString returns the string representation 528func (s EmptyEvent) GoString() string { 529 return s.String() 530} 531 532// The EmptyEvent is and event in the EventStream group of events. 533func (s *EmptyEvent) eventEventStream() {} 534 535// UnmarshalEvent unmarshals the EventStream Message into the EmptyEvent value. 536// This method is only used internally within the SDK's EventStream handling. 537func (s *EmptyEvent) UnmarshalEvent( 538 payloadUnmarshaler protocol.PayloadUnmarshaler, 539 msg eventstream.Message, 540) error { 541 return nil 542} 543 544func (s *EmptyEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 545 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 546 return msg, err 547} 548 549// EmptyEventStreamEvent groups together all EventStream 550// events writes for EmptyEventStream. 551// 552// These events are: 553// 554type EmptyEventStreamEvent interface { 555 eventEmptyEventStream() 556 eventstreamapi.Marshaler 557 eventstreamapi.Unmarshaler 558} 559 560// EmptyEventStreamReader provides the interface for reading to the stream. The 561// default implementation for this interface will be EmptyEventStream. 562// 563// The reader's Close method must allow multiple concurrent calls. 564// 565// These events are: 566// 567type EmptyEventStreamReader interface { 568 // Returns a channel of events as they are read from the event stream. 569 Events() <-chan EmptyEventStreamEvent 570 571 // Close will stop the reader reading events from the stream. 572 Close() error 573 574 // Returns any error that has occurred while reading from the event stream. 575 Err() error 576} 577 578type readEmptyEventStream struct { 579 eventReader *eventstreamapi.EventReader 580 stream chan EmptyEventStreamEvent 581 err *eventstreamapi.OnceError 582 583 done chan struct{} 584 closeOnce sync.Once 585} 586 587func newReadEmptyEventStream(eventReader *eventstreamapi.EventReader) *readEmptyEventStream { 588 r := &readEmptyEventStream{ 589 eventReader: eventReader, 590 stream: make(chan EmptyEventStreamEvent), 591 done: make(chan struct{}), 592 err: eventstreamapi.NewOnceError(), 593 } 594 go r.readEventStream() 595 596 return r 597} 598 599// Close will close the underlying event stream reader. 600func (r *readEmptyEventStream) Close() error { 601 r.closeOnce.Do(r.safeClose) 602 return r.Err() 603} 604 605func (r *readEmptyEventStream) ErrorSet() <-chan struct{} { 606 return r.err.ErrorSet() 607} 608 609func (r *readEmptyEventStream) Closed() <-chan struct{} { 610 return r.done 611} 612 613func (r *readEmptyEventStream) safeClose() { 614 close(r.done) 615} 616 617func (r *readEmptyEventStream) Err() error { 618 return r.err.Err() 619} 620 621func (r *readEmptyEventStream) Events() <-chan EmptyEventStreamEvent { 622 return r.stream 623} 624 625func (r *readEmptyEventStream) readEventStream() { 626 defer r.Close() 627 defer close(r.stream) 628 629 for { 630 event, err := r.eventReader.ReadEvent() 631 if err != nil { 632 if err == io.EOF { 633 return 634 } 635 select { 636 case <-r.done: 637 // If closed already ignore the error 638 return 639 default: 640 } 641 r.err.SetError(err) 642 return 643 } 644 645 select { 646 case r.stream <- event.(EmptyEventStreamEvent): 647 case <-r.done: 648 return 649 } 650 } 651} 652 653type unmarshalerForEmptyEventStreamEvent struct { 654 metadata protocol.ResponseMetadata 655} 656 657func (u unmarshalerForEmptyEventStreamEvent) UnmarshalerForEventName(eventType string) (eventstreamapi.Unmarshaler, error) { 658 switch eventType { 659 default: 660 return nil, awserr.New( 661 request.ErrCodeSerialization, 662 fmt.Sprintf("unknown event type name, %s, for EmptyEventStream", eventType), 663 nil, 664 ) 665 } 666} 667 668type EmptyStreamInput struct { 669 _ struct{} `type:"structure"` 670} 671 672// String returns the string representation 673func (s EmptyStreamInput) String() string { 674 return awsutil.Prettify(s) 675} 676 677// GoString returns the string representation 678func (s EmptyStreamInput) GoString() string { 679 return s.String() 680} 681 682type EmptyStreamOutput struct { 683 _ struct{} `type:"structure"` 684 685 eventStream *EmptyStreamEventStream 686} 687 688// String returns the string representation 689func (s EmptyStreamOutput) String() string { 690 return awsutil.Prettify(s) 691} 692 693// GoString returns the string representation 694func (s EmptyStreamOutput) GoString() string { 695 return s.String() 696} 697 698// GetStream returns the type to interact with the event stream. 699func (s *EmptyStreamOutput) GetStream() *EmptyStreamEventStream { 700 return s.eventStream 701} 702 703// EventStreamEvent groups together all EventStream 704// events writes for EventStream. 705// 706// These events are: 707// 708// * EmptyEvent 709// * ExplicitPayloadEvent 710// * HeaderOnlyEvent 711// * ImplicitPayloadEvent 712// * PayloadOnlyEvent 713// * PayloadOnlyBlobEvent 714// * PayloadOnlyStringEvent 715type EventStreamEvent interface { 716 eventEventStream() 717 eventstreamapi.Marshaler 718 eventstreamapi.Unmarshaler 719} 720 721// EventStreamReader provides the interface for reading to the stream. The 722// default implementation for this interface will be EventStream. 723// 724// The reader's Close method must allow multiple concurrent calls. 725// 726// These events are: 727// 728// * EmptyEvent 729// * ExplicitPayloadEvent 730// * HeaderOnlyEvent 731// * ImplicitPayloadEvent 732// * PayloadOnlyEvent 733// * PayloadOnlyBlobEvent 734// * PayloadOnlyStringEvent 735type EventStreamReader interface { 736 // Returns a channel of events as they are read from the event stream. 737 Events() <-chan EventStreamEvent 738 739 // Close will stop the reader reading events from the stream. 740 Close() error 741 742 // Returns any error that has occurred while reading from the event stream. 743 Err() error 744} 745 746type readEventStream struct { 747 eventReader *eventstreamapi.EventReader 748 stream chan EventStreamEvent 749 err *eventstreamapi.OnceError 750 751 done chan struct{} 752 closeOnce sync.Once 753} 754 755func newReadEventStream(eventReader *eventstreamapi.EventReader) *readEventStream { 756 r := &readEventStream{ 757 eventReader: eventReader, 758 stream: make(chan EventStreamEvent), 759 done: make(chan struct{}), 760 err: eventstreamapi.NewOnceError(), 761 } 762 go r.readEventStream() 763 764 return r 765} 766 767// Close will close the underlying event stream reader. 768func (r *readEventStream) Close() error { 769 r.closeOnce.Do(r.safeClose) 770 return r.Err() 771} 772 773func (r *readEventStream) ErrorSet() <-chan struct{} { 774 return r.err.ErrorSet() 775} 776 777func (r *readEventStream) Closed() <-chan struct{} { 778 return r.done 779} 780 781func (r *readEventStream) safeClose() { 782 close(r.done) 783} 784 785func (r *readEventStream) Err() error { 786 return r.err.Err() 787} 788 789func (r *readEventStream) Events() <-chan EventStreamEvent { 790 return r.stream 791} 792 793func (r *readEventStream) readEventStream() { 794 defer r.Close() 795 defer close(r.stream) 796 797 for { 798 event, err := r.eventReader.ReadEvent() 799 if err != nil { 800 if err == io.EOF { 801 return 802 } 803 select { 804 case <-r.done: 805 // If closed already ignore the error 806 return 807 default: 808 } 809 r.err.SetError(err) 810 return 811 } 812 813 select { 814 case r.stream <- event.(EventStreamEvent): 815 case <-r.done: 816 return 817 } 818 } 819} 820 821type unmarshalerForEventStreamEvent struct { 822 metadata protocol.ResponseMetadata 823} 824 825func (u unmarshalerForEventStreamEvent) UnmarshalerForEventName(eventType string) (eventstreamapi.Unmarshaler, error) { 826 switch eventType { 827 case "Empty": 828 return &EmptyEvent{}, nil 829 case "ExplicitPayload": 830 return &ExplicitPayloadEvent{}, nil 831 case "Headers": 832 return &HeaderOnlyEvent{}, nil 833 case "ImplicitPayload": 834 return &ImplicitPayloadEvent{}, nil 835 case "PayloadOnly": 836 return &PayloadOnlyEvent{}, nil 837 case "PayloadOnlyBlob": 838 return &PayloadOnlyBlobEvent{}, nil 839 case "PayloadOnlyString": 840 return &PayloadOnlyStringEvent{}, nil 841 case "Exception": 842 return newErrorExceptionEvent(u.metadata).(eventstreamapi.Unmarshaler), nil 843 case "Exception2": 844 return newErrorExceptionEvent2(u.metadata).(eventstreamapi.Unmarshaler), nil 845 default: 846 return nil, awserr.New( 847 request.ErrCodeSerialization, 848 fmt.Sprintf("unknown event type name, %s, for EventStream", eventType), 849 nil, 850 ) 851 } 852} 853 854type ExceptionEvent struct { 855 _ struct{} `type:"structure"` 856 respMetadata protocol.ResponseMetadata 857 858 IntVal *int64 `type:"integer"` 859 860 Message_ *string `locationName:"message" type:"string"` 861} 862 863// String returns the string representation 864func (s ExceptionEvent) String() string { 865 return awsutil.Prettify(s) 866} 867 868// GoString returns the string representation 869func (s ExceptionEvent) GoString() string { 870 return s.String() 871} 872 873// The ExceptionEvent is and event in the EventStream group of events. 874func (s *ExceptionEvent) eventEventStream() {} 875 876// UnmarshalEvent unmarshals the EventStream Message into the ExceptionEvent value. 877// This method is only used internally within the SDK's EventStream handling. 878func (s *ExceptionEvent) UnmarshalEvent( 879 payloadUnmarshaler protocol.PayloadUnmarshaler, 880 msg eventstream.Message, 881) error { 882 if err := payloadUnmarshaler.UnmarshalPayload( 883 bytes.NewReader(msg.Payload), s, 884 ); err != nil { 885 return err 886 } 887 return nil 888} 889 890func (s *ExceptionEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 891 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.ExceptionMessageType)) 892 var buf bytes.Buffer 893 if err = pm.MarshalPayload(&buf, s); err != nil { 894 return eventstream.Message{}, err 895 } 896 msg.Payload = buf.Bytes() 897 return msg, err 898} 899 900func newErrorExceptionEvent(v protocol.ResponseMetadata) error { 901 return &ExceptionEvent{ 902 respMetadata: v, 903 } 904} 905 906// Code returns the exception type name. 907func (s ExceptionEvent) Code() string { 908 return "ExceptionEvent" 909} 910 911// Message returns the exception's message. 912func (s ExceptionEvent) Message() string { 913 if s.Message_ != nil { 914 return *s.Message_ 915 } 916 return "" 917} 918 919// OrigErr always returns nil, satisfies awserr.Error interface. 920func (s ExceptionEvent) OrigErr() error { 921 return nil 922} 923 924func (s ExceptionEvent) Error() string { 925 return fmt.Sprintf("%s: %s\n%s", s.Code(), s.Message(), s.String()) 926} 927 928// Status code returns the HTTP status code for the request's response error. 929func (s ExceptionEvent) StatusCode() int { 930 return s.respMetadata.StatusCode 931} 932 933// RequestID returns the service's response RequestID for request. 934func (s ExceptionEvent) RequestID() string { 935 return s.respMetadata.RequestID 936} 937 938type ExceptionEvent2 struct { 939 _ struct{} `type:"structure"` 940 respMetadata protocol.ResponseMetadata 941 942 Message_ *string `locationName:"message" type:"string"` 943} 944 945// String returns the string representation 946func (s ExceptionEvent2) String() string { 947 return awsutil.Prettify(s) 948} 949 950// GoString returns the string representation 951func (s ExceptionEvent2) GoString() string { 952 return s.String() 953} 954 955// The ExceptionEvent2 is and event in the EventStream group of events. 956func (s *ExceptionEvent2) eventEventStream() {} 957 958// UnmarshalEvent unmarshals the EventStream Message into the ExceptionEvent2 value. 959// This method is only used internally within the SDK's EventStream handling. 960func (s *ExceptionEvent2) UnmarshalEvent( 961 payloadUnmarshaler protocol.PayloadUnmarshaler, 962 msg eventstream.Message, 963) error { 964 if err := payloadUnmarshaler.UnmarshalPayload( 965 bytes.NewReader(msg.Payload), s, 966 ); err != nil { 967 return err 968 } 969 return nil 970} 971 972func (s *ExceptionEvent2) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 973 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.ExceptionMessageType)) 974 var buf bytes.Buffer 975 if err = pm.MarshalPayload(&buf, s); err != nil { 976 return eventstream.Message{}, err 977 } 978 msg.Payload = buf.Bytes() 979 return msg, err 980} 981 982func newErrorExceptionEvent2(v protocol.ResponseMetadata) error { 983 return &ExceptionEvent2{ 984 respMetadata: v, 985 } 986} 987 988// Code returns the exception type name. 989func (s ExceptionEvent2) Code() string { 990 return "ExceptionEvent2" 991} 992 993// Message returns the exception's message. 994func (s ExceptionEvent2) Message() string { 995 if s.Message_ != nil { 996 return *s.Message_ 997 } 998 return "" 999} 1000 1001// OrigErr always returns nil, satisfies awserr.Error interface. 1002func (s ExceptionEvent2) OrigErr() error { 1003 return nil 1004} 1005 1006func (s ExceptionEvent2) Error() string { 1007 return fmt.Sprintf("%s: %s", s.Code(), s.Message()) 1008} 1009 1010// Status code returns the HTTP status code for the request's response error. 1011func (s ExceptionEvent2) StatusCode() int { 1012 return s.respMetadata.StatusCode 1013} 1014 1015// RequestID returns the service's response RequestID for request. 1016func (s ExceptionEvent2) RequestID() string { 1017 return s.respMetadata.RequestID 1018} 1019 1020type ExplicitPayloadEvent struct { 1021 _ struct{} `type:"structure" payload:"NestedVal"` 1022 1023 LongVal *int64 `location:"header" type:"long"` 1024 1025 NestedVal *NestedShape `locationName:"NestedVal" type:"structure"` 1026 1027 StringVal *string `location:"header" type:"string"` 1028} 1029 1030// String returns the string representation 1031func (s ExplicitPayloadEvent) String() string { 1032 return awsutil.Prettify(s) 1033} 1034 1035// GoString returns the string representation 1036func (s ExplicitPayloadEvent) GoString() string { 1037 return s.String() 1038} 1039 1040// SetLongVal sets the LongVal field's value. 1041func (s *ExplicitPayloadEvent) SetLongVal(v int64) *ExplicitPayloadEvent { 1042 s.LongVal = &v 1043 return s 1044} 1045 1046// SetNestedVal sets the NestedVal field's value. 1047func (s *ExplicitPayloadEvent) SetNestedVal(v *NestedShape) *ExplicitPayloadEvent { 1048 s.NestedVal = v 1049 return s 1050} 1051 1052// SetStringVal sets the StringVal field's value. 1053func (s *ExplicitPayloadEvent) SetStringVal(v string) *ExplicitPayloadEvent { 1054 s.StringVal = &v 1055 return s 1056} 1057 1058// The ExplicitPayloadEvent is and event in the EventStream group of events. 1059func (s *ExplicitPayloadEvent) eventEventStream() {} 1060 1061// UnmarshalEvent unmarshals the EventStream Message into the ExplicitPayloadEvent value. 1062// This method is only used internally within the SDK's EventStream handling. 1063func (s *ExplicitPayloadEvent) UnmarshalEvent( 1064 payloadUnmarshaler protocol.PayloadUnmarshaler, 1065 msg eventstream.Message, 1066) error { 1067 if hv := msg.Headers.Get("LongVal"); hv != nil { 1068 v := hv.Get().(int64) 1069 s.LongVal = &v 1070 } 1071 if hv := msg.Headers.Get("StringVal"); hv != nil { 1072 v := hv.Get().(string) 1073 s.StringVal = &v 1074 } 1075 if err := payloadUnmarshaler.UnmarshalPayload( 1076 bytes.NewReader(msg.Payload), s, 1077 ); err != nil { 1078 return err 1079 } 1080 return nil 1081} 1082 1083func (s *ExplicitPayloadEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1084 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 1085 msg.Headers.Set("LongVal", eventstream.Int64Value(*s.LongVal)) 1086 msg.Headers.Set("StringVal", eventstream.StringValue(*s.StringVal)) 1087 var buf bytes.Buffer 1088 if err = pm.MarshalPayload(&buf, s); err != nil { 1089 return eventstream.Message{}, err 1090 } 1091 msg.Payload = buf.Bytes() 1092 return msg, err 1093} 1094 1095type GetEventStreamInput struct { 1096 _ struct{} `type:"structure"` 1097 1098 InputVal *string `type:"string"` 1099} 1100 1101// String returns the string representation 1102func (s GetEventStreamInput) String() string { 1103 return awsutil.Prettify(s) 1104} 1105 1106// GoString returns the string representation 1107func (s GetEventStreamInput) GoString() string { 1108 return s.String() 1109} 1110 1111// SetInputVal sets the InputVal field's value. 1112func (s *GetEventStreamInput) SetInputVal(v string) *GetEventStreamInput { 1113 s.InputVal = &v 1114 return s 1115} 1116 1117type GetEventStreamOutput struct { 1118 _ struct{} `type:"structure"` 1119 1120 eventStream *GetEventStreamEventStream 1121 1122 IntVal *int64 `type:"integer"` 1123 1124 StrVal *string `type:"string"` 1125} 1126 1127// String returns the string representation 1128func (s GetEventStreamOutput) String() string { 1129 return awsutil.Prettify(s) 1130} 1131 1132// GoString returns the string representation 1133func (s GetEventStreamOutput) GoString() string { 1134 return s.String() 1135} 1136 1137// SetIntVal sets the IntVal field's value. 1138func (s *GetEventStreamOutput) SetIntVal(v int64) *GetEventStreamOutput { 1139 s.IntVal = &v 1140 return s 1141} 1142 1143// SetStrVal sets the StrVal field's value. 1144func (s *GetEventStreamOutput) SetStrVal(v string) *GetEventStreamOutput { 1145 s.StrVal = &v 1146 return s 1147} 1148 1149// GetStream returns the type to interact with the event stream. 1150func (s *GetEventStreamOutput) GetStream() *GetEventStreamEventStream { 1151 return s.eventStream 1152} 1153 1154type HeaderOnlyEvent struct { 1155 _ struct{} `type:"structure"` 1156 1157 // BlobVal is automatically base64 encoded/decoded by the SDK. 1158 BlobVal []byte `location:"header" type:"blob"` 1159 1160 BoolVal *bool `location:"header" type:"boolean"` 1161 1162 ByteVal *int64 `location:"header" type:"byte"` 1163 1164 IntegerVal *int64 `location:"header" type:"integer"` 1165 1166 LongVal *int64 `location:"header" type:"long"` 1167 1168 ShortVal *int64 `location:"header" type:"short"` 1169 1170 StringVal *string `location:"header" type:"string"` 1171 1172 TimeVal *time.Time `location:"header" type:"timestamp"` 1173} 1174 1175// String returns the string representation 1176func (s HeaderOnlyEvent) String() string { 1177 return awsutil.Prettify(s) 1178} 1179 1180// GoString returns the string representation 1181func (s HeaderOnlyEvent) GoString() string { 1182 return s.String() 1183} 1184 1185// SetBlobVal sets the BlobVal field's value. 1186func (s *HeaderOnlyEvent) SetBlobVal(v []byte) *HeaderOnlyEvent { 1187 s.BlobVal = v 1188 return s 1189} 1190 1191// SetBoolVal sets the BoolVal field's value. 1192func (s *HeaderOnlyEvent) SetBoolVal(v bool) *HeaderOnlyEvent { 1193 s.BoolVal = &v 1194 return s 1195} 1196 1197// SetByteVal sets the ByteVal field's value. 1198func (s *HeaderOnlyEvent) SetByteVal(v int64) *HeaderOnlyEvent { 1199 s.ByteVal = &v 1200 return s 1201} 1202 1203// SetIntegerVal sets the IntegerVal field's value. 1204func (s *HeaderOnlyEvent) SetIntegerVal(v int64) *HeaderOnlyEvent { 1205 s.IntegerVal = &v 1206 return s 1207} 1208 1209// SetLongVal sets the LongVal field's value. 1210func (s *HeaderOnlyEvent) SetLongVal(v int64) *HeaderOnlyEvent { 1211 s.LongVal = &v 1212 return s 1213} 1214 1215// SetShortVal sets the ShortVal field's value. 1216func (s *HeaderOnlyEvent) SetShortVal(v int64) *HeaderOnlyEvent { 1217 s.ShortVal = &v 1218 return s 1219} 1220 1221// SetStringVal sets the StringVal field's value. 1222func (s *HeaderOnlyEvent) SetStringVal(v string) *HeaderOnlyEvent { 1223 s.StringVal = &v 1224 return s 1225} 1226 1227// SetTimeVal sets the TimeVal field's value. 1228func (s *HeaderOnlyEvent) SetTimeVal(v time.Time) *HeaderOnlyEvent { 1229 s.TimeVal = &v 1230 return s 1231} 1232 1233// The HeaderOnlyEvent is and event in the EventStream group of events. 1234func (s *HeaderOnlyEvent) eventEventStream() {} 1235 1236// UnmarshalEvent unmarshals the EventStream Message into the HeaderOnlyEvent value. 1237// This method is only used internally within the SDK's EventStream handling. 1238func (s *HeaderOnlyEvent) UnmarshalEvent( 1239 payloadUnmarshaler protocol.PayloadUnmarshaler, 1240 msg eventstream.Message, 1241) error { 1242 if hv := msg.Headers.Get("BlobVal"); hv != nil { 1243 v := hv.Get().([]byte) 1244 s.BlobVal = v 1245 } 1246 if hv := msg.Headers.Get("BoolVal"); hv != nil { 1247 v := hv.Get().(bool) 1248 s.BoolVal = &v 1249 } 1250 if hv := msg.Headers.Get("ByteVal"); hv != nil { 1251 v := hv.Get().(int8) 1252 m := int64(v) 1253 s.ByteVal = &m 1254 } 1255 if hv := msg.Headers.Get("IntegerVal"); hv != nil { 1256 v := hv.Get().(int32) 1257 m := int64(v) 1258 s.IntegerVal = &m 1259 } 1260 if hv := msg.Headers.Get("LongVal"); hv != nil { 1261 v := hv.Get().(int64) 1262 s.LongVal = &v 1263 } 1264 if hv := msg.Headers.Get("ShortVal"); hv != nil { 1265 v := hv.Get().(int16) 1266 m := int64(v) 1267 s.ShortVal = &m 1268 } 1269 if hv := msg.Headers.Get("StringVal"); hv != nil { 1270 v := hv.Get().(string) 1271 s.StringVal = &v 1272 } 1273 if hv := msg.Headers.Get("TimeVal"); hv != nil { 1274 v := hv.Get().(time.Time) 1275 s.TimeVal = &v 1276 } 1277 return nil 1278} 1279 1280func (s *HeaderOnlyEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1281 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 1282 msg.Headers.Set("BlobVal", eventstream.BytesValue(s.BlobVal)) 1283 msg.Headers.Set("BoolVal", eventstream.BoolValue(*s.BoolVal)) 1284 msg.Headers.Set("ByteVal", eventstream.Int8Value(int8(*s.ByteVal))) 1285 msg.Headers.Set("IntegerVal", eventstream.Int32Value(int32(*s.IntegerVal))) 1286 msg.Headers.Set("LongVal", eventstream.Int64Value(*s.LongVal)) 1287 msg.Headers.Set("ShortVal", eventstream.Int16Value(int16(*s.ShortVal))) 1288 msg.Headers.Set("StringVal", eventstream.StringValue(*s.StringVal)) 1289 msg.Headers.Set("TimeVal", eventstream.TimestampValue(*s.TimeVal)) 1290 return msg, err 1291} 1292 1293type ImplicitPayloadEvent struct { 1294 _ struct{} `type:"structure"` 1295 1296 ByteVal *int64 `location:"header" type:"byte"` 1297 1298 IntegerVal *int64 `type:"integer"` 1299 1300 ShortVal *int64 `type:"short"` 1301} 1302 1303// String returns the string representation 1304func (s ImplicitPayloadEvent) String() string { 1305 return awsutil.Prettify(s) 1306} 1307 1308// GoString returns the string representation 1309func (s ImplicitPayloadEvent) GoString() string { 1310 return s.String() 1311} 1312 1313// SetByteVal sets the ByteVal field's value. 1314func (s *ImplicitPayloadEvent) SetByteVal(v int64) *ImplicitPayloadEvent { 1315 s.ByteVal = &v 1316 return s 1317} 1318 1319// SetIntegerVal sets the IntegerVal field's value. 1320func (s *ImplicitPayloadEvent) SetIntegerVal(v int64) *ImplicitPayloadEvent { 1321 s.IntegerVal = &v 1322 return s 1323} 1324 1325// SetShortVal sets the ShortVal field's value. 1326func (s *ImplicitPayloadEvent) SetShortVal(v int64) *ImplicitPayloadEvent { 1327 s.ShortVal = &v 1328 return s 1329} 1330 1331// The ImplicitPayloadEvent is and event in the EventStream group of events. 1332func (s *ImplicitPayloadEvent) eventEventStream() {} 1333 1334// UnmarshalEvent unmarshals the EventStream Message into the ImplicitPayloadEvent value. 1335// This method is only used internally within the SDK's EventStream handling. 1336func (s *ImplicitPayloadEvent) UnmarshalEvent( 1337 payloadUnmarshaler protocol.PayloadUnmarshaler, 1338 msg eventstream.Message, 1339) error { 1340 if hv := msg.Headers.Get("ByteVal"); hv != nil { 1341 v := hv.Get().(int8) 1342 m := int64(v) 1343 s.ByteVal = &m 1344 } 1345 if err := payloadUnmarshaler.UnmarshalPayload( 1346 bytes.NewReader(msg.Payload), s, 1347 ); err != nil { 1348 return err 1349 } 1350 return nil 1351} 1352 1353func (s *ImplicitPayloadEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1354 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 1355 msg.Headers.Set("ByteVal", eventstream.Int8Value(int8(*s.ByteVal))) 1356 var buf bytes.Buffer 1357 if err = pm.MarshalPayload(&buf, s); err != nil { 1358 return eventstream.Message{}, err 1359 } 1360 msg.Payload = buf.Bytes() 1361 return msg, err 1362} 1363 1364type NestedShape struct { 1365 _ struct{} `type:"structure"` 1366 1367 IntVal *int64 `type:"integer"` 1368 1369 StrVal *string `type:"string"` 1370} 1371 1372// String returns the string representation 1373func (s NestedShape) String() string { 1374 return awsutil.Prettify(s) 1375} 1376 1377// GoString returns the string representation 1378func (s NestedShape) GoString() string { 1379 return s.String() 1380} 1381 1382// SetIntVal sets the IntVal field's value. 1383func (s *NestedShape) SetIntVal(v int64) *NestedShape { 1384 s.IntVal = &v 1385 return s 1386} 1387 1388// SetStrVal sets the StrVal field's value. 1389func (s *NestedShape) SetStrVal(v string) *NestedShape { 1390 s.StrVal = &v 1391 return s 1392} 1393 1394type OtherOperationInput struct { 1395 _ struct{} `type:"structure"` 1396} 1397 1398// String returns the string representation 1399func (s OtherOperationInput) String() string { 1400 return awsutil.Prettify(s) 1401} 1402 1403// GoString returns the string representation 1404func (s OtherOperationInput) GoString() string { 1405 return s.String() 1406} 1407 1408type OtherOperationOutput struct { 1409 _ struct{} `type:"structure"` 1410} 1411 1412// String returns the string representation 1413func (s OtherOperationOutput) String() string { 1414 return awsutil.Prettify(s) 1415} 1416 1417// GoString returns the string representation 1418func (s OtherOperationOutput) GoString() string { 1419 return s.String() 1420} 1421 1422type PayloadOnlyBlobEvent struct { 1423 _ struct{} `type:"structure" payload:"BlobPayload"` 1424 1425 // BlobPayload is automatically base64 encoded/decoded by the SDK. 1426 BlobPayload []byte `type:"blob"` 1427} 1428 1429// String returns the string representation 1430func (s PayloadOnlyBlobEvent) String() string { 1431 return awsutil.Prettify(s) 1432} 1433 1434// GoString returns the string representation 1435func (s PayloadOnlyBlobEvent) GoString() string { 1436 return s.String() 1437} 1438 1439// SetBlobPayload sets the BlobPayload field's value. 1440func (s *PayloadOnlyBlobEvent) SetBlobPayload(v []byte) *PayloadOnlyBlobEvent { 1441 s.BlobPayload = v 1442 return s 1443} 1444 1445// The PayloadOnlyBlobEvent is and event in the EventStream group of events. 1446func (s *PayloadOnlyBlobEvent) eventEventStream() {} 1447 1448// UnmarshalEvent unmarshals the EventStream Message into the PayloadOnlyBlobEvent value. 1449// This method is only used internally within the SDK's EventStream handling. 1450func (s *PayloadOnlyBlobEvent) UnmarshalEvent( 1451 payloadUnmarshaler protocol.PayloadUnmarshaler, 1452 msg eventstream.Message, 1453) error { 1454 s.BlobPayload = make([]byte, len(msg.Payload)) 1455 copy(s.BlobPayload, msg.Payload) 1456 return nil 1457} 1458 1459func (s *PayloadOnlyBlobEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1460 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 1461 msg.Headers.Set(":content-type", eventstream.StringValue("application/octet-stream")) 1462 msg.Payload = s.BlobPayload 1463 return msg, err 1464} 1465 1466type PayloadOnlyEvent struct { 1467 _ struct{} `type:"structure" payload:"NestedVal"` 1468 1469 NestedVal *NestedShape `locationName:"NestedVal" type:"structure"` 1470} 1471 1472// String returns the string representation 1473func (s PayloadOnlyEvent) String() string { 1474 return awsutil.Prettify(s) 1475} 1476 1477// GoString returns the string representation 1478func (s PayloadOnlyEvent) GoString() string { 1479 return s.String() 1480} 1481 1482// SetNestedVal sets the NestedVal field's value. 1483func (s *PayloadOnlyEvent) SetNestedVal(v *NestedShape) *PayloadOnlyEvent { 1484 s.NestedVal = v 1485 return s 1486} 1487 1488// The PayloadOnlyEvent is and event in the EventStream group of events. 1489func (s *PayloadOnlyEvent) eventEventStream() {} 1490 1491// UnmarshalEvent unmarshals the EventStream Message into the PayloadOnlyEvent value. 1492// This method is only used internally within the SDK's EventStream handling. 1493func (s *PayloadOnlyEvent) UnmarshalEvent( 1494 payloadUnmarshaler protocol.PayloadUnmarshaler, 1495 msg eventstream.Message, 1496) error { 1497 if err := payloadUnmarshaler.UnmarshalPayload( 1498 bytes.NewReader(msg.Payload), s, 1499 ); err != nil { 1500 return err 1501 } 1502 return nil 1503} 1504 1505func (s *PayloadOnlyEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1506 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 1507 var buf bytes.Buffer 1508 if err = pm.MarshalPayload(&buf, s); err != nil { 1509 return eventstream.Message{}, err 1510 } 1511 msg.Payload = buf.Bytes() 1512 return msg, err 1513} 1514 1515type PayloadOnlyStringEvent struct { 1516 _ struct{} `type:"structure" payload:"StringPayload"` 1517 1518 StringPayload *string `locationName:"StringPayload" type:"string"` 1519} 1520 1521// String returns the string representation 1522func (s PayloadOnlyStringEvent) String() string { 1523 return awsutil.Prettify(s) 1524} 1525 1526// GoString returns the string representation 1527func (s PayloadOnlyStringEvent) GoString() string { 1528 return s.String() 1529} 1530 1531// SetStringPayload sets the StringPayload field's value. 1532func (s *PayloadOnlyStringEvent) SetStringPayload(v string) *PayloadOnlyStringEvent { 1533 s.StringPayload = &v 1534 return s 1535} 1536 1537// The PayloadOnlyStringEvent is and event in the EventStream group of events. 1538func (s *PayloadOnlyStringEvent) eventEventStream() {} 1539 1540// UnmarshalEvent unmarshals the EventStream Message into the PayloadOnlyStringEvent value. 1541// This method is only used internally within the SDK's EventStream handling. 1542func (s *PayloadOnlyStringEvent) UnmarshalEvent( 1543 payloadUnmarshaler protocol.PayloadUnmarshaler, 1544 msg eventstream.Message, 1545) error { 1546 s.StringPayload = aws.String(string(msg.Payload)) 1547 return nil 1548} 1549 1550func (s *PayloadOnlyStringEvent) MarshalEvent(pm protocol.PayloadMarshaler) (msg eventstream.Message, err error) { 1551 msg.Headers.Set(eventstreamapi.MessageTypeHeader, eventstream.StringValue(eventstreamapi.EventMessageType)) 1552 msg.Payload = []byte(aws.StringValue(s.StringPayload)) 1553 return msg, err 1554} 1555