# coding: utf-8
# Copyright (c) 2016, 2026, Oracle and/or its affiliates.  All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.

# NOTE: This class is auto generated by OracleSDKGenerator. DO NOT EDIT. API Version: 20190101

from .target_scaling_configuration import TargetScalingConfiguration
from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel  # noqa: F401
from oci.decorators import init_model_state_from_kwargs


@init_model_state_from_kwargs
class TargetCustomExpressionQueryScalingConfiguration(TargetScalingConfiguration):
    """
    The scaling configuration for the custom expression query for the workload.
    """

    def __init__(self, **kwargs):
        """
        Initializes a new TargetCustomExpressionQueryScalingConfiguration object with values from keyword arguments. The default value of the :py:attr:`~oci.data_science.models.TargetCustomExpressionQueryScalingConfiguration.target_scaling_configuration_type` attribute
        of this class is ``QUERY`` and it should not be changed.
        The following keyword arguments are supported (corresponding to the getters/setters of this class):

        :param target_scaling_configuration_type:
            The value to assign to the target_scaling_configuration_type property of this TargetCustomExpressionQueryScalingConfiguration.
            Allowed values for this property are: "THRESHOLD", "QUERY", 'UNKNOWN_ENUM_VALUE'.
            Any unrecognized values returned by a service will be mapped to 'UNKNOWN_ENUM_VALUE'.
        :type target_scaling_configuration_type: str

        :param query:
            The value to assign to the query property of this TargetCustomExpressionQueryScalingConfiguration.
        :type query: str

        :param threshold:
            The value to assign to the threshold property of this TargetCustomExpressionQueryScalingConfiguration.
        :type threshold: float

        :param metric_namespace:
            The value to assign to the metric_namespace property of this TargetCustomExpressionQueryScalingConfiguration.
        :type metric_namespace: str

        """
        self.swagger_types = {
            'target_scaling_configuration_type': 'str',
            'query': 'str',
            'threshold': 'float',
            'metric_namespace': 'str'
        }
        self.attribute_map = {
            'target_scaling_configuration_type': 'targetScalingConfigurationType',
            'query': 'query',
            'threshold': 'threshold',
            'metric_namespace': 'metricNamespace'
        }
        self._target_scaling_configuration_type = None
        self._query = None
        self._threshold = None
        self._metric_namespace = None
        self._target_scaling_configuration_type = 'QUERY'

    @property
    def query(self):
        """
        **[Required]** Gets the query of this TargetCustomExpressionQueryScalingConfiguration.
        The Monitoring Query Language (MQL) expression to evaluate for the alarm. The Alarms feature of the Monitoring service
        interprets results for each returned time series as Boolean values, where zero represents false and a non-zero value
        represents true. A true value means that the trigger rule condition has been met. The query must specify a metric,
        statistic, interval, and trigger rule (threshold or absence). Supported values for interval: 1m-60m (also 1h).
        You can optionally specify dimensions and grouping functions. Supported grouping functions: grouping(), groupBy().
        Example of threshold alarm:
          ```
          CPUUtilization[1m]{resourceId = \"Model_Deployment_OCID\"}.grouping().mean() < 25
          CPUUtilization[1m]{resourceId = \"Model_Deployment_OCID\"}.grouping().mean() > 75
          ```


        :return: The query of this TargetCustomExpressionQueryScalingConfiguration.
        :rtype: str
        """
        return self._query

    @query.setter
    def query(self, query):
        """
        Sets the query of this TargetCustomExpressionQueryScalingConfiguration.
        The Monitoring Query Language (MQL) expression to evaluate for the alarm. The Alarms feature of the Monitoring service
        interprets results for each returned time series as Boolean values, where zero represents false and a non-zero value
        represents true. A true value means that the trigger rule condition has been met. The query must specify a metric,
        statistic, interval, and trigger rule (threshold or absence). Supported values for interval: 1m-60m (also 1h).
        You can optionally specify dimensions and grouping functions. Supported grouping functions: grouping(), groupBy().
        Example of threshold alarm:
          ```
          CPUUtilization[1m]{resourceId = \"Model_Deployment_OCID\"}.grouping().mean() < 25
          CPUUtilization[1m]{resourceId = \"Model_Deployment_OCID\"}.grouping().mean() > 75
          ```


        :param query: The query of this TargetCustomExpressionQueryScalingConfiguration.
        :type: str
        """
        self._query = query

    @property
    def threshold(self):
        """
        **[Required]** Gets the threshold of this TargetCustomExpressionQueryScalingConfiguration.
        A metric value at which the scaling operation will be triggered.


        :return: The threshold of this TargetCustomExpressionQueryScalingConfiguration.
        :rtype: float
        """
        return self._threshold

    @threshold.setter
    def threshold(self, threshold):
        """
        Sets the threshold of this TargetCustomExpressionQueryScalingConfiguration.
        A metric value at which the scaling operation will be triggered.


        :param threshold: The threshold of this TargetCustomExpressionQueryScalingConfiguration.
        :type: float
        """
        self._threshold = threshold

    @property
    def metric_namespace(self):
        """
        Gets the metric_namespace of this TargetCustomExpressionQueryScalingConfiguration.
        Namespace to read the metrics from. Default value will be service metric namespace.


        :return: The metric_namespace of this TargetCustomExpressionQueryScalingConfiguration.
        :rtype: str
        """
        return self._metric_namespace

    @metric_namespace.setter
    def metric_namespace(self, metric_namespace):
        """
        Sets the metric_namespace of this TargetCustomExpressionQueryScalingConfiguration.
        Namespace to read the metrics from. Default value will be service metric namespace.


        :param metric_namespace: The metric_namespace of this TargetCustomExpressionQueryScalingConfiguration.
        :type: str
        """
        self._metric_namespace = metric_namespace

    def __repr__(self):
        return formatted_flat_dict(self)

    def __eq__(self, other):
        if other is None:
            return False

        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not self == other
