1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package pinpoint
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/pinpoint/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Updates an existing message template for messages that are sent through the
15// email channel.
16func (c *Client) UpdateEmailTemplate(ctx context.Context, params *UpdateEmailTemplateInput, optFns ...func(*Options)) (*UpdateEmailTemplateOutput, error) {
17	if params == nil {
18		params = &UpdateEmailTemplateInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "UpdateEmailTemplate", params, optFns, addOperationUpdateEmailTemplateMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*UpdateEmailTemplateOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type UpdateEmailTemplateInput struct {
32
33	// Specifies the content and settings for a message template that can be used in
34	// messages that are sent through the email channel.
35	//
36	// This member is required.
37	EmailTemplateRequest *types.EmailTemplateRequest
38
39	// The name of the message template. A template name must start with an
40	// alphanumeric character and can contain a maximum of 128 characters. The
41	// characters can be alphanumeric characters, underscores (_), or hyphens (-).
42	// Template names are case sensitive.
43	//
44	// This member is required.
45	TemplateName *string
46
47	// Specifies whether to save the updates as a new version of the message template.
48	// Valid values are: true, save the updates as a new version; and, false, save the
49	// updates to (overwrite) the latest existing version of the template. If you don't
50	// specify a value for this parameter, Amazon Pinpoint saves the updates to
51	// (overwrites) the latest existing version of the template. If you specify a value
52	// of true for this parameter, don't specify a value for the version parameter.
53	// Otherwise, an error will occur.
54	CreateNewVersion bool
55
56	// The unique identifier for the version of the message template to update,
57	// retrieve information about, or delete. To retrieve identifiers and other
58	// information for all the versions of a template, use the Template Versions
59	// resource. If specified, this value must match the identifier for an existing
60	// template version. If specified for an update operation, this value must match
61	// the identifier for the latest existing version of the template. This restriction
62	// helps ensure that race conditions don't occur. If you don't specify a value for
63	// this parameter, Amazon Pinpoint does the following:
64	//
65	// * For a get operation,
66	// retrieves information about the active version of the template.
67	//
68	// * For an update
69	// operation, saves the updates to (overwrites) the latest existing version of the
70	// template, if the create-new-version parameter isn't used or is set to false.
71	//
72	// *
73	// For a delete operation, deletes the template, including all versions of the
74	// template.
75	Version *string
76}
77
78type UpdateEmailTemplateOutput struct {
79
80	// Provides information about an API request or response.
81	//
82	// This member is required.
83	MessageBody *types.MessageBody
84
85	// Metadata pertaining to the operation's result.
86	ResultMetadata middleware.Metadata
87}
88
89func addOperationUpdateEmailTemplateMiddlewares(stack *middleware.Stack, options Options) (err error) {
90	err = stack.Serialize.Add(&awsRestjson1_serializeOpUpdateEmailTemplate{}, middleware.After)
91	if err != nil {
92		return err
93	}
94	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpUpdateEmailTemplate{}, middleware.After)
95	if err != nil {
96		return err
97	}
98	if err = addSetLoggerMiddleware(stack, options); err != nil {
99		return err
100	}
101	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
102		return err
103	}
104	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
105		return err
106	}
107	if err = addResolveEndpointMiddleware(stack, options); err != nil {
108		return err
109	}
110	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
111		return err
112	}
113	if err = addRetryMiddlewares(stack, options); err != nil {
114		return err
115	}
116	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
120		return err
121	}
122	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
123		return err
124	}
125	if err = addClientUserAgent(stack); err != nil {
126		return err
127	}
128	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
129		return err
130	}
131	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
132		return err
133	}
134	if err = addOpUpdateEmailTemplateValidationMiddleware(stack); err != nil {
135		return err
136	}
137	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateEmailTemplate(options.Region), middleware.Before); err != nil {
138		return err
139	}
140	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addResponseErrorMiddleware(stack); err != nil {
144		return err
145	}
146	if err = addRequestResponseLogging(stack, options); err != nil {
147		return err
148	}
149	return nil
150}
151
152func newServiceMetadataMiddleware_opUpdateEmailTemplate(region string) *awsmiddleware.RegisterServiceMetadata {
153	return &awsmiddleware.RegisterServiceMetadata{
154		Region:        region,
155		ServiceID:     ServiceID,
156		SigningName:   "mobiletargeting",
157		OperationName: "UpdateEmailTemplate",
158	}
159}
160