You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.6 KiB

# Copyright (C) 2005-2024 Splunk Inc. All Rights Reserved.
from ITOA.itoa_object import ItoaObject
from ITOA.setup_logging import logger
class ItsiKpiEntityThreshold(ItoaObject):
'''
Implements ITSI KPI Entity Threshold for Entity level Adaptive Thresholding
'''
log_prefix = '[ITSI KPI Entity Threshold] '
collection_name = 'itsi_entity_thresholds'
# TODO: Make this object Securable
def __init__(self, session_key, current_user_name):
super(ItsiKpiEntityThreshold, self).__init__(
session_key, current_user_name, 'kpi_entity_threshold', collection_name=self.collection_name,
is_securable_object=False, title_validation_required=False)
def do_object_validation(self, owner, objects, validate_name=True, dupname_tag=None, transaction_id=None,
skip_local_failure=False, ignore_same_key=False):
super(ItsiKpiEntityThreshold, self).do_object_validation(owner, objects, validate_name, dupname_tag, transaction_id=transaction_id)
for json_data in objects:
if not (json_data.get('kpi_id', None) and json_data.get('entity_title', None)):
self.raise_error_bad_validation(logger,
'KPI Id and Entity Title are required for the object_type: {}.'.format(self.object_type))
json_data["entity_key"] = json_data.get('entity_key', 'N/A')
# TODO: Update super delete_bulk method for performance improment
def delete_bulk(
self,
owner,
filter_data=None,
req_source='unknown',
transaction_id=None
):
"""
Overwrites ItoaObject.delete_bulk() to remove dependency checks and only remove objects
Deletes objects matching criteria, if no filtering specified, deletes all objects of this object type
@type owner: string
@param owner: user who is performing this operation
@type filter_data: dictionary
@param filter_data: json filter constructed to filter data. Follows mongodb syntax
@type req_source: string
@param req_source: identified source initiating the operation
@return: none, throws exceptions on errors
"""
# Delete all the filtered objects
self.storage_interface.delete_all(
self.session_key,
owner,
self.object_type,
filter_data=filter_data,
current_user_name=self.current_user_name
)
logger.debug(
'Objects of type %s deleted, request source: %s' % (self.object_type, req_source))