createSecurityProfile method
- required String securityProfileName,
- List<
String> ? additionalMetricsToRetain, - List<
MetricToRetain> ? additionalMetricsToRetainV2, - Map<
AlertTargetType, AlertTarget> ? alertTargets, - List<
Behavior> ? behaviors, - String? securityProfileDescription,
- List<
Tag> ? tags,
Creates a Device Defender security profile.
May throw InvalidRequestException. May throw ResourceAlreadyExistsException. May throw ThrottlingException. May throw InternalFailureException.
Parameter securityProfileName :
The name you are giving to the security profile.
Parameter additionalMetricsToRetain :
Please use
CreateSecurityProfileRequest$additionalMetricsToRetainV2
instead.
A list of metrics whose data is retained (stored). By default, data is
retained for any metric used in the profile's behaviors, but
it is also retained for any metric specified here. Can be used with custom
metrics; cannot be used with dimensions.
Parameter additionalMetricsToRetainV2 :
A list of metrics whose data is retained (stored). By default, data is
retained for any metric used in the profile's behaviors, but
it is also retained for any metric specified here. Can be used with custom
metrics; cannot be used with dimensions.
Parameter alertTargets :
Specifies the destinations to which alerts are sent. (Alerts are always
sent to the console.) Alerts are generated when a device (thing) violates
a behavior.
Parameter behaviors :
Specifies the behaviors that, when violated by a device (thing), cause an
alert.
Parameter securityProfileDescription :
A description of the security profile.
Parameter tags :
Metadata that can be used to manage the security profile.
Implementation
Future<CreateSecurityProfileResponse> createSecurityProfile({
required String securityProfileName,
List<String>? additionalMetricsToRetain,
List<MetricToRetain>? additionalMetricsToRetainV2,
Map<AlertTargetType, AlertTarget>? alertTargets,
List<Behavior>? behaviors,
String? securityProfileDescription,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(securityProfileName, 'securityProfileName');
_s.validateStringLength(
'securityProfileName',
securityProfileName,
1,
128,
isRequired: true,
);
_s.validateStringLength(
'securityProfileDescription',
securityProfileDescription,
0,
1000,
);
final $payload = <String, dynamic>{
if (additionalMetricsToRetain != null)
'additionalMetricsToRetain': additionalMetricsToRetain,
if (additionalMetricsToRetainV2 != null)
'additionalMetricsToRetainV2': additionalMetricsToRetainV2,
if (alertTargets != null)
'alertTargets': alertTargets.map((k, e) => MapEntry(k.toValue(), e)),
if (behaviors != null) 'behaviors': behaviors,
if (securityProfileDescription != null)
'securityProfileDescription': securityProfileDescription,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/security-profiles/${Uri.encodeComponent(securityProfileName)}',
exceptionFnMap: _exceptionFns,
);
return CreateSecurityProfileResponse.fromJson(response);
}