Skip to content

Conversation

pmajali
Copy link
Contributor

@pmajali pmajali commented Aug 20, 2025

📝 Description

  1. Adding Monitor in the regions endpoint. This specifies the monitor services enabled in a particular region.
  2. Adding group_by and filters field to the dashboard widget

✔️ How to Test

  1. Testing the regions endpoint
import os
import logging
from linode_api4 import LinodeClient

client = LinodeClient(os.environ.get("MY_PERSONAL_ACCESS_TOKEN"))
client.base_url = "https://api.linode.com/v4beta"

regions=client.regions()
for reg in regions:
    print(f"Region: {reg.id}")
    print(f"  Monitors - Alerts: {reg.monitors.alerts}")
    print(f"  Monitors - Metrics: {reg.monitors.metrics}")
    print("---")
  1. Test group_by and filter in dashboard widget
dashboard = client.monitor.dashboards(service_type="linode")
for d in dashboard:
    print("ID:", d.id)
    print("Service Type:", d.service_type)
    for widget in d.widgets:
        print("Label:", widget.label)
        print("Metric:", widget.metric)
        print("Unit:", widget.unit)
        print("group_by:", widget.group_by)
        if widget.filters:
            for f in widget.filters:
                print("label:", f.dimension_label)
                print("operator:", f.operator)
                print("values:", f.value)

How do I run the relevant unit/integration tests?

unit-test: make test-unit TEST_SUITE=monitor
integration tests: make testint TEST_SUITE=monitor

@pmajali pmajali requested a review from a team as a code owner August 20, 2025 09:30
@pmajali pmajali requested review from yec-akamai and ezilber-akamai and removed request for a team August 20, 2025 09:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds monitoring capabilities to the regions endpoint and enhances dashboard widgets with filtering and grouping functionality. It introduces monitor services information for regions and extends dashboard widget properties to support more advanced query capabilities.

  • Adds monitors field to regions showing which monitoring services are available (alerts and metrics)
  • Adds group_by and filters fields to dashboard widgets for more granular data querying
  • Includes alert configuration properties for monitor services

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

File Description
linode_api4/objects/region.py Adds RegionMonitors class and monitors property to Region class
linode_api4/objects/monitor.py Adds Filter and ServiceAlert classes, updates DashboardWidget with group_by and filters
test/fixtures/*.json Updates test fixtures with new monitor and widget properties
test/unit/objects/*_test.py Adds test coverage for new monitor and region functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

"service_type": Property(ServiceType),
"type": Property(DashboardType),
"widgets": Property(List[DashboardWidget]),
"widgets": Property(json_object=DashboardWidget),
Copy link
Preview

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

The 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 Property(List[DashboardWidget]) to maintain the original list functionality.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@yec-akamai
Copy link
Contributor

Overall looks good, can you fix the build issue please?

@pmajali
Copy link
Contributor Author

pmajali commented Sep 23, 2025

Overall looks good, can you fix the build issue please?

I'm already using the default_factory for filters field in dashboard, I still see this in build logs.
ValueError: mutable default <class 'types.SimpleNamespace'> for field filters is not allowed: use default_factory

Can you suggest how can this be resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants