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 explore_lookml = { 63 "name": self.views["base_view"], 64 "always_filter": { 65 "filters": [ 66 {"branch": self.branches}, 67 ] 68 }, 69 "hidden": "yes", 70 } 71 72 if datagroup := self.get_datagroup(): 73 explore_lookml["persist_with"] = datagroup 74 75 defn: List[Dict[str, Any]] = [explore_lookml] 76 77 return defn 78 79 80class OperationalMonitoringAlertingExplore(Explore): 81 """An Operational Monitoring Alerting Explore.""" 82 83 type: str = "operational_monitoring_alerting_explore" 84 85 def __init__( 86 self, 87 name: str, 88 views: Dict[str, str], 89 views_path: Optional[Path] = None, 90 defn: Optional[Dict[str, Any]] = None, 91 ): 92 """Initialize OperationalMonitoringExplore.""" 93 super().__init__(name, views, views_path) 94 95 @staticmethod 96 def from_views(views: List[View]) -> Iterator[Explore]: 97 """Generate an Operational Monitoring explore for this namespace.""" 98 for view in views: 99 if view.view_type in { 100 "operational_monitoring_alerting_view", 101 }: 102 yield OperationalMonitoringAlertingExplore( 103 "operational_monitoring", 104 {"base_view": view.name}, 105 ) 106 107 @staticmethod 108 def from_dict( 109 name: str, defn: dict, views_path: Path 110 ) -> OperationalMonitoringAlertingExplore: 111 """Get an instance of this explore from a dictionary definition.""" 112 return OperationalMonitoringAlertingExplore( 113 name, defn["views"], views_path, defn 114 ) 115 116 def _to_lookml( 117 self, 118 v1_name: Optional[str], 119 ) -> List[Dict[str, Any]]: 120 explore_lookml = {"name": self.views["base_view"], "hidden": "yes"} 121 122 if datagroup := self.get_datagroup(): 123 explore_lookml["persist_with"] = datagroup 124 125 defn: List[Dict[str, Any]] = [explore_lookml] 126 127 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 explore_lookml = { 64 "name": self.views["base_view"], 65 "always_filter": { 66 "filters": [ 67 {"branch": self.branches}, 68 ] 69 }, 70 "hidden": "yes", 71 } 72 73 if datagroup := self.get_datagroup(): 74 explore_lookml["persist_with"] = datagroup 75 76 defn: List[Dict[str, Any]] = [explore_lookml] 77 78 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.
81class OperationalMonitoringAlertingExplore(Explore): 82 """An Operational Monitoring Alerting Explore.""" 83 84 type: str = "operational_monitoring_alerting_explore" 85 86 def __init__( 87 self, 88 name: str, 89 views: Dict[str, str], 90 views_path: Optional[Path] = None, 91 defn: Optional[Dict[str, Any]] = None, 92 ): 93 """Initialize OperationalMonitoringExplore.""" 94 super().__init__(name, views, views_path) 95 96 @staticmethod 97 def from_views(views: List[View]) -> Iterator[Explore]: 98 """Generate an Operational Monitoring explore for this namespace.""" 99 for view in views: 100 if view.view_type in { 101 "operational_monitoring_alerting_view", 102 }: 103 yield OperationalMonitoringAlertingExplore( 104 "operational_monitoring", 105 {"base_view": view.name}, 106 ) 107 108 @staticmethod 109 def from_dict( 110 name: str, defn: dict, views_path: Path 111 ) -> OperationalMonitoringAlertingExplore: 112 """Get an instance of this explore from a dictionary definition.""" 113 return OperationalMonitoringAlertingExplore( 114 name, defn["views"], views_path, defn 115 ) 116 117 def _to_lookml( 118 self, 119 v1_name: Optional[str], 120 ) -> List[Dict[str, Any]]: 121 explore_lookml = {"name": self.views["base_view"], "hidden": "yes"} 122 123 if datagroup := self.get_datagroup(): 124 explore_lookml["persist_with"] = datagroup 125 126 defn: List[Dict[str, Any]] = [explore_lookml] 127 128 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)
86 def __init__( 87 self, 88 name: str, 89 views: Dict[str, str], 90 views_path: Optional[Path] = None, 91 defn: Optional[Dict[str, Any]] = None, 92 ): 93 """Initialize OperationalMonitoringExplore.""" 94 super().__init__(name, views, views_path)
Initialize OperationalMonitoringExplore.
@staticmethod
def
from_views( views: List[generator.views.view.View]) -> Iterator[generator.explores.explore.Explore]:
96 @staticmethod 97 def from_views(views: List[View]) -> Iterator[Explore]: 98 """Generate an Operational Monitoring explore for this namespace.""" 99 for view in views: 100 if view.view_type in { 101 "operational_monitoring_alerting_view", 102 }: 103 yield OperationalMonitoringAlertingExplore( 104 "operational_monitoring", 105 {"base_view": view.name}, 106 )
Generate an Operational Monitoring explore for this namespace.
@staticmethod
def
from_dict( name: str, defn: dict, views_path: pathlib.Path) -> OperationalMonitoringAlertingExplore:
108 @staticmethod 109 def from_dict( 110 name: str, defn: dict, views_path: Path 111 ) -> OperationalMonitoringAlertingExplore: 112 """Get an instance of this explore from a dictionary definition.""" 113 return OperationalMonitoringAlertingExplore( 114 name, defn["views"], views_path, defn 115 )
Get an instance of this explore from a dictionary definition.