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

[DO NOT MERGE] Bruce.tu/fix stacked widget display legend required 2 #2503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-30 19:44:25.543007",
"spec_repo_commit": "909e369c"
"regenerated": "2024-09-30 20:17:21.197466",
"spec_repo_commit": "64b1c61a"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-30 19:44:25.557128",
"spec_repo_commit": "909e369c"
"regenerated": "2024-09-30 20:17:21.212019",
"spec_repo_commit": "64b1c61a"
}
}
}
1 change: 0 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17286,7 +17286,6 @@ components:
$ref: '#/components/schemas/ToplistWidgetStackedType'
required:
- type
- legend
type: object
ToplistWidgetStackedType:
default: stacked
Expand Down
44 changes: 0 additions & 44 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19089,25 +19089,6 @@ components:
meta:
$ref: '#/components/schemas/ResponseMetaAttributes'
type: object
SecurityMonitoringReferenceTable:
description: Reference table for the rule.
properties:
checkPresence:
description: Whether to include or exclude the matched values.
type: boolean
columnName:
description: The name of the column in the reference table.
type: string
logFieldPath:
description: The field in the log to match against the reference table.
type: string
ruleQueryName:
description: The name of the rule query to apply the reference table to.
type: string
tableName:
description: The name of the reference table.
type: string
type: object
SecurityMonitoringRuleCase:
description: Case when signal is generated.
properties:
Expand Down Expand Up @@ -19613,11 +19594,6 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringRuleQuery'
type: array
referenceTables:
description: Reference tables for the rule.
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
tags:
description: Tags for generated signals.
items:
Expand Down Expand Up @@ -20322,11 +20298,6 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
type: array
referenceTables:
description: Reference tables for the rule.
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
tags:
description: Tags for generated signals.
example:
Expand Down Expand Up @@ -20394,11 +20365,6 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
type: array
referenceTables:
description: Reference tables for the rule.
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
tags:
description: Tags for generated signals.
example:
Expand Down Expand Up @@ -20539,11 +20505,6 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
type: array
referenceTables:
description: Reference tables for the rule.
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
tags:
description: Tags for generated signals.
items:
Expand Down Expand Up @@ -20608,11 +20569,6 @@ components:
items:
$ref: '#/components/schemas/SecurityMonitoringStandardRuleQuery'
type: array
referenceTables:
description: Reference tables for the rule.
items:
$ref: '#/components/schemas/SecurityMonitoringReferenceTable'
type: array
tags:
description: Tags for generated signals.
example:
Expand Down
112 changes: 112 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1413226400.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Create a new dashboard with a toplist widget with stacked type and no legend specified

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.DashboardsApi;
import com.datadog.api.client.v1.model.Dashboard;
import com.datadog.api.client.v1.model.DashboardLayoutType;
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricAggregation;
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricDataSource;
import com.datadog.api.client.v1.model.FormulaAndFunctionMetricQueryDefinition;
import com.datadog.api.client.v1.model.FormulaAndFunctionQueryDefinition;
import com.datadog.api.client.v1.model.FormulaAndFunctionResponseFormat;
import com.datadog.api.client.v1.model.GroupType;
import com.datadog.api.client.v1.model.ToplistWidgetDefinition;
import com.datadog.api.client.v1.model.ToplistWidgetDefinitionType;
import com.datadog.api.client.v1.model.ToplistWidgetDisplay;
import com.datadog.api.client.v1.model.ToplistWidgetRequest;
import com.datadog.api.client.v1.model.ToplistWidgetScaling;
import com.datadog.api.client.v1.model.ToplistWidgetStacked;
import com.datadog.api.client.v1.model.ToplistWidgetStackedType;
import com.datadog.api.client.v1.model.ToplistWidgetStyle;
import com.datadog.api.client.v1.model.Widget;
import com.datadog.api.client.v1.model.WidgetDefinition;
import com.datadog.api.client.v1.model.WidgetFormula;
import com.datadog.api.client.v1.model.WidgetGroupSort;
import com.datadog.api.client.v1.model.WidgetLayout;
import com.datadog.api.client.v1.model.WidgetLegacyLiveSpan;
import com.datadog.api.client.v1.model.WidgetSort;
import com.datadog.api.client.v1.model.WidgetSortBy;
import com.datadog.api.client.v1.model.WidgetSortOrderBy;
import com.datadog.api.client.v1.model.WidgetTextAlign;
import com.datadog.api.client.v1.model.WidgetTime;
import java.util.Collections;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
DashboardsApi apiInstance = new DashboardsApi(defaultClient);

