=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 '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. # # @see #create_dashboard_with_http_info 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 opts [Hash] 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, :AuthZ] 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(Net::HTTP::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. # # @see #delete_dashboard_with_http_info 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 opts [Hash] 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).gsub('%2F', '/')) # 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, :AuthZ] 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(Net::HTTP::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 # Delete dashboards. # # @see #delete_dashboards_with_http_info def delete_dashboards(body, opts = {}) delete_dashboards_with_http_info(body, opts) nil end # Delete dashboards. # # Delete dashboards using the specified IDs. If there are any failures, no dashboards will be deleted (partial success is not allowed). # # @param body [DashboardBulkDeleteRequest] Delete dashboards request body. # @param opts [Hash] the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_dashboards_with_http_info(body, opts = {}) if @api_client.config.unstable_operations.has_key?(:delete_dashboards) unstable_enabled = @api_client.config.unstable_operations[:delete_dashboards] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "delete_dashboards") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "delete_dashboards")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DashboardsAPI.delete_dashboards ...' 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.delete_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(['*/*']) # 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] # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :delete_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(Net::HTTP::Delete, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DashboardsAPI#delete_dashboards\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a dashboard. # # @see #get_dashboard_with_http_info 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 opts [Hash] 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).gsub('%2F', '/')) # 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, :AuthZ] 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(Net::HTTP::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. # # @see #list_dashboards_with_http_info 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 opts [Hash] the optional parameters # @option opts [Boolean] :filter_shared When `true`, this query only returns shared custom created or cloned dashboards. # @option opts [Boolean] :filter_deleted When `true`, this query returns only deleted custom-created or cloned dashboards. This parameter is incompatible with `filter[shared]`. # @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] || {} query_params[:'filter[shared]'] = opts[:'filter_shared'] if !opts[:'filter_shared'].nil? query_params[:'filter[deleted]'] = opts[:'filter_deleted'] if !opts[:'filter_deleted'].nil? # 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, :AuthZ] 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(Net::HTTP::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 # Restore deleted dashboards. # # @see #restore_dashboards_with_http_info def restore_dashboards(body, opts = {}) restore_dashboards_with_http_info(body, opts) nil end # Restore deleted dashboards. # # Restore dashboards using the specified IDs. If there are any failures, no dashboards will be restored (partial success is not allowed). # # @param body [DashboardRestoreRequest] Restore dashboards request body. # @param opts [Hash] the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def restore_dashboards_with_http_info(body, opts = {}) if @api_client.config.unstable_operations.has_key?(:restore_dashboards) unstable_enabled = @api_client.config.unstable_operations[:restore_dashboards] if unstable_enabled @api_client.config.logger.warn format("Using unstable operation '%s'", "restore_dashboards") else raise APIError.new(message: format("Unstable operation '%s' is disabled", "restore_dashboards")) end end if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DashboardsAPI.restore_dashboards ...' 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.restore_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(['*/*']) # 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] # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :restore_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(Net::HTTP::Patch, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: DashboardsAPI#restore_dashboards\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update a dashboard. # # @see #update_dashboard_with_http_info 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 opts [Hash] 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).gsub('%2F', '/')) # 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, :AuthZ] 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(Net::HTTP::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