Module aws_lambda_powertools.utilities.data_classes.cloud_watch_custom_widget_event

Classes

class CloudWatchDashboardCustomWidgetEvent (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

CloudWatch dashboard custom widget event

You can use a Lambda function to create a custom widget on a CloudWatch dashboard.

Documentation:

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchDashboardCustomWidgetEvent(DictWrapper):
    """CloudWatch dashboard custom widget event

    You can use a Lambda function to create a custom widget on a CloudWatch dashboard.

    Documentation:
    -------------
    - https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/add_custom_widget_dashboard_about.html
    """

    @property
    def describe(self) -> bool:
        """Display widget documentation"""
        return bool(self.get("describe", False))

    @property
    def widget_context(self) -> Optional[CloudWatchWidgetContext]:
        """The widget context"""
        if self.get("widgetContext"):
            return CloudWatchWidgetContext(self["widgetContext"])

        return None

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop describe : bool

Display widget documentation

Expand source code
@property
def describe(self) -> bool:
    """Display widget documentation"""
    return bool(self.get("describe", False))
prop widget_context : Optional[CloudWatchWidgetContext]

The widget context

Expand source code
@property
def widget_context(self) -> Optional[CloudWatchWidgetContext]:
    """The widget context"""
    if self.get("widgetContext"):
        return CloudWatchWidgetContext(self["widgetContext"])

    return None

Inherited members

class CloudWatchWidgetContext (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class CloudWatchWidgetContext(DictWrapper):
    @property
    def dashboard_name(self) -> str:
        """Get dashboard name, in which the widget is used"""
        return self["dashboardName"]

    @property
    def widget_id(self) -> str:
        """Get widget ID"""
        return self["widgetId"]

    @property
    def domain(self) -> str:
        """AWS domain name"""
        return self["domain"]

    @property
    def account_id(self) -> str:
        """Get AWS Account ID"""
        return self["accountId"]

    @property
    def locale(self) -> str:
        """Get locale language"""
        return self["locale"]

    @property
    def timezone(self) -> TimeZone:
        """Timezone information of the dashboard"""
        return TimeZone(self["timezone"])

    @property
    def period(self) -> int:
        """The period shown on the dashboard"""
        return int(self["period"])

    @property
    def is_auto_period(self) -> bool:
        """Whether auto period is enabled"""
        return bool(self["isAutoPeriod"])

    @property
    def time_range(self) -> TimeRange:
        """The widget time range"""
        return TimeRange(self["timeRange"])

    @property
    def theme(self) -> str:
        """The dashboard theme, i.e. 'light' or 'dark'"""
        return self["theme"]

    @property
    def link_charts(self) -> bool:
        """The widget is linked to other charts"""
        return bool(self["linkCharts"])

    @property
    def title(self) -> str:
        """Get widget title"""
        return self["title"]

    @property
    def params(self) -> Dict[str, Any]:
        """Get widget parameters"""
        return self["params"]

    @property
    def forms(self) -> Dict[str, Any]:
        """Get widget form data"""
        return self["forms"]["all"]

    @property
    def height(self) -> int:
        """Get widget height"""
        return int(self["height"])

    @property
    def width(self) -> int:
        """Get widget width"""
        return int(self["width"])

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop account_id : str

Get AWS Account ID

Expand source code
@property
def account_id(self) -> str:
    """Get AWS Account ID"""
    return self["accountId"]
prop dashboard_name : str

Get dashboard name, in which the widget is used

Expand source code
@property
def dashboard_name(self) -> str:
    """Get dashboard name, in which the widget is used"""
    return self["dashboardName"]
prop domain : str

AWS domain name

Expand source code
@property
def domain(self) -> str:
    """AWS domain name"""
    return self["domain"]
prop forms : Dict[str, Any]

Get widget form data

Expand source code
@property
def forms(self) -> Dict[str, Any]:
    """Get widget form data"""
    return self["forms"]["all"]
prop height : int

Get widget height

Expand source code
@property
def height(self) -> int:
    """Get widget height"""
    return int(self["height"])
prop is_auto_period : bool

Whether auto period is enabled

Expand source code
@property
def is_auto_period(self) -> bool:
    """Whether auto period is enabled"""
    return bool(self["isAutoPeriod"])

The widget is linked to other charts

Expand source code
@property
def link_charts(self) -> bool:
    """The widget is linked to other charts"""
    return bool(self["linkCharts"])
prop locale : str

Get locale language

Expand source code
@property
def locale(self) -> str:
    """Get locale language"""
    return self["locale"]
prop params : Dict[str, Any]

Get widget parameters

Expand source code
@property
def params(self) -> Dict[str, Any]:
    """Get widget parameters"""
    return self["params"]
prop period : int

The period shown on the dashboard

Expand source code
@property
def period(self) -> int:
    """The period shown on the dashboard"""
    return int(self["period"])
prop theme : str

The dashboard theme, i.e. 'light' or 'dark'

Expand source code
@property
def theme(self) -> str:
    """The dashboard theme, i.e. 'light' or 'dark'"""
    return self["theme"]
prop time_rangeTimeRange

The widget time range

Expand source code
@property
def time_range(self) -> TimeRange:
    """The widget time range"""
    return TimeRange(self["timeRange"])
prop timezoneTimeZone

Timezone information of the dashboard

Expand source code
@property
def timezone(self) -> TimeZone:
    """Timezone information of the dashboard"""
    return TimeZone(self["timezone"])
prop title : str

Get widget title

Expand source code
@property
def title(self) -> str:
    """Get widget title"""
    return self["title"]
prop widget_id : str

Get widget ID

Expand source code
@property
def widget_id(self) -> str:
    """Get widget ID"""
    return self["widgetId"]
prop width : int

Get widget width

Expand source code
@property
def width(self) -> int:
    """Get widget width"""
    return int(self["width"])

Inherited members

class TimeRange (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class TimeRange(DictWrapper):
    @property
    def mode(self) -> str:
        """The time range mode, i.e. 'relative' or 'absolute'"""
        return self["mode"]

    @property
    def start(self) -> int:
        """The start time within the time range"""
        return self["start"]

    @property
    def end(self) -> int:
        """The end time within the time range"""
        return self["end"]

    @property
    def relative_start(self) -> Optional[int]:
        """The relative start time within the time range"""
        return self.get("relativeStart")

    @property
    def zoom_start(self) -> Optional[int]:
        """The start time within the zoomed time range"""
        return (self.get("zoom") or {}).get("start")

    @property
    def zoom_end(self) -> Optional[int]:
        """The end time within the zoomed time range"""
        return (self.get("zoom") or {}).get("end")

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop end : int

The end time within the time range

Expand source code
@property
def end(self) -> int:
    """The end time within the time range"""
    return self["end"]
prop mode : str

The time range mode, i.e. 'relative' or 'absolute'

Expand source code
@property
def mode(self) -> str:
    """The time range mode, i.e. 'relative' or 'absolute'"""
    return self["mode"]
prop relative_start : Optional[int]

The relative start time within the time range

Expand source code
@property
def relative_start(self) -> Optional[int]:
    """The relative start time within the time range"""
    return self.get("relativeStart")
prop start : int

The start time within the time range

Expand source code
@property
def start(self) -> int:
    """The start time within the time range"""
    return self["start"]
prop zoom_end : Optional[int]

The end time within the zoomed time range

Expand source code
@property
def zoom_end(self) -> Optional[int]:
    """The end time within the zoomed time range"""
    return (self.get("zoom") or {}).get("end")
prop zoom_start : Optional[int]

The start time within the zoomed time range

Expand source code
@property
def zoom_start(self) -> Optional[int]:
    """The start time within the zoomed time range"""
    return (self.get("zoom") or {}).get("start")

Inherited members

class TimeZone (data: Dict[str, Any], json_deserializer: Optional[Callable] = None)

Provides a single read only access to a wrapper dict

Parameters

data : Dict[str, Any]
Lambda Event Source Event payload
json_deserializer : Callable, optional
function to deserialize str, bytes, bytearray containing a JSON document to a Python obj, by default json.loads
Expand source code
class TimeZone(DictWrapper):
    @property
    def label(self) -> str:
        """The time range label. Either 'UTC' or 'Local'"""
        return self["label"]

    @property
    def offset_iso(self) -> str:
        """The time range offset in the format +/-00:00"""
        return self["offsetISO"]

    @property
    def offset_in_minutes(self) -> int:
        """The time range offset in minutes"""
        return int(self["offsetInMinutes"])

Ancestors

  • DictWrapper
  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container

Instance variables

prop label : str

The time range label. Either 'UTC' or 'Local'

Expand source code
@property
def label(self) -> str:
    """The time range label. Either 'UTC' or 'Local'"""
    return self["label"]
prop offset_in_minutes : int

The time range offset in minutes

Expand source code
@property
def offset_in_minutes(self) -> int:
    """The time range offset in minutes"""
    return int(self["offsetInMinutes"])
prop offset_iso : str

The time range offset in the format +/-00:00

Expand source code
@property
def offset_iso(self) -> str:
    """The time range offset in the format +/-00:00"""
    return self["offsetISO"]

Inherited members