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.
46 lines
2.1 KiB
46 lines
2.1 KiB
# Copyright (C) 2005-2025 Splunk Inc. All Rights Reserved.
|
|
|
|
import re
|
|
|
|
from ITOA.itoa_object import ItoaObject
|
|
from ITOA.setup_logging import logger
|
|
from ITOA.itoa_common import is_valid_num
|
|
|
|
|
|
class ItsiHomeView(ItoaObject):
|
|
'''
|
|
Implements ITSI home view
|
|
'''
|
|
|
|
log_prefix = '[ITSI Home View] '
|
|
collection_name = 'itsi_service_analyzer'
|
|
service_id_regex = re.compile('^(?!-)([a-zA-Z0-9-_]+?)(?<!-)$')
|
|
|
|
def __init__(self, session_key, current_user_name):
|
|
super(ItsiHomeView, self).__init__(session_key,
|
|
current_user_name,
|
|
'home_view',
|
|
collection_name=self.collection_name,
|
|
title_validation_required=False)
|
|
|
|
def do_object_validation(self, owner, objects, validate_name=True, dupname_tag=None, transaction_id=None,
|
|
skip_local_failure=False):
|
|
super(ItsiHomeView, self).do_object_validation(owner, objects,
|
|
validate_name, dupname_tag, transaction_id, skip_local_failure)
|
|
for json_data in objects:
|
|
# Type check numTiles to make sure it contains integer values
|
|
for key in ['serviceTilesSettings', 'kpiTilesSettings']:
|
|
tile_settings = json_data.get(key)
|
|
if tile_settings and not is_valid_num(tile_settings.get('numTiles')):
|
|
self.raise_error_bad_validation(
|
|
logger, self.log_prefix + 'Set a valid integer for numTiles.'
|
|
)
|
|
|
|
# Validate serviceWhitelist to only contain service ids
|
|
service_ids_list = json_data.get('serviceWhitelist').split(',') if json_data.get('serviceWhitelist') else []
|
|
for service_id in service_ids_list:
|
|
if service_id and not bool(self.service_id_regex.match(service_id.strip())):
|
|
self.raise_error_bad_validation(
|
|
logger, self.log_prefix + 'Set valid comma seperated service ids for serviceWhitelist.'
|
|
)
|