當前位置: 首頁>>代碼示例>>Python>>正文


Python SavedSearch.all方法代碼示例

本文整理匯總了Python中splunk.models.saved_search.SavedSearch.all方法的典型用法代碼示例。如果您正苦於以下問題:Python SavedSearch.all方法的具體用法?Python SavedSearch.all怎麽用?Python SavedSearch.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在splunk.models.saved_search.SavedSearch的用法示例。


在下文中一共展示了SavedSearch.all方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: list

# 需要導入模塊: from splunk.models.saved_search import SavedSearch [as 別名]
# 或者: from splunk.models.saved_search.SavedSearch import all [as 別名]
    def list(self, app, action, **kwargs):
        ''' provides list of saved searches for backfill lister'''

        host_app = cherrypy.request.path_info.split('/')[3]
        user = cherrypy.session['user']['name'] 
            
        searches = SavedSearch.all()
        searches = searches.filter_by_app(app)
        searches = searches.search('action.summary_index=1')

        return self.render_template('/%s:/templates/backfill_select.html' % host_app, 
                                    dict(app=app, searches=searches))
開發者ID:DRArpitha,項目名稱:splunk,代碼行數:14,代碼來源:dmbackfill.py

示例2: searchedit

# 需要導入模塊: from splunk.models.saved_search import SavedSearch [as 別名]
# 或者: from splunk.models.saved_search.SavedSearch import all [as 別名]
    def searchedit(self, app, action, row, column, **params):
        row = int(row)
        column = int(column)
        dashboard = Dashboard.get(params.get('id'))
        dashboard_panel = DashboardPanel(None, (row, column), dashboard=dashboard)
        saved_searches = SavedSearch.all().filter_by_app(app)
        saved_search_id = params.get('saved_search_id')
        owner = splunk.auth.getCurrentUser()['name']
        inline_search = SavedSearch(app, owner, None)
        ui_search_mode = dashboard_panel.panel_model.searchMode
        # set the saved_search object
        if saved_search_id:
            saved_search = SavedSearch.get(saved_search_id)
            ui_search_mode = 'saved' 
        # otherwise defer to the first saved search item if it exists or an empty one
        else:
            saved_search_query = SavedSearch.all()
            if len(saved_search_query)>0:
                saved_search = saved_search_query[0]
            else:
                saved_search = SavedSearch(app, owner, None)
        
        # based on search mode pre-populate an active saved_search and the inline_search accordingly
        if dashboard_panel.panel_model.searchMode=='saved' and not saved_search_id:
            saved_search_query = SavedSearch.all().filter_by_app(None).search('name=%s' % util.fieldListToString([dashboard_panel.panel_model.searchCommand]))
            if len(saved_search_query)>0:
                saved_search = saved_search_query[0]
            # invalid/non-existant saved search reference, revert to empty saved search model
            else:
                saved_search.search = dashboard_panel.panel_model.searchCommand
                saved_search.dispatch.earliest_time = dashboard_panel.panel_model.searchEarliestTime
                saved_search.dispatch.latest_time = dashboard_panel.panel_model.searchLatestTime
        elif dashboard_panel.panel_model.searchMode=='string':
            inline_search.search = dashboard_panel.panel_model.searchCommand
            inline_search.dispatch.earliest_time = dashboard_panel.panel_model.searchEarliestTime
            inline_search.dispatch.latest_time = dashboard_panel.panel_model.searchLatestTime

        template_args = dict(app=app, dashboard=dashboard, dashboard_panel=dashboard_panel, saved_searches=saved_searches, saved_search=saved_search, 
                             ui_search_mode=ui_search_mode, inline_search=inline_search)
        return self.render_template('paneleditor/searchedit.html', template_args)
開發者ID:DRArpitha,項目名稱:splunk,代碼行數:42,代碼來源:paneleditor.py

示例3: new

# 需要導入模塊: from splunk.models.saved_search import SavedSearch [as 別名]
# 或者: from splunk.models.saved_search.SavedSearch import all [as 別名]
    def new(self, app, action, **kwargs):
        ''' render the _new template '''

        user = cherrypy.session['user']['name'] 
        host_app = cherrypy.request.path_info.split('/')[3]
       
        headline = Headlines(app, user, '_new')
        alerts = SavedSearch.all()
        alerts = alerts.filter_by_app(app)
        alerts = alerts.search('is_scheduled=True')

        return self.render_template('/%s:/templates/headlines_new.html' \
                                    % host_app,
                                    dict(app=app, headline=headline, alerts=alerts))
開發者ID:pierretsai,項目名稱:splunk-HadoopOps,代碼行數:16,代碼來源:hadoopopsheadlines.py

示例4: save

# 需要導入模塊: from splunk.models.saved_search import SavedSearch [as 別名]
# 或者: from splunk.models.saved_search.SavedSearch import all [as 別名]
    def save(self, app, action, **params):
        ''' save the posted headline '''

        user = cherrypy.session['user']['name'] 
        host_app = cherrypy.request.path_info.split('/')[3]

        key = params.get('name')

        try:
            if key == '_new':
                headline = Headlines(app, user, uuid4())
            else:
                headline = Headlines.get(Headlines.build_id(key, app, user))
        except:
            headline = Headlines(app, user, uuid4())

        headline.label = params.get('label')
        if not headline.label:
            headline.errors = ['label cannot be blank']
        else:
            headline.message = params.get('message')
            headline.description = params.get('description')
            headline.alert_name = params.get('alert_name')
            headline.metadata.sharing = 'app'

        if headline.errors or not headline.passive_save():
            logger.error('Error saving headline %s: %s' % (headline.name, headline.errors[0]))
            alerts = SavedSearch.all()
            alerts = alerts.filter_by_app(app)
            alerts = alerts.search('is_scheduled=True')
            if key != '_new':
                return self.render_template('/%s:/templates/headlines_detail.html' % host_app,
                                             dict(app=app, headline=headline, alerts=alerts))
            else:
                headline.name = key
                return self.render_template('/%s:/templates/headlines_new.html' % host_app,
                                             dict(app=app, headline=headline, alerts=alerts))
        else:
            raise cherrypy.HTTPRedirect(self._redirect(host_app, app, 'success'), 303)
開發者ID:pierretsai,項目名稱:splunk-HadoopOps,代碼行數:41,代碼來源:hadoopopsheadlines.py


注:本文中的splunk.models.saved_search.SavedSearch.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。