=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 HostsAPI attr_accessor :api_client def initialize(api_client = DatadogAPIClient::APIClient.default) @api_client = api_client end # Get the total number of active hosts. # # @see #get_host_totals_with_http_info def get_host_totals(opts = {}) data, _status_code, _headers = get_host_totals_with_http_info(opts) data end # Get the total number of active hosts. # # This endpoint returns the total number of active and up hosts in your Datadog account. # Active means the host has reported in the past hour, and up means it has reported in the past two hours. # # @param opts [Hash] the optional parameters # @option opts [Integer] :from Number of seconds from which you want to get total number of active hosts. # @return [Array<(HostTotals, Integer, Hash)>] HostTotals data, response status code and response headers def get_host_totals_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: HostsAPI.get_host_totals ...' end # resource path local_var_path = '/api/v1/hosts/totals' # query parameters query_params = opts[:query_params] || {} query_params[:'from'] = opts[:'from'] if !opts[:'from'].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] || 'HostTotals' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :get_host_totals, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type, :api_version => "V1" ) 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: HostsAPI#get_host_totals\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get all hosts for your organization. # # @see #list_hosts_with_http_info def list_hosts(opts = {}) data, _status_code, _headers = list_hosts_with_http_info(opts) data end # Get all hosts for your organization. # # This endpoint allows searching for hosts by name, alias, or tag. # Hosts live within the past 3 hours are included by default. # Retention is 7 days. # Results are paginated with a max of 1000 results at a time. # # @param opts [Hash] the optional parameters # @option opts [String] :filter String to filter search results. # @option opts [String] :sort_field Sort hosts by this field. # @option opts [String] :sort_dir Direction of sort. Options include `asc` and `desc`. # @option opts [Integer] :start Host result to start search from. # @option opts [Integer] :count Number of hosts to return. Max 1000. # @option opts [Integer] :from Number of seconds since UNIX epoch from which you want to search your hosts. # @option opts [Boolean] :include_muted_hosts_data Include information on the muted status of hosts and when the mute expires. # @option opts [Boolean] :include_hosts_metadata Include additional metadata about the hosts (agent_version, machine, platform, processor, etc.). # @return [Array<(HostListResponse, Integer, Hash)>] HostListResponse data, response status code and response headers def list_hosts_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: HostsAPI.list_hosts ...' end # resource path local_var_path = '/api/v1/hosts' # query parameters query_params = opts[:query_params] || {} query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil? query_params[:'sort_field'] = opts[:'sort_field'] if !opts[:'sort_field'].nil? query_params[:'sort_dir'] = opts[:'sort_dir'] if !opts[:'sort_dir'].nil? query_params[:'start'] = opts[:'start'] if !opts[:'start'].nil? query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil? query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil? query_params[:'include_muted_hosts_data'] = opts[:'include_muted_hosts_data'] if !opts[:'include_muted_hosts_data'].nil? query_params[:'include_hosts_metadata'] = opts[:'include_hosts_metadata'] if !opts[:'include_hosts_metadata'].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] || 'HostListResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :list_hosts, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type, :api_version => "V1" ) 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: HostsAPI#list_hosts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Mute a host. # # @see #mute_host_with_http_info def mute_host(host_name, body, opts = {}) data, _status_code, _headers = mute_host_with_http_info(host_name, body, opts) data end # Mute a host. # # Mute a host. **Note:** This creates a [Downtime V2](https://docs.datadoghq.com/api/latest/downtimes/#schedule-a-downtime) for the host. # # @param host_name [String] Name of the host to mute. # @param body [HostMuteSettings] Mute a host request body. # @param opts [Hash] the optional parameters # @return [Array<(HostMuteResponse, Integer, Hash)>] HostMuteResponse data, response status code and response headers def mute_host_with_http_info(host_name, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: HostsAPI.mute_host ...' end # verify the required parameter 'host_name' is set if @api_client.config.client_side_validation && host_name.nil? fail ArgumentError, "Missing the required parameter 'host_name' when calling HostsAPI.mute_host" 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 HostsAPI.mute_host" end # resource path local_var_path = '/api/v1/host/{host_name}/mute'.sub('{host_name}', CGI.escape(host_name.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] || 'HostMuteResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :mute_host, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type, :api_version => "V1" ) 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: HostsAPI#mute_host\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Unmute a host. # # @see #unmute_host_with_http_info def unmute_host(host_name, opts = {}) data, _status_code, _headers = unmute_host_with_http_info(host_name, opts) data end # Unmute a host. # # Unmutes a host. This endpoint takes no JSON arguments. # # @param host_name [String] Name of the host to unmute. # @param opts [Hash] the optional parameters # @return [Array<(HostMuteResponse, Integer, Hash)>] HostMuteResponse data, response status code and response headers def unmute_host_with_http_info(host_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: HostsAPI.unmute_host ...' end # verify the required parameter 'host_name' is set if @api_client.config.client_side_validation && host_name.nil? fail ArgumentError, "Missing the required parameter 'host_name' when calling HostsAPI.unmute_host" end # resource path local_var_path = '/api/v1/host/{host_name}/unmute'.sub('{host_name}', CGI.escape(host_name.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] || 'HostMuteResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :unmute_host, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type, :api_version => "V1" ) 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: HostsAPI#unmute_host\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end