createApprovalRuleTemplate method
Creates a template for approval rules that can then be associated with one or more repositories in your Amazon Web Services account. When you associate a template with a repository, CodeCommit creates an approval rule that matches the conditions of the template for all pull requests that meet the conditions of the template. For more information, see AssociateApprovalRuleTemplateWithRepository.
May throw ApprovalRuleTemplateContentRequiredException.
May throw ApprovalRuleTemplateNameAlreadyExistsException.
May throw ApprovalRuleTemplateNameRequiredException.
May throw InvalidApprovalRuleTemplateContentException.
May throw InvalidApprovalRuleTemplateDescriptionException.
May throw InvalidApprovalRuleTemplateNameException.
May throw NumberOfRuleTemplatesExceededException.
Parameter approvalRuleTemplateContent :
The content of the approval rule that is created on pull requests in
associated repositories. If you specify one or more destination references
(branches), approval rules are created in an associated repository only if
their destination references (branches) match those specified in the
template.
-
CodeCommitApprovers: This option only requires an Amazon Web
Services account and a resource. It can be used for both IAM users and
federated access users whose name matches the provided resource name. This
is a very powerful option that offers a great deal of flexibility. For
example, if you specify the Amazon Web Services account
123456789012 and Mary_Major, all of the following are
counted as approvals coming from that user:
- An IAM user in the account (arn:aws:iam::123456789012:user/Mary_Major)
- A federated user identified in IAM as Mary_Major (arn:aws:sts::123456789012:federated-user/Mary_Major)
- Fully qualified ARN: This option allows you to specify the fully qualified Amazon Resource Name (ARN) of the IAM user or role.
Parameter approvalRuleTemplateName :
The name of the approval rule template. Provide descriptive names, because
this name is applied to the approval rules created automatically in
associated repositories.
Parameter approvalRuleTemplateDescription :
The description of the approval rule template. Consider providing a
description that explains what this template does and when it might be
appropriate to associate it with repositories.
Implementation
Future<CreateApprovalRuleTemplateOutput> createApprovalRuleTemplate({
required String approvalRuleTemplateContent,
required String approvalRuleTemplateName,
String? approvalRuleTemplateDescription,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'CodeCommit_20150413.CreateApprovalRuleTemplate'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'approvalRuleTemplateContent': approvalRuleTemplateContent,
'approvalRuleTemplateName': approvalRuleTemplateName,
if (approvalRuleTemplateDescription != null)
'approvalRuleTemplateDescription': approvalRuleTemplateDescription,
},
);
return CreateApprovalRuleTemplateOutput.fromJson(jsonResponse.body);
}