grafana / cog

Code Generation with a human touch
Apache License 2.0
48 stars 2 forks source link

Java: Fix aliases #485

Closed spinillos closed 4 months ago

spinillos commented 4 months ago

This PR fixes some issues when we a class extends from a List and, in that case, we want to use the list directly. This is was working as an alias that didn't work because extending from a list/map needs extra implementations.

Apart of this, it fixes the case when a map value is ref of an any scalar.

github-actions[bot] commented 4 months ago

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` ```patch diff --git a/python/grafana_foundation_sdk/cog/plugins.py b/python/grafana_foundation_sdk/cog/plugins.py index 1a2e2d0..79cdecb 100644 --- a/python/grafana_foundation_sdk/cog/plugins.py +++ b/python/grafana_foundation_sdk/cog/plugins.py @@ -1,39 +1,39 @@ # Code generated - EDITING IS FUTILE. DO NOT EDIT. -from ..models import googlecloudmonitoring +from ..models import grafanapyroscope +from ..models import logs +from ..models import loki +from ..models import statushistory +from ..models import prometheus +from ..models import barchart +from ..models import datagrid from ..models import nodegraph -from ..models import tempo -from ..models import text -from ..models import cloudwatch +from ..models import azuremonitor +from ..models import table from ..models import dashboardlist +from ..models import tempo +from ..models import elasticsearch from ..models import parca -from ..models import table -from ..models import barchart -from ..models import statushistory -from ..models import timeseries from ..models import stat +from ..models import expr +from ..models import googlecloudmonitoring +from ..models import trend +from ..models import bargauge +from ..models import cloudwatch from ..models import gauge -from ..models import heatmap +from ..models import geomap from ..models import xychart -from ..models import azuremonitor from ..models import annotationslist -from ..models import bargauge -from ..models import elasticsearch -from ..models import geomap -from ..models import histogram -from ..models import logs -from ..models import candlestick -from ..models import grafanapyroscope -from ..models import news -from ..models import piechart -from ..models import expr -from ..models import datagrid +from ..models import canvas from ..models import debug -from ..models import loki +from ..models import piechart +from ..models import news from ..models import statetimeline -from ..models import trend -from ..models import prometheus -from ..models import canvas +from ..models import text +from ..models import candlestick +from ..models import heatmap +from ..models import histogram +from ..models import timeseries from . import runtime as cogruntime diff --git a/python/grafana_foundation_sdk/models/cloudwatch.py b/python/grafana_foundation_sdk/models/cloudwatch.py index 68ad69b..4db2b96 100644 --- a/python/grafana_foundation_sdk/models/cloudwatch.py +++ b/python/grafana_foundation_sdk/models/cloudwatch.py @@ -332,7 +332,7 @@ class SQLExpression: if "select" in data: args["select"] = QueryEditorFunctionExpression.from_json(data["select"]) if "from" in data: - decoding_map: dict[str, typing.Union[typing.Type[QueryEditorFunctionExpression], typing.Type[QueryEditorPropertyExpression]]] = {"function": QueryEditorFunctionExpression, "property": QueryEditorPropertyExpression} + decoding_map: dict[str, typing.Union[typing.Type[QueryEditorPropertyExpression], typing.Type[QueryEditorFunctionExpression]]] = {"property": QueryEditorPropertyExpression, "function": QueryEditorFunctionExpression} args["from_val"] = decoding_map[data["from"]["type"]].from_json(data["from"]) if "where" in data: args["where"] = QueryEditorArrayExpression.from_json(data["where"]) @@ -894,7 +894,7 @@ CloudWatchQuery: typing.TypeAlias = typing.Union['CloudWatchMetricsQuery', 'Clou def variant_config() -> cogruntime.DataqueryConfig: - decoding_map: dict[str, typing.Union[typing.Type[CloudWatchMetricsQuery], typing.Type[CloudWatchLogsQuery], typing.Type[CloudWatchAnnotationQuery]]] = {"Metrics": CloudWatchMetricsQuery, "Logs": CloudWatchLogsQuery, "Annotations": CloudWatchAnnotationQuery} + decoding_map: dict[str, typing.Union[typing.Type[CloudWatchLogsQuery], typing.Type[CloudWatchAnnotationQuery], typing.Type[CloudWatchMetricsQuery]]] = {"Logs": CloudWatchLogsQuery, "Annotations": CloudWatchAnnotationQuery, "Metrics": CloudWatchMetricsQuery} return cogruntime.DataqueryConfig( identifier="cloudwatch", from_json_hook=lambda data: decoding_map[data["queryMode"]].from_json(data), diff --git a/python/grafana_foundation_sdk/models/expr.py b/python/grafana_foundation_sdk/models/expr.py index bcd9dbf..5dd1737 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[TypeReduce], typing.Type[TypeResample], typing.Type[TypeClassicConditions], typing.Type[TypeThreshold], typing.Type[TypeSql], typing.Type[TypeMath]]] = {"reduce": TypeReduce, "resample": TypeResample, "classic_conditions": TypeClassicConditions, "threshold": TypeThreshold, "sql": TypeSql, "math": TypeMath} + 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 6382073..3f94a3c 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -13,7 +13,7 @@ keywords = [ "traces", "metrics" ] -version = "1719238427!next" +version = "1719248757!next" dependencies = [] requires-python = ">=3.11" classifiers = [ diff --git a/typescript/package.json b/typescript/package.json index 20699cd..a1a4b23 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@grafana/grafana-foundation-sdk", - "version": "next-cogv0.0.x.1719238427", + "version": "next-cogv0.0.x.1719248757", "description": "A set of tools, types and libraries for building and manipulating Grafana objects.", "keywords": [ "observability", ```