1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package codecommit
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/codecommit/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Posts a comment in reply to an existing comment on a comparison between commits
16// or a pull request.
17func (c *Client) PostCommentReply(ctx context.Context, params *PostCommentReplyInput, optFns ...func(*Options)) (*PostCommentReplyOutput, error) {
18	if params == nil {
19		params = &PostCommentReplyInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "PostCommentReply", params, optFns, addOperationPostCommentReplyMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*PostCommentReplyOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type PostCommentReplyInput struct {
33
34	// The contents of your reply to a comment.
35	//
36	// This member is required.
37	Content *string
38
39	// The system-generated ID of the comment to which you want to reply. To get this
40	// ID, use GetCommentsForComparedCommit or GetCommentsForPullRequest.
41	//
42	// This member is required.
43	InReplyTo *string
44
45	// A unique, client-generated idempotency token that, when provided in a request,
46	// ensures the request cannot be repeated with a changed parameter. If a request is
47	// received with the same parameters and a token is included, the request returns
48	// information about the initial request that used that token.
49	ClientRequestToken *string
50}
51
52type PostCommentReplyOutput struct {
53
54	// Information about the reply to a comment.
55	Comment *types.Comment
56
57	// Metadata pertaining to the operation's result.
58	ResultMetadata middleware.Metadata
59}
60
61func addOperationPostCommentReplyMiddlewares(stack *middleware.Stack, options Options) (err error) {
62	err = stack.Serialize.Add(&awsAwsjson11_serializeOpPostCommentReply{}, middleware.After)
63	if err != nil {
64		return err
65	}
66	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPostCommentReply{}, middleware.After)
67	if err != nil {
68		return err
69	}
70	if err = addSetLoggerMiddleware(stack, options); err != nil {
71		return err
72	}
73	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
74		return err
75	}
76	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
77		return err
78	}
79	if err = addResolveEndpointMiddleware(stack, options); err != nil {
80		return err
81	}
82	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
83		return err
84	}
85	if err = addRetryMiddlewares(stack, options); err != nil {
86		return err
87	}
88	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
89		return err
90	}
91	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
92		return err
93	}
94	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
95		return err
96	}
97	if err = addClientUserAgent(stack); err != nil {
98		return err
99	}
100	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
104		return err
105	}
106	if err = addIdempotencyToken_opPostCommentReplyMiddleware(stack, options); err != nil {
107		return err
108	}
109	if err = addOpPostCommentReplyValidationMiddleware(stack); err != nil {
110		return err
111	}
112	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPostCommentReply(options.Region), middleware.Before); err != nil {
113		return err
114	}
115	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
116		return err
117	}
118	if err = addResponseErrorMiddleware(stack); err != nil {
119		return err
120	}
121	if err = addRequestResponseLogging(stack, options); err != nil {
122		return err
123	}
124	return nil
125}
126
127type idempotencyToken_initializeOpPostCommentReply struct {
128	tokenProvider IdempotencyTokenProvider
129}
130
131func (*idempotencyToken_initializeOpPostCommentReply) ID() string {
132	return "OperationIdempotencyTokenAutoFill"
133}
134
135func (m *idempotencyToken_initializeOpPostCommentReply) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
136	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
137) {
138	if m.tokenProvider == nil {
139		return next.HandleInitialize(ctx, in)
140	}
141
142	input, ok := in.Parameters.(*PostCommentReplyInput)
143	if !ok {
144		return out, metadata, fmt.Errorf("expected middleware input to be of type *PostCommentReplyInput ")
145	}
146
147	if input.ClientRequestToken == nil {
148		t, err := m.tokenProvider.GetIdempotencyToken()
149		if err != nil {
150			return out, metadata, err
151		}
152		input.ClientRequestToken = &t
153	}
154	return next.HandleInitialize(ctx, in)
155}
156func addIdempotencyToken_opPostCommentReplyMiddleware(stack *middleware.Stack, cfg Options) error {
157	return stack.Initialize.Add(&idempotencyToken_initializeOpPostCommentReply{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
158}
159
160func newServiceMetadataMiddleware_opPostCommentReply(region string) *awsmiddleware.RegisterServiceMetadata {
161	return &awsmiddleware.RegisterServiceMetadata{
162		Region:        region,
163		ServiceID:     ServiceID,
164		SigningName:   "codecommit",
165		OperationName: "PostCommentReply",
166	}
167}
168