diff --git a/.apigentools-info b/.apigentools-info index 2dbd98076e6e..6056da4c548c 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-02-01 09:26:43.902164", - "spec_repo_commit": "a0ca58a8" + "regenerated": "2023-02-01 12:21:37.018659", + "spec_repo_commit": "0563dbc3" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-02-01 09:26:43.913917", - "spec_repo_commit": "a0ca58a8" + "regenerated": "2023-02-01 12:21:37.033033", + "spec_repo_commit": "0563dbc3" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 027b5cfb27ae..47eed2691184 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -8725,6 +8725,65 @@ components: page: $ref: '#/components/schemas/Pagination' type: object + RunWorkflowWidgetDefinition: + description: Run workflow is widget that allows you to run a workflow from a + dashboard. + properties: + custom_links: + description: List of custom links. + items: + $ref: '#/components/schemas/WidgetCustomLink' + type: array + inputs: + description: Array of workflow inputs to map to dashboard template variables. + items: + $ref: '#/components/schemas/RunWorkflowWidgetInput' + type: array + time: + $ref: '#/components/schemas/WidgetTime' + title: + description: Title of your widget. + type: string + title_align: + $ref: '#/components/schemas/WidgetTextAlign' + title_size: + description: Size of the title. + type: string + type: + $ref: '#/components/schemas/RunWorkflowWidgetDefinitionType' + workflow_id: + description: Workflow id. + example: + type: string + required: + - type + - workflow_id + type: object + RunWorkflowWidgetDefinitionType: + default: run_workflow + description: Type of the run workflow widget. + enum: + - run_workflow + example: run_workflow + type: string + x-enum-varnames: + - RUN_WORKFLOW + RunWorkflowWidgetInput: + description: Object to map a dashboard template variable to a workflow input. + properties: + name: + description: Name of the workflow input. + example: Environment + type: string + value: + description: Dashboard template variable. Can be suffixed with '.value' + or '.key'. + example: $env.value + type: string + required: + - name + - value + type: object SLOBulkDelete: additionalProperties: description: An array of all SLO timeframes. @@ -18278,6 +18337,7 @@ components: - $ref: '#/components/schemas/MonitorSummaryWidgetDefinition' - $ref: '#/components/schemas/NoteWidgetDefinition' - $ref: '#/components/schemas/QueryValueWidgetDefinition' + - $ref: '#/components/schemas/RunWorkflowWidgetDefinition' - $ref: '#/components/schemas/ScatterPlotWidgetDefinition' - $ref: '#/components/schemas/SLOWidgetDefinition' - $ref: '#/components/schemas/SLOListWidgetDefinition' diff --git a/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-run-workflow-widget.frozen b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-run-workflow-widget.frozen new file mode 100644 index 000000000000..0442a1a3c88a --- /dev/null +++ b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-run-workflow-widget.frozen @@ -0,0 +1 @@ +2023-01-26T10:05:59.820Z \ No newline at end of file diff --git a/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-run-workflow-widget.yml b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-run-workflow-widget.yml new file mode 100644 index 000000000000..d64f3f5ec167 --- /dev/null +++ b/cassettes/features/v1/dashboards/Create-a-new-dashboard-with-run-workflow-widget.yml @@ -0,0 +1,48 @@ +http_interactions: +- recorded_at: Thu, 26 Jan 2023 10:05:59 GMT + request: + body: + encoding: UTF-8 + string: '{"description":"","is_read_only":false,"layout_type":"free","notify_list":[],"template_variables":[],"title":"Test-Create_a_new_dashboard_with_run_workflow_widget-1674727559","widgets":[{"definition":{"inputs":[{"name":"environment","value":"$env.value"}],"time":{},"title":"Run + workflow title","title_align":"left","title_size":"16","type":"run_workflow","workflow_id":"2e055f16-8b6a-4cdd-b452-17a34c44b160"},"layout":{"height":15,"width":47,"x":0,"y":0}}]}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v1/dashboard + response: + body: + encoding: UTF-8 + string: '{"notify_list":[],"description":"","restricted_roles":[],"author_name":null,"template_variables":[],"is_read_only":false,"id":"pnw-fkv-n4x","title":"Test-Create_a_new_dashboard_with_run_workflow_widget-1674727559","url":"/dashboard/pnw-fkv-n4x/test-createanewdashboardwithrunworkflowwidget-1674727559","created_at":"2023-01-26T10:06:00.011221+00:00","modified_at":"2023-01-26T10:06:00.011221+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"inputs":[{"name":"environment","value":"$env.value"}],"title_size":"16","title":"Run + workflow title","title_align":"left","workflow_id":"2e055f16-8b6a-4cdd-b452-17a34c44b160","time":{},"type":"run_workflow"},"layout":{"y":0,"width":47,"x":0,"height":15},"id":737363147915504}],"layout_type":"free"} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Thu, 26 Jan 2023 10:05:59 GMT + request: + body: null + headers: + Accept: + - application/json + method: DELETE + uri: https://api.datadoghq.com/api/v1/dashboard/pnw-fkv-n4x + response: + body: + encoding: UTF-8 + string: '{"deleted_dashboard_id":"pnw-fkv-n4x"} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v1/dashboards/CreateDashboard_2610827685.rb b/examples/v1/dashboards/CreateDashboard_2610827685.rb new file mode 100644 index 000000000000..749c7b59e7b2 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_2610827685.rb @@ -0,0 +1,38 @@ +# Create a new dashboard with run-workflow widget + +require "datadog_api_client" +api_instance = DatadogAPIClient::V1::DashboardsAPI.new + +body = DatadogAPIClient::V1::Dashboard.new({ + title: "Example-Create_a_new_dashboard_with_run_workflow_widget", + description: "", + widgets: [ + DatadogAPIClient::V1::Widget.new({ + layout: DatadogAPIClient::V1::WidgetLayout.new({ + x: 0, + y: 0, + width: 47, + height: 15, + }), + definition: DatadogAPIClient::V1::RunWorkflowWidgetDefinition.new({ + title: "Run workflow title", + title_size: "16", + title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT, + time: DatadogAPIClient::V1::WidgetTime.new({}), + type: DatadogAPIClient::V1::RunWorkflowWidgetDefinitionType::RUN_WORKFLOW, + workflow_id: "2e055f16-8b6a-4cdd-b452-17a34c44b160", + inputs: [ + DatadogAPIClient::V1::RunWorkflowWidgetInput.new({ + name: "environment", + value: "$env.value", + }), + ], + }), + }), + ], + template_variables: [], + layout_type: DatadogAPIClient::V1::DashboardLayoutType::FREE, + is_read_only: false, + notify_list: [], +}) +p api_instance.create_dashboard(body) diff --git a/features/v1/dashboards.feature b/features/v1/dashboards.feature index 204e36b90cc1..f1cfe43c87d1 100644 --- a/features/v1/dashboards.feature +++ b/features/v1/dashboards.feature @@ -413,6 +413,16 @@ Feature: Dashboards When the request is sent Then the response status is 200 OK + @team:DataDog/dashboards + Scenario: Create a new dashboard with run-workflow widget + Given new "CreateDashboard" request + And body from file "dashboards_json_payload/run_workflow_widget.json" + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.type" is equal to "run_workflow" + And the response "widgets[0].definition.workflow_id" is equal to "2e055f16-8b6a-4cdd-b452-17a34c44b160" + And the response "widgets[0].definition.inputs[0]" is equal to {"name": "environment", "value": "$env.value"} + @team:DataDog/dashboards Scenario: Create a new dashboard with scatterplot widget Given new "CreateDashboard" request diff --git a/features/v1/dashboards_json_payload/run_workflow_widget.json b/features/v1/dashboards_json_payload/run_workflow_widget.json new file mode 100644 index 000000000000..8f03275935f8 --- /dev/null +++ b/features/v1/dashboards_json_payload/run_workflow_widget.json @@ -0,0 +1,32 @@ +{ + "title": "{{ unique }}", + "description": "", + "widgets": [ + { + "layout": { + "x": 0, + "y": 0, + "width": 47, + "height": 15 + }, + "definition": { + "title": "Run workflow title", + "title_size": "16", + "title_align": "left", + "time": {}, + "type": "run_workflow", + "workflow_id": "2e055f16-8b6a-4cdd-b452-17a34c44b160", + "inputs": [ + { + "name": "environment", + "value": "$env.value" + } + ] + } + } + ], + "template_variables": [], + "layout_type": "free", + "is_read_only": false, + "notify_list": [] +} diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 97272e768e22..9a0bac9aff01 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -370,6 +370,9 @@ def overrides "v1.query_value_widget_request" => "QueryValueWidgetRequest", "v1.reference_table_logs_lookup_processor" => "ReferenceTableLogsLookupProcessor", "v1.response_meta_attributes" => "ResponseMetaAttributes", + "v1.run_workflow_widget_definition" => "RunWorkflowWidgetDefinition", + "v1.run_workflow_widget_definition_type" => "RunWorkflowWidgetDefinitionType", + "v1.run_workflow_widget_input" => "RunWorkflowWidgetInput", "v1.scatterplot_dimension" => "ScatterplotDimension", "v1.scatter_plot_request" => "ScatterPlotRequest", "v1.scatterplot_table_request" => "ScatterplotTableRequest", diff --git a/lib/datadog_api_client/v1/models/run_workflow_widget_definition.rb b/lib/datadog_api_client/v1/models/run_workflow_widget_definition.rb new file mode 100644 index 000000000000..999b1a95f4d1 --- /dev/null +++ b/lib/datadog_api_client/v1/models/run_workflow_widget_definition.rb @@ -0,0 +1,187 @@ +=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 + # Run workflow is widget that allows you to run a workflow from a dashboard. + class RunWorkflowWidgetDefinition + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # List of custom links. + attr_accessor :custom_links + + # Array of workflow inputs to map to dashboard template variables. + attr_accessor :inputs + + # Time setting for the widget. + attr_accessor :time + + # Title of your widget. + attr_accessor :title + + # How to align the text on the widget. + attr_accessor :title_align + + # Size of the title. + attr_accessor :title_size + + # Type of the run workflow widget. + attr_reader :type + + # Workflow id. + attr_reader :workflow_id + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'custom_links' => :'custom_links', + :'inputs' => :'inputs', + :'time' => :'time', + :'title' => :'title', + :'title_align' => :'title_align', + :'title_size' => :'title_size', + :'type' => :'type', + :'workflow_id' => :'workflow_id' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'custom_links' => :'Array', + :'inputs' => :'Array', + :'time' => :'WidgetTime', + :'title' => :'String', + :'title_align' => :'WidgetTextAlign', + :'title_size' => :'String', + :'type' => :'RunWorkflowWidgetDefinitionType', + :'workflow_id' => :'String' + } + 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::RunWorkflowWidgetDefinition` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::RunWorkflowWidgetDefinition`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'custom_links') + if (value = attributes[:'custom_links']).is_a?(Array) + self.custom_links = value + end + end + + if attributes.key?(:'inputs') + if (value = attributes[:'inputs']).is_a?(Array) + self.inputs = value + end + end + + if attributes.key?(:'time') + self.time = attributes[:'time'] + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + end + + if attributes.key?(:'title_align') + self.title_align = attributes[:'title_align'] + end + + if attributes.key?(:'title_size') + self.title_size = attributes[:'title_size'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'workflow_id') + self.workflow_id = attributes[:'workflow_id'] + 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 @type.nil? + return false if @workflow_id.nil? + true + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Custom attribute writer method with validation + # @param workflow_id [Object] Object to be assigned + # @!visibility private + def workflow_id=(workflow_id) + if workflow_id.nil? + fail ArgumentError, 'invalid value for "workflow_id", workflow_id cannot be nil.' + end + @workflow_id = workflow_id + 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 && + custom_links == o.custom_links && + inputs == o.inputs && + time == o.time && + title == o.title && + title_align == o.title_align && + title_size == o.title_size && + type == o.type && + workflow_id == o.workflow_id + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [custom_links, inputs, time, title, title_align, title_size, type, workflow_id].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/run_workflow_widget_definition_type.rb b/lib/datadog_api_client/v1/models/run_workflow_widget_definition_type.rb new file mode 100644 index 000000000000..a35950d35838 --- /dev/null +++ b/lib/datadog_api_client/v1/models/run_workflow_widget_definition_type.rb @@ -0,0 +1,26 @@ +=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 + # Type of the run workflow widget. + class RunWorkflowWidgetDefinitionType + include BaseEnumModel + + RUN_WORKFLOW = "run_workflow".freeze + end +end diff --git a/lib/datadog_api_client/v1/models/run_workflow_widget_input.rb b/lib/datadog_api_client/v1/models/run_workflow_widget_input.rb new file mode 100644 index 000000000000..5f71c3a88538 --- /dev/null +++ b/lib/datadog_api_client/v1/models/run_workflow_widget_input.rb @@ -0,0 +1,123 @@ +=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 + # Object to map a dashboard template variable to a workflow input. + class RunWorkflowWidgetInput + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Name of the workflow input. + attr_reader :name + + # Dashboard template variable. Can be suffixed with '.value' or '.key'. + attr_reader :value + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'value' => :'value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'value' => :'String' + } + 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::RunWorkflowWidgetInput` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::RunWorkflowWidgetInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + 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? + return false if @value.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 + + # Custom attribute writer method with validation + # @param value [Object] Object to be assigned + # @!visibility private + def value=(value) + if value.nil? + fail ArgumentError, 'invalid value for "value", value cannot be nil.' + end + @value = value + 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 && + name == o.name && + value == o.value + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, value].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/widget_definition.rb b/lib/datadog_api_client/v1/models/widget_definition.rb index ea7fca1b0480..dc01b7395f60 100644 --- a/lib/datadog_api_client/v1/models/widget_definition.rb +++ b/lib/datadog_api_client/v1/models/widget_definition.rb @@ -44,6 +44,7 @@ def openapi_one_of :'MonitorSummaryWidgetDefinition', :'NoteWidgetDefinition', :'QueryValueWidgetDefinition', + :'RunWorkflowWidgetDefinition', :'ScatterPlotWidgetDefinition', :'SLOWidgetDefinition', :'SLOListWidgetDefinition',