-
Notifications
You must be signed in to change notification settings - Fork 79
adding monitors in region endpoint #587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 6 commits
c29a060
5d883ea
132fbf2
487bce6
7b9bc6c
4c3e65f
90518a9
ae967c3
126a93c
c764906
a45a0fa
8bd812f
fa01030
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,7 +5,7 @@ | |||||||||||
"MonitorServiceToken", | ||||||||||||
"AggregateFunction", | ||||||||||||
] | ||||||||||||
from dataclasses import dataclass, field | ||||||||||||
from dataclasses import dataclass | ||||||||||||
from typing import List, Optional | ||||||||||||
|
||||||||||||
from linode_api4.objects.base import Base, Property | ||||||||||||
|
@@ -49,6 +49,7 @@ class ServiceType(StrEnum): | |||||||||||
firewall = "firewall" | ||||||||||||
object_storage = "object_storage" | ||||||||||||
aclb = "aclb" | ||||||||||||
net_load_balancer = "netloadbalancer" | ||||||||||||
|
||||||||||||
|
||||||||||||
class MetricType(StrEnum): | ||||||||||||
|
@@ -82,6 +83,10 @@ class MetricUnit(StrEnum): | |||||||||||
RATIO = "ratio" | ||||||||||||
OPS_PER_SECOND = "ops_per_second" | ||||||||||||
IOPS = "iops" | ||||||||||||
KILO_BYTES_PER_SECOND = "kilo_bytes_per_second" | ||||||||||||
SESSIONS_PER_SECOND = "sessions_per_second" | ||||||||||||
PACKETS_PER_SECOND = "packets_per_second" | ||||||||||||
KILO_BITS_PER_SECOND = "kilo_bits_per_second" | ||||||||||||
|
||||||||||||
|
||||||||||||
class DashboardType(StrEnum): | ||||||||||||
|
@@ -93,6 +98,17 @@ class DashboardType(StrEnum): | |||||||||||
custom = "custom" | ||||||||||||
|
||||||||||||
|
||||||||||||
@dataclass | ||||||||||||
class Filter(JSONObject): | ||||||||||||
""" | ||||||||||||
Represents a filter in the filters list of a dashboard widget. | ||||||||||||
""" | ||||||||||||
|
||||||||||||
dimension_label: str = "" | ||||||||||||
operator: str = "" | ||||||||||||
value: str = "" | ||||||||||||
|
||||||||||||
|
||||||||||||
@dataclass | ||||||||||||
class DashboardWidget(JSONObject): | ||||||||||||
""" | ||||||||||||
|
@@ -107,6 +123,19 @@ class DashboardWidget(JSONObject): | |||||||||||
chart_type: ChartType = "" | ||||||||||||
y_label: str = "" | ||||||||||||
aggregate_function: AggregateFunction = "" | ||||||||||||
group_by: Optional[List[str]] = None | ||||||||||||
filters: Optional[List[Filter]] = None | ||||||||||||
|
||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The filters field should specify the Filter type properly in the DashboardWidget class. Consider adding a Property mapping in the api_spec similar to how other nested objects are handled, to ensure proper deserialization of Filter objects.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||
|
||||||||||||
@dataclass | ||||||||||||
class ServiceAlert(JSONObject): | ||||||||||||
""" | ||||||||||||
Represents alert configuration options for a monitor service. | ||||||||||||
""" | ||||||||||||
|
||||||||||||
polling_interval_seconds: Optional[List[int]] = None | ||||||||||||
evaluation_period_seconds: Optional[List[int]] = None | ||||||||||||
scope: Optional[List[str]] = None | ||||||||||||
|
||||||||||||
|
||||||||||||
@dataclass | ||||||||||||
|
@@ -135,9 +164,7 @@ class MonitorMetricsDefinition(JSONObject): | |||||||||||
scrape_interval: int = 0 | ||||||||||||
is_alertable: bool = False | ||||||||||||
dimensions: Optional[List[Dimension]] = None | ||||||||||||
available_aggregate_functions: List[AggregateFunction] = field( | ||||||||||||
default_factory=list | ||||||||||||
) | ||||||||||||
available_aggregate_functions: Optional[List[AggregateFunction]] = None | ||||||||||||
|
||||||||||||
|
||||||||||||
class MonitorDashboard(Base): | ||||||||||||
|
@@ -154,7 +181,7 @@ class MonitorDashboard(Base): | |||||||||||
"label": Property(), | ||||||||||||
"service_type": Property(ServiceType), | ||||||||||||
"type": Property(DashboardType), | ||||||||||||
"widgets": Property(List[DashboardWidget]), | ||||||||||||
"widgets": Property(json_object=DashboardWidget), | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The widgets property should be a list of DashboardWidget objects, but the current implementation will only handle a single widget. This should be Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the codebase handles all lists in this way, its specified like this and client can handle widget as list.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The widgets property should use a list type since widgets is expected to be a list of DashboardWidget objects. This should be
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The widgets property should handle a list of DashboardWidget objects, but the current implementation only handles a single object. This should be
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||
"updated": Property(is_datetime=True), | ||||||||||||
} | ||||||||||||
|
||||||||||||
|
@@ -171,6 +198,7 @@ class MonitorService(Base): | |||||||||||
properties = { | ||||||||||||
"service_type": Property(ServiceType), | ||||||||||||
"label": Property(), | ||||||||||||
"alert": Property(json_object=ServiceAlert), | ||||||||||||
} | ||||||||||||
|
||||||||||||
|
||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.