updateSecurityProfile method

Future<UpdateSecurityProfileResponse> updateSecurityProfile({
  1. required String securityProfileName,
  2. List<String>? additionalMetricsToRetain,
  3. List<MetricToRetain>? additionalMetricsToRetainV2,
  4. Map<AlertTargetType, AlertTarget>? alertTargets,
  5. List<Behavior>? behaviors,
  6. bool? deleteAdditionalMetricsToRetain,
  7. bool? deleteAlertTargets,
  8. bool? deleteBehaviors,
  9. bool? deleteMetricsExportConfig,
  10. int? expectedVersion,
  11. MetricsExportConfig? metricsExportConfig,
  12. String? securityProfileDescription,
})

Updates a Device Defender security profile.

Requires permission to access the UpdateSecurityProfile action.

May throw InternalFailureException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw VersionConflictException.

Parameter securityProfileName : The name of the security profile you want to update.

Parameter additionalMetricsToRetain : Please use UpdateSecurityProfileRequest$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 : Where the alerts are sent. (Alerts are always sent to the console.)

Parameter behaviors : Specifies the behaviors that, when violated by a device (thing), cause an alert.

Parameter deleteAdditionalMetricsToRetain : If true, delete all additionalMetricsToRetain defined for this security profile. If any additionalMetricsToRetain are defined in the current invocation, an exception occurs.

Parameter deleteAlertTargets : If true, delete all alertTargets defined for this security profile. If any alertTargets are defined in the current invocation, an exception occurs.

Parameter deleteBehaviors : If true, delete all behaviors defined for this security profile. If any behaviors are defined in the current invocation, an exception occurs.

Parameter deleteMetricsExportConfig : Set the value as true to delete metrics export related configurations.

Parameter expectedVersion : The expected version of the security profile. A new version is generated whenever the security profile is updated. If you specify a value that is different from the actual version, a VersionConflictException is thrown.

Parameter metricsExportConfig : Specifies the MQTT topic and role ARN required for metric export.

Parameter securityProfileDescription : A description of the security profile.

Implementation

Future<UpdateSecurityProfileResponse> updateSecurityProfile({
  required String securityProfileName,
  List<String>? additionalMetricsToRetain,
  List<MetricToRetain>? additionalMetricsToRetainV2,
  Map<AlertTargetType, AlertTarget>? alertTargets,
  List<Behavior>? behaviors,
  bool? deleteAdditionalMetricsToRetain,
  bool? deleteAlertTargets,
  bool? deleteBehaviors,
  bool? deleteMetricsExportConfig,
  int? expectedVersion,
  MetricsExportConfig? metricsExportConfig,
  String? securityProfileDescription,
}) async {
  final $query = <String, List<String>>{
    if (expectedVersion != null)
      'expectedVersion': [expectedVersion.toString()],
  };
  final $payload = <String, dynamic>{
    if (additionalMetricsToRetain != null)
      'additionalMetricsToRetain': additionalMetricsToRetain,
    if (additionalMetricsToRetainV2 != null)
      'additionalMetricsToRetainV2': additionalMetricsToRetainV2,
    if (alertTargets != null)
      'alertTargets': alertTargets.map((k, e) => MapEntry(k.value, e)),
    if (behaviors != null) 'behaviors': behaviors,
    if (deleteAdditionalMetricsToRetain != null)
      'deleteAdditionalMetricsToRetain': deleteAdditionalMetricsToRetain,
    if (deleteAlertTargets != null) 'deleteAlertTargets': deleteAlertTargets,
    if (deleteBehaviors != null) 'deleteBehaviors': deleteBehaviors,
    if (deleteMetricsExportConfig != null)
      'deleteMetricsExportConfig': deleteMetricsExportConfig,
    if (metricsExportConfig != null)
      'metricsExportConfig': metricsExportConfig,
    if (securityProfileDescription != null)
      'securityProfileDescription': securityProfileDescription,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PATCH',
    requestUri:
        '/security-profiles/${Uri.encodeComponent(securityProfileName)}',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  return UpdateSecurityProfileResponse.fromJson(response);
}