当前位置: 首页>>代码示例>>Python>>正文


Python SavedSearch.get方法代码示例

本文整理汇总了Python中splunk.models.saved_search.SavedSearch.get方法的典型用法代码示例。如果您正苦于以下问题:Python SavedSearch.get方法的具体用法?Python SavedSearch.get怎么用?Python SavedSearch.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在splunk.models.saved_search.SavedSearch的用法示例。


在下文中一共展示了SavedSearch.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: step3_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
    def step3_update(self, app, step, action, **params):
        # saved search models
        saved_search = SavedSearch.get(params.get('id'))
        schedule_type = params.get('schedule_type')
        saved_search.schedule.is_scheduled = True
        saved_search.is_disabled = False
        if schedule_type=='preset':
            alert_preset = params.get('alert_preset')
            if alert_preset=='cron':
                saved_search.schedule.cron_schedule = params.get('alert_cron')
            else:
                saved_search.schedule.cron_schedule = alert_preset
        elif schedule_type=='never':
            saved_search.schedule.is_scheduled = False
            saved_search.schedule.cron_schedule = None
        elif schedule_type=='continuous':
            saved_search.schedule.cron_schedule = '* * * * *'

        # dashboard model
        dashboard = Dashboard.get(params.get('dashboard_id'))
        panel_type = params.get('panel_type', 'event')
        dashboard.create_panel(panel_type, saved_search=saved_search.name, title=params.get('panel_title'))

        if saved_search.passive_save() and dashboard.passive_save():
            # update saved search only on save success         
            raise cherrypy.HTTPRedirect(self.make_url(['dashboardwizard', app, 'success'], _qs=dict(search_id=saved_search.id, dashboard_id=dashboard.id)), 303)
        template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboard_action=params.get('dashboard_action'))
        return self.render_template('dashboardwizard/step3.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:30,代码来源:dashboardwizard.py

示例2: get_headlines_detail

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
    def get_headlines_detail(self, headlines, app, user, count, earliest, severity=None, srtd=None):
        search_string = "" 
        sorted_list = []
        if earliest is not None: 
            search_string = search_string + ' trigger_time > ' + str(self.get_time(earliest))

        for headline in headlines:
            try:
                s = SavedSearch.get(SavedSearch.build_id(headline.alert_name, app, user))
                alerts = None
                if s.alert.severity in severity:
                    alerts = s.get_alerts()
                if alerts is not None:
                    if len(search_string) > 0:
                        alerts.search(search_string)
                    for alert in alerts:
                        h = {'message'   : self.replace_tokens(headline.message, alert.sid), 
                             'job_id'    : alert.sid,
                             'severity'  : s.alert.severity,
                             'count'     : alert.triggered_alerts,
                             'time'      : alert.trigger_time.strftime('%s'),
                             'timesince' : timesince(alert.trigger_time)}
                        sorted_list.append(h)
            except Exception, ex:
                logger.warn('problem retreiving alerts for saved search %s' % headline.alert_name) 
                logger.debug(ex)
开发者ID:parth88,项目名称:GitHub,代码行数:28,代码来源:unixheadlines.py

示例3: step2_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step2_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get("id"))
     saved_search.update(params)
     saved_search.action.email.enabled = False if params.get("action.email.enabled") is None else True
     if saved_search.action.email.enabled is False:
         saved_search.action.email.to = None
     saved_search.action.script.enabled = False if params.get("action.script.enabled") is None else True
     saved_search.alert.track = False if params.get("alert.track") is None else True
     saved_search.alert.suppress.enabled = False if params.get("alert.suppress.enabled") is None else True
     if (
         saved_search.action.email.enabled is False
         and saved_search.action.script.enabled is False
         and saved_search.alert.track is False
     ):
         saved_search.errors.append(_("Enable at least one action."))
     self.step2_from_ui(params, saved_search)
     if not saved_search.errors and saved_search.passive_save():
         raise cherrypy.HTTPRedirect(
             self.make_url(["alertswizardv2", app, "step3"], _qs=dict(id=saved_search.id)), 303
         )
     for idx, error in enumerate(saved_search.errors):
         if error == "action.email.to is required if email action is enabled":
             saved_search.errors[idx] = _("Provide at least one address for scheduled report emails.")
     self.step1_to_ui(saved_search)
     self.step2_to_ui(saved_search)
     return self.render_template("alertswizardv2/step2.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:28,代码来源:alertswizardv2.py

示例4: step1_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step1_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get('id'))
     self.step1_from_ui(params, saved_search)
     if saved_search.passive_save():
         raise cherrypy.HTTPRedirect(self.make_url(['scheduledigestwizard', app, 'step2'], _qs=dict(id=saved_search.id)), 303)
     self.step1_to_ui(saved_search)
     return self.render_template('scheduledigestwizard/step1_edit.html', dict(app=app, saved_search=saved_search))
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:9,代码来源:scheduledigestwizard.py

示例5: step3_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step3_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get('id'))
     saved_search.update(params)
     saved_search.action.rss.enabled = False if params.get('action.rss.enabled') is None else True
     saved_search.action.script.enabled = False if params.get('action.script.enabled') is None else True
     saved_search.action.email.enabled = False if params.get('action.email.enabled') is None else True
     email_results_type = params.get('email_results_type')
     if email_results_type == 'csv':
         saved_search.action.email.format = 'csv'
         saved_search.action.email.sendresults = True
         saved_search.action.email.inline = False
     elif email_results_type == 'inline':
         saved_search.action.email.format = 'html'
         saved_search.action.email.sendresults = True
         saved_search.action.email.inline = True
     elif email_results_type == 'pdf':
         saved_search.action.email.format = None
         saved_search.action.email.sendresults = False
         saved_search.action.email.sendpdf = True
     elif email_results_type == 'raw' or email_results_type == 'plain':
         saved_search.action.email.format = email_results_type
         saved_search.action.email.sendresults = True
         saved_search.action.email.inline = True
     saved_search.alert.track = False if params.get('alert.track') is None else True
     saved_search.is_disabled = False
     has_action = saved_search.action.email.enabled or saved_search.action.rss.enabled or saved_search.action.script.enabled or saved_search.alert.track
     if saved_search.passive_save() and has_action:
         raise cherrypy.HTTPRedirect(self.make_url(['alertswizard', app, 'success'], _qs=dict(id=saved_search.id)), 303)
     pdf_config = PDFConfig.get()
     if has_action is False:
         saved_search.errors.append(_('Please select at least one action'))
     return self.render_template('alertswizard/step3.html', dict(app=app, email_results_type=email_results_type, saved_search=saved_search, pdf_config=pdf_config))
开发者ID:DRArpitha,项目名称:splunk,代码行数:34,代码来源:alertswizard.py

