class DatadogAPIClient::V1::TagsAPI

Attributes

api_client[RW]

Public Class Methods

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

Public Instance Methods

create_host_tags(host_name, body, opts = {}) click to toggle source

Add tags to a host This endpoint allows you to add new tags to a host, optionally specifying where these tags come from. @param host_name [String] This endpoint allows you to add new tags to a host, optionally specifying where the tags came from. @param body [HostTags] Update host tags request body. @param [Hash] opts the optional parameters @option opts [String] :source The source of the tags. [Complete list of source attribute values](docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). @return [HostTags]

# File lib/datadog_api_client/v1/api/tags_api.rb, line 32
def create_host_tags(host_name, body, opts = {})
  data, _status_code, _headers = create_host_tags_with_http_info(host_name, body, opts)
  data
end
create_host_tags_with_http_info(host_name, body, opts = {}) click to toggle source

Add tags to a host This endpoint allows you to add new tags to a host, optionally specifying where these tags come from. @param host_name [String] This endpoint allows you to add new tags to a host, optionally specifying where the tags came from. @param body [HostTags] Update host tags request body. @param [Hash] opts the optional parameters @option opts [String] :source The source of the tags. [Complete list of source attribute values](docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). @return [Array<(HostTags, Integer, Hash)>] HostTags data, response status code and response headers

# File lib/datadog_api_client/v1/api/tags_api.rb, line 44
def create_host_tags_with_http_info(host_name, body, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TagsAPI.create_host_tags ...'
  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 TagsAPI.create_host_tags"
  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 TagsAPI.create_host_tags"
  end
  # resource path
  local_var_path = '/api/v1/tags/hosts/{host_name}'.sub('{' + 'host_name' + '}', CGI.escape(host_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?

  # 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] || 'HostTags'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :create_host_tags,
    :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: TagsAPI#create_host_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
delete_host_tags(host_name, opts = {}) click to toggle source

Remove host tags This endpoint allows you to remove all user-assigned tags for a single host. @param host_name [String] This endpoint allows you to remove all user-assigned tags for a single host. @param [Hash] opts the optional parameters @option opts [String] :source The source of the tags (e.g. chef, puppet). [Complete list of source attribute values](docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). @return [nil]

# File lib/datadog_api_client/v1/api/tags_api.rb, line 115
def delete_host_tags(host_name, opts = {})
  delete_host_tags_with_http_info(host_name, opts)
  nil
end
delete_host_tags_with_http_info(host_name, opts = {}) click to toggle source

Remove host tags This endpoint allows you to remove all user-assigned tags for a single host. @param host_name [String] This endpoint allows you to remove all user-assigned tags for a single host. @param [Hash] opts the optional parameters @option opts [String] :source The source of the tags (e.g. chef, puppet). [Complete list of source attribute values](docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/datadog_api_client/v1/api/tags_api.rb, line 126
def delete_host_tags_with_http_info(host_name, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TagsAPI.delete_host_tags ...'
  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 TagsAPI.delete_host_tags"
  end
  # resource path
  local_var_path = '/api/v1/tags/hosts/{host_name}'.sub('{' + 'host_name' + '}', CGI.escape(host_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].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]

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :delete_host_tags,
    :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: TagsAPI#delete_host_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_host_tags(host_name, opts = {}) click to toggle source

Get host tags Return the list of tags that apply to a given host. @param host_name [String] When specified, filters list of tags to those tags with the specified source. @param [Hash] opts the optional parameters @option opts [String] :source Source to filter. @return [HostTags]

# File lib/datadog_api_client/v1/api/tags_api.rb, line 191
def get_host_tags(host_name, opts = {})
  data, _status_code, _headers = get_host_tags_with_http_info(host_name, opts)
  data
end
get_host_tags_with_http_info(host_name, opts = {}) click to toggle source

Get host tags Return the list of tags that apply to a given host. @param host_name [String] When specified, filters list of tags to those tags with the specified source. @param [Hash] opts the optional parameters @option opts [String] :source Source to filter. @return [Array<(HostTags, Integer, Hash)>] HostTags data, response status code and response headers

# File lib/datadog_api_client/v1/api/tags_api.rb, line 202
def get_host_tags_with_http_info(host_name, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TagsAPI.get_host_tags ...'
  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 TagsAPI.get_host_tags"
  end
  # resource path
  local_var_path = '/api/v1/tags/hosts/{host_name}'.sub('{' + 'host_name' + '}', CGI.escape(host_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].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] || 'HostTags'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :get_host_tags,
    :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: TagsAPI#get_host_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
list_host_tags(opts = {}) click to toggle source

Get Tags Return a mapping of tags to hosts for your whole infrastructure. @param [Hash] opts the optional parameters @option opts [String] :source When specified, filters host list to those tags with the specified source. @return [TagToHosts]

# File lib/datadog_api_client/v1/api/tags_api.rb, line 266
def list_host_tags(opts = {})
  data, _status_code, _headers = list_host_tags_with_http_info(opts)
  data
end
list_host_tags_with_http_info(opts = {}) click to toggle source

Get Tags Return a mapping of tags to hosts for your whole infrastructure. @param [Hash] opts the optional parameters @option opts [String] :source When specified, filters host list to those tags with the specified source. @return [Array<(TagToHosts, Integer, Hash)>] TagToHosts data, response status code and response headers

# File lib/datadog_api_client/v1/api/tags_api.rb, line 276
def list_host_tags_with_http_info(opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TagsAPI.list_host_tags ...'
  end
  # resource path
  local_var_path = '/api/v1/tags/hosts'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].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] || 'TagToHosts'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

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

Update host tags This endpoint allows you to update/replace all tags in an integration source with those supplied in the request. @param host_name [String] This endpoint allows you to update/replace all in an integration source with those supplied in the request. @param body [HostTags] Add tags to host @param [Hash] opts the optional parameters @option opts [String] :source The source of the tags (e.g. chef, puppet). [Complete list of source attribute values](docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value) @return [HostTags]

# File lib/datadog_api_client/v1/api/tags_api.rb, line 338
def update_host_tags(host_name, body, opts = {})
  data, _status_code, _headers = update_host_tags_with_http_info(host_name, body, opts)
  data
end
update_host_tags_with_http_info(host_name, body, opts = {}) click to toggle source

Update host tags This endpoint allows you to update/replace all tags in an integration source with those supplied in the request. @param host_name [String] This endpoint allows you to update/replace all in an integration source with those supplied in the request. @param body [HostTags] Add tags to host @param [Hash] opts the optional parameters @option opts [String] :source The source of the tags (e.g. chef, puppet). [Complete list of source attribute values](docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value) @return [Array<(HostTags, Integer, Hash)>] HostTags data, response status code and response headers

# File lib/datadog_api_client/v1/api/tags_api.rb, line 350
def update_host_tags_with_http_info(host_name, body, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TagsAPI.update_host_tags ...'
  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 TagsAPI.update_host_tags"
  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 TagsAPI.update_host_tags"
  end
  # resource path
  local_var_path = '/api/v1/tags/hosts/{host_name}'.sub('{' + 'host_name' + '}', CGI.escape(host_name.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?

  # 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] || 'HostTags'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :update_host_tags,
    :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: TagsAPI#update_host_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end