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/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/private/bdd_runner/src/support/scenarios_model_mapping.ts b/private/bdd_runner/src/support/scenarios_model_mapping.ts index 8b9b327c80f7..f43c820016f1 100644 --- a/private/bdd_runner/src/support/scenarios_model_mapping.ts +++ b/private/bdd_runner/src/support/scenarios_model_mapping.ts @@ -2273,7 +2273,7 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { type: "string", format: "", }, - operationResponseType: "HostTags", + operationResponseType: "HostTagsOutput", }, "TagsApi.V1.UpdateHostTags": { hostName: { @@ -2285,10 +2285,10 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { format: "", }, body: { - type: "HostTags", + type: "HostTagsInput", format: "", }, - operationResponseType: "HostTags", + operationResponseType: "HostTagsOutput", }, "TagsApi.V1.CreateHostTags": { hostName: { @@ -2300,10 +2300,10 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = { format: "", }, body: { - type: "HostTags", + type: "HostTagsInput", format: "", }, - operationResponseType: "HostTags", + operationResponseType: "HostTagsOutput", }, "TagsApi.V1.DeleteHostTags": { hostName: { diff --git a/services/tags/README.md b/services/tags/README.md index 84be2c28f6f2..701e9152cee2 100644 --- a/services/tags/README.md +++ b/services/tags/README.md @@ -10,7 +10,7 @@ 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. +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/services/tags/src/v1/TagsApi.ts b/services/tags/src/v1/TagsApi.ts index 1fc664dcebd7..cdec4d9ed220 100644 --- a/services/tags/src/v1/TagsApi.ts +++ b/services/tags/src/v1/TagsApi.ts @@ -23,7 +23,8 @@ import { import { TypingInfo } from "./models/TypingInfo"; import { APIErrorResponse } from "./models/APIErrorResponse"; -import { HostTags } from "./models/HostTags"; +import { HostTagsInput } from "./models/HostTagsInput"; +import { HostTagsOutput } from "./models/HostTagsOutput"; import { TagToHosts } from "./models/TagToHosts"; import { version } from "../version"; @@ -38,7 +39,7 @@ export class TagsApiRequestFactory extends BaseAPIRequestFactory { } public async createHostTags( hostName: string, - body: HostTags, + body: HostTagsInput, source?: string, _options?: Configuration, ): Promise { @@ -91,7 +92,7 @@ export class TagsApiRequestFactory extends BaseAPIRequestFactory { const contentType = getPreferredMediaType(["application/json"]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = stringify( - serialize(body, TypingInfo, "HostTags", ""), + serialize(body, TypingInfo, "HostTagsInput", ""), contentType, ); requestContext.setBody(serializedBody); @@ -261,7 +262,7 @@ export class TagsApiRequestFactory extends BaseAPIRequestFactory { public async updateHostTags( hostName: string, - body: HostTags, + body: HostTagsInput, source?: string, _options?: Configuration, ): Promise { @@ -314,7 +315,7 @@ export class TagsApiRequestFactory extends BaseAPIRequestFactory { const contentType = getPreferredMediaType(["application/json"]); requestContext.setHeaderParam("Content-Type", contentType); const serializedBody = stringify( - serialize(body, TypingInfo, "HostTags", ""), + serialize(body, TypingInfo, "HostTagsInput", ""), contentType, ); requestContext.setBody(serializedBody); @@ -337,14 +338,16 @@ export class TagsApiResponseProcessor { * @params response Response returned by the server for a request to createHostTags * @throws ApiException if the response code was not in [200, 299] */ - public async createHostTags(response: ResponseContext): Promise { + public async createHostTags( + response: ResponseContext, + ): Promise { const contentType = normalizeMediaType(response.headers["content-type"]); if (response.httpStatusCode === 201) { - const body: HostTags = deserialize( + const body: HostTagsOutput = deserialize( parse(await response.body.text(), contentType), TypingInfo, - "HostTags", - ) as HostTags; + "HostTagsOutput", + ) as HostTagsOutput; return body; } if ( @@ -372,12 +375,12 @@ export class TagsApiResponseProcessor { // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const body: HostTags = deserialize( + const body: HostTagsOutput = deserialize( parse(await response.body.text(), contentType), TypingInfo, - "HostTags", + "HostTagsOutput", "", - ) as HostTags; + ) as HostTagsOutput; return body; } @@ -442,14 +445,14 @@ export class TagsApiResponseProcessor { * @params response Response returned by the server for a request to getHostTags * @throws ApiException if the response code was not in [200, 299] */ - public async getHostTags(response: ResponseContext): Promise { + public async getHostTags(response: ResponseContext): Promise { const contentType = normalizeMediaType(response.headers["content-type"]); if (response.httpStatusCode === 200) { - const body: HostTags = deserialize( + const body: HostTagsOutput = deserialize( parse(await response.body.text(), contentType), TypingInfo, - "HostTags", - ) as HostTags; + "HostTagsOutput", + ) as HostTagsOutput; return body; } if ( @@ -477,12 +480,12 @@ export class TagsApiResponseProcessor { // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const body: HostTags = deserialize( + const body: HostTagsOutput = deserialize( parse(await response.body.text(), contentType), TypingInfo, - "HostTags", + "HostTagsOutput", "", - ) as HostTags; + ) as HostTagsOutput; return body; } @@ -558,14 +561,16 @@ export class TagsApiResponseProcessor { * @params response Response returned by the server for a request to updateHostTags * @throws ApiException if the response code was not in [200, 299] */ - public async updateHostTags(response: ResponseContext): Promise { + public async updateHostTags( + response: ResponseContext, + ): Promise { const contentType = normalizeMediaType(response.headers["content-type"]); if (response.httpStatusCode === 201) { - const body: HostTags = deserialize( + const body: HostTagsOutput = deserialize( parse(await response.body.text(), contentType), TypingInfo, - "HostTags", - ) as HostTags; + "HostTagsOutput", + ) as HostTagsOutput; return body; } if ( @@ -593,12 +598,12 @@ export class TagsApiResponseProcessor { // Work around for missing responses in specification, e.g. for petstore.yaml if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { - const body: HostTags = deserialize( + const body: HostTagsOutput = deserialize( parse(await response.body.text(), contentType), TypingInfo, - "HostTags", + "HostTagsOutput", "", - ) as HostTags; + ) as HostTagsOutput; return body; } @@ -612,18 +617,17 @@ export class TagsApiResponseProcessor { export interface TagsApiCreateHostTagsRequest { /** - * This endpoint allows you to add new tags to a host, optionally specifying where the tags came from. + * Specified host name to add new tags * @type string */ hostName: string; /** * Update host tags request body. - * @type HostTags + * @type HostTagsInput */ - body: HostTags; + body: HostTagsInput; /** - * The source of the tags. - * [Complete list of source attribute values](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value). + * 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. * @type string */ source?: string; @@ -631,13 +635,12 @@ export interface TagsApiCreateHostTagsRequest { export interface TagsApiDeleteHostTagsRequest { /** - * This endpoint allows you to remove all user-assigned tags for a single host. + * Specified host name to delete tags * @type string */ hostName: string; /** - * 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). + * 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. * @type string */ source?: string; @@ -645,12 +648,12 @@ export interface TagsApiDeleteHostTagsRequest { export interface TagsApiGetHostTagsRequest { /** - * When specified, filters list of tags to those tags with the specified source. + * Name of the host to retrieve tags for * @type string */ hostName: string; /** - * Source to filter. + * 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. * @type string */ source?: string; @@ -658,7 +661,7 @@ export interface TagsApiGetHostTagsRequest { export interface TagsApiListHostTagsRequest { /** - * When specified, filters host list to those tags with the specified 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. * @type string */ source?: string; @@ -666,18 +669,17 @@ export interface TagsApiListHostTagsRequest { export interface TagsApiUpdateHostTagsRequest { /** - * This endpoint allows you to update/replace all in an integration source with those supplied in the request. + * Specified host name to change tags * @type string */ hostName: string; /** * Add tags to host - * @type HostTags + * @type HostTagsInput */ - body: HostTags; + body: HostTagsInput; /** - * 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) + * 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. * @type string */ source?: string; @@ -704,13 +706,13 @@ export class TagsApi { /** * 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 param The request object */ public createHostTags( param: TagsApiCreateHostTagsRequest, options?: Configuration, - ): Promise { + ): Promise { const requestContextPromise = this.requestFactory.createHostTags( param.hostName, param.body, @@ -727,8 +729,8 @@ export class TagsApi { } /** - * 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 param The request object */ public deleteHostTags( @@ -756,7 +758,7 @@ export class TagsApi { public getHostTags( param: TagsApiGetHostTagsRequest, options?: Configuration, - ): Promise { + ): Promise { const requestContextPromise = this.requestFactory.getHostTags( param.hostName, param.source, @@ -772,7 +774,7 @@ export class TagsApi { } /** - * 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 param The request object */ public listHostTags( @@ -800,7 +802,7 @@ export class TagsApi { public updateHostTags( param: TagsApiUpdateHostTagsRequest, options?: Configuration, - ): Promise { + ): Promise { const requestContextPromise = this.requestFactory.updateHostTags( param.hostName, param.body, diff --git a/services/tags/src/v1/index.ts b/services/tags/src/v1/index.ts index 5c406e9d6ef7..2fe7760e9369 100644 --- a/services/tags/src/v1/index.ts +++ b/services/tags/src/v1/index.ts @@ -8,5 +8,6 @@ export { } from "./TagsApi"; export { APIErrorResponse } from "./models/APIErrorResponse"; -export { HostTags } from "./models/HostTags"; +export { HostTagsInput } from "./models/HostTagsInput"; +export { HostTagsOutput } from "./models/HostTagsOutput"; export { TagToHosts } from "./models/TagToHosts"; diff --git a/services/tags/src/v1/models/HostTags.ts b/services/tags/src/v1/models/HostTagsInput.ts similarity index 93% rename from services/tags/src/v1/models/HostTags.ts rename to services/tags/src/v1/models/HostTagsInput.ts index 1b5fc513914e..a299b37bcc43 100644 --- a/services/tags/src/v1/models/HostTags.ts +++ b/services/tags/src/v1/models/HostTagsInput.ts @@ -3,7 +3,7 @@ import { AttributeTypeMap } from "@datadog/datadog-api-client"; /** * Set of tags to associate with your host. */ -export class HostTags { +export class HostTagsInput { /** * Your host name. */ @@ -45,7 +45,7 @@ export class HostTags { * @ignore */ static getAttributeTypeMap(): AttributeTypeMap { - return HostTags.attributeTypeMap; + return HostTagsInput.attributeTypeMap; } public constructor() {} diff --git a/services/tags/src/v1/models/HostTagsOutput.ts b/services/tags/src/v1/models/HostTagsOutput.ts new file mode 100644 index 000000000000..fbc56e0dfa4e --- /dev/null +++ b/services/tags/src/v1/models/HostTagsOutput.ts @@ -0,0 +1,52 @@ +import { AttributeTypeMap } from "@datadog/datadog-api-client"; + +/** + * Host name and an array of its tags + */ +export class HostTagsOutput { + /** + * Your host name. + */ + "host"?: string; + /** + * A list of tags attached to a given host. + */ + "tags"?: Array; + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + "additionalProperties"?: { [key: string]: any }; + /** + * @ignore + */ + "_unparsed"?: boolean; + + /** + * @ignore + */ + static readonly attributeTypeMap: AttributeTypeMap = { + host: { + baseName: "host", + type: "string", + }, + tags: { + baseName: "tags", + type: "Array", + }, + additionalProperties: { + baseName: "additionalProperties", + type: "{ [key: string]: any; }", + }, + }; + + /** + * @ignore + */ + static getAttributeTypeMap(): AttributeTypeMap { + return HostTagsOutput.attributeTypeMap; + } + + public constructor() {} +} diff --git a/services/tags/src/v1/models/TagToHosts.ts b/services/tags/src/v1/models/TagToHosts.ts index 063bb545b1e5..71251fd8c9fa 100644 --- a/services/tags/src/v1/models/TagToHosts.ts +++ b/services/tags/src/v1/models/TagToHosts.ts @@ -1,11 +1,11 @@ import { AttributeTypeMap } from "@datadog/datadog-api-client"; /** - * 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. */ export class TagToHosts { /** - * A list of tags to apply to the host. + * A mapping of tags to host names */ "tags"?: { [key: string]: Array }; /** diff --git a/services/tags/src/v1/models/TypingInfo.ts b/services/tags/src/v1/models/TypingInfo.ts index 5a8fab248317..4ce7531ca2ad 100644 --- a/services/tags/src/v1/models/TypingInfo.ts +++ b/services/tags/src/v1/models/TypingInfo.ts @@ -1,7 +1,8 @@ import { ModelTypingInfo } from "@datadog/datadog-api-client"; import { APIErrorResponse } from "./APIErrorResponse"; -import { HostTags } from "./HostTags"; +import { HostTagsInput } from "./HostTagsInput"; +import { HostTagsOutput } from "./HostTagsOutput"; import { TagToHosts } from "./TagToHosts"; export const TypingInfo: ModelTypingInfo = { @@ -9,7 +10,8 @@ export const TypingInfo: ModelTypingInfo = { oneOfMap: {}, typeMap: { APIErrorResponse: APIErrorResponse, - HostTags: HostTags, + HostTagsInput: HostTagsInput, + HostTagsOutput: HostTagsOutput, TagToHosts: TagToHosts, }, };