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 on a pull request. 16func (c *Client) PostCommentForPullRequest(ctx context.Context, params *PostCommentForPullRequestInput, optFns ...func(*Options)) (*PostCommentForPullRequestOutput, error) { 17 if params == nil { 18 params = &PostCommentForPullRequestInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "PostCommentForPullRequest", params, optFns, addOperationPostCommentForPullRequestMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*PostCommentForPullRequestOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type PostCommentForPullRequestInput struct { 32 33 // The full commit ID of the commit in the source branch that is the current tip of 34 // the branch for the pull request when you post the comment. 35 // 36 // This member is required. 37 AfterCommitId *string 38 39 // The full commit ID of the commit in the destination branch that was the tip of 40 // the branch at the time the pull request was created. 41 // 42 // This member is required. 43 BeforeCommitId *string 44 45 // The content of your comment on the change. 46 // 47 // This member is required. 48 Content *string 49 50 // The system-generated ID of the pull request. To get this ID, use 51 // ListPullRequests. 52 // 53 // This member is required. 54 PullRequestId *string 55 56 // The name of the repository where you want to post a comment on a pull request. 57 // 58 // This member is required. 59 RepositoryName *string 60 61 // A unique, client-generated idempotency token that, when provided in a request, 62 // ensures the request cannot be repeated with a changed parameter. If a request is 63 // received with the same parameters and a token is included, the request returns 64 // information about the initial request that used that token. 65 ClientRequestToken *string 66 67 // The location of the change where you want to post your comment. If no location 68 // is provided, the comment is posted as a general comment on the pull request 69 // difference between the before commit ID and the after commit ID. 70 Location *types.Location 71} 72 73type PostCommentForPullRequestOutput struct { 74 75 // In the directionality of the pull request, the blob ID of the after blob. 76 AfterBlobId *string 77 78 // The full commit ID of the commit in the destination branch where the pull 79 // request is merged. 80 AfterCommitId *string 81 82 // In the directionality of the pull request, the blob ID of the before blob. 83 BeforeBlobId *string 84 85 // The full commit ID of the commit in the source branch used to create the pull 86 // request, or in the case of an updated pull request, the full commit ID of the 87 // commit used to update the pull request. 88 BeforeCommitId *string 89 90 // The content of the comment you posted. 91 Comment *types.Comment 92 93 // The location of the change where you posted your comment. 94 Location *types.Location 95 96 // The system-generated ID of the pull request. 97 PullRequestId *string 98 99 // The name of the repository where you posted a comment on a pull request. 100 RepositoryName *string 101 102 // Metadata pertaining to the operation's result. 103 ResultMetadata middleware.Metadata 104} 105 106func addOperationPostCommentForPullRequestMiddlewares(stack *middleware.Stack, options Options) (err error) { 107 err = stack.Serialize.Add(&awsAwsjson11_serializeOpPostCommentForPullRequest{}, middleware.After) 108 if err != nil { 109 return err 110 } 111 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPostCommentForPullRequest{}, middleware.After) 112 if err != nil { 113 return err 114 } 115 if err = addSetLoggerMiddleware(stack, options); err != nil { 116 return err 117 } 118 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 119 return err 120 } 121 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addResolveEndpointMiddleware(stack, options); err != nil { 125 return err 126 } 127 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 128 return err 129 } 130 if err = addRetryMiddlewares(stack, options); err != nil { 131 return err 132 } 133 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 134 return err 135 } 136 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 137 return err 138 } 139 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 140 return err 141 } 142 if err = addClientUserAgent(stack); err != nil { 143 return err 144 } 145 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 146 return err 147 } 148 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 149 return err 150 } 151 if err = addIdempotencyToken_opPostCommentForPullRequestMiddleware(stack, options); err != nil { 152 return err 153 } 154 if err = addOpPostCommentForPullRequestValidationMiddleware(stack); err != nil { 155 return err 156 } 157 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPostCommentForPullRequest(options.Region), middleware.Before); err != nil { 158 return err 159 } 160 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 161 return err 162 } 163 if err = addResponseErrorMiddleware(stack); err != nil { 164 return err 165 } 166 if err = addRequestResponseLogging(stack, options); err != nil { 167 return err 168 } 169 return nil 170} 171 172type idempotencyToken_initializeOpPostCommentForPullRequest struct { 173 tokenProvider IdempotencyTokenProvider 174} 175 176func (*idempotencyToken_initializeOpPostCommentForPullRequest) ID() string { 177 return "OperationIdempotencyTokenAutoFill" 178} 179 180func (m *idempotencyToken_initializeOpPostCommentForPullRequest) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 181 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 182) { 183 if m.tokenProvider == nil { 184 return next.HandleInitialize(ctx, in) 185 } 186 187 input, ok := in.Parameters.(*PostCommentForPullRequestInput) 188 if !ok { 189 return out, metadata, fmt.Errorf("expected middleware input to be of type *PostCommentForPullRequestInput ") 190 } 191 192 if input.ClientRequestToken == nil { 193 t, err := m.tokenProvider.GetIdempotencyToken() 194 if err != nil { 195 return out, metadata, err 196 } 197 input.ClientRequestToken = &t 198 } 199 return next.HandleInitialize(ctx, in) 200} 201func addIdempotencyToken_opPostCommentForPullRequestMiddleware(stack *middleware.Stack, cfg Options) error { 202 return stack.Initialize.Add(&idempotencyToken_initializeOpPostCommentForPullRequest{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 203} 204 205func newServiceMetadataMiddleware_opPostCommentForPullRequest(region string) *awsmiddleware.RegisterServiceMetadata { 206 return &awsmiddleware.RegisterServiceMetadata{ 207 Region: region, 208 ServiceID: ServiceID, 209 SigningName: "codecommit", 210 OperationName: "PostCommentForPullRequest", 211 } 212} 213