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. int? expectedVersion,
  10. String? securityProfileDescription,
})

Updates a Device Defender security profile.

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

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 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 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,
  int? expectedVersion,
  String? securityProfileDescription,
}) async {
  ArgumentError.checkNotNull(securityProfileName, 'securityProfileName');
  _s.validateStringLength(
    'securityProfileName',
    securityProfileName,
    1,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'securityProfileDescription',
    securityProfileDescription,
    0,
    1000,
  );
  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.toValue(), e)),
    if (behaviors != null) 'behaviors': behaviors,
    if (deleteAdditionalMetricsToRetain != null)
      'deleteAdditionalMetricsToRetain': deleteAdditionalMetricsToRetain,
    if (deleteAlertTargets != null) 'deleteAlertTargets': deleteAlertTargets,
    if (deleteBehaviors != null) 'deleteBehaviors': deleteBehaviors,
    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);
}