Widget

Struct Widget 

Source
#[non_exhaustive]
pub struct Widget { pub definition: WidgetDefinition, pub id: Option<i64>, pub layout: Option<WidgetLayout>, pub additional_properties: BTreeMap<String, Value>, /* private fields */ }
Expand description

Information about widget.

Note: The layout property is required for widgets in dashboards with free layout_type. For the new dashboard layout, the layout property depends on the reflow_type of the dashboard. - If reflow_type is fixed, layout is required. - If reflow_type is auto, layout should not be set.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§definition: WidgetDefinition§id: Option<i64>

ID of the widget.

§layout: Option<WidgetLayout>

The layout for a widget on a free or new dashboard layout dashboard.

§additional_properties: BTreeMap<String, Value>

Implementations§

Source§

impl Widget

Source

pub fn new(definition: WidgetDefinition) -> Widget

Examples found in repository?
examples/v1_dashboards_CreateDashboard_417992286.rs (lines 17-19)
13async fn main() {
14    let body = Dashboard::new(
15        DashboardLayoutType::FREE,
16        "Example-Dashboard".to_string(),
17        vec![Widget::new(WidgetDefinition::NoteWidgetDefinition(Box::new(
18            NoteWidgetDefinition::new("# Example Note".to_string(), NoteWidgetDefinitionType::NOTE),
19        )))
20        .layout(WidgetLayout::new(24, 18, 0, 0))],
21    )
22    .description(Some("".to_string()))
23    .notify_list(Some(vec![]))
24    .template_variables(Some(vec![]));
25    let configuration = datadog::Configuration::new();
26    let api = DashboardsAPI::with_config(configuration);
27    let resp = api.create_dashboard(body).await;
28    if let Ok(value) = resp {
29        println!("{:#?}", value);
30    } else {
31        println!("{:#?}", resp.unwrap_err());
32    }
33}
More examples
Hide additional examples
examples/v1_dashboards_CreateDashboard_927141680.rs (lines 20-28)
16async fn main() {
17    let body = Dashboard::new(
18        DashboardLayoutType::ORDERED,
19        "Example-Dashboard with funnel widget".to_string(),
20        vec![Widget::new(WidgetDefinition::FunnelWidgetDefinition(
21            Box::new(FunnelWidgetDefinition::new(
22                vec![FunnelWidgetRequest::new(
23                    FunnelQuery::new(FunnelSource::RUM, "".to_string(), vec![]),
24                    FunnelRequestType::FUNNEL,
25                )],
26                FunnelWidgetDefinitionType::FUNNEL,
27            )),
28        ))],
29    );
30    let configuration = datadog::Configuration::new();
31    let api = DashboardsAPI::with_config(configuration);
32    let resp = api.create_dashboard(body).await;
33    if let Ok(value) = resp {
34        println!("{:#?}", value);
35    } else {
36        println!("{:#?}", resp.unwrap_err());
37    }
38}
examples/v1_dashboards_CreateDashboard_913313564.rs (lines 18-23)
13async fn main() {
14    let body = Dashboard::new(
15        DashboardLayoutType::FREE,
16        "Example-Dashboard".to_string(),
17        vec![
18            Widget::new(WidgetDefinition::IFrameWidgetDefinition(Box::new(
19                IFrameWidgetDefinition::new(
20                    IFrameWidgetDefinitionType::IFRAME,
21                    "https://docs.datadoghq.com/api/latest/".to_string(),
22                ),
23            )))
24            .layout(WidgetLayout::new(12, 12, 0, 0)),
25        ],
26    )
27    .description(Some("".to_string()))
28    .notify_list(Some(vec![]))
29    .template_variables(Some(vec![]));
30    let configuration = datadog::Configuration::new();
31    let api = DashboardsAPI::with_config(configuration);
32    let resp = api.create_dashboard(body).await;
33    if let Ok(value) = resp {
34        println!("{:#?}", value);
35    } else {
36        println!("{:#?}", resp.unwrap_err());
37    }
38}
examples/v1_dashboards_CreateDashboard_651038379.rs (lines 19-25)
14async fn main() {
15    let body = Dashboard::new(
16        DashboardLayoutType::FREE,
17        "Example-Dashboard".to_string(),
18        vec![
19            Widget::new(WidgetDefinition::ImageWidgetDefinition(Box::new(
20                ImageWidgetDefinition::new(
21                    ImageWidgetDefinitionType::IMAGE,
22                    "https://example.com/image.png".to_string(),
23                )
24                .sizing(WidgetImageSizing::COVER),
25            )))
26            .layout(WidgetLayout::new(12, 12, 0, 0)),
27        ],
28    )
29    .description(Some("".to_string()))
30    .notify_list(Some(vec![]))
31    .template_variables(Some(vec![]));
32    let configuration = datadog::Configuration::new();
33    let api = DashboardsAPI::with_config(configuration);
34    let resp = api.create_dashboard(body).await;
35    if let Ok(value) = resp {
36        println!("{:#?}", value);
37    } else {
38        println!("{:#?}", resp.unwrap_err());
39    }
40}
examples/v1_dashboards_CreateDashboard_1738608750.rs (lines 19-27)
14async fn main() {
15    let body = Dashboard::new(
16        DashboardLayoutType::FREE,
17        "Example-Dashboard".to_string(),
18        vec![
19            Widget::new(WidgetDefinition::FreeTextWidgetDefinition(Box::new(
20                FreeTextWidgetDefinition::new(
21                    "Example free text".to_string(),
22                    FreeTextWidgetDefinitionType::FREE_TEXT,
23                )
24                .color("#4d4d4d".to_string())
25                .font_size("auto".to_string())
26                .text_align(WidgetTextAlign::LEFT),
27            )))
28            .layout(WidgetLayout::new(6, 24, 0, 0)),
29        ],
30    )
31    .description(None)
32    .notify_list(Some(vec![]))
33    .template_variables(Some(vec![]));
34    let configuration = datadog::Configuration::new();
35    let api = DashboardsAPI::with_config(configuration);
36    let resp = api.create_dashboard(body).await;
37    if let Ok(value) = resp {
38        println!("{:#?}", value);
39    } else {
40        println!("{:#?}", resp.unwrap_err());
41    }
42}
examples/v1_dashboards_CreateDashboard_2338918735.rs (lines 22-34)
18async fn main() {
19    let body = Dashboard::new(
20        DashboardLayoutType::ORDERED,
21        "Example-Dashboard with list_stream widget".to_string(),
22        vec![Widget::new(WidgetDefinition::ListStreamWidgetDefinition(
23            Box::new(ListStreamWidgetDefinition::new(
24                vec![ListStreamWidgetRequest::new(
25                    vec![ListStreamColumn::new(
26                        "timestamp".to_string(),
27                        ListStreamColumnWidth::AUTO,
28                    )],
29                    ListStreamQuery::new(ListStreamSource::APM_ISSUE_STREAM, "".to_string()),
30                    ListStreamResponseFormat::EVENT_LIST,
31                )],
32                ListStreamWidgetDefinitionType::LIST_STREAM,
33            )),
34        ))],
35    );
36    let configuration = datadog::Configuration::new();
37    let api = DashboardsAPI::with_config(configuration);
38    let resp = api.create_dashboard(body).await;
39    if let Ok(value) = resp {
40        println!("{:#?}", value);
41    } else {
42        println!("{:#?}", resp.unwrap_err());
43    }
44}
Source

pub fn id(self, value: i64) -> Self

Examples found in repository?
examples/v1_dashboards_CreateDashboard_2104498738.rs (line 82)
23async fn main() {
24    let body =
25        Dashboard::new(
26            DashboardLayoutType::ORDERED,
27            "Example-Dashboard".to_string(),
28            vec![
29                Widget::new(
30                    WidgetDefinition::ScatterPlotWidgetDefinition(
31                        Box::new(
32                            ScatterPlotWidgetDefinition::new(
33                                ScatterPlotWidgetDefinitionRequests
34                                ::new().table(
35                                    ScatterplotTableRequest::new()
36                                        .formulas(
37                                            vec![
38                                                ScatterplotWidgetFormula::new(
39                                                    ScatterplotDimension::X,
40                                                    "query1".to_string(),
41                                                ).alias("my-query1".to_string()),
42                                                ScatterplotWidgetFormula::new(
43                                                    ScatterplotDimension::Y,
44                                                    "query2".to_string(),
45                                                ).alias("my-query2".to_string())
46                                            ],
47                                        )
48                                        .queries(
49                                            vec![
50                                                FormulaAndFunctionQueryDefinition
51                                                ::FormulaAndFunctionMetricQueryDefinition(
52                                                    Box::new(
53                                                        FormulaAndFunctionMetricQueryDefinition::new(
54                                                            FormulaAndFunctionMetricDataSource::METRICS,
55                                                            "query1".to_string(),
56                                                            "avg:system.cpu.user{*} by {service}".to_string(),
57                                                        ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
58                                                    ),
59                                                ),
60                                                FormulaAndFunctionQueryDefinition
61                                                ::FormulaAndFunctionMetricQueryDefinition(
62                                                    Box::new(
63                                                        FormulaAndFunctionMetricQueryDefinition::new(
64                                                            FormulaAndFunctionMetricDataSource::METRICS,
65                                                            "query2".to_string(),
66                                                            "avg:system.mem.used{*} by {service}".to_string(),
67                                                        ).aggregator(FormulaAndFunctionMetricAggregation::AVG),
68                                                    ),
69                                                )
70                                            ],
71                                        )
72                                        .response_format(FormulaAndFunctionResponseFormat::SCALAR),
73                                ),
74                                ScatterPlotWidgetDefinitionType::SCATTERPLOT,
75                            )
76                                .title("".to_string())
77                                .title_align(WidgetTextAlign::LEFT)
78                                .title_size("16".to_string()),
79                        ),
80                    ),
81                )
82                    .id(5346764334358972)
83                    .layout(WidgetLayout::new(2, 4, 0, 0))
84            ],
85        );
86    let configuration = datadog::Configuration::new();
87    let api = DashboardsAPI::with_config(configuration);
88    let resp = api.create_dashboard(body).await;
89    if let Ok(value) = resp {
90        println!("{:#?}", value);
91    } else {
92        println!("{:#?}", resp.unwrap_err());
93    }
94}
Source

pub fn layout(self, value: WidgetLayout) -> Self

Examples found in repository?
examples/v1_dashboards_CreateDashboard_417992286.rs (line 20)
13async fn main() {
14    let body = Dashboard::new(
15        DashboardLayoutType::FREE,
16        "Example-Dashboard".to_string(),
17        vec![Widget::new(WidgetDefinition::NoteWidgetDefinition(Box::new(
18            NoteWidgetDefinition::new("# Example Note".to_string(), NoteWidgetDefinitionType::NOTE),
19        )))
20        .layout(WidgetLayout::new(24, 18, 0, 0))],
21    )
22    .description(Some("".to_string()))
23    .notify_list(Some(vec![]))
24    .template_variables(Some(vec![]));
25    let configuration = datadog::Configuration::new();
26    let api = DashboardsAPI::with_config(configuration);
27    let resp = api.create_dashboard(body).await;
28    if let Ok(value) = resp {
29        println!("{:#?}", value);
30    } else {
31        println!("{:#?}", resp.unwrap_err());
32    }
33}
More examples
Hide additional examples
examples/v1_dashboards_CreateDashboard_913313564.rs (line 24)
13async fn main() {
14    let body = Dashboard::new(
15        DashboardLayoutType::FREE,
16        "Example-Dashboard".to_string(),
17        vec![
18            Widget::new(WidgetDefinition::IFrameWidgetDefinition(Box::new(
19                IFrameWidgetDefinition::new(
20                    IFrameWidgetDefinitionType::IFRAME,
21                    "https://docs.datadoghq.com/api/latest/".to_string(),
22                ),
23            )))
24            .layout(WidgetLayout::new(12, 12, 0, 0)),
25        ],
26    )
27    .description(Some("".to_string()))
28    .notify_list(Some(vec![]))
29    .template_variables(Some(vec![]));
30    let configuration = datadog::Configuration::new();
31    let api = DashboardsAPI::with_config(configuration);
32    let resp = api.create_dashboard(body).await;
33    if let Ok(value) = resp {
34        println!("{:#?}", value);
35    } else {
36        println!("{:#?}", resp.unwrap_err());
37    }
38}
examples/v1_dashboards_CreateDashboard_651038379.rs (line 26)
14async fn main() {
15    let body = Dashboard::new(
16        DashboardLayoutType::FREE,
17        "Example-Dashboard".to_string(),
18        vec![
19            Widget::new(WidgetDefinition::ImageWidgetDefinition(Box::new(
20                ImageWidgetDefinition::new(
21                    ImageWidgetDefinitionType::IMAGE,
22                    "https://example.com/image.png".to_string(),
23                )
24                .sizing(WidgetImageSizing::COVER),
25            )))
26            .layout(WidgetLayout::new(12, 12, 0, 0)),
27        ],
28    )
29    .description(Some("".to_string()))
30    .notify_list(Some(vec![]))
31    .template_variables(Some(vec![]));
32    let configuration = datadog::Configuration::new();
33    let api = DashboardsAPI::with_config(configuration);
34    let resp = api.create_dashboard(body).await;
35    if let Ok(value) = resp {
36        println!("{:#?}", value);
37    } else {
38        println!("{:#?}", resp.unwrap_err());
39    }
40}
examples/v1_dashboards_CreateDashboard_1738608750.rs (line 28)
14async fn main() {
15    let body = Dashboard::new(
16        DashboardLayoutType::FREE,
17        "Example-Dashboard".to_string(),
18        vec![
19            Widget::new(WidgetDefinition::FreeTextWidgetDefinition(Box::new(
20                FreeTextWidgetDefinition::new(
21                    "Example free text".to_string(),
22                    FreeTextWidgetDefinitionType::FREE_TEXT,
23                )
24                .color("#4d4d4d".to_string())
25                .font_size("auto".to_string())
26                .text_align(WidgetTextAlign::LEFT),
27            )))
28            .layout(WidgetLayout::new(6, 24, 0, 0)),
29        ],
30    )
31    .description(None)
32    .notify_list(Some(vec![]))
33    .template_variables(Some(vec![]));
34    let configuration = datadog::Configuration::new();
35    let api = DashboardsAPI::with_config(configuration);
36    let resp = api.create_dashboard(body).await;
37    if let Ok(value) = resp {
38        println!("{:#?}", value);
39    } else {
40        println!("{:#?}", resp.unwrap_err());
41    }
42}
examples/v1_dashboards_CreateDashboard_2607944105.rs (line 30)
15async fn main() {
16    let body = Dashboard::new(
17        DashboardLayoutType::FREE,
18        "Example-Dashboard".to_string(),
19        vec![
20            Widget::new(WidgetDefinition::CheckStatusWidgetDefinition(Box::new(
21                CheckStatusWidgetDefinition::new(
22                    "datadog.agent.up".to_string(),
23                    WidgetGrouping::CHECK,
24                    CheckStatusWidgetDefinitionType::CHECK_STATUS,
25                )
26                .tags(vec!["*".to_string()])
27                .title_align(WidgetTextAlign::LEFT)
28                .title_size("16".to_string()),
29            )))
30            .layout(WidgetLayout::new(8, 15, 0, 0)),
31        ],
32    )
33    .description(Some("".to_string()))
34    .notify_list(Some(vec![]))
35    .template_variables(Some(vec![]));
36    let configuration = datadog::Configuration::new();
37    let api = DashboardsAPI::with_config(configuration);
38    let resp = api.create_dashboard(body).await;
39    if let Ok(value) = resp {
40        println!("{:#?}", value);
41    } else {
42        println!("{:#?}", resp.unwrap_err());
43    }
44}
examples/v1_dashboards_CreateDashboard_3250131584.rs (line 29)
14async fn main() {
15    let body = Dashboard::new(
16        DashboardLayoutType::FREE,
17        "Example-Dashboard".to_string(),
18        vec![
19            Widget::new(WidgetDefinition::EventTimelineWidgetDefinition(Box::new(
20                EventTimelineWidgetDefinition::new(
21                    "status:error priority:all".to_string(),
22                    EventTimelineWidgetDefinitionType::EVENT_TIMELINE,
23                )
24                .tags_execution("and".to_string())
25                .title("".to_string())
26                .title_align(WidgetTextAlign::LEFT)
27                .title_size("16".to_string()),
28            )))
29            .layout(WidgetLayout::new(9, 47, 0, 0)),
30        ],
31    )
32    .description(None)
33    .notify_list(Some(vec![]))
34    .template_variables(Some(vec![]));
35    let configuration = datadog::Configuration::new();
36    let api = DashboardsAPI::with_config(configuration);
37    let resp = api.create_dashboard(body).await;
38    if let Ok(value) = resp {
39        println!("{:#?}", value);
40    } else {
41        println!("{:#?}", resp.unwrap_err());
42    }
43}
Source

pub fn additional_properties(self, value: BTreeMap<String, Value>) -> Self

Trait Implementations§

Source§

impl Clone for Widget

Source§

fn clone(&self) -> Widget

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Widget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Widget

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Widget

Source§

fn eq(&self, other: &Widget) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Widget

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Widget

Auto Trait Implementations§

§

impl Freeze for Widget

§

impl RefUnwindSafe for Widget

§

impl Send for Widget

§

impl Sync for Widget

§

impl Unpin for Widget

§

impl UnwindSafe for Widget

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,