示例6: step3_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step3_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get("id"))
     saved_search.update(params)
     saved_search.is_disabled = False
     metadata_sharing = params.get("metadata.sharing")
     if metadata_sharing == "user":
         try:
             saved_search.unshare()
         except Exception:
             saved_search.errors = [
                 _(
                     "Search %s cannot be private because it already exists. Try using another search name by cancelling this alert and creating a new one."
                 )
                 % saved_search.name
             ]
     elif metadata_sharing == "app":
         try:
             saved_search.share_app()
         except Exception:
             saved_search.errors = [
                 _(
                     "Search %s cannot be shared because it already exists. Try using another search name by cancelling this alert and creating a new one."
                 )
                 % saved_search.name
             ]
     if not saved_search.errors and saved_search.passive_save():
         raise cherrypy.HTTPRedirect(
             self.make_url(["alertswizardv2", app, "success"], _qs=dict(id=saved_search.id)), 303
         )
     self.step1_to_ui(saved_search)
     return self.render_template("alertswizardv2/step3.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:33,代码来源:alertswizardv2.py

示例7: step2_new

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step2_new(self, app, action, **params):
     owner = splunk.auth.getCurrentUser()['name']
     saved_search = SavedSearch.get(params.get('id'))
     dashboard = Dashboard(app, owner, None)
     dashboard.metadata.sharing = 'app'
     dashboards = Dashboard.filter_by_can_write_simple_xml(app)
     template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, 
                          dashboard_action=None, panel_type='event', panel_title=None)
     return self.render_template('dashboardwizard/step2.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:11,代码来源:dashboardwizard.py

示例8: step3_edit

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step3_edit(self, app, action, **params):
     owner = splunk.auth.getCurrentUser()['name']
     saved_search = SavedSearch.get(params.get('search_id'))
     dashboard = Dashboard.get(params.get('dashboard_id'))
     dashboard_action = params.get('dashboard_action')
     panel_type = 'event' 
     if saved_search.ui.display_view in ['charting', 'report_builder_format_report', 'report_builder_display']:
         panel_type = 'chart' 
     template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboard_action=dashboard_action, panel_type=panel_type, panel_title=None)
     return self.render_template('dashboardwizard/step3.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:12,代码来源:dashboardwizard.py

示例9: step1_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step1_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get("id"))
     saved_search.update(params)
     self.step1_from_ui(params, saved_search)
     if len(saved_search.errors) == 0 and saved_search.passive_save():
         raise cherrypy.HTTPRedirect(
             self.make_url(["alertswizardv2", app, "step2"], _qs=dict(id=saved_search.id)), 303
         )
     self.step1_to_ui(saved_search)
     return self.render_template("alertswizardv2/step1_edit.html", dict(app=app, saved_search=saved_search))
开发者ID:mealy,项目名称:splunk,代码行数:12,代码来源:alertswizardv2.py

示例10: step2_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step2_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get('id'))
     saved_search.update(params)
     saved_search.action.email.enabled = False if params.get('action.email.enabled') is None else True
     saved_search.action.script.enabled = False if params.get('action.script.enabled') is None else True            
     self.step2_from_ui(params, saved_search)
     if saved_search.passive_save():
         raise cherrypy.HTTPRedirect(self.make_url(['scheduledigestwizard', app, 'step3'], _qs=dict(id=saved_search.id)), 303)
     self.step2_to_ui(saved_search)
     return self.render_template('scheduledigestwizard/step2.html', dict(app=app, saved_search=saved_search))
开发者ID:DRArpitha,项目名称:splunk,代码行数:12,代码来源:scheduledigestwizard.py

示例11: step2_edit

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step2_edit(self, app, action, **params):
     owner = splunk.auth.getCurrentUser()['name']
     saved_search = SavedSearch.get(params.get('id'))
     dashboard = Dashboard.get(params.get('dashboard_id'))
     dashboard_action = params.get('dashboard_action')
     if dashboard_action=='new':
         dashboard.delete()
     dashboards = Dashboard.filter_by_can_write_simple_xml()
     template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, 
                          dashboard_action=dashboard_action)
     return self.render_template('dashboardwizard/step2.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:13,代码来源:dashboardwizard.py

示例12: step3_edit

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step3_edit(self, app, action, **params):
     saved_search = SavedSearch.get(params.get('id'))
     pdf_config = PDFConfig.get()
     email_results_type = None
     if saved_search.action.email.format == 'html':
         saved_search.action.email.format = 'inline'
     elif saved_search.action.email.sendpdf:
         saved_search.action.email.format = 'pdf'
     # first time nudge them not to track if always was selected
     saved_search.alert.track = False if saved_search.alert.type=='always' else True
     return self.render_template('alertswizard/step3.html', dict(app=app, email_results_type=email_results_type, saved_search=saved_search, pdf_config=pdf_config))
开发者ID:DRArpitha,项目名称:splunk,代码行数:13,代码来源:alertswizard.py

示例13: step1_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step1_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get('id'))
     saved_search.update(params)
     if params.get('sharing')=='app':
         try:
             saved_search.share_app()
         except Exception:
             saved_search.errors = [_('Search %s cannot be shared because it already exists. Try using another search name by cancelling this alert and creating a new one.') % saved_search.name ]
     else:
         try:
             saved_search.unshare()
         except Exception:
             saved_search.errors = [_('Search %s cannot be private because it already exists. Try using another search name by cancelling this alert and creating a new one.') % saved_search.name ]
     if not saved_search.errors and saved_search.passive_save():
         raise cherrypy.HTTPRedirect(self.make_url(['alertswizard', app, 'step2'], _qs=dict(id=saved_search.id)), 303)
     return self.render_template('alertswizard/step1_edit.html', dict(app=app, saved_search=saved_search))
开发者ID:DRArpitha,项目名称:splunk,代码行数:18,代码来源:alertswizard.py

示例14: step3_update

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
 def step3_update(self, app, step, action, **params):
     saved_search = SavedSearch.get(params.get('id'))
     saved_search.update(params)
     saved_search.is_disabled = False
     metadata_sharing = params.get('metadata.sharing')
     if metadata_sharing == 'user':
         try:
             saved_search.unshare()
         except Exception:
             saved_search.errors = [_('Search %s cannot be private because it already exists. Try using another search name by cancelling this alert and creating a new one.') % saved_search.name ]
     elif metadata_sharing == 'app':
         try:
             saved_search.share_app()
         except Exception:
             saved_search.errors = [_('Search %s cannot be shared because it already exists. Try using another search name by cancelling this alert and creating a new one.') % saved_search.name ]
     if not saved_search.errors and saved_search.passive_save():
         raise cherrypy.HTTPRedirect(self.make_url(['scheduledigestwizard', app, 'success'], _qs=dict(id=saved_search.id)), 303)
     return self.render_template('scheduledigestwizard/step3.html', dict(app=app, saved_search=saved_search))
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:20,代码来源:scheduledigestwizard.py

示例15: step2_create

# 需要导入模块: from splunk.models.saved_search import SavedSearch [as 别名]
# 或者: from splunk.models.saved_search.SavedSearch import get [as 别名]
    def step2_create(self, app, step, action, **params):
        # saved search models
        saved_search = SavedSearch.get(params.get('id'))
        # dashboard model
        dashboard_action = params.get('dashboard.action')
        owner = splunk.auth.getCurrentUser()['name']
        if dashboard_action=='get':
            try:
                dashboard = Dashboard.get(params.get('dashboard.id'))
            except:
                dashboard = Dashboard(app, owner, None)
                dashboard.errors = [_('Please choose an existing dashboard.')]
        else:
            dashboard_name = params.get('dashboard.name', '')
            try:
                dashboard_name.encode('ascii')
            except:
                date = str(splunk.util.dt2epoch(datetime.datetime.now())).replace('.', '_')
                dashboard_name = '%s_%s' % (splunk.auth.getCurrentUser()['name'], date)
            dashboard = Dashboard(app, owner, dashboard_name)
            dashboard.label = params.get('dashboard.label')
            dashboard.metadata.sharing = params.get('sharing', 'user')

        if not dashboard.errors and saved_search.passive_save() and dashboard.passive_save():
            # update saved search only on save success
            if dashboard.metadata.sharing=='app':
                try:
                    saved_search.share_app()
                except Exception:
                    saved_search.errors = [_('Search %s cannot be shared because it already exists. Try using another search name in the previous step.') % saved_search.name ]
            else:
                try:
                    saved_search.unshare()
                except Exception:
                    saved_search.errors = [_('Search %s cannot be private because it already exists. Try using another search name in the previous step.') % saved_search.name]
            if not saved_search.errors:
                raise cherrypy.HTTPRedirect(self.make_url(['dashboardwizard', app, 'step3'], _qs=dict(search_id=saved_search.id, dashboard_id=dashboard.id, dashboard_action=dashboard_action)), 303)
        dashboards = Dashboard.filter_by_can_write_simple_xml()
        template_args = dict(app=app, saved_search=saved_search, dashboard=dashboard, dashboards=dashboards, dashboard_action=dashboard_action)
        return self.render_template('dashboardwizard/step2.html', template_args)
开发者ID:DRArpitha,项目名称:splunk,代码行数:42,代码来源:dashboardwizard.py


注:本文中的splunk.models.saved_search.SavedSearch.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。