createAssessmentTemplate method
Creates an assessment template for the assessment target that is specified by the ARN of the assessment target. If the service-linked role isn’t already registered, this action also creates and registers a service-linked role to grant Amazon Inspector access to AWS Services needed to perform security assessments.
May throw InternalException. May throw InvalidInputException. May throw LimitExceededException. May throw AccessDeniedException. May throw NoSuchEntityException. May throw ServiceTemporarilyUnavailableException.
Parameter assessmentTargetArn
:
The ARN that specifies the assessment target for which you want to create
the assessment template.
Parameter assessmentTemplateName
:
The user-defined name that identifies the assessment template that you
want to create. You can create several assessment templates for an
assessment target. The names of the assessment templates that correspond
to a particular assessment target must be unique.
Parameter durationInSeconds
:
The duration of the assessment run in seconds.
Parameter rulesPackageArns
:
The ARNs that specify the rules packages that you want to attach to the
assessment template.
Parameter userAttributesForFindings
:
The user-defined attributes that are assigned to every finding that is
generated by the assessment run that uses this assessment template. An
attribute is a key and value pair (an Attribute object). Within an
assessment template, each key must be unique.
Implementation
Future<CreateAssessmentTemplateResponse> createAssessmentTemplate({
required String assessmentTargetArn,
required String assessmentTemplateName,
required int durationInSeconds,
required List<String> rulesPackageArns,
List<Attribute>? userAttributesForFindings,
}) async {
ArgumentError.checkNotNull(assessmentTargetArn, 'assessmentTargetArn');
_s.validateStringLength(
'assessmentTargetArn',
assessmentTargetArn,
1,
300,
isRequired: true,
);
ArgumentError.checkNotNull(
assessmentTemplateName, 'assessmentTemplateName');
_s.validateStringLength(
'assessmentTemplateName',
assessmentTemplateName,
1,
140,
isRequired: true,
);
ArgumentError.checkNotNull(durationInSeconds, 'durationInSeconds');
_s.validateNumRange(
'durationInSeconds',
durationInSeconds,
180,
86400,
isRequired: true,
);
ArgumentError.checkNotNull(rulesPackageArns, 'rulesPackageArns');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'InspectorService.CreateAssessmentTemplate'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'assessmentTargetArn': assessmentTargetArn,
'assessmentTemplateName': assessmentTemplateName,
'durationInSeconds': durationInSeconds,
'rulesPackageArns': rulesPackageArns,
if (userAttributesForFindings != null)
'userAttributesForFindings': userAttributesForFindings,
},
);
return CreateAssessmentTemplateResponse.fromJson(jsonResponse.body);
}