Skip to content

update_security_profile async

update_security_profile(
    security_profile_name: SecurityProfileName,
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    security_profile_description: Optional[SecurityProfileDescription] = None,
    behaviors: Optional[Behaviors] = None,
    alert_targets: Optional[AlertTargets] = None,
    additional_metrics_to_retain: Optional[AdditionalMetricsToRetainList] = None,
    additional_metrics_to_retain_v2: Optional[AdditionalMetricsToRetainV2List] = None,
    delete_behaviors: Optional[DeleteBehaviors] = None,
    delete_alert_targets: Optional[DeleteAlertTargets] = None,
    delete_additional_metrics_to_retain: Optional[
        DeleteAdditionalMetricsToRetain
    ] = None,
    expected_version: Optional[OptionalVersion] = None,
    metrics_export_config: Optional[MetricsExportConfig] = None,
    delete_metrics_export_config: Optional[DeleteMetricsExportConfig] = None,
) -> UpdateSecurityProfileResponse

The IoT Device Defender detect feature will no longer be available to new customers starting August 31, 2026. If you would like to use the detect feature, sign up prior to August 31, 2026. To learn about alternatives to IoT Device Defender detect, see IoT Device Defender detect feature availability change in the IoT Device Defender Developer Guide. There is no change to IoT Device Defender audit availability.

Updates a Device Defender security profile.

Requires permission to access the UpdateSecurityProfile action.

Parameters:

  • security_profile_name (SecurityProfileName) –

    The name of the security profile you want to update.

  • security_profile_description (Optional[SecurityProfileDescription], default: None ) –

    A description of the security profile.

  • behaviors (Optional[Behaviors], default: None ) –

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

  • alert_targets (Optional[AlertTargets], default: None ) –

    Where the alerts are sent. (Alerts are always sent to the console.)

  • additional_metrics_to_retain (Optional[AdditionalMetricsToRetainList], default: None ) –

    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.

  • additional_metrics_to_retain_v2 (Optional[AdditionalMetricsToRetainV2List], default: None ) –

    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.

  • delete_behaviors (Optional[DeleteBehaviors], default: None ) –

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

  • delete_alert_targets (Optional[DeleteAlertTargets], default: None ) –

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

  • delete_additional_metrics_to_retain (Optional[DeleteAdditionalMetricsToRetain], default: None ) –

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

  • expected_version (Optional[OptionalVersion], default: None ) –

    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.

  • metrics_export_config (Optional[MetricsExportConfig], default: None ) –

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

  • delete_metrics_export_config (Optional[DeleteMetricsExportConfig], default: None ) –

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

Raises:

Source code in docs_src/capo_iot/_services/async_io_t.py
async def update_security_profile(
    self,
    security_profile_name: "capo_iot.types.security_profile_name.SecurityProfileName",
    *,
    config_overrides: Optional[AsyncIoTClientConfig] = None,
    security_profile_description: Optional[
        "capo_iot.types.security_profile_description.SecurityProfileDescription"
    ] = None,
    behaviors: Optional["capo_iot.types.behaviors.Behaviors"] = None,
    alert_targets: Optional["capo_iot.types.alert_targets.AlertTargets"] = None,
    additional_metrics_to_retain: Optional[
        "capo_iot.types.additional_metrics_to_retain_list.AdditionalMetricsToRetainList"
    ] = None,
    additional_metrics_to_retain_v2: Optional[
        "capo_iot.types.additional_metrics_to_retain_v2_list.AdditionalMetricsToRetainV2List"
    ] = None,
    delete_behaviors: Optional[
        "capo_iot.types.delete_behaviors.DeleteBehaviors"
    ] = None,
    delete_alert_targets: Optional[
        "capo_iot.types.delete_alert_targets.DeleteAlertTargets"
    ] = None,
    delete_additional_metrics_to_retain: Optional[
        "capo_iot.types.delete_additional_metrics_to_retain.DeleteAdditionalMetricsToRetain"
    ] = None,
    expected_version: Optional[
        "capo_iot.types.optional_version.OptionalVersion"
    ] = None,
    metrics_export_config: Optional[
        "capo_iot.types.metrics_export_config.MetricsExportConfig"
    ] = None,
    delete_metrics_export_config: Optional[
        "capo_iot.types.delete_metrics_export_config.DeleteMetricsExportConfig"
    ] = None,
) -> (
    "capo_iot.types.update_security_profile_response.UpdateSecurityProfileResponse"
):
    """<note> <p>The IoT Device Defender detect feature will no longer be available to new customers starting August 31, 2026. If you would like to use the detect feature, sign up prior to August 31, 2026. To learn about alternatives to IoT Device Defender detect, see IoT Device Defender detect feature availability change in the IoT Device Defender Developer Guide. There is no change to IoT Device Defender audit availability.</p> </note> <p>Updates a Device Defender security profile.</p> <p>Requires permission to access the <a href="https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions">UpdateSecurityProfile</a> action.</p>

    Args:
        security_profile_name: <p>The name of the security profile you want to update.</p>
        security_profile_description: <p>A description of the security profile.</p>
        behaviors: <p>Specifies the behaviors that, when violated by a device (thing), cause an alert.</p>
        alert_targets: <p>Where the alerts are sent. (Alerts are always sent to the console.)</p>
        additional_metrics_to_retain: <p> <i>Please use <a>UpdateSecurityProfileRequest$additionalMetricsToRetainV2</a> instead.</i> </p> <p>A list of metrics whose data is retained (stored). By default, data is retained for any metric used in the profile's <code>behaviors</code>, but it is also retained for any metric specified here. Can be used with custom metrics; cannot be used with dimensions.</p>
        additional_metrics_to_retain_v2: <p>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.</p>
        delete_behaviors: <p>If true, delete all <code>behaviors</code> defined for this security profile. If any <code>behaviors</code> are defined in the current invocation, an exception occurs.</p>
        delete_alert_targets: <p>If true, delete all <code>alertTargets</code> defined for this security profile. If any <code>alertTargets</code> are defined in the current invocation, an exception occurs.</p>
        delete_additional_metrics_to_retain: <p>If true, delete all <code>additionalMetricsToRetain</code> defined for this security profile. If any <code>additionalMetricsToRetain</code> are defined in the current invocation, an exception occurs.</p>
        expected_version: <p>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 <code>VersionConflictException</code> is thrown.</p>
        metrics_export_config: <p>Specifies the MQTT topic and role ARN required for metric export.</p>
        delete_metrics_export_config: <p>Set the value as true to delete metrics export related configurations.</p>

    Raises:
        capo_iot.errors.internal_failure_exception.InternalFailureException: <p>An unexpected error has occurred.</p>
        capo_iot.errors.invalid_request_exception.InvalidRequestException: <p>The request is not valid.</p>
        capo_iot.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_iot.errors.throttling_exception.ThrottlingException: <p>The rate exceeds the limit.</p>
        capo_iot.errors.version_conflict_exception.VersionConflictException: <p>An exception thrown when the version of an entity specified with the <code>expectedVersion</code> parameter does not match the latest version in the system.</p>
        capo_iot.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_iot.types.update_security_profile_request.UpdateSecurityProfileRequest]",
    ) -> AsyncOperationResponse[
        "capo_iot.types.update_security_profile_response.UpdateSecurityProfileResponse"
    ]:
        import capo_iot._operations.aws_iot_service.update_security_profile

        (
            output,
            http_response,
        ) = await capo_iot._operations.aws_iot_service.update_security_profile.async_update_security_profile(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateSecurityProfile")
    )
    input_: capo_iot.types.update_security_profile_request.UpdateSecurityProfileRequest = {
        "security_profile_name": security_profile_name
    }
    if security_profile_description is not None:
        input_["security_profile_description"] = security_profile_description
    if behaviors is not None:
        input_["behaviors"] = behaviors
    if alert_targets is not None:
        input_["alert_targets"] = alert_targets
    if additional_metrics_to_retain is not None:
        input_["additional_metrics_to_retain"] = additional_metrics_to_retain
    if additional_metrics_to_retain_v2 is not None:
        input_["additional_metrics_to_retain_v2"] = additional_metrics_to_retain_v2
    if delete_behaviors is not None:
        input_["delete_behaviors"] = delete_behaviors
    if delete_alert_targets is not None:
        input_["delete_alert_targets"] = delete_alert_targets
    if delete_additional_metrics_to_retain is not None:
        input_["delete_additional_metrics_to_retain"] = (
            delete_additional_metrics_to_retain
        )
    if expected_version is not None:
        input_["expected_version"] = expected_version
    if metrics_export_config is not None:
        input_["metrics_export_config"] = metrics_export_config
    if delete_metrics_export_config is not None:
        input_["delete_metrics_export_config"] = delete_metrics_export_config

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output