Skip to content
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
63 changes: 63 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10354,6 +10354,16 @@ components:
type: string
status:
$ref: '#/components/schemas/NotebookStatus'
template_variables:
description: List of template variables for this notebook.
example:
- available_values: []
default: '*'
name: host
prefix: host
items:
$ref: '#/components/schemas/NotebookTemplateVariable'
type: array
time:
$ref: '#/components/schemas/NotebookGlobalTime'
required:
Expand Down Expand Up @@ -10657,6 +10667,39 @@ components:
type: string
x-enum-varnames:
- PUBLISHED
NotebookTemplateVariable:
description: Template variable for a notebook.
properties:
available_values:
description: The list of values that the template variable drop-down is
limited to.
example:
- my-host
- host1
- host2
items:
description: Template variable value.
type: string
nullable: true
type: array
default:
description: The default value for the template variable.
example: '*'
nullable: true
type: string
name:
description: The name of the variable.
example: host
type: string
prefix:
description: The tag prefix associated with the variable. Only tags with
this prefix appear in the variable drop-down.
example: host
nullable: true
type: string
required:
- name
type: object
NotebookTimeseriesCellAttributes:
description: The attributes of a notebook `timeseries` cell.
properties:
Expand Down Expand Up @@ -10760,6 +10803,16 @@ components:
type: string
status:
$ref: '#/components/schemas/NotebookStatus'
template_variables:
description: List of template variables for this notebook.
example:
- available_values: []
default: '*'
name: host
prefix: host
items:
$ref: '#/components/schemas/NotebookTemplateVariable'
type: array
time:
$ref: '#/components/schemas/NotebookGlobalTime'
required:
Expand Down Expand Up @@ -10836,6 +10889,16 @@ components:
type: string
status:
$ref: '#/components/schemas/NotebookStatus'
template_variables:
description: List of template variables for this notebook.
example:
- available_values: []
default: '*'
name: host
prefix: host
items:
$ref: '#/components/schemas/NotebookTemplateVariable'
type: array
time:
$ref: '#/components/schemas/NotebookGlobalTime'
required:
Expand Down
8 changes: 4 additions & 4 deletions features/v1/notebooks.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: Notebooks
@generated @skip @team:DataDog/notebooks
Scenario: Create a notebook returns "Bad Request" response
Given new "CreateNotebook" request
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}}
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": [], "default": "*", "name": "host", "prefix": "host"}], "time": {"live_span": "1h"}}, "type": "notebooks"}}
When the request is sent
Then the response status is 400 Bad Request

Expand Down Expand Up @@ -98,23 +98,23 @@ Feature: Notebooks
Scenario: Update a notebook returns "Bad Request" response
Given new "UpdateNotebook" request
And request contains "notebook_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}}
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": [], "default": "*", "name": "host", "prefix": "host"}], "time": {"live_span": "1h"}}, "type": "notebooks"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/notebooks
Scenario: Update a notebook returns "Conflict" response
Given new "UpdateNotebook" request
And request contains "notebook_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}}
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": [], "default": "*", "name": "host", "prefix": "host"}], "time": {"live_span": "1h"}}, "type": "notebooks"}}
When the request is sent
Then the response status is 409 Conflict

@generated @skip @team:DataDog/notebooks
Scenario: Update a notebook returns "Not Found" response
Given new "UpdateNotebook" request
And request contains "notebook_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "time": {"live_span": "1h"}}, "type": "notebooks"}}
And body with value {"data": {"attributes": {"cells": [{"attributes": {"definition": {"text": "## Some test markdown\n\n```\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown"}}, "id": "bzbycoya", "type": "notebook_cells"}, {"attributes": {"definition": {"requests": [{"display_type": "line", "q": "avg:system.load.1{*}", "style": {"line_type": "solid", "line_width": "normal", "palette": "dog_classic"}}], "show_legend": true, "type": "timeseries", "yaxis": {"scale": "linear"}}, "graph_size": "m", "split_by": {"keys": [], "tags": []}, "time": null}, "id": "9k6bc6xc", "type": "notebook_cells"}], "metadata": {"is_template": false, "take_snapshots": false, "type": "investigation"}, "name": "Example Notebook", "status": "published", "template_variables": [{"available_values": [], "default": "*", "name": "host", "prefix": "host"}], "time": {"live_span": "1h"}}, "type": "notebooks"}}
When the request is sent
Then the response status is 404 Not Found

Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ def overrides
"v1.notebooks_response_meta" => "NotebooksResponseMeta",
"v1.notebooks_response_page" => "NotebooksResponsePage",
"v1.notebook_status" => "NotebookStatus",
"v1.notebook_template_variable" => "NotebookTemplateVariable",
"v1.notebook_timeseries_cell_attributes" => "NotebookTimeseriesCellAttributes",
"v1.notebook_toplist_cell_attributes" => "NotebookToplistCellAttributes",
"v1.notebook_update_cell" => "NotebookUpdateCell",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class NotebookCreateDataAttributes
# Publication status of the notebook. For now, always "published".
attr_accessor :status

