class DatadogAPIClient::V1::HostsAPI

Attributes

api_client[RW]

Public Class Methods

new(api_client = APIClient.default) click to toggle source
# File lib/datadog_api_client/v1/api/hosts_api.rb, line 22
def initialize(api_client = APIClient.default)
  @api_client = api_client
end

Public Instance Methods

get_host_totals(opts = {}) click to toggle source

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 [Hash] opts the optional parameters @option opts [Integer] :from Number of seconds from which you want to get total number of active hosts. @return [HostTotals]

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 30
def get_host_totals(opts = {})
  data, _status_code, _headers = get_host_totals_with_http_info(opts)
  data
end
get_host_totals_with_http_info(opts = {}) click to toggle source

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 [Hash] opts 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

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 40
def get_host_totals_with_http_info(opts = {})

  if @api_client.config.unstable_operations.has_key?(:get_host_totals)
    unstable_enabled = @api_client.config.unstable_operations[:get_host_totals]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "get_host_totals")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "get_host_totals"))
    end
  end

  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]

  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
  )

  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: HostsAPI#get_host_totals\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
list_hosts(opts = {}) click to toggle source

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 [Hash] opts 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 &#x60;asc&#x60; and &#x60;desc&#x60;. @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 [HostListResponse]

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 107
def list_hosts(opts = {})
  data, _status_code, _headers = list_hosts_with_http_info(opts)
  data
end
list_hosts_with_http_info(opts = {}) click to toggle source

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 [Hash] opts 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 &#x60;asc&#x60; and &#x60;desc&#x60;. @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

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 124
def list_hosts_with_http_info(opts = {})

  if @api_client.config.unstable_operations.has_key?(:list_hosts)
    unstable_enabled = @api_client.config.unstable_operations[:list_hosts]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "list_hosts")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "list_hosts"))
    end
  end

  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]

  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
  )

  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: HostsAPI#list_hosts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
mute_host(host_name, body, opts = {}) click to toggle source

Mute a host Mute a host. @param host_name [String] Name of the host to mute. @param body [HostMuteSettings] Mute a host request body. @param [Hash] opts the optional parameters @return [HostMuteResponse]

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 192
def mute_host(host_name, body, opts = {})
  data, _status_code, _headers = mute_host_with_http_info(host_name, body, opts)
  data
end
mute_host_with_http_info(host_name, body, opts = {}) click to toggle source

Mute a host Mute a host. @param host_name [String] Name of the host to mute. @param body [HostMuteSettings] Mute a host request body. @param [Hash] opts the optional parameters @return [Array<(HostMuteResponse, Integer, Hash)>] HostMuteResponse data, response status code and response headers

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 203
def mute_host_with_http_info(host_name, body, opts = {})

  if @api_client.config.unstable_operations.has_key?(:mute_host)
    unstable_enabled = @api_client.config.unstable_operations[:mute_host]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "mute_host")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "mute_host"))
    end
  end

  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))

  # 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
  )

  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: HostsAPI#mute_host\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
unmute_host(host_name, opts = {}) click to toggle source

Unmute a host Unmutes a host. This endpoint takes no JSON arguments. @param host_name [String] Name of the host to unmute. @param [Hash] opts the optional parameters @return [HostMuteResponse]

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 272
def unmute_host(host_name, opts = {})
  data, _status_code, _headers = unmute_host_with_http_info(host_name, opts)
  data
end
unmute_host_with_http_info(host_name, opts = {}) click to toggle source

Unmute a host Unmutes a host. This endpoint takes no JSON arguments. @param host_name [String] Name of the host to unmute. @param [Hash] opts the optional parameters @return [Array<(HostMuteResponse, Integer, Hash)>] HostMuteResponse data, response status code and response headers

# File lib/datadog_api_client/v1/api/hosts_api.rb, line 282
def unmute_host_with_http_info(host_name, opts = {})

  if @api_client.config.unstable_operations.has_key?(:unmute_host)
    unstable_enabled = @api_client.config.unstable_operations[:unmute_host]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "unmute_host")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "unmute_host"))
    end
  end

  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))

  # 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
  )

  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: HostsAPI#unmute_host\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end