api.go 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package apigatewaymanagementapi
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/awsutil"
  6. "github.com/aws/aws-sdk-go/aws/request"
  7. "github.com/aws/aws-sdk-go/private/protocol"
  8. "github.com/aws/aws-sdk-go/private/protocol/restjson"
  9. )
  10. const opPostToConnection = "PostToConnection"
  11. // PostToConnectionRequest generates a "aws/request.Request" representing the
  12. // client's request for the PostToConnection operation. The "output" return
  13. // value will be populated with the request's response once the request completes
  14. // successfully.
  15. //
  16. // Use "Send" method on the returned Request to send the API call to the service.
  17. // the "output" return value is not valid until after Send returns without error.
  18. //
  19. // See PostToConnection for more information on using the PostToConnection
  20. // API call, and error handling.
  21. //
  22. // This method is useful when you want to inject custom logic or configuration
  23. // into the SDK's request lifecycle. Such as custom headers, or retry logic.
  24. //
  25. //
  26. // // Example sending a request using the PostToConnectionRequest method.
  27. // req, resp := client.PostToConnectionRequest(params)
  28. //
  29. // err := req.Send()
  30. // if err == nil { // resp is now filled
  31. // fmt.Println(resp)
  32. // }
  33. //
  34. // See also, https://docs.aws.amazon.com/goto/WebAPI/apigatewaymanagementapi-2018-11-29/PostToConnection
  35. func (c *ApiGatewayManagementApi) PostToConnectionRequest(input *PostToConnectionInput) (req *request.Request, output *PostToConnectionOutput) {
  36. op := &request.Operation{
  37. Name: opPostToConnection,
  38. HTTPMethod: "POST",
  39. HTTPPath: "/@connections/{connectionId}",
  40. }
  41. if input == nil {
  42. input = &PostToConnectionInput{}
  43. }
  44. output = &PostToConnectionOutput{}
  45. req = c.newRequest(op, input, output)
  46. req.Handlers.Unmarshal.Swap(restjson.UnmarshalHandler.Name, protocol.UnmarshalDiscardBodyHandler)
  47. return
  48. }
  49. // PostToConnection API operation for AmazonApiGatewayManagementApi.
  50. //
  51. // Sends the provided data to the specified connection.
  52. //
  53. // Returns awserr.Error for service API and SDK errors. Use runtime type assertions
  54. // with awserr.Error's Code and Message methods to get detailed information about
  55. // the error.
  56. //
  57. // See the AWS API reference guide for AmazonApiGatewayManagementApi's
  58. // API operation PostToConnection for usage and error information.
  59. //
  60. // Returned Error Codes:
  61. // * ErrCodeGoneException "GoneException"
  62. // The connection with the provided id no longer exists.
  63. //
  64. // * ErrCodeLimitExceededException "LimitExceededException"
  65. // The client is sending more than the allowed number of requests per unit of
  66. // time.
  67. //
  68. // * ErrCodePayloadTooLargeException "PayloadTooLargeException"
  69. // The data has exceeded the maximum size allowed.
  70. //
  71. // * ErrCodeForbiddenException "ForbiddenException"
  72. // The caller is not authorized to invoke this operation.
  73. //
  74. // See also, https://docs.aws.amazon.com/goto/WebAPI/apigatewaymanagementapi-2018-11-29/PostToConnection
  75. func (c *ApiGatewayManagementApi) PostToConnection(input *PostToConnectionInput) (*PostToConnectionOutput, error) {
  76. req, out := c.PostToConnectionRequest(input)
  77. return out, req.Send()
  78. }
  79. // PostToConnectionWithContext is the same as PostToConnection with the addition of
  80. // the ability to pass a context and additional request options.
  81. //
  82. // See PostToConnection for details on how to use this API operation.
  83. //
  84. // The context must be non-nil and will be used for request cancellation. If
  85. // the context is nil a panic will occur. In the future the SDK may create
  86. // sub-contexts for http.Requests. See https://golang.org/pkg/context/
  87. // for more information on using Contexts.
  88. func (c *ApiGatewayManagementApi) PostToConnectionWithContext(ctx aws.Context, input *PostToConnectionInput, opts ...request.Option) (*PostToConnectionOutput, error) {
  89. req, out := c.PostToConnectionRequest(input)
  90. req.SetContext(ctx)
  91. req.ApplyOptions(opts...)
  92. return out, req.Send()
  93. }
  94. type PostToConnectionInput struct {
  95. _ struct{} `type:"structure" payload:"Data"`
  96. // ConnectionId is a required field
  97. ConnectionId *string `location:"uri" locationName:"connectionId" type:"string" required:"true"`
  98. // The data to be sent to the client specified by its connection id.
  99. //
  100. // Data is a required field
  101. Data []byte `type:"blob" required:"true"`
  102. }
  103. // String returns the string representation
  104. func (s PostToConnectionInput) String() string {
  105. return awsutil.Prettify(s)
  106. }
  107. // GoString returns the string representation
  108. func (s PostToConnectionInput) GoString() string {
  109. return s.String()
  110. }
  111. // Validate inspects the fields of the type to determine if they are valid.
  112. func (s *PostToConnectionInput) Validate() error {
  113. invalidParams := request.ErrInvalidParams{Context: "PostToConnectionInput"}
  114. if s.ConnectionId == nil {
  115. invalidParams.Add(request.NewErrParamRequired("ConnectionId"))
  116. }
  117. if s.ConnectionId != nil && len(*s.ConnectionId) < 1 {
  118. invalidParams.Add(request.NewErrParamMinLen("ConnectionId", 1))
  119. }
  120. if s.Data == nil {
  121. invalidParams.Add(request.NewErrParamRequired("Data"))
  122. }
  123. if invalidParams.Len() > 0 {
  124. return invalidParams
  125. }
  126. return nil
  127. }
  128. // SetConnectionId sets the ConnectionId field's value.
  129. func (s *PostToConnectionInput) SetConnectionId(v string) *PostToConnectionInput {
  130. s.ConnectionId = &v
  131. return s
  132. }
  133. // SetData sets the Data field's value.
  134. func (s *PostToConnectionInput) SetData(v []byte) *PostToConnectionInput {
  135. s.Data = v
  136. return s
  137. }
  138. type PostToConnectionOutput struct {
  139. _ struct{} `type:"structure"`
  140. }
  141. // String returns the string representation
  142. func (s PostToConnectionOutput) String() string {
  143. return awsutil.Prettify(s)
  144. }
  145. // GoString returns the string representation
  146. func (s PostToConnectionOutput) GoString() string {
  147. return s.String()
  148. }