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 #2187

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:29.650607",
"spec_repo_commit": "909e369c"
"regenerated": "2024-09-30 20:17:08.960106",
"spec_repo_commit": "64b1c61a"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-30 19:44:29.664206",
"spec_repo_commit": "909e369c"
"regenerated": "2024-09-30 20:17:08.973530",
"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
7 changes: 0 additions & 7 deletions docs/datadog_api_client.v2.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8488,13 +8488,6 @@ datadog\_api\_client.v2.model.security\_monitoring\_list\_rules\_response module
:members:
:show-inheritance:

datadog\_api\_client.v2.model.security\_monitoring\_reference\_table module
---------------------------------------------------------------------------

.. automodule:: datadog_api_client.v2.model.security_monitoring_reference_table
:members:
:show-inheritance:

datadog\_api\_client.v2.model.security\_monitoring\_rule\_case module
---------------------------------------------------------------------

Expand Down
98 changes: 98 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1413226400.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""
Create a new dashboard with a toplist widget with stacked type and no legend specified
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
from datadog_api_client.v1.model.dashboard import Dashboard
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType
from datadog_api_client.v1.model.formula_and_function_metric_aggregation import FormulaAndFunctionMetricAggregation
from datadog_api_client.v1.model.formula_and_function_metric_data_source import FormulaAndFunctionMetricDataSource
from datadog_api_client.v1.model.formula_and_function_metric_query_definition import (
FormulaAndFunctionMetricQueryDefinition,
)
from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat
from datadog_api_client.v1.model.group_type import GroupType
from datadog_api_client.v1.model.toplist_widget_definition import ToplistWidgetDefinition
from datadog_api_client.v1.model.toplist_widget_definition_type import ToplistWidgetDefinitionType
from datadog_api_client.v1.model.toplist_widget_request import ToplistWidgetRequest
from datadog_api_client.v1.model.toplist_widget_scaling import ToplistWidgetScaling
from datadog_api_client.v1.model.toplist_widget_stacked import ToplistWidgetStacked
from datadog_api_client.v1.model.toplist_widget_stacked_type import ToplistWidgetStackedType
from datadog_api_client.v1.model.toplist_widget_style import ToplistWidgetStyle
from datadog_api_client.v1.model.widget import Widget
from datadog_api_client.v1.model.widget_formula import WidgetFormula
from datadog_api_client.v1.model.widget_group_sort import WidgetGroupSort
from datadog_api_client.v1.model.widget_layout import WidgetLayout
from datadog_api_client.v1.model.widget_legacy_live_span import WidgetLegacyLiveSpan
from datadog_api_client.v1.model.widget_sort import WidgetSort
from datadog_api_client.v1.model.widget_sort_by import WidgetSortBy
from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign

body = Dashboard(
title="Example-Dashboard",
description="",
widgets=[
Widget(
layout=WidgetLayout(
x=0,
y=0,
width=47,
height=15,
),
definition=ToplistWidgetDefinition(
title="",
title_size="16",
title_align=WidgetTextAlign.LEFT,
time=WidgetLegacyLiveSpan(),
style=ToplistWidgetStyle(
display=ToplistWidgetStacked(
type=ToplistWidgetStackedType.STACKED,
),
scaling=ToplistWidgetScaling.RELATIVE,
palette="dog_classic",
),
type=ToplistWidgetDefinitionType.TOPLIST,
requests=[
ToplistWidgetRequest(
queries=[
FormulaAndFunctionMetricQueryDefinition(
data_source=FormulaAndFunctionMetricDataSource.METRICS,
name="query1",
query="avg:system.cpu.user{*} by {service}",
aggregator=FormulaAndFunctionMetricAggregation.AVG,
),
],
formulas=[
WidgetFormula(
formula="query1",
),
],
sort=WidgetSortBy(
count=10,
order_by=[
WidgetGroupSort(
type=GroupType.GROUP,
name="service",
order=WidgetSort.ASCENDING,
),
],
),
response_format=FormulaAndFunctionResponseFormat.SCALAR,
),
],
),
),
],
template_variables=[],
layout_type=DashboardLayoutType.FREE,
is_read_only=False,
notify_list=[],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = DashboardsApi(api_client)
response = api_instance.create_dashboard(body=body)

print(response)
10 changes: 0 additions & 10 deletions examples/v2/security-monitoring/CreateSecurityMonitoringRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi
from datadog_api_client.v2.model.security_monitoring_reference_table import SecurityMonitoringReferenceTable
from datadog_api_client.v2.model.security_monitoring_rule_case_create import SecurityMonitoringRuleCaseCreate
from datadog_api_client.v2.model.security_monitoring_rule_evaluation_window import (
SecurityMonitoringRuleEvaluationWindow,
Expand Down Expand Up @@ -53,15 +52,6 @@
tags=[],
is_enabled=True,
type=SecurityMonitoringRuleTypeCreate.LOG_DETECTION,
reference_tables=[
SecurityMonitoringReferenceTable(
table_name="synthetics_test_reference_table_dont_delete",
column_name="value",
log_field_path="testtag",
check_presence=True,
rule_query_name="a",
),
],
)

configuration = Configuration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, **kwargs):
Top list widget display options.

:param legend: Top list widget stacked legend behavior.
:type legend: ToplistWidgetLegend
:type legend: ToplistWidgetLegend, optional

:param type: Top list widget stacked display type.
:type type: ToplistWidgetStackedType
Expand Down
13 changes: 9 additions & 4 deletions src/datadog_api_client/v1/model/toplist_widget_stacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


Expand All @@ -32,17 +34,20 @@ def openapi_types(_):
"type": "type",
}

def __init__(self_, legend: ToplistWidgetLegend, type: ToplistWidgetStackedType, **kwargs):
def __init__(
self_, type: ToplistWidgetStackedType, legend: Union[ToplistWidgetLegend, UnsetType] = unset, **kwargs

Choose a reason for hiding this comment

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

🔴 Code Quality Violation

Suggested change
self_, type: ToplistWidgetStackedType, legend: Union[ToplistWidgetLegend, UnsetType] = unset, **kwargs
self, type: ToplistWidgetStackedType, legend: Union[ToplistWidgetLegend, UnsetType] = unset, **kwargs
first parameter of a class function should be self (...read more)

In a class method (that is not a class method nor a static method), the first argument must be self by convention.

Learn More

View in Datadog  Leave us feedback  Documentation

):
"""
Top list widget stacked display options.

:param legend: Top list widget stacked legend behavior.
:type legend: ToplistWidgetLegend
:type legend: ToplistWidgetLegend, optional

:param type: Top list widget stacked display type.
:type type: ToplistWidgetStackedType
"""
if legend is not unset:
kwargs["legend"] = legend
super().__init__(kwargs)

self_.legend = legend
self_.type = type

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def __init__(self, **kwargs):
:param queries: Queries for selecting logs which are part of the rule.
:type queries: [SecurityMonitoringStandardRuleQuery]

:param reference_tables: Reference tables for the rule.
:type reference_tables: [SecurityMonitoringReferenceTable], optional

:param tags: Tags for generated signals.
:type tags: [str], optional

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def __init__(self, **kwargs):
:param queries: Queries for selecting logs which are part of the rule.
:type queries: [SecurityMonitoringStandardRuleQuery]

:param reference_tables: Reference tables for the rule.
:type reference_tables: [SecurityMonitoringReferenceTable], optional

:param tags: Tags for generated signals.
:type tags: [str], optional

Expand Down
Loading
Loading