updateApprovalRuleTemplateContent method

Future<UpdateApprovalRuleTemplateContentOutput> updateApprovalRuleTemplateContent({
  1. required String approvalRuleTemplateName,
  2. required String newRuleContent,
  3. String? existingRuleContentSha256,
})

Updates the content of an approval rule template. You can change the number of required approvals, the membership of the approval rule, and whether an approval pool is defined.

May throw InvalidApprovalRuleTemplateNameException. May throw ApprovalRuleTemplateNameRequiredException. May throw ApprovalRuleTemplateDoesNotExistException. May throw InvalidApprovalRuleTemplateContentException. May throw InvalidRuleContentSha256Exception. May throw ApprovalRuleTemplateContentRequiredException.

Parameter approvalRuleTemplateName : The name of the approval rule template where you want to update the content of the rule.

Parameter newRuleContent : The content that replaces the existing content of the rule. Content statements must be complete. You cannot provide only the changes.

Parameter existingRuleContentSha256 : The SHA-256 hash signature for the content of the approval rule. You can retrieve this information by using GetPullRequest.

Implementation

Future<UpdateApprovalRuleTemplateContentOutput>
    updateApprovalRuleTemplateContent({
  required String approvalRuleTemplateName,
  required String newRuleContent,
  String? existingRuleContentSha256,
}) async {
  ArgumentError.checkNotNull(
      approvalRuleTemplateName, 'approvalRuleTemplateName');
  _s.validateStringLength(
    'approvalRuleTemplateName',
    approvalRuleTemplateName,
    1,
    100,
    isRequired: true,
  );
  ArgumentError.checkNotNull(newRuleContent, 'newRuleContent');
  _s.validateStringLength(
    'newRuleContent',
    newRuleContent,
    1,
    3000,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'CodeCommit_20150413.UpdateApprovalRuleTemplateContent'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'approvalRuleTemplateName': approvalRuleTemplateName,
      'newRuleContent': newRuleContent,
      if (existingRuleContentSha256 != null)
        'existingRuleContentSha256': existingRuleContentSha256,
    },
  );

  return UpdateApprovalRuleTemplateContentOutput.fromJson(jsonResponse.body);
}