diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index d9bb88a10f27..660ab5044a3c 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -4179,7 +4179,7 @@ components: example: false type: boolean type: object - HostTags: + HostTagsInput: description: Set of tags to associate with your host. properties: host: @@ -4194,6 +4194,21 @@ components: type: string type: array type: object + HostTagsOutput: + description: Host name and an array of its tags + properties: + host: + description: Your host name. + example: test.host + type: string + tags: + description: A list of tags attached to a given host. + items: + description: A given tag in a list. + example: environment:production + type: string + type: array + type: object HostTotals: description: Total number of host currently monitored by Datadog. properties: @@ -18689,18 +18704,18 @@ components: - match type: object TagToHosts: - description: In this object, the key is the tag, the value is a list of host - names that are reporting that tag. + description: In this object, the key is the tag, and the value is a list of + host names that are reporting that tag. properties: tags: additionalProperties: - description: A list of additional properties for tags. + description: A list of host names which contain this tag items: description: A given tag in a list. example: test.metric.host type: string type: array - description: A list of tags to apply to the host. + description: A mapping of tags to host names type: object type: object TargetFormatType: @@ -35712,11 +35727,13 @@ paths: - synthetics_global_variable_write /api/v1/tags/hosts: get: - description: Return a mapping of tags to hosts for your whole infrastructure. + description: Returns a mapping of tags to hosts. For each tag, the response + returns a list of host names that contain this tag. There is a restriction + of 10k total host names from the org that can be attached to tags and returned. operationId: ListHostTags parameters: - - description: When specified, filters host list to those tags with the specified - source. + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35747,7 +35764,7 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: [] - summary: Get Tags + summary: Get All Host Tags tags: - Tags x-permission: @@ -35755,21 +35772,20 @@ paths: permissions: [] /api/v1/tags/hosts/{host_name}: delete: - description: 'This endpoint allows you to remove all user-assigned tags + description: 'This endpoint allows you to remove all tags - for a single host.' + for a single host. If no source is specified, only deletes tags with no source.' operationId: DeleteHostTags parameters: - - description: This endpoint allows you to remove all user-assigned tags for - a single host. + - description: Specified host name to delete tags in: path name: host_name required: true schema: type: string - - description: 'The source of the tags (for example chef, puppet). - - [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).' + - description: Source of the tags to be deleted. [Complete list of source attribute + values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35799,14 +35815,14 @@ paths: description: Return the list of tags that apply to a given host. operationId: GetHostTags parameters: - - description: When specified, filters list of tags to those tags with the specified - source. + - description: Name of the host to retrieve tags for in: path name: host_name required: true schema: type: string - - description: Source to filter. + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35817,7 +35833,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsOutput' description: OK '403': content: @@ -35833,25 +35849,23 @@ paths: description: Not Found '429': $ref: '#/components/responses/TooManyRequestsResponse' - summary: Get host tags + summary: Get Host Tags tags: - Tags post: description: 'This endpoint allows you to add new tags to a host, - optionally specifying where these tags come from.' + optionally specifying what source these tags come from.' operationId: CreateHostTags parameters: - - description: This endpoint allows you to add new tags to a host, optionally - specifying where the tags came from. + - description: Specified host name to add new tags in: path name: host_name required: true schema: type: string - - description: 'The source of the tags. - - [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).' + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. example: chef in: query name: source @@ -35862,7 +35876,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsInput' description: Update host tags request body. required: true responses: @@ -35870,7 +35884,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsOutput' description: Created '403': content: @@ -35896,16 +35910,14 @@ paths: an integration source with those supplied in the request.' operationId: UpdateHostTags parameters: - - description: This endpoint allows you to update/replace all in an integration - source with those supplied in the request. + - description: Specified host name to change tags in: path name: host_name required: true schema: type: string - - description: 'The source of the tags (for example chef, puppet). - - [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value)' + - description: Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + Use "user" source for custom-defined tags. in: query name: source required: false @@ -35915,7 +35927,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsInput' description: Add tags to host required: true responses: @@ -35923,7 +35935,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/HostTags' + $ref: '#/components/schemas/HostTagsOutput' description: OK '403': content: @@ -38918,7 +38930,8 @@ tags: by a source. For example, some valid sources include nagios, hudson, jenkins, - users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc. + users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc. Find a complete + list of source type names under [API Source Attributes](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Read more about tags on [Getting Started with Tags](https://docs.datadoghq.com/getting_started/tagging/).' diff --git a/examples/v1/tags/CreateHostTags.rb b/examples/v1/tags/CreateHostTags.rb index ac7e955a5402..b241f395fad3 100644 --- a/examples/v1/tags/CreateHostTags.rb +++ b/examples/v1/tags/CreateHostTags.rb @@ -3,7 +3,7 @@ require "datadog_api_client" api_instance = DatadogAPIClient::V1::TagsAPI.new -body = DatadogAPIClient::V1::HostTags.new({ +body = DatadogAPIClient::V1::HostTagsInput.new({ host: "test.host", tags: [ "environment:production", diff --git a/examples/v1/tags/GetHostTags.rb b/examples/v1/tags/GetHostTags.rb index b2ca9e0a1189..e69699394ea4 100644 --- a/examples/v1/tags/GetHostTags.rb +++ b/examples/v1/tags/GetHostTags.rb @@ -1,4 +1,4 @@ -# Get host tags returns "OK" response +# Get Host Tags returns "OK" response require "datadog_api_client" api_instance = DatadogAPIClient::V1::TagsAPI.new diff --git a/examples/v1/tags/ListHostTags.rb b/examples/v1/tags/ListHostTags.rb index 64d438a3d8fe..b69d45d004b9 100644 --- a/examples/v1/tags/ListHostTags.rb +++ b/examples/v1/tags/ListHostTags.rb @@ -1,4 +1,4 @@ -# Get Tags returns "OK" response +# Get All Host Tags returns "OK" response require "datadog_api_client" api_instance = DatadogAPIClient::V1::TagsAPI.new diff --git a/examples/v1/tags/UpdateHostTags.rb b/examples/v1/tags/UpdateHostTags.rb index 85b445066848..f204582399d2 100644 --- a/examples/v1/tags/UpdateHostTags.rb +++ b/examples/v1/tags/UpdateHostTags.rb @@ -3,7 +3,7 @@ require "datadog_api_client" api_instance = DatadogAPIClient::V1::TagsAPI.new -body = DatadogAPIClient::V1::HostTags.new({ +body = DatadogAPIClient::V1::HostTagsInput.new({ host: "test.host", tags: [ "environment:production", diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 52ba0405690e..7b9b8a9dbf5a 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -819,12 +819,12 @@ "v1.CreateHostTags" => { "host_name" => "String", "source" => "String", - "body" => "HostTags", + "body" => "HostTagsInput", }, "v1.UpdateHostTags" => { "host_name" => "String", "source" => "String", - "body" => "HostTags", + "body" => "HostTagsInput", }, "v1.CreateUser" => { "body" => "User", diff --git a/features/v1/tags.feature b/features/v1/tags.feature index 36e1eabfdc25..d6557ca18821 100644 --- a/features/v1/tags.feature +++ b/features/v1/tags.feature @@ -6,8 +6,11 @@ Feature: Tags tags to a particular host. The component of your infrastructure responsible for a tag is identified by a source. For example, some valid sources include nagios, hudson, jenkins, users, feed, chef, puppet, git, - bitbucket, fabric, capistrano, etc. Read more about tags on [Getting - Started with Tags](https://docs.datadoghq.com/getting_started/tagging/). + bitbucket, fabric, capistrano, etc. Find a complete list of source type + names under [API Source + Attributes](https://docs.datadoghq.com/integrations/faq/list-of-api- + source-attribute-value). Read more about tags on [Getting Started with + Tags](https://docs.datadoghq.com/getting_started/tagging/). Background: Given a valid "apiKeyAuth" key in the system @@ -31,26 +34,26 @@ Feature: Tags Then the response status is 404 Not Found @generated @skip @team:DataDog/core-index - Scenario: Get Tags returns "Not Found" response + Scenario: Get All Host Tags returns "Not Found" response Given new "ListHostTags" request When the request is sent Then the response status is 404 Not Found @generated @skip @team:DataDog/core-index - Scenario: Get Tags returns "OK" response + Scenario: Get All Host Tags returns "OK" response Given new "ListHostTags" request When the request is sent Then the response status is 200 OK @generated @skip @team:DataDog/core-index - Scenario: Get host tags returns "Not Found" response + Scenario: Get Host Tags returns "Not Found" response Given new "GetHostTags" request And request contains "host_name" parameter from "REPLACE.ME" When the request is sent Then the response status is 404 Not Found @generated @skip @team:DataDog/core-index - Scenario: Get host tags returns "OK" response + Scenario: Get Host Tags returns "OK" response Given new "GetHostTags" request And request contains "host_name" parameter from "REPLACE.ME" When the request is sent diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 50449cdc25f7..d253016d6b43 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -182,7 +182,8 @@ def overrides "v1.host_metrics" => "HostMetrics", "v1.host_mute_response" => "HostMuteResponse", "v1.host_mute_settings" => "HostMuteSettings", - "v1.host_tags" => "HostTags", + "v1.host_tags_input" => "HostTagsInput", + "v1.host_tags_output" => "HostTagsOutput", "v1.host_totals" => "HostTotals", "v1.hourly_usage_attribution_body" => "HourlyUsageAttributionBody", "v1.hourly_usage_attribution_metadata" => "HourlyUsageAttributionMetadata", diff --git a/lib/datadog_api_client/v1/api/tags_api.rb b/lib/datadog_api_client/v1/api/tags_api.rb index 7f07a24ccb44..d3aa0c4a2a87 100644 --- a/lib/datadog_api_client/v1/api/tags_api.rb +++ b/lib/datadog_api_client/v1/api/tags_api.rb @@ -34,13 +34,13 @@ def create_host_tags(host_name, body, opts = {}) # Add tags to a host. # # This endpoint allows you to add new tags to a host, - # optionally specifying where these tags come from. + # optionally specifying what source 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 host_name [String] Specified host name to add new tags + # @param body [HostTagsInput] Update host tags request body. # @param opts [Hash] the optional parameters - # @option opts [String] :source The source of the tags. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). - # @return [Array<(HostTags, Integer, Hash)>] HostTags data, response status code and response headers + # @option opts [String] :source Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Use "user" source for custom-defined tags. + # @return [Array<(HostTagsOutput, Integer, Hash)>] HostTagsOutput data, response status code and response headers def create_host_tags_with_http_info(host_name, body, opts = {}) if @api_client.config.debugging @@ -75,7 +75,7 @@ def create_host_tags_with_http_info(host_name, body, opts = {}) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type - return_type = opts[:debug_return_type] || 'HostTags' + return_type = opts[:debug_return_type] || 'HostTagsOutput' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] @@ -108,12 +108,12 @@ def delete_host_tags(host_name, opts = {}) # Remove host tags. # - # This endpoint allows you to remove all user-assigned tags - # for a single host. + # This endpoint allows you to remove all tags + # for a single host. If no source is specified, only deletes tags with no source. # - # @param host_name [String] This endpoint allows you to remove all user-assigned tags for a single host. + # @param host_name [String] Specified host name to delete tags # @param opts [Hash] the optional parameters - # @option opts [String] :source The source of the tags (for example chef, puppet). [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + # @option opts [String] :source Source of the tags to be deleted. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Use "user" source for custom-defined tags. # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_host_tags_with_http_info(host_name, opts = {}) @@ -166,7 +166,7 @@ def delete_host_tags_with_http_info(host_name, opts = {}) return data, status_code, headers end - # Get host tags. + # Get Host Tags. # # @see #get_host_tags_with_http_info def get_host_tags(host_name, opts = {}) @@ -174,14 +174,14 @@ def get_host_tags(host_name, opts = {}) data end - # Get host tags. + # 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 host_name [String] Name of the host to retrieve tags for # @param opts [Hash] the optional parameters - # @option opts [String] :source Source to filter. - # @return [Array<(HostTags, Integer, Hash)>] HostTags data, response status code and response headers + # @option opts [String] :source Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Use "user" source for custom-defined tags. + # @return [Array<(HostTagsOutput, Integer, Hash)>] HostTagsOutput data, response status code and response headers def get_host_tags_with_http_info(host_name, opts = {}) if @api_client.config.debugging @@ -210,7 +210,7 @@ def get_host_tags_with_http_info(host_name, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'HostTags' + return_type = opts[:debug_return_type] || 'HostTagsOutput' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] @@ -233,7 +233,7 @@ def get_host_tags_with_http_info(host_name, opts = {}) return data, status_code, headers end - # Get Tags. + # Get All Host Tags. # # @see #list_host_tags_with_http_info def list_host_tags(opts = {}) @@ -241,12 +241,12 @@ def list_host_tags(opts = {}) data end - # Get Tags. + # Get All Host Tags. # - # Return a mapping of tags to hosts for your whole infrastructure. + # Returns a mapping of tags to hosts. For each tag, the response returns a list of host names that contain this tag. There is a restriction of 10k total host names from the org that can be attached to tags and returned. # # @param opts [Hash] the optional parameters - # @option opts [String] :source When specified, filters host list to those tags with the specified source. + # @option opts [String] :source Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Use "user" source for custom-defined tags. # @return [Array<(TagToHosts, Integer, Hash)>] TagToHosts data, response status code and response headers def list_host_tags_with_http_info(opts = {}) @@ -308,11 +308,11 @@ def update_host_tags(host_name, body, opts = {}) # 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 host_name [String] Specified host name to change tags + # @param body [HostTagsInput] Add tags to host # @param opts [Hash] the optional parameters - # @option opts [String] :source The source of the tags (for example chef, puppet). [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value) - # @return [Array<(HostTags, Integer, Hash)>] HostTags data, response status code and response headers + # @option opts [String] :source Source to filter. [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). Use "user" source for custom-defined tags. + # @return [Array<(HostTagsOutput, Integer, Hash)>] HostTagsOutput data, response status code and response headers def update_host_tags_with_http_info(host_name, body, opts = {}) if @api_client.config.debugging @@ -347,7 +347,7 @@ def update_host_tags_with_http_info(host_name, body, opts = {}) post_body = opts[:debug_body] || @api_client.object_to_http_body(body) # return_type - return_type = opts[:debug_return_type] || 'HostTags' + return_type = opts[:debug_return_type] || 'HostTagsOutput' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] diff --git a/lib/datadog_api_client/v1/models/host_tags.rb b/lib/datadog_api_client/v1/models/host_tags_input.rb similarity index 97% rename from lib/datadog_api_client/v1/models/host_tags.rb rename to lib/datadog_api_client/v1/models/host_tags_input.rb index 95e8e40ff23a..22695e5f6a24 100644 --- a/lib/datadog_api_client/v1/models/host_tags.rb +++ b/lib/datadog_api_client/v1/models/host_tags_input.rb @@ -18,7 +18,7 @@ module DatadogAPIClient::V1 # Set of tags to associate with your host. - class HostTags + class HostTagsInput include BaseGenericModel # Your host name. @@ -52,7 +52,7 @@ def self.openapi_types # @!visibility private def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::HostTags` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::HostTagsInput` initialize method" end self.additional_properties = {} diff --git a/lib/datadog_api_client/v1/models/host_tags_output.rb b/lib/datadog_api_client/v1/models/host_tags_output.rb new file mode 100644 index 000000000000..3d98febd5e57 --- /dev/null +++ b/lib/datadog_api_client/v1/models/host_tags_output.rb @@ -0,0 +1,117 @@ +=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 'date' +require 'time' + +module DatadogAPIClient::V1 + # Host name and an array of its tags + class HostTagsOutput + include BaseGenericModel + + # Your host name. + attr_accessor :host + + # A list of tags attached to a given host. + attr_accessor :tags + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'host' => :'host', + :'tags' => :'tags' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'host' => :'String', + :'tags' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::HostTagsOutput` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'host') + self.host = attributes[:'host'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + host == o.host && + tags == o.tags && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [host, tags, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/tag_to_hosts.rb b/lib/datadog_api_client/v1/models/tag_to_hosts.rb index 1c06c7f7a0c3..eb12598a3aef 100644 --- a/lib/datadog_api_client/v1/models/tag_to_hosts.rb +++ b/lib/datadog_api_client/v1/models/tag_to_hosts.rb @@ -17,11 +17,11 @@ require 'time' module DatadogAPIClient::V1 - # In this object, the key is the tag, the value is a list of host names that are reporting that tag. + # In this object, the key is the tag, and the value is a list of host names that are reporting that tag. class TagToHosts include BaseGenericModel - # A list of tags to apply to the host. + # A mapping of tags to host names attr_accessor :tags attr_accessor :additional_properties