=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://openapi-generator.tech 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 'cgi' module DatadogAPIClient::V1 class DashboardsAPI attr_accessor :api_client def initialize(api_client = APIClient.default) @api_client = api_client end # Create a new dashboard # Create a dashboard using the specified options. When defining queries in your widgets, take note of which queries should have the `as_count()` or `as_rate()` modifiers appended. Refer to the following [documentation](https://docs.datadoghq.com/developers/metrics/type_modifiers/?tab=count#in-application-modifiers) for more information on these modifiers. # @param body [Dashboard] Create a dashboard request body. # @param [Hash] opts the optional parameters # @return [Dashboard] def create_dashboard(body, opts = {}) data, _status_code, _headers = create_dashboard_with_http_info(body, opts) data end # Create a new dashboard # Create a dashboard using the specified options. When defining queries in your widgets, take note of which queries should have the `as_count()` or `as_rate()` modifiers appended. Refer to the following [documentation](https://docs.datadoghq.com/developers/metrics/type_modifiers/?tab=count#in-application-modifiers) for more information on these modifiers. # @param body [Dashboard] Create a dashboard request body. # @param [Hash] opts the optional parameters # @return [Array<(Dashboard, Integer, Hash)>] Dashboard data, response status code and response headers def create_dashboard_with_http_info(body, opts = {}) if @api_client.config.unstable_operations.has_key?(:create_dashboard) unstable_enabled = @api_client.config.unstable_operations[:create_dashboard] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "create_dashboard") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "create_dashboard")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DashboardsAPI.create_dashboard ...' end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling DashboardsAPI.create_dashboard" end # resource path local_var_path = '/api/v1/dashboard' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:debug_return_type] || 'Dashboard' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :create_dashboard, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DashboardsAPI#create_dashboard\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete a dashboard # Delete a dashboard using the specified ID. # @param dashboard_id [String] The ID of the dashboard. # @param [Hash] opts the optional parameters # @return [DashboardDeleteResponse] def delete_dashboard(dashboard_id, opts = {}) data, _status_code, _headers = delete_dashboard_with_http_info(dashboard_id, opts) data end # Delete a dashboard # Delete a dashboard using the specified ID. # @param dashboard_id [String] The ID of the dashboard. # @param [Hash] opts the optional parameters # @return [Array<(DashboardDeleteResponse, Integer, Hash)>] DashboardDeleteResponse data, response status code and response headers def delete_dashboard_with_http_info(dashboard_id, opts = {}) if @api_client.config.unstable_operations.has_key?(:delete_dashboard) unstable_enabled = @api_client.config.unstable_operations[:delete_dashboard] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "delete_dashboard") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "delete_dashboard")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DashboardsAPI.delete_dashboard ...' end # verify the required parameter 'dashboard_id' is set if @api_client.config.client_side_validation && dashboard_id.nil? fail ArgumentError, "Missing the required parameter 'dashboard_id' when calling DashboardsAPI.delete_dashboard" end # resource path local_var_path = '/api/v1/dashboard/{dashboard_id}'.sub('{' + 'dashboard_id' + '}', CGI.escape(dashboard_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'DashboardDeleteResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :delete_dashboard, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DashboardsAPI#delete_dashboard\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a dashboard # Get a dashboard using the specified ID. # @param dashboard_id [String] The ID of the dashboard. # @param [Hash] opts the optional parameters # @return [Dashboard] def get_dashboard(dashboard_id, opts = {}) data, _status_code, _headers = get_dashboard_with_http_info(dashboard_id, opts) data end # Get a dashboard # Get a dashboard using the specified ID. # @param dashboard_id [String] The ID of the dashboard. # @param [Hash] opts the optional parameters # @return [Array<(Dashboard, Integer, Hash)>] Dashboard data, response status code and response headers def get_dashboard_with_http_info(dashboard_id, opts = {}) if @api_client.config.unstable_operations.has_key?(:get_dashboard) unstable_enabled = @api_client.config.unstable_operations[:get_dashboard] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "get_dashboard") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "get_dashboard")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DashboardsAPI.get_dashboard ...' end # verify the required parameter 'dashboard_id' is set if @api_client.config.client_side_validation && dashboard_id.nil? fail ArgumentError, "Missing the required parameter 'dashboard_id' when calling DashboardsAPI.get_dashboard" end # resource path local_var_path = '/api/v1/dashboard/{dashboard_id}'.sub('{' + 'dashboard_id' + '}', CGI.escape(dashboard_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Dashboard' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :get_dashboard, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DashboardsAPI#get_dashboard\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all dashboards # Get all dashboards. **Note**: This query will only return custom created or cloned dashboards. This query will not return preset dashboards. # @param [Hash] opts the optional parameters # @return [DashboardSummary] def list_dashboards(opts = {}) data, _status_code, _headers = list_dashboards_with_http_info(opts) data end # Get all dashboards # Get all dashboards. **Note**: This query will only return custom created or cloned dashboards. This query will not return preset dashboards. # @param [Hash] opts the optional parameters # @return [Array<(DashboardSummary, Integer, Hash)>] DashboardSummary data, response status code and response headers def list_dashboards_with_http_info(opts = {}) if @api_client.config.unstable_operations.has_key?(:list_dashboards) unstable_enabled = @api_client.config.unstable_operations[:list_dashboards] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "list_dashboards") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "list_dashboards")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DashboardsAPI.list_dashboards ...' end # resource path local_var_path = '/api/v1/dashboard' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'DashboardSummary' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :list_dashboards, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DashboardsAPI#list_dashboards\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update a dashboard # Update a dashboard using the specified ID. # @param dashboard_id [String] The ID of the dashboard. # @param body [Dashboard] Update Dashboard request body. # @param [Hash] opts the optional parameters # @return [Dashboard] def update_dashboard(dashboard_id, body, opts = {}) data, _status_code, _headers = update_dashboard_with_http_info(dashboard_id, body, opts) data end # Update a dashboard # Update a dashboard using the specified ID. # @param dashboard_id [String] The ID of the dashboard. # @param body [Dashboard] Update Dashboard request body. # @param [Hash] opts the optional parameters # @return [Array<(Dashboard, Integer, Hash)>] Dashboard data, response status code and response headers def update_dashboard_with_http_info(dashboard_id, body, opts = {}) if @api_client.config.unstable_operations.has_key?(:update_dashboard) unstable_enabled = @api_client.config.unstable_operations[:update_dashboard] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "update_dashboard") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "update_dashboard")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DashboardsAPI.update_dashboard ...' end # verify the required parameter 'dashboard_id' is set if @api_client.config.client_side_validation && dashboard_id.nil? fail ArgumentError, "Missing the required parameter 'dashboard_id' when calling DashboardsAPI.update_dashboard" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling DashboardsAPI.update_dashboard" end # resource path local_var_path = '/api/v1/dashboard/{dashboard_id}'.sub('{' + 'dashboard_id' + '}', CGI.escape(dashboard_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type return_type = opts[:debug_return_type] || 'Dashboard' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :update_dashboard, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DashboardsAPI#update_dashboard\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end