-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathUpdateNotebook.rb
More file actions
61 lines (58 loc) · 2.62 KB
/
UpdateNotebook.rb
File metadata and controls
61 lines (58 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Update a notebook returns "OK" response
require "datadog_api_client"
api_instance = DatadogAPIClient::V1::NotebooksAPI.new
# there is a valid "notebook" in the system
NOTEBOOK_DATA_ID = ENV["NOTEBOOK_DATA_ID"]
body = DatadogAPIClient::V1::NotebookUpdateRequest.new({
data: DatadogAPIClient::V1::NotebookUpdateData.new({
attributes: DatadogAPIClient::V1::NotebookUpdateDataAttributes.new({
cells: [
DatadogAPIClient::V1::NotebookCellCreateRequest.new({
attributes: DatadogAPIClient::V1::NotebookMarkdownCellAttributes.new({
definition: DatadogAPIClient::V1::NotebookMarkdownCellDefinition.new({
text: '## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```',
type: DatadogAPIClient::V1::NotebookMarkdownCellDefinitionType::MARKDOWN,
}),
}),
type: DatadogAPIClient::V1::NotebookCellResourceType::NOTEBOOK_CELLS,
}),
DatadogAPIClient::V1::NotebookCellCreateRequest.new({
attributes: DatadogAPIClient::V1::NotebookTimeseriesCellAttributes.new({
definition: DatadogAPIClient::V1::TimeseriesWidgetDefinition.new({
requests: [
DatadogAPIClient::V1::TimeseriesWidgetRequest.new({
display_type: DatadogAPIClient::V1::WidgetDisplayType::LINE,
q: "avg:system.load.1{*}",
style: DatadogAPIClient::V1::WidgetRequestStyle.new({
line_type: DatadogAPIClient::V1::WidgetLineType::SOLID,
line_width: DatadogAPIClient::V1::WidgetLineWidth::NORMAL,
palette: "dog_classic",
}),
}),
],
show_legend: true,
type: DatadogAPIClient::V1::TimeseriesWidgetDefinitionType::TIMESERIES,
yaxis: DatadogAPIClient::V1::WidgetAxis.new({
scale: "linear",
}),
}),
graph_size: DatadogAPIClient::V1::NotebookGraphSize::MEDIUM,
split_by: DatadogAPIClient::V1::NotebookSplitBy.new({
keys: [],
tags: [],
}),
time: nil,
}),
type: DatadogAPIClient::V1::NotebookCellResourceType::NOTEBOOK_CELLS,
}),
],
name: "Example-Notebook-updated",
status: DatadogAPIClient::V1::NotebookStatus::PUBLISHED,
time: DatadogAPIClient::V1::NotebookRelativeTime.new({
live_span: DatadogAPIClient::V1::WidgetLiveSpan::PAST_ONE_HOUR,
}),
}),
type: DatadogAPIClient::V1::NotebookResourceType::NOTEBOOKS,
}),
})
p api_instance.update_notebook(NOTEBOOK_DATA_ID.to_i, body)