diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index d9bb88a10f..660ab5044a 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/docs/datadog_api_client.v1.model.rst b/docs/datadog_api_client.v1.model.rst index 60a000a874..eb62816443 100644 --- a/docs/datadog_api_client.v1.model.rst +++ b/docs/datadog_api_client.v1.model.rst @@ -1236,10 +1236,17 @@ datadog\_api\_client.v1.model.host\_mute\_settings module :members: :show-inheritance: -datadog\_api\_client.v1.model.host\_tags module ------------------------------------------------ +datadog\_api\_client.v1.model.host\_tags\_input module +------------------------------------------------------ + +.. automodule:: datadog_api_client.v1.model.host_tags_input + :members: + :show-inheritance: + +datadog\_api\_client.v1.model.host\_tags\_output module +------------------------------------------------------- -.. automodule:: datadog_api_client.v1.model.host_tags +.. automodule:: datadog_api_client.v1.model.host_tags_output :members: :show-inheritance: diff --git a/examples/v1/tags/CreateHostTags.py b/examples/v1/tags/CreateHostTags.py index 5b8f2a9256..31dd6fb193 100644 --- a/examples/v1/tags/CreateHostTags.py +++ b/examples/v1/tags/CreateHostTags.py @@ -4,9 +4,9 @@ from datadog_api_client import ApiClient, Configuration from datadog_api_client.v1.api.tags_api import TagsApi -from datadog_api_client.v1.model.host_tags import HostTags +from datadog_api_client.v1.model.host_tags_input import HostTagsInput -body = HostTags( +body = HostTagsInput( host="test.host", tags=[ "environment:production", diff --git a/examples/v1/tags/GetHostTags.py b/examples/v1/tags/GetHostTags.py index 828e1f440c..eac7f14976 100644 --- a/examples/v1/tags/GetHostTags.py +++ b/examples/v1/tags/GetHostTags.py @@ -1,5 +1,5 @@ """ -Get host tags returns "OK" response +Get Host Tags returns "OK" response """ from datadog_api_client import ApiClient, Configuration diff --git a/examples/v1/tags/ListHostTags.py b/examples/v1/tags/ListHostTags.py index ec1b394f6e..6e1e3b2307 100644 --- a/examples/v1/tags/ListHostTags.py +++ b/examples/v1/tags/ListHostTags.py @@ -1,5 +1,5 @@ """ -Get Tags returns "OK" response +Get All Host Tags returns "OK" response """ from datadog_api_client import ApiClient, Configuration diff --git a/examples/v1/tags/UpdateHostTags.py b/examples/v1/tags/UpdateHostTags.py index 3b8b437bcd..ba23dfb087 100644 --- a/examples/v1/tags/UpdateHostTags.py +++ b/examples/v1/tags/UpdateHostTags.py @@ -4,9 +4,9 @@ from datadog_api_client import ApiClient, Configuration from datadog_api_client.v1.api.tags_api import TagsApi -from datadog_api_client.v1.model.host_tags import HostTags +from datadog_api_client.v1.model.host_tags_input import HostTagsInput -body = HostTags( +body = HostTagsInput( host="test.host", tags=[ "environment:production", diff --git a/src/datadog_api_client/v1/api/tags_api.py b/src/datadog_api_client/v1/api/tags_api.py index 8d030ab309..930e064e5f 100644 --- a/src/datadog_api_client/v1/api/tags_api.py +++ b/src/datadog_api_client/v1/api/tags_api.py @@ -12,7 +12,8 @@ unset, ) from datadog_api_client.v1.model.tag_to_hosts import TagToHosts -from datadog_api_client.v1.model.host_tags import HostTags +from datadog_api_client.v1.model.host_tags_output import HostTagsOutput +from datadog_api_client.v1.model.host_tags_input import HostTagsInput class TagsApi: @@ -25,7 +26,7 @@ class TagsApi: 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. + users, feed, chef, puppet, git, bitbucket, fabric, capistrano, etc. Find a complete list of source type names under `API Source Attributes `_. Read more about tags on `Getting Started with Tags `_. """ @@ -37,7 +38,7 @@ def __init__(self, api_client=None): self._create_host_tags_endpoint = _Endpoint( settings={ - "response_type": (HostTags,), + "response_type": (HostTagsOutput,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/tags/hosts/{host_name}", "operation_id": "create_host_tags", @@ -58,7 +59,7 @@ def __init__(self, api_client=None): }, "body": { "required": True, - "openapi_types": (HostTags,), + "openapi_types": (HostTagsInput,), "location": "body", }, }, @@ -96,7 +97,7 @@ def __init__(self, api_client=None): self._get_host_tags_endpoint = _Endpoint( settings={ - "response_type": (HostTags,), + "response_type": (HostTagsOutput,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/tags/hosts/{host_name}", "operation_id": "get_host_tags", @@ -146,7 +147,7 @@ def __init__(self, api_client=None): self._update_host_tags_endpoint = _Endpoint( settings={ - "response_type": (HostTags,), + "response_type": (HostTagsOutput,), "auth": ["apiKeyAuth", "appKeyAuth"], "endpoint_path": "/api/v1/tags/hosts/{host_name}", "operation_id": "update_host_tags", @@ -167,7 +168,7 @@ def __init__(self, api_client=None): }, "body": { "required": True, - "openapi_types": (HostTags,), + "openapi_types": (HostTagsInput,), "location": "body", }, }, @@ -178,23 +179,22 @@ def __init__(self, api_client=None): def create_host_tags( self, host_name: str, - body: HostTags, + body: HostTagsInput, *, source: Union[str, UnsetType] = unset, - ) -> HostTags: + ) -> HostTagsOutput: """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: This endpoint allows you to add new tags to a host, optionally specifying where the tags came from. + :param host_name: Specified host name to add new tags :type host_name: str :param body: Update host tags request body. - :type body: HostTags - :param source: The source of the tags. - `Complete list of source attribute values `_. + :type body: HostTagsInput + :param source: Source to filter. `Complete list of source attribute values `_. Use "user" source for custom-defined tags. :type source: str, optional - :rtype: HostTags + :rtype: HostTagsOutput """ kwargs: Dict[str, Any] = {} kwargs["host_name"] = host_name @@ -214,13 +214,12 @@ def delete_host_tags( ) -> None: """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: This endpoint allows you to remove all user-assigned tags for a single host. + :param host_name: Specified host name to delete tags :type host_name: str - :param source: The source of the tags (for example chef, puppet). - `Complete list of source attribute values `_. + :param source: Source of the tags to be deleted. `Complete list of source attribute values `_. Use "user" source for custom-defined tags. :type source: str, optional :rtype: None """ @@ -237,16 +236,16 @@ def get_host_tags( host_name: str, *, source: Union[str, UnsetType] = unset, - ) -> HostTags: - """Get host tags. + ) -> HostTagsOutput: + """Get Host Tags. Return the list of tags that apply to a given host. - :param host_name: When specified, filters list of tags to those tags with the specified source. + :param host_name: Name of the host to retrieve tags for :type host_name: str - :param source: Source to filter. + :param source: Source to filter. `Complete list of source attribute values `_. Use "user" source for custom-defined tags. :type source: str, optional - :rtype: HostTags + :rtype: HostTagsOutput """ kwargs: Dict[str, Any] = {} kwargs["host_name"] = host_name @@ -261,11 +260,11 @@ def list_host_tags( *, source: Union[str, UnsetType] = unset, ) -> TagToHosts: - """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 source: When specified, filters host list to those tags with the specified source. + :param source: Source to filter. `Complete list of source attribute values `_. Use "user" source for custom-defined tags. :type source: str, optional :rtype: TagToHosts """ @@ -278,23 +277,22 @@ def list_host_tags( def update_host_tags( self, host_name: str, - body: HostTags, + body: HostTagsInput, *, source: Union[str, UnsetType] = unset, - ) -> HostTags: + ) -> HostTagsOutput: """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: This endpoint allows you to update/replace all in an integration source with those supplied in the request. + :param host_name: Specified host name to change tags :type host_name: str :param body: Add tags to host - :type body: HostTags - :param source: The source of the tags (for example chef, puppet). - `Complete list of source attribute values `_ + :type body: HostTagsInput + :param source: Source to filter. `Complete list of source attribute values `_. Use "user" source for custom-defined tags. :type source: str, optional - :rtype: HostTags + :rtype: HostTagsOutput """ kwargs: Dict[str, Any] = {} kwargs["host_name"] = host_name diff --git a/src/datadog_api_client/v1/model/host_tags.py b/src/datadog_api_client/v1/model/host_tags_input.py similarity index 97% rename from src/datadog_api_client/v1/model/host_tags.py rename to src/datadog_api_client/v1/model/host_tags_input.py index c09a39b28a..c1644ee693 100644 --- a/src/datadog_api_client/v1/model/host_tags.py +++ b/src/datadog_api_client/v1/model/host_tags_input.py @@ -13,7 +13,7 @@ ) -class HostTags(ModelNormal): +class HostTagsInput(ModelNormal): @cached_property def openapi_types(_): return { diff --git a/src/datadog_api_client/v1/model/host_tags_output.py b/src/datadog_api_client/v1/model/host_tags_output.py new file mode 100644 index 0000000000..c2b31bd2d9 --- /dev/null +++ b/src/datadog_api_client/v1/model/host_tags_output.py @@ -0,0 +1,43 @@ +# 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 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class HostTagsOutput(ModelNormal): + @cached_property + def openapi_types(_): + return { + "host": (str,), + "tags": ([str],), + } + + attribute_map = { + "host": "host", + "tags": "tags", + } + + def __init__(self_, host: Union[str, UnsetType] = unset, tags: Union[List[str], UnsetType] = unset, **kwargs): + """ + Host name and an array of its tags + + :param host: Your host name. + :type host: str, optional + + :param tags: A list of tags attached to a given host. + :type tags: [str], optional + """ + if host is not unset: + kwargs["host"] = host + if tags is not unset: + kwargs["tags"] = tags + super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/model/tag_to_hosts.py b/src/datadog_api_client/v1/model/tag_to_hosts.py index 1cf451bd58..8898eb5f09 100644 --- a/src/datadog_api_client/v1/model/tag_to_hosts.py +++ b/src/datadog_api_client/v1/model/tag_to_hosts.py @@ -26,9 +26,9 @@ def openapi_types(_): def __init__(self_, tags: Union[Dict[str, List[str]], UnsetType] = unset, **kwargs): """ - 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. - :param tags: A list of tags to apply to the host. + :param tags: A mapping of tags to host names :type tags: {str: ([str],)}, optional """ if tags is not unset: diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index 062b19bebe..4d3b869ab3 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -211,7 +211,8 @@ from datadog_api_client.v1.model.host_metrics import HostMetrics from datadog_api_client.v1.model.host_mute_response import HostMuteResponse from datadog_api_client.v1.model.host_mute_settings import HostMuteSettings -from datadog_api_client.v1.model.host_tags import HostTags +from datadog_api_client.v1.model.host_tags_input import HostTagsInput +from datadog_api_client.v1.model.host_tags_output import HostTagsOutput from datadog_api_client.v1.model.host_totals import HostTotals from datadog_api_client.v1.model.hourly_usage_attribution_body import HourlyUsageAttributionBody from datadog_api_client.v1.model.hourly_usage_attribution_metadata import HourlyUsageAttributionMetadata @@ -1302,7 +1303,8 @@ "HostMetrics", "HostMuteResponse", "HostMuteSettings", - "HostTags", + "HostTagsInput", + "HostTagsOutput", "HostTotals", "HourlyUsageAttributionBody", "HourlyUsageAttributionMetadata", diff --git a/tests/v1/features/tags.feature b/tests/v1/features/tags.feature index 36e1eabfdc..d6557ca188 100644 --- a/tests/v1/features/tags.feature +++ b/tests/v1/features/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