<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def create( self, policy_id, name, threshold_type, query, since_value, terms, expected_groups=None, value_function=None, runbook_url=None, ignore_overlap=None, enabled=True):
 """ Creates an alert condition nrql :type policy_id: int :param policy_id: Alert policy id where target alert condition nrql belongs to :type name: str :param name: The name of the alert :type threshold_type: str :param type: The threshold_type of the condition, can be static or outlier :type query: str :param query: nrql query for the alerts :type since_value: str :param since_value: since value for the alert :type terms: list[hash] :param terms: list of hashes containing threshold config for the alert :type expected_groups: int :param expected_groups: expected groups setting for outlier alerts :type value_function: str :param type: value function for static alerts :type runbook_url: str :param runbook_url: The url of the runbook :type ignore_overlap: bool :param ignore_overlap: Whether to ignore overlaps for outlier alerts :type enabled: bool :param enabled: Whether to enable that alert condition :rtype: dict :return: The JSON response of the API :raises: This will raise a :class:`NewRelicAPIServerException<newrelic_api.exceptions.NoEntityException>` if target alert condition is not included in target policy :raises: This will raise a :class:`ConfigurationException<newrelic_api.exceptions.ConfigurationException>` if metric is set as user_defined but user_defined config is not passed :: { "nrql_condition": { "name": "string", "runbook_url": "string", "enabled": "boolean", "expected_groups": "integer", "ignore_overlap": "boolean", "value_function": "string", "terms": [ { "duration": "string", "operator": "string", "priority": "string", "threshold": "string", "time_function": "string" } ], "nrql": { "query": "string", "since_value": "string" } } } """


        data = {
            'nrql_condition': {
                'type': threshold_type,
                'name': name,
                'enabled': enabled,
                'terms': terms,
                'nrql': {
                    'query': query,
                    'since_value': since_value
                }
            }
        }

        if runbook_url is not None:
            data['nrql_condition']['runbook_url'] = runbook_url

        if expected_groups is not None:
            data['nrql_condition']['expected_groups'] = expected_groups

        if ignore_overlap is not None:
            data['nrql_condition']['ignore_overlap'] = ignore_overlap

        if value_function is not None:
            data['nrql_condition']['value_function'] = value_function

        if data['nrql_condition']['type'] == 'static':
            if 'value_function' not in data['nrql_condition']:
                raise ConfigurationException(
                    'Alert is set as static but no value_function config specified'
                )
            data['nrql_condition'].pop('expected_groups', None)
            data['nrql_condition'].pop('ignore_overlap', None)

        elif data['nrql_condition']['type'] == 'outlier':
            if 'expected_groups' not in data['nrql_condition']:
                raise ConfigurationException(
                    'Alert is set as outlier but expected_groups config is not specified'
                )
            if 'ignore_overlap' not in data['nrql_condition']:
                raise ConfigurationException(
                    'Alert is set as outlier but ignore_overlap config is not  specified'
                )
            data['nrql_condition'].pop('value_function', None)

        return self._post(
            url='{0}alerts_nrql_conditions/policies/{1}.json'.format(self.URL, policy_id),
            headers=self.headers,
            data=data
        )