1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package alexaforbusiness
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/aws-sdk-go-v2/service/alexaforbusiness/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Triggers an asynchronous flow to send text, SSML, or audio announcements to
16// rooms that are identified by a search or filter.
17func (c *Client) SendAnnouncement(ctx context.Context, params *SendAnnouncementInput, optFns ...func(*Options)) (*SendAnnouncementOutput, error) {
18	if params == nil {
19		params = &SendAnnouncementInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "SendAnnouncement", params, optFns, addOperationSendAnnouncementMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*SendAnnouncementOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type SendAnnouncementInput struct {
33
34	// The unique, user-specified identifier for the request that ensures idempotency.
35	//
36	// This member is required.
37	ClientRequestToken *string
38
39	// The announcement content. This can contain only one of the three possible
40	// announcement types (text, SSML or audio).
41	//
42	// This member is required.
43	Content *types.Content
44
45	// The filters to use to send an announcement to a specified list of rooms. The
46	// supported filter keys are RoomName, ProfileName, RoomArn, and ProfileArn. To
47	// send to all rooms, specify an empty RoomFilters list.
48	//
49	// This member is required.
50	RoomFilters []types.Filter
51
52	// The time to live for an announcement. Default is 300. If delivery doesn't occur
53	// within this time, the announcement is not delivered.
54	TimeToLiveInSeconds *int32
55}
56
57type SendAnnouncementOutput struct {
58
59	// The identifier of the announcement.
60	AnnouncementArn *string
61
62	// Metadata pertaining to the operation's result.
63	ResultMetadata middleware.Metadata
64}
65
66func addOperationSendAnnouncementMiddlewares(stack *middleware.Stack, options Options) (err error) {
67	err = stack.Serialize.Add(&awsAwsjson11_serializeOpSendAnnouncement{}, middleware.After)
68	if err != nil {
69		return err
70	}
71	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpSendAnnouncement{}, middleware.After)
72	if err != nil {
73		return err
74	}
75	if err = addSetLoggerMiddleware(stack, options); err != nil {
76		return err
77	}
78	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
79		return err
80	}
81	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
82		return err
83	}
84	if err = addResolveEndpointMiddleware(stack, options); err != nil {
85		return err
86	}
87	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
88		return err
89	}
90	if err = addRetryMiddlewares(stack, options); err != nil {
91		return err
92	}
93	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
94		return err
95	}
96	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
97		return err
98	}
99	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
100		return err
101	}
102	if err = addClientUserAgent(stack); err != nil {
103		return err
104	}
105	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
106		return err
107	}
108	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
109		return err
110	}
111	if err = addIdempotencyToken_opSendAnnouncementMiddleware(stack, options); err != nil {
112		return err
113	}
114	if err = addOpSendAnnouncementValidationMiddleware(stack); err != nil {
115		return err
116	}
117	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSendAnnouncement(options.Region), middleware.Before); err != nil {
118		return err
119	}
120	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addResponseErrorMiddleware(stack); err != nil {
124		return err
125	}
126	if err = addRequestResponseLogging(stack, options); err != nil {
127		return err
128	}
129	return nil
130}
131
132type idempotencyToken_initializeOpSendAnnouncement struct {
133	tokenProvider IdempotencyTokenProvider
134}
135
136func (*idempotencyToken_initializeOpSendAnnouncement) ID() string {
137	return "OperationIdempotencyTokenAutoFill"
138}
139
140func (m *idempotencyToken_initializeOpSendAnnouncement) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
141	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
142) {
143	if m.tokenProvider == nil {
144		return next.HandleInitialize(ctx, in)
145	}
146
147	input, ok := in.Parameters.(*SendAnnouncementInput)
148	if !ok {
149		return out, metadata, fmt.Errorf("expected middleware input to be of type *SendAnnouncementInput ")
150	}
151
152	if input.ClientRequestToken == nil {
153		t, err := m.tokenProvider.GetIdempotencyToken()
154		if err != nil {
155			return out, metadata, err
156		}
157		input.ClientRequestToken = &t
158	}
159	return next.HandleInitialize(ctx, in)
160}
161func addIdempotencyToken_opSendAnnouncementMiddleware(stack *middleware.Stack, cfg Options) error {
162	return stack.Initialize.Add(&idempotencyToken_initializeOpSendAnnouncement{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
163}
164
165func newServiceMetadataMiddleware_opSendAnnouncement(region string) *awsmiddleware.RegisterServiceMetadata {
166	return &awsmiddleware.RegisterServiceMetadata{
167		Region:        region,
168		ServiceID:     ServiceID,
169		SigningName:   "a4b",
170		OperationName: "SendAnnouncement",
171	}
172}
173