1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package connectparticipant 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Sends a message. Note that ConnectionToken is used for invoking this API instead 15// of ParticipantToken. The Amazon Connect Participant Service APIs do not use 16// Signature Version 4 authentication 17// (https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html). 18func (c *Client) SendMessage(ctx context.Context, params *SendMessageInput, optFns ...func(*Options)) (*SendMessageOutput, error) { 19 if params == nil { 20 params = &SendMessageInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "SendMessage", params, optFns, addOperationSendMessageMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*SendMessageOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type SendMessageInput struct { 34 35 // The authentication token associated with the connection. 36 // 37 // This member is required. 38 ConnectionToken *string 39 40 // The content of the message. 41 // 42 // This member is required. 43 Content *string 44 45 // The type of the content. Supported types are text/plain. 46 // 47 // This member is required. 48 ContentType *string 49 50 // A unique, case-sensitive identifier that you provide to ensure the idempotency 51 // of the request. 52 ClientToken *string 53} 54 55type SendMessageOutput struct { 56 57 // The time when the message was sent. It's specified in ISO 8601 format: 58 // yyyy-MM-ddThh:mm:ss.SSSZ. For example, 2019-11-08T02:41:28.172Z. 59 AbsoluteTime *string 60 61 // The ID of the message. 62 Id *string 63 64 // Metadata pertaining to the operation's result. 65 ResultMetadata middleware.Metadata 66} 67 68func addOperationSendMessageMiddlewares(stack *middleware.Stack, options Options) (err error) { 69 err = stack.Serialize.Add(&awsRestjson1_serializeOpSendMessage{}, middleware.After) 70 if err != nil { 71 return err 72 } 73 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpSendMessage{}, middleware.After) 74 if err != nil { 75 return err 76 } 77 if err = addSetLoggerMiddleware(stack, options); err != nil { 78 return err 79 } 80 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 81 return err 82 } 83 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 84 return err 85 } 86 if err = addResolveEndpointMiddleware(stack, options); err != nil { 87 return err 88 } 89 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 90 return err 91 } 92 if err = addRetryMiddlewares(stack, options); err != nil { 93 return err 94 } 95 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 96 return err 97 } 98 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 99 return err 100 } 101 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 102 return err 103 } 104 if err = addClientUserAgent(stack); err != nil { 105 return err 106 } 107 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 108 return err 109 } 110 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addIdempotencyToken_opSendMessageMiddleware(stack, options); err != nil { 114 return err 115 } 116 if err = addOpSendMessageValidationMiddleware(stack); err != nil { 117 return err 118 } 119 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSendMessage(options.Region), middleware.Before); err != nil { 120 return err 121 } 122 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addResponseErrorMiddleware(stack); err != nil { 126 return err 127 } 128 if err = addRequestResponseLogging(stack, options); err != nil { 129 return err 130 } 131 return nil 132} 133 134type idempotencyToken_initializeOpSendMessage struct { 135 tokenProvider IdempotencyTokenProvider 136} 137 138func (*idempotencyToken_initializeOpSendMessage) ID() string { 139 return "OperationIdempotencyTokenAutoFill" 140} 141 142func (m *idempotencyToken_initializeOpSendMessage) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 143 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 144) { 145 if m.tokenProvider == nil { 146 return next.HandleInitialize(ctx, in) 147 } 148 149 input, ok := in.Parameters.(*SendMessageInput) 150 if !ok { 151 return out, metadata, fmt.Errorf("expected middleware input to be of type *SendMessageInput ") 152 } 153 154 if input.ClientToken == nil { 155 t, err := m.tokenProvider.GetIdempotencyToken() 156 if err != nil { 157 return out, metadata, err 158 } 159 input.ClientToken = &t 160 } 161 return next.HandleInitialize(ctx, in) 162} 163func addIdempotencyToken_opSendMessageMiddleware(stack *middleware.Stack, cfg Options) error { 164 return stack.Initialize.Add(&idempotencyToken_initializeOpSendMessage{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 165} 166 167func newServiceMetadataMiddleware_opSendMessage(region string) *awsmiddleware.RegisterServiceMetadata { 168 return &awsmiddleware.RegisterServiceMetadata{ 169 Region: region, 170 ServiceID: ServiceID, 171 SigningName: "execute-api", 172 OperationName: "SendMessage", 173 } 174} 175