Dashboard body =
new Dashboard()
.title("Example-Dashboard")
.description("")
.widgets(
Collections.singletonList(
new Widget()
.layout(new WidgetLayout().x(0L).y(0L).width(47L).height(15L))
.definition(
new WidgetDefinition(
new ToplistWidgetDefinition()
.title("")
.titleSize("16")
.titleAlign(WidgetTextAlign.LEFT)
.time(new WidgetTime(new WidgetLegacyLiveSpan()))
.style(
new ToplistWidgetStyle()
.display(
new ToplistWidgetDisplay(
new ToplistWidgetStacked()
.type(ToplistWidgetStackedType.STACKED)))
.scaling(ToplistWidgetScaling.RELATIVE)
.palette("dog_classic"))
.type(ToplistWidgetDefinitionType.TOPLIST)
.requests(
Collections.singletonList(
new ToplistWidgetRequest()
.queries(
Collections.singletonList(
new FormulaAndFunctionQueryDefinition(
new FormulaAndFunctionMetricQueryDefinition()
.dataSource(
FormulaAndFunctionMetricDataSource
.METRICS)
.name("query1")
.query(
"avg:system.cpu.user{*} by"
+ " {service}")
.aggregator(
FormulaAndFunctionMetricAggregation
.AVG))))
.formulas(
Collections.singletonList(
new WidgetFormula().formula("query1")))
.sort(
new WidgetSortBy()
.count(10L)
.orderBy(
Collections.singletonList(
new WidgetSortOrderBy(
new WidgetGroupSort()
.type(GroupType.GROUP)
.name("service")
.order(
WidgetSort
.ASCENDING)))))
.responseFormat(
FormulaAndFunctionResponseFormat.SCALAR)))))))
.layoutType(DashboardLayoutType.FREE)
.isReadOnly(false);

try {
Dashboard result = apiInstance.createDashboard(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DashboardsApi#createDashboard");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SecurityMonitoringApi;
import com.datadog.api.client.v2.model.SecurityMonitoringReferenceTable;
import com.datadog.api.client.v2.model.SecurityMonitoringRuleCaseCreate;
import com.datadog.api.client.v2.model.SecurityMonitoringRuleCreatePayload;
import com.datadog.api.client.v2.model.SecurityMonitoringRuleEvaluationWindow;
Expand Down Expand Up @@ -46,15 +45,7 @@ public static void main(String[] args) {
.maxSignalDuration(SecurityMonitoringRuleMaxSignalDuration.ONE_DAY))
.message("Test rule")
.isEnabled(true)
.type(SecurityMonitoringRuleTypeCreate.LOG_DETECTION)
.referenceTables(
Collections.singletonList(
new SecurityMonitoringReferenceTable()
.tableName("synthetics_test_reference_table_dont_delete")
.columnName("value")
.logFieldPath("testtag")
.checkPresence(true)
.ruleQueryName("a"))));
.type(SecurityMonitoringRuleTypeCreate.LOG_DETECTION));

try {
SecurityMonitoringRuleResponse result = apiInstance.createSecurityMonitoringRule(body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public ToplistWidgetStacked() {}

@JsonCreator
public ToplistWidgetStacked(
@JsonProperty(required = true, value = JSON_PROPERTY_LEGEND) ToplistWidgetLegend legend,
@JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ToplistWidgetStackedType type) {
this.legend = legend;
this.unparsed |= !legend.isValid();
this.type = type;
this.unparsed |= !type.isValid();
}
Expand All @@ -55,8 +52,9 @@ public ToplistWidgetStacked legend(ToplistWidgetLegend legend) {
*
* @return legend
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_LEGEND)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public ToplistWidgetLegend getLegend() {
return legend;
}
Expand Down
Loading
Loading