# List of template variables for this notebook.
attr_accessor :template_variables

# Notebook global timeframe.
attr_reader :time

Expand All @@ -46,6 +49,7 @@ def self.attribute_map
:'metadata' => :'metadata',
:'name' => :'name',
:'status' => :'status',
:'template_variables' => :'template_variables',
:'time' => :'time'
}
end
Expand All @@ -58,6 +62,7 @@ def self.openapi_types
:'metadata' => :'NotebookMetadata',
:'name' => :'String',
:'status' => :'NotebookStatus',
:'template_variables' => :'Array<NotebookTemplateVariable>',
:'time' => :'NotebookGlobalTime'
}
end
Expand Down Expand Up @@ -98,6 +103,12 @@ def initialize(attributes = {})
self.status = attributes[:'status']
end

if attributes.key?(:'template_variables')
if (value = attributes[:'template_variables']).is_a?(Array)
self.template_variables = value
end
end

if attributes.key?(:'time')
self.time = attributes[:'time']
end
Expand Down Expand Up @@ -181,6 +192,7 @@ def ==(o)
metadata == o.metadata &&
name == o.name &&
status == o.status &&
template_variables == o.template_variables &&
time == o.time &&
additional_properties == o.additional_properties
end
Expand All @@ -189,7 +201,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[cells, metadata, name, status, time, additional_properties].hash
[cells, metadata, name, status, template_variables, time, additional_properties].hash
end
end
end
165 changes: 165 additions & 0 deletions lib/datadog_api_client/v1/models/notebook_template_variable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
=begin
#Datadog API V1 Collection

#Collection of all Datadog Public endpoints.

The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator

Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2020-Present Datadog, Inc.

=end

require 'date'
require 'time'

module DatadogAPIClient::V1
# Template variable for a notebook.
class NotebookTemplateVariable
include BaseGenericModel

# The list of values that the template variable drop-down is limited to.
attr_accessor :available_values

# The default value for the template variable.
attr_accessor :default

# The name of the variable.
attr_reader :name

# The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
attr_accessor :prefix

attr_accessor :additional_properties

# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'available_values' => :'available_values',
:'default' => :'default',
:'name' => :'name',
:'prefix' => :'prefix'
}
end

# Attribute type mapping.
# @!visibility private
def self.openapi_types
{
:'available_values' => :'Array<String>',
:'default' => :'String',
:'name' => :'String',
:'prefix' => :'String'
}
end

# List of attributes with nullable: true
# @!visibility private
def self.openapi_nullable
Set.new([
:'available_values',
:'default',
:'prefix',
])
end

# Initializes the object
# @param attributes [Hash] Model attributes in the form of hash
# @!visibility private
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::NotebookTemplateVariable` initialize method"
end

self.additional_properties = {}
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
self.additional_properties[k.to_sym] = v
else
h[k.to_sym] = v
end
}

if attributes.key?(:'available_values')
if (value = attributes[:'available_values']).is_a?(Array)
self.available_values = value
end
end

if attributes.key?(:'default')
self.default = attributes[:'default']
end

if attributes.key?(:'name')
self.name = attributes[:'name']
end

if attributes.key?(:'prefix')
self.prefix = attributes[:'prefix']
end
end

# Check to see if the all the properties in the model are valid
# @return true if the model is valid
# @!visibility private
def valid?
return false if @name.nil?
true
end

# Custom attribute writer method with validation
# @param name [Object] Object to be assigned
# @!visibility private
def name=(name)
if name.nil?
fail ArgumentError, 'invalid value for "name", name cannot be nil.'
end
@name = name
end

# Returns the object in the form of hash, with additionalProperties support.
# @return [Hash] Returns the object in the form of hash
# @!visibility private
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
if value.nil?
is_nullable = self.class.openapi_nullable.include?(attr)
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end

hash[param] = _to_hash(value)
end
self.additional_properties.each_pair do |attr, value|
hash[attr] = value
end
hash
end

# Checks equality by comparing each attribute.
# @param o [Object] Object to be compared
# @!visibility private
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
available_values == o.available_values &&
default == o.default &&
name == o.name &&
prefix == o.prefix &&
additional_properties == o.additional_properties
end

# Calculates hash code according to all attributes.
# @return [Integer] Hash code
# @!visibility private
def hash
[available_values, default, name, prefix, additional_properties].hash
end
end
end
Loading
Loading