Skip to content
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

Java: Generate builders for panels #364

Merged
merged 13 commits into from
May 21, 2024
Merged

Java: Generate builders for panels #364

merged 13 commits into from
May 21, 2024

Conversation

spinillos
Copy link
Member

@spinillos spinillos commented May 10, 2024

Contributes to #360

It generates panel's builders for Panels.

It adds a bit "hacky" things to make it works assuming that if there is a builder called "Panel" under a package, it needs a builder. Dashboard one is skipped since it already has a "Panel" builder and we could have file conflicts if we generate it twice.

Most of the changes in the template is to able to do cast to generic objects to be able to set the values. Also the functions that do the stuff have comments to be able to understand what they are doing if we need to re-check them in the future.

@spinillos spinillos requested a review from a team as a code owner May 10, 2024 10:40
Copy link

github-actions bot commented May 10, 2024

Note: in addition to the changes introduced by this PR, the diff includes unreleased changes living in main.

🔎 Changes to grafana-foundation-sdk@next+cog-v0.0.x

diff --git a/python/grafana_foundation_sdk/cog/plugins.py b/python/grafana_foundation_sdk/cog/plugins.py
index 531c293..0123285 100644
--- a/python/grafana_foundation_sdk/cog/plugins.py
+++ b/python/grafana_foundation_sdk/cog/plugins.py
@@ -1,37 +1,37 @@
 # Code generated - EDITING IS FUTILE. DO NOT EDIT.
 
+from ..models import datagrid
+from ..models import googlecloudmonitoring
+from ..models import azuremonitor
+from ..models import loki
+from ..models import stat
 from ..models import statetimeline
+from ..models import table
+from ..models import news
 from ..models import statushistory
-from ..models import annotationslist
-from ..models import geomap
-from ..models import prometheus
 from ..models import trend
-from ..models import gauge
-from ..models import piechart
+from ..models import annotationslist
 from ..models import barchart
-from ..models import news
-from ..models import parca
-from ..models import azuremonitor
-from ..models import logs
-from ..models import dashboardlist
-from ..models import elasticsearch
-from ..models import heatmap
-from ..models import bargauge
-from ..models import cloudwatch
-from ..models import googlecloudmonitoring
+from ..models import canvas
 from ..models import grafanapyroscope
-from ..models import stat
+from ..models import histogram
+from ..models import logs
 from ..models import tempo
-from ..models import text
+from ..models import dashboardlist
+from ..models import nodegraph
 from ..models import candlestick
-from ..models import datagrid
+from ..models import parca
 from ..models import debug
-from ..models import histogram
-from ..models import loki
-from ..models import nodegraph
-from ..models import table
-from ..models import canvas
+from ..models import elasticsearch
+from ..models import geomap
+from ..models import prometheus
+from ..models import text
 from ..models import timeseries
+from ..models import bargauge
+from ..models import cloudwatch
+from ..models import gauge
+from ..models import heatmap
+from ..models import piechart
 from ..models import xychart
 from . import runtime as cogruntime
 
diff --git a/python/grafana_foundation_sdk/models/expr.py b/python/grafana_foundation_sdk/models/expr.py
index 607595d..8297051 100644
--- a/python/grafana_foundation_sdk/models/expr.py
+++ b/python/grafana_foundation_sdk/models/expr.py
@@ -9,7 +9,7 @@ Expr: typing.TypeAlias = typing.Union['TypeMath', 'TypeReduce', 'TypeResample',
 
 
 def variant_config() -> cogruntime.DataqueryConfig:
-    decoding_map: dict[str, typing.Union[typing.Type[TypeSql], typing.Type[TypeMath], typing.Type[TypeReduce], typing.Type[TypeResample], typing.Type[TypeClassicConditions], typing.Type[TypeThreshold]]] = {"sql": TypeSql, "math": TypeMath, "reduce": TypeReduce, "resample": TypeResample, "classic_conditions": TypeClassicConditions, "threshold": TypeThreshold}
+    decoding_map: dict[str, typing.Union[typing.Type[TypeMath], typing.Type[TypeReduce], typing.Type[TypeResample], typing.Type[TypeClassicConditions], typing.Type[TypeThreshold], typing.Type[TypeSql]]] = {"math": TypeMath, "reduce": TypeReduce, "resample": TypeResample, "classic_conditions": TypeClassicConditions, "threshold": TypeThreshold, "sql": TypeSql}
     return cogruntime.DataqueryConfig(
         identifier="__expr__",
         from_json_hook=lambda data: decoding_map[data["type"]].from_json(data),
diff --git a/python/pyproject.toml b/python/pyproject.toml
index 56e834b..70aef6f 100644
--- a/python/pyproject.toml
+++ b/python/pyproject.toml
@@ -13,7 +13,7 @@ keywords = [
     "traces",
     "metrics"
 ]
-version = "1716284551!next"
+version = "1716290218!next"
 dependencies = []
 requires-python = ">=3.11"
 classifiers = [
diff --git a/typescript/package.json b/typescript/package.json
index c4642f3..88908af 100644
--- a/typescript/package.json
+++ b/typescript/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@grafana/grafana-foundation-sdk",
-  "version": "next-cogv0.0.x.1716284551",
+  "version": "next-cogv0.0.x.1716290218",
   "description": "A set of tools, types and libraries for building and manipulating Grafana objects.",
   "keywords": [
     "observability",

@spinillos spinillos mentioned this pull request May 10, 2024
11 tasks
Copy link
Member

@K-Phoen K-Phoen left a comment

Choose a reason for hiding this comment

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

Approving so that we can keep iterating on this, but we need to fix the tests before merging 😬

@spinillos
Copy link
Member Author

The error is fixed in the other PR.

@spinillos spinillos merged commit 2726ab0 into main May 21, 2024
10 checks passed
@spinillos spinillos deleted the java/panel-builders branch May 21, 2024 11:19
K-Phoen pushed a commit that referenced this pull request May 21, 2024
* Generate builders for panels

* Already fixed in other PR to avoid to add noise

* Update comments

* Fix casting

* Add functions to all class templates

* Fix defaults

* Fix imports in panel template

* Fix missing function error

* Create generic function for template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants