Skip to content
Merged
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
116 changes: 112 additions & 4 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4612,10 +4612,14 @@ components:
- $ref: "#/components/schemas/HeatgridThemeColors"
HeatgridColorBin:
additionalProperties: false
description: A color and optional lower threshold for a discrete bin.
description: A color, optional lower threshold, and optional label for a discrete bin.
properties:
color:
$ref: "#/components/schemas/HeatgridColor"
label:
description: Name of the bin.
maxLength: 255
type: string
lower_bound:
description: Inclusive lower bound. Omit for the first bin.
format: double
Expand Down Expand Up @@ -4749,12 +4753,15 @@ components:
type: object
HeatgridLabelColumn:
additionalProperties: false
description: Configuration of the group label column.
description: Configuration of the group label column. Its width is sized automatically when omitted.
properties:
text_formats:
description: Ordered string replacement rules for the group labels.
items:
$ref: "#/components/schemas/HeatgridTextFormatRule"
type: array
width:
$ref: "#/components/schemas/HeatgridLabelColumnWidth"
required:
- width
type: object
HeatgridLabelColumnWidth:
description: Width of the label column.
Expand Down Expand Up @@ -4880,6 +4887,107 @@ components:
x-enum-varnames:
- ASC
- DESC
HeatgridTextFormatMatch:
additionalProperties: false
description: Match a group label against a string.
properties:
type:
$ref: "#/components/schemas/HeatgridTextFormatMatchType"
value:
description: String to compare with the group label.
example: ""
maxLength: 255
type: string
required:
- type
- value
type: object
HeatgridTextFormatMatchType:
description: Comparison used to match a group label.
enum:
- is
- is_not
- contains
- does_not_contain
- starts_with
- ends_with
example: is
type: string
x-enum-varnames:
- IS
- IS_NOT
- CONTAINS
- DOES_NOT_CONTAIN
- STARTS_WITH
- ENDS_WITH
HeatgridTextFormatReplace:
description: Replace all or part of a matching group label.
oneOf:
- $ref: "#/components/schemas/HeatgridTextFormatReplaceAll"
- $ref: "#/components/schemas/HeatgridTextFormatReplaceSubstring"
HeatgridTextFormatReplaceAll:
additionalProperties: false
description: Replace the entire matching group label.
properties:
type:
$ref: "#/components/schemas/HeatgridTextFormatReplaceAllType"
with:
description: Replacement string.
example: ""
maxLength: 255
type: string
required:
- type
- with
type: object
HeatgridTextFormatReplaceAllType:
description: Replace the entire matching group label.
enum:
- all
example: all
type: string
x-enum-varnames:
- ALL
HeatgridTextFormatReplaceSubstring:
additionalProperties: false
description: Replace a substring of the matching group label.
properties:
substring:
description: Substring to replace.
example: ""
maxLength: 255
type: string
type:
$ref: "#/components/schemas/HeatgridTextFormatReplaceSubstringType"
with:
description: Replacement string.
example: ""
maxLength: 255
type: string
required:
- type
- substring
- with
type: object
HeatgridTextFormatReplaceSubstringType:
description: Replace a substring of a matching group label.
enum:
- substring
example: substring
type: string
x-enum-varnames:
- SUBSTRING
HeatgridTextFormatRule:
additionalProperties: false
description: A rule for matching and optionally replacing a group label.
properties:
match:
$ref: "#/components/schemas/HeatgridTextFormatMatch"
replace:
$ref: "#/components/schemas/HeatgridTextFormatReplace"
required:
- match
type: object
HeatgridThemeColors:
description: Two color strings for the light and dark themes, in that order.
example: ["#FFFFFF", "#000000"]
Expand Down
122 changes: 122 additions & 0 deletions examples/v1/dashboards/CreateDashboard_209524718.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
"""
Create a heatgrid widget with bin labels and formatted row labels
"""

from os import environ
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_data_source import FormulaAndFunctionMetricDataSource
from datadog_api_client.v1.model.formula_and_function_metric_query_definition import (
FormulaAndFunctionMetricQueryDefinition,
)
from datadog_api_client.v1.model.heatgrid_color_bin import HeatgridColorBin
from datadog_api_client.v1.model.heatgrid_custom_color_source import HeatgridCustomColorSource
from datadog_api_client.v1.model.heatgrid_discrete_custom_color import HeatgridDiscreteCustomColor
from datadog_api_client.v1.model.heatgrid_discrete_mode import HeatgridDiscreteMode
from datadog_api_client.v1.model.heatgrid_label_column import HeatgridLabelColumn
from datadog_api_client.v1.model.heatgrid_nesting_display import HeatgridNestingDisplay
from datadog_api_client.v1.model.heatgrid_sort import HeatgridSort
from datadog_api_client.v1.model.heatgrid_sort_by_label import HeatgridSortByLabel
from datadog_api_client.v1.model.heatgrid_sort_by_label_property import HeatgridSortByLabelProperty
from datadog_api_client.v1.model.heatgrid_sort_order import HeatgridSortOrder
from datadog_api_client.v1.model.heatgrid_text_format_match import HeatgridTextFormatMatch
from datadog_api_client.v1.model.heatgrid_text_format_match_type import HeatgridTextFormatMatchType
from datadog_api_client.v1.model.heatgrid_text_format_replace_all import HeatgridTextFormatReplaceAll
from datadog_api_client.v1.model.heatgrid_text_format_replace_all_type import HeatgridTextFormatReplaceAllType
from datadog_api_client.v1.model.heatgrid_text_format_replace_substring import HeatgridTextFormatReplaceSubstring
from datadog_api_client.v1.model.heatgrid_text_format_replace_substring_type import (
HeatgridTextFormatReplaceSubstringType,
)
from datadog_api_client.v1.model.heatgrid_text_format_rule import HeatgridTextFormatRule
from datadog_api_client.v1.model.heatgrid_widget_definition import HeatgridWidgetDefinition
from datadog_api_client.v1.model.heatgrid_widget_definition_type import HeatgridWidgetDefinitionType
from datadog_api_client.v1.model.heatgrid_widget_formula import HeatgridWidgetFormula
from datadog_api_client.v1.model.heatgrid_widget_request import HeatgridWidgetRequest
from datadog_api_client.v1.model.heatgrid_widget_response_format import HeatgridWidgetResponseFormat
from datadog_api_client.v1.model.widget import Widget

body = Dashboard(
title="Example-Dashboard",
layout_type=DashboardLayoutType.ORDERED,
widgets=[
Widget(
definition=HeatgridWidgetDefinition(
type=HeatgridWidgetDefinitionType.HEATGRID,
requests=[
HeatgridWidgetRequest(
response_format=HeatgridWidgetResponseFormat.TIMESERIES,
queries=[
FormulaAndFunctionMetricQueryDefinition(
data_source=FormulaAndFunctionMetricDataSource.METRICS,
name="query1",
query="avg:system.cpu.user{*} by {host}",
),
],
formulas=[
HeatgridWidgetFormula(
formula="query1",
),
],
),
],
sort=HeatgridSort(
nesting_display=HeatgridNestingDisplay.FLAT,
sort_by=HeatgridSortByLabel(
_property=HeatgridSortByLabelProperty.LABEL,
order=HeatgridSortOrder.ASC,
),
),
color=HeatgridDiscreteCustomColor(
mode=HeatgridDiscreteMode.DISCRETE,
source=HeatgridCustomColorSource.CUSTOM,
bins=[
HeatgridColorBin(
color="#00FF00",
label="Normal",
),
HeatgridColorBin(
color="#FF0000",
lower_bound=80.0,
label="High",
),
],
),
label_column=HeatgridLabelColumn(
text_formats=[
HeatgridTextFormatRule(
match=HeatgridTextFormatMatch(
type=HeatgridTextFormatMatchType.STARTS_WITH,
value="api-",
),
replace=HeatgridTextFormatReplaceSubstring(
type=HeatgridTextFormatReplaceSubstringType.SUBSTRING,
substring="api-",
_with="",
),
),
HeatgridTextFormatRule(
match=HeatgridTextFormatMatch(
type=HeatgridTextFormatMatchType.IS,
value="unknown",
),
replace=HeatgridTextFormatReplaceAll(
type=HeatgridTextFormatReplaceAllType.ALL,
_with="Other",
),
),
],
),
),
),
],
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = DashboardsApi(api_client)
response = api_instance.create_dashboard(body=body)

print(response)
21 changes: 19 additions & 2 deletions src/datadog_api_client/v1/model/heatgrid_color_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@


class HeatgridColorBin(ModelNormal):
validations = {
"label": {
"max_length": 255,
},
}

@cached_property
def additional_properties_type(_):
return None
Expand All @@ -28,26 +34,37 @@ def openapi_types(_):

return {
"color": (HeatgridColor,),
"label": (str,),
"lower_bound": (float,),
}

attribute_map = {
"color": "color",
"label": "label",
"lower_bound": "lower_bound",
}

def __init__(
self_, color: Union[HeatgridColor, str, List[str]], lower_bound: Union[float, UnsetType] = unset, **kwargs
self_,
color: Union[HeatgridColor, str, List[str]],
label: Union[str, UnsetType] = unset,
lower_bound: Union[float, UnsetType] = unset,
**kwargs,
):
"""
A color and optional lower threshold for a discrete bin.
A color, optional lower threshold, and optional label for a discrete bin.

:param color: A color string, or two color strings for the light and dark themes, in that order.
:type color: HeatgridColor

:param label: Name of the bin.
:type label: str, optional

:param lower_bound: Inclusive lower bound. Omit for the first bin.
:type lower_bound: float, optional
"""
if label is not unset:
kwargs["label"] = label
if lower_bound is not unset:
kwargs["lower_bound"] = lower_bound
super().__init__(kwargs)
Expand Down
28 changes: 22 additions & 6 deletions src/datadog_api_client/v1/model/heatgrid_label_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import List, Union, TYPE_CHECKING

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


if TYPE_CHECKING:
from datadog_api_client.v1.model.heatgrid_text_format_rule import HeatgridTextFormatRule
from datadog_api_client.v1.model.heatgrid_label_column_width import HeatgridLabelColumnWidth


Expand All @@ -22,23 +25,36 @@ def additional_properties_type(_):

@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.heatgrid_text_format_rule import HeatgridTextFormatRule
from datadog_api_client.v1.model.heatgrid_label_column_width import HeatgridLabelColumnWidth

return {
"text_formats": ([HeatgridTextFormatRule],),
"width": (HeatgridLabelColumnWidth,),
}

attribute_map = {
"text_formats": "text_formats",
"width": "width",
}

def __init__(self_, width: HeatgridLabelColumnWidth, **kwargs):
def __init__(
self_,
text_formats: Union[List[HeatgridTextFormatRule], UnsetType] = unset,
width: Union[HeatgridLabelColumnWidth, UnsetType] = unset,
**kwargs,
):
"""
Configuration of the group label column.
Configuration of the group label column. Its width is sized automatically when omitted.

:param text_formats: Ordered string replacement rules for the group labels.
:type text_formats: [HeatgridTextFormatRule], optional

:param width: Width of the label column.
:type width: HeatgridLabelColumnWidth
:type width: HeatgridLabelColumnWidth, optional
"""
if text_formats is not unset:
kwargs["text_formats"] = text_formats
if width is not unset:
kwargs["width"] = width
super().__init__(kwargs)

self_.width = width
Loading
Loading