def get_all(self, project_id=None, fields=None): """Gets all health monitors.""" pcontext = pecan.request.context context = pcontext.get('octavia_context') query_filter = self._auth_get_all(context, project_id) db_hm, links = self.repositories.health_monitor.get_all( context.session, show_deleted=False, pagination_helper=pcontext.get(constants.PAGINATION_HELPER), **query_filter) result = self._convert_db_to_type( db_hm, [hm_types.HealthMonitorResponse]) if fields is not None: result = self._filter_fields(result, fields) return hm_types.HealthMonitorsRootResponse( healthmonitors=result, healthmonitors_links=links)
def get_all(self, tenant_id=None, project_id=None): """Gets a single health monitor's details.""" # NOTE(blogan): since a pool can only have one health monitor # we are using the get_all method to only get the single health monitor context = pecan.request.context.get('octavia_context') if context.is_admin or CONF.auth_strategy == constants.NOAUTH: if project_id or tenant_id: project_id = {'project_id': project_id or tenant_id} else: project_id = {} else: project_id = {'project_id': context.project_id} db_hm = self.repositories.health_monitor.get_all( context.session, **project_id) result = self._convert_db_to_type(db_hm, [hm_types.HealthMonitorResponse]) return hm_types.HealthMonitorsRootResponse(healthmonitors=result)