{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/amazon-iot-core/json-schema/amazon-iot-core-update-security-profile-request-schema.json",
  "title": "UpdateSecurityProfileRequest",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amazon-iot-core-security-profiles-api-openapi.yml#/components/schemas/UpdateSecurityProfileRequest",
  "type": "object",
  "properties": {
    "securityProfileName": {
      "type": "string",
      "description": "The name of the security profile you want to update."
    },
    "securityProfileDescription": {
      "type": "string",
      "description": "A description of the security profile."
    },
    "behaviors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Behavior"
      },
      "description": "Specifies the behaviors that, when violated by a device (thing), cause an alert."
    },
    "alertTargets": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/AlertTarget"
      },
      "description": "Where the alerts are sent. (Alerts are always sent to the console.)"
    },
    "additionalMetricsToRetain": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "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."
    },
    "additionalMetricsToRetainV2": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MetricToRetain"
      },
      "description": "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."
    },
    "deleteBehaviors": {
      "type": "boolean",
      "description": "If true, delete all behaviors defined for this security profile. If any behaviors are defined in the current invocation, an exception occurs."
    },
    "deleteAlertTargets": {
      "type": "boolean",
      "description": "If true, delete all alertTargets defined for this security profile. If any alertTargets are defined in the current invocation, an exception occurs."
    },
    "deleteAdditionalMetricsToRetain": {
      "type": "boolean",
      "description": "If true, delete all additionalMetricsToRetain defined for this security profile. If any additionalMetricsToRetain are defined in the current invocation, an exception occurs."
    },
    "expectedVersion": {
      "type": "integer",
      "description": "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."
    },
    "metricsExportConfig": {
      "$ref": "#/$defs/MetricsExportConfig"
    },
    "deleteMetricsExportConfig": {
      "type": "boolean",
      "description": "Set the value as true to delete metrics export related configurations."
    }
  },
  "required": [
    "securityProfileName"
  ],
  "$defs": {
    "AlertTarget": {
      "type": "object",
      "properties": {
        "alertTargetArn": {
          "type": "string",
          "description": "The Amazon Resource Name (ARN) of the notification target to which alerts are sent."
        },
        "roleArn": {
          "type": "string",
          "description": "The ARN of the role that grants permission to send alerts to the notification target."
        }
      },
      "required": [
        "alertTargetArn",
        "roleArn"
      ]
    },
    "Behavior": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name you've given to the behavior."
        },
        "metric": {
          "type": "string",
          "description": "What is measured by the behavior."
        },
        "metricDimension": {
          "$ref": "#/$defs/MetricDimension"
        },
        "criteria": {
          "$ref": "#/$defs/BehaviorCriteria"
        },
        "suppressAlerts": {
          "type": "boolean",
          "description": "Suppresses alerts."
        },
        "exportMetric": {
          "type": "boolean",
          "description": "Value indicates exporting metrics related to the behavior when it is true."
        }
      },
      "required": [
        "name"
      ]
    },
    "BehaviorCriteria": {
      "type": "object",
      "properties": {
        "comparisonOperator": {
          "type": "string",
          "enum": [
            "less-than",
            "less-than-equals",
            "greater-than",
            "greater-than-equals",
            "in-cidr-set",
            "not-in-cidr-set",
            "in-port-set",
            "not-in-port-set",
            "in-set",
            "not-in-set"
          ],
          "description": "The operator that relates the thing measured (metric) to the criteria (containing a value or statisticalThreshold). Valid operators include: string-list: in-set and not-in-set number-list: in-set and not-in-set ip-address-list: in-cidr-set and not-in-cidr-set number: less-than, less-than-equals, greater-than, and greater-than-equals"
        },
        "value": {
          "$ref": "#/$defs/MetricValue"
        },
        "durationSeconds": {
          "type": "integer",
          "description": "Use this to specify the time duration over which the behavior is evaluated, for those criteria that have a time dimension (for example, NUM_MESSAGES_SENT). For a statisticalThreshhold metric comparison, measurements from all devices are accumulated over this time duration before being used to calculate percentiles, and later, measurements from an individual device are also accumulated over this time duration before being given a percentile rank. Cannot be used with list-based metric datatypes."
        },
        "consecutiveDatapointsToAlarm": {
          "type": "integer",
          "description": "If a device is in violation of the behavior for the specified number of consecutive datapoints, an alarm occurs. If not specified, the default is 1."
        },
        "consecutiveDatapointsToClear": {
          "type": "integer",
          "description": "If an alarm has occurred and the offending device is no longer in violation of the behavior for the specified number of consecutive datapoints, the alarm is cleared. If not specified, the default is 1."
        },
        "statisticalThreshold": {
          "$ref": "#/$defs/StatisticalThreshold"
        },
        "mlDetectionConfig": {
          "$ref": "#/$defs/MachineLearningDetectionConfig"
        }
      }
    },
    "MachineLearningDetectionConfig": {
      "type": "object",
      "properties": {
        "confidenceLevel": {
          "type": "string",
          "enum": [
            "LOW",
            "MEDIUM",
            "HIGH"
          ],
          "description": "The sensitivity of anomalous behavior evaluation. Can be Low, Medium, or High."
        }
      },
      "required": [
        "confidenceLevel"
      ]
    },
    "MetricDimension": {
      "type": "object",
      "properties": {
        "dimensionName": {
          "type": "string",
          "description": "A unique identifier for the dimension."
        },
        "operator": {
          "type": "string",
          "enum": [
            "IN",
            "NOT_IN"
          ],
          "description": "Defines how the dimensionValues of a dimension are interpreted. For example, for dimension type TOPIC_FILTER, the IN operator, a message will be counted only if its topic matches one of the topic filters. With NOT_IN operator, a message will be counted only if it doesn't match any of the topic filters. The operator is optional: if it's not provided (is null), it will be interpreted as IN."
        }
      },
      "required": [
        "dimensionName"
      ]
    },
    "MetricToRetain": {
      "type": "object",
      "properties": {
        "metric": {
          "type": "string",
          "description": "What is measured by the behavior."
        },
        "metricDimension": {
          "$ref": "#/$defs/MetricDimension"
        },
        "exportMetric": {
          "type": "boolean",
          "description": "The value indicates exporting metrics related to the MetricToRetain when it's true."
        }
      },
      "required": [
        "metric"
      ]
    },
    "MetricValue": {
      "type": "object",
      "properties": {
        "count": {
          "type": "integer",
          "description": "If the comparisonOperator calls for a numeric value, use this to specify that numeric value to be compared with the metric."
        },
        "cidrs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "If the comparisonOperator calls for a set of CIDRs, use this to specify that set to be compared with the metric."
        },
        "ports": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "description": "If the comparisonOperator calls for a set of ports, use this to specify that set to be compared with the metric."
        },
        "number": {
          "type": "number",
          "description": "The numeral value of a metric."
        },
        "numbers": {
          "type": "array",
          "items": {
            "type": "number"
          },
          "description": "The numeral values of a metric."
        },
        "strings": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The string values of a metric."
        }
      }
    },
    "MetricsExportConfig": {
      "type": "object",
      "properties": {
        "mqttTopic": {
          "type": "string",
          "description": "The MQTT topic that Device Defender Detect should publish messages to for metrics export."
        },
        "roleArn": {
          "type": "string",
          "description": "This role ARN has permission to publish MQTT messages, after which Device Defender Detect can assume the role and publish messages on your behalf."
        }
      },
      "required": [
        "mqttTopic",
        "roleArn"
      ]
    },
    "StatisticalThreshold": {
      "type": "object",
      "properties": {
        "statistic": {
          "type": "string",
          "description": "The percentile that resolves to a threshold value by which compliance with a behavior is determined. Metrics are collected over the specified period (durationSeconds) from all reporting devices in your account and statistical ranks are calculated. Then, the measurements from a device are collected over the same period. If the accumulated measurements from the device fall above or below (comparisonOperator) the value associated with the percentile specified, then the device is considered to be in compliance with the behavior, otherwise a violation occurs."
        }
      }
    }
  }
}