generator.explores.operational_monitoring_explore
Operational Monitoring Explore type.
1"""Operational Monitoring Explore type.""" 2 3from __future__ import annotations 4 5from pathlib import Path 6from typing import Any, Dict, Iterator, List, Optional 7 8from ..views import View 9from . import Explore 10 11 12class OperationalMonitoringExplore(Explore): 13 """An Operational Monitoring Explore.""" 14 15 type: str = "operational_monitoring_explore" 16 17 def __init__( 18 self, 19 name: str, 20 views: Dict[str, str], 21 views_path: Optional[Path] = None, 22 defn: Optional[Dict[str, Any]] = None, 23 ): 24 """Initialize OperationalMonitoringExplore.""" 25 super().__init__(name, views, views_path) 26 if defn is not None: 27 self.branches = ", ".join(defn["branches"]) 28 self.xaxis = defn.get("xaxis") 29 self.dimensions = defn.get("dimensions", {}) 30 self.summaries = defn.get("summaries", []) 31 32 @staticmethod 33 def from_views(views: List[View]) -> Iterator[Explore]: 34 """Generate an Operational Monitoring explore for this namespace.""" 35 for view in views: 36 if view.view_type == "operational_monitoring_view": 37 yield OperationalMonitoringExplore( 38 "operational_monitoring", 39 {"base_view": view.name}, 40 ) 41 42 @staticmethod 43 def from_dict( 44 name: str, defn: dict, views_path: Path 45 ) -> OperationalMonitoringExplore: 46 """Get an instance of this explore from a dictionary definition.""" 47 return OperationalMonitoringExplore(name, defn["views"], views_path, defn) 48 49 def _to_lookml( 50 self, 51 v1_name: Optional[str], 52 ) -> List[Dict[str, Any]]: 53 base_view_name = self.views["base_view"] 54 55 filters = [ 56 {f"{base_view_name}.branch": self.branches}, 57 ] 58 for dimension, info in self.dimensions.items(): 59 if "default" in info: 60 filters.append({f"{base_view_name}.{dimension}": info["default"]}) 61 62 defn: List[Dict[str, Any]] = [ 63 { 64 "name": self.views["base_view"], 65 "always_filter": { 66 "filters": [ 67 {"branch": self.branches}, 68 ] 69 }, 70 "hidden": "yes", 71 }, 72 ] 73 74 return defn 75 76 77class OperationalMonitoringAlertingExplore(Explore): 78 """An Operational Monitoring Alerting Explore.""" 79 80 type: str = "operational_monitoring_alerting_explore" 81 82 def __init__( 83 self, 84 name: str, 85 views: Dict[str, str], 86 views_path: Optional[Path] = None, 87 defn: Optional[Dict[str, Any]] = None, 88 ): 89 """Initialize OperationalMonitoringExplore.""" 90 super().__init__(name, views, views_path) 91 92 @staticmethod 93 def from_views(views: List[View]) -> Iterator[Explore]: 94 """Generate an Operational Monitoring explore for this namespace.""" 95 for view in views: 96 if view.view_type in { 97 "operational_monitoring_alerting_view", 98 }: 99 yield OperationalMonitoringAlertingExplore( 100 "operational_monitoring", 101 {"base_view": view.name}, 102 ) 103 104 @staticmethod 105 def from_dict( 106 name: str, defn: dict, views_path: Path 107 ) -> OperationalMonitoringAlertingExplore: 108 """Get an instance of this explore from a dictionary definition.""" 109 return OperationalMonitoringAlertingExplore( 110 name, defn["views"], views_path, defn 111 ) 112 113 def _to_lookml( 114 self, 115 v1_name: Optional[str], 116 ) -> List[Dict[str, Any]]: 117 defn: List[Dict[str, Any]] = [ 118 {"name": self.views["base_view"], "hidden": "yes"}, 119 ] 120 121 return defn
13class OperationalMonitoringExplore(Explore): 14 """An Operational Monitoring Explore.""" 15 16 type: str = "operational_monitoring_explore" 17 18 def __init__( 19 self, 20 name: str, 21 views: Dict[str, str], 22 views_path: Optional[Path] = None, 23 defn: Optional[Dict[str, Any]] = None, 24 ): 25 """Initialize OperationalMonitoringExplore.""" 26 super().__init__(name, views, views_path) 27 if defn is not None: 28 self.branches = ", ".join(defn["branches"]) 29 self.xaxis = defn.get("xaxis") 30 self.dimensions = defn.get("dimensions", {}) 31 self.summaries = defn.get("summaries", []) 32 33 @staticmethod 34 def from_views(views: List[View]) -> Iterator[Explore]: 35 """Generate an Operational Monitoring explore for this namespace.""" 36 for view in views: 37 if view.view_type == "operational_monitoring_view": 38 yield OperationalMonitoringExplore( 39 "operational_monitoring", 40 {"base_view": view.name}, 41 ) 42 43 @staticmethod 44 def from_dict( 45 name: str, defn: dict, views_path: Path 46 ) -> OperationalMonitoringExplore: 47 """Get an instance of this explore from a dictionary definition.""" 48 return OperationalMonitoringExplore(name, defn["views"], views_path, defn) 49 50 def _to_lookml( 51 self, 52 v1_name: Optional[str], 53 ) -> List[Dict[str, Any]]: 54 base_view_name = self.views["base_view"] 55 56 filters = [ 57 {f"{base_view_name}.branch": self.branches}, 58 ] 59 for dimension, info in self.dimensions.items(): 60 if "default" in info: 61 filters.append({f"{base_view_name}.{dimension}": info["default"]}) 62 63 defn: List[Dict[str, Any]] = [ 64 { 65 "name": self.views["base_view"], 66 "always_filter": { 67 "filters": [ 68 {"branch": self.branches}, 69 ] 70 }, 71 "hidden": "yes", 72 }, 73 ] 74 75 return defn
An Operational Monitoring Explore.
OperationalMonitoringExplore( name: str, views: Dict[str, str], views_path: Optional[pathlib.Path] = None, defn: Optional[Dict[str, Any]] = None)
18 def __init__( 19 self, 20 name: str, 21 views: Dict[str, str], 22 views_path: Optional[Path] = None, 23 defn: Optional[Dict[str, Any]] = None, 24 ): 25 """Initialize OperationalMonitoringExplore.""" 26 super().__init__(name, views, views_path) 27 if defn is not None: 28 self.branches = ", ".join(defn["branches"]) 29 self.xaxis = defn.get("xaxis") 30 self.dimensions = defn.get("dimensions", {}) 31 self.summaries = defn.get("summaries", [])
Initialize OperationalMonitoringExplore.
@staticmethod
def
from_views( views: List[generator.views.view.View]) -> Iterator[generator.explores.explore.Explore]:
33 @staticmethod 34 def from_views(views: List[View]) -> Iterator[Explore]: 35 """Generate an Operational Monitoring explore for this namespace.""" 36 for view in views: 37 if view.view_type == "operational_monitoring_view": 38 yield OperationalMonitoringExplore( 39 "operational_monitoring", 40 {"base_view": view.name}, 41 )
Generate an Operational Monitoring explore for this namespace.
@staticmethod
def
from_dict( name: str, defn: dict, views_path: pathlib.Path) -> OperationalMonitoringExplore:
43 @staticmethod 44 def from_dict( 45 name: str, defn: dict, views_path: Path 46 ) -> OperationalMonitoringExplore: 47 """Get an instance of this explore from a dictionary definition.""" 48 return OperationalMonitoringExplore(name, defn["views"], views_path, defn)
Get an instance of this explore from a dictionary definition.
78class OperationalMonitoringAlertingExplore(Explore): 79 """An Operational Monitoring Alerting Explore.""" 80 81 type: str = "operational_monitoring_alerting_explore" 82 83 def __init__( 84 self, 85 name: str, 86 views: Dict[str, str], 87 views_path: Optional[Path] = None, 88 defn: Optional[Dict[str, Any]] = None, 89 ): 90 """Initialize OperationalMonitoringExplore.""" 91 super().__init__(name, views, views_path) 92 93 @staticmethod 94 def from_views(views: List[View]) -> Iterator[Explore]: 95 """Generate an Operational Monitoring explore for this namespace.""" 96 for view in views: 97 if view.view_type in { 98 "operational_monitoring_alerting_view", 99 }: 100 yield OperationalMonitoringAlertingExplore( 101 "operational_monitoring", 102 {"base_view": view.name}, 103 ) 104 105 @staticmethod 106 def from_dict( 107 name: str, defn: dict, views_path: Path 108 ) -> OperationalMonitoringAlertingExplore: 109 """Get an instance of this explore from a dictionary definition.""" 110 return OperationalMonitoringAlertingExplore( 111 name, defn["views"], views_path, defn 112 ) 113 114 def _to_lookml( 115 self, 116 v1_name: Optional[str], 117 ) -> List[Dict[str, Any]]: 118 defn: List[Dict[str, Any]] = [ 119 {"name": self.views["base_view"], "hidden": "yes"}, 120 ] 121 122 return defn
An Operational Monitoring Alerting Explore.
OperationalMonitoringAlertingExplore( name: str, views: Dict[str, str], views_path: Optional[pathlib.Path] = None, defn: Optional[Dict[str, Any]] = None)
83 def __init__( 84 self, 85 name: str, 86 views: Dict[str, str], 87 views_path: Optional[Path] = None, 88 defn: Optional[Dict[str, Any]] = None, 89 ): 90 """Initialize OperationalMonitoringExplore.""" 91 super().__init__(name, views, views_path)
Initialize OperationalMonitoringExplore.
@staticmethod
def
from_views( views: List[generator.views.view.View]) -> Iterator[generator.explores.explore.Explore]:
93 @staticmethod 94 def from_views(views: List[View]) -> Iterator[Explore]: 95 """Generate an Operational Monitoring explore for this namespace.""" 96 for view in views: 97 if view.view_type in { 98 "operational_monitoring_alerting_view", 99 }: 100 yield OperationalMonitoringAlertingExplore( 101 "operational_monitoring", 102 {"base_view": view.name}, 103 )
Generate an Operational Monitoring explore for this namespace.
@staticmethod
def
from_dict( name: str, defn: dict, views_path: pathlib.Path) -> OperationalMonitoringAlertingExplore:
105 @staticmethod 106 def from_dict( 107 name: str, defn: dict, views_path: Path 108 ) -> OperationalMonitoringAlertingExplore: 109 """Get an instance of this explore from a dictionary definition.""" 110 return OperationalMonitoringAlertingExplore( 111 name, defn["views"], views_path, defn 112 )
Get an instance of this explore from a dictionary definition.