Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4317,8 +4317,16 @@ components:
type: array
namespace_filters:
$ref: "#/components/schemas/AWSNamespaceFilters"
resource_type_tag_filters:
description: AWS Metrics collection resource type tag filters list. Defaults to `[]`.
items:
$ref: "#/components/schemas/AWSResourceTypeTagFilter"
type: array
tag_filters:
description: AWS Metrics collection tag filters list. Defaults to `[]`.
deprecated: true
description: |-
AWS Metrics collection tag filters list. Defaults to `[]`.
Deprecated in favor of `resource_type_tag_filters`. The two fields are mutually exclusive on an account.
items:
$ref: "#/components/schemas/AWSNamespaceTagFilter"
type: array
Expand Down Expand Up @@ -4512,6 +4520,38 @@ components:
required:
- include_only
type: object
AWSResourceTypeTagFilter:
description: |-
AWS Metrics Collection resource type tag filter.
Each filter targets either a specific AWS service's resource types (`service` and
`resource_types`) or custom metrics (`custom`). These two modes are mutually exclusive.
The `expression` defines a tag filter that Datadog uses when collecting metrics from the
resource types of a specified service. Wildcards, such as `?` (match a single character)
and `*` (match multiple characters), and exclusion using `!` before the tag are supported.
For example, `env:production AND instance-type:c?.* AND !region:us-east-1`.
properties:
custom:
description: Whether the tag filter applies to custom metrics. When `true`, `service` and `resource_types` must be omitted.
example: false
type: boolean
expression:
description: The tag filter expression to apply when collecting metrics for the matching resource types.
example: "env:production"
type: string
resource_types:
description: The AWS resource types of the service to which the tag filter applies. Required when `service` is set. Use `*` as the only entry to match all resource types of the service; `*` cannot be combined with specific resource types.
items:
description: An AWS resource type of the service.
example: "instance"
type: string
type: array
service:
description: The AWS service for which the tag filter defined in `expression` will be applied. Required unless `custom` is `true`, and must be set together with `resource_types`.
example: "ec2"
type: string
required:
- expression
type: object
AWSResourcesConfig:
description: AWS Resources Collection config.
properties:
Expand Down Expand Up @@ -187941,8 +187981,11 @@ paths:
- include_only:
- aws.ec2.network_in
namespace: AWS/EC2
tag_filters:
- namespace: AWS/EC2
resource_type_tag_filters:
- expression: env:production
resource_types:
- instance
service: ec2
resources_config:
cloud_security_posture_management_collection: false
extended_collection: true
Expand Down Expand Up @@ -188084,8 +188127,11 @@ paths:
- include_only:
- aws.ec2.network_in
namespace: AWS/EC2
tag_filters:
- namespace: AWS/EC2
resource_type_tag_filters:
- expression: env:production
resource_types:
- instance
service: ec2
resources_config:
cloud_security_posture_management_collection: false
extended_collection: true
Expand Down
13 changes: 7 additions & 6 deletions examples/v2/aws-integration/UpdateAWSAccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from datadog_api_client.v2.model.aws_log_source_tag_filter import AWSLogSourceTagFilter
from datadog_api_client.v2.model.aws_logs_config import AWSLogsConfig
from datadog_api_client.v2.model.aws_metrics_config import AWSMetricsConfig
from datadog_api_client.v2.model.aws_namespace_tag_filter import AWSNamespaceTagFilter
from datadog_api_client.v2.model.aws_resource_type_tag_filter import AWSResourceTypeTagFilter
from datadog_api_client.v2.model.aws_resources_config import AWSResourcesConfig
from datadog_api_client.v2.model.aws_traces_config import AWSTracesConfig

Expand Down Expand Up @@ -61,12 +61,13 @@
collect_cloudwatch_alarms=True,
collect_custom_metrics=True,
enabled=True,
tag_filters=[
AWSNamespaceTagFilter(
namespace="AWS/EC2",
tags=[
"key:value",
resource_type_tag_filters=[
AWSResourceTypeTagFilter(
service="ec2",
resource_types=[
"instance",
],
expression="env:staging",
),
],
),
Expand Down
11 changes: 11 additions & 0 deletions src/datadog_api_client/v2/model/aws_metrics_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
if TYPE_CHECKING:
from datadog_api_client.v2.model.aws_metric_name_filters import AWSMetricNameFilters
from datadog_api_client.v2.model.aws_namespace_filters import AWSNamespaceFilters
from datadog_api_client.v2.model.aws_resource_type_tag_filter import AWSResourceTypeTagFilter
from datadog_api_client.v2.model.aws_namespace_tag_filter import AWSNamespaceTagFilter
from datadog_api_client.v2.model.aws_metric_name_filters_include_only import AWSMetricNameFiltersIncludeOnly
from datadog_api_client.v2.model.aws_metric_name_filters_exclude_only import AWSMetricNameFiltersExcludeOnly
Expand All @@ -28,6 +29,7 @@ class AWSMetricsConfig(ModelNormal):
def openapi_types(_):
from datadog_api_client.v2.model.aws_metric_name_filters import AWSMetricNameFilters
from datadog_api_client.v2.model.aws_namespace_filters import AWSNamespaceFilters
from datadog_api_client.v2.model.aws_resource_type_tag_filter import AWSResourceTypeTagFilter
from datadog_api_client.v2.model.aws_namespace_tag_filter import AWSNamespaceTagFilter

return {
Expand All @@ -38,6 +40,7 @@ def openapi_types(_):
"enabled": (bool,),
"metric_name_filters": ([AWSMetricNameFilters],),
"namespace_filters": (AWSNamespaceFilters,),
"resource_type_tag_filters": ([AWSResourceTypeTagFilter],),
"tag_filters": ([AWSNamespaceTagFilter],),
}

Expand All @@ -49,6 +52,7 @@ def openapi_types(_):
"enabled": "enabled",
"metric_name_filters": "metric_name_filters",
"namespace_filters": "namespace_filters",
"resource_type_tag_filters": "resource_type_tag_filters",
"tag_filters": "tag_filters",
}

Expand All @@ -66,6 +70,7 @@ def __init__(
namespace_filters: Union[
AWSNamespaceFilters, AWSNamespaceFiltersExcludeOnly, AWSNamespaceFiltersIncludeOnly, UnsetType
] = unset,
resource_type_tag_filters: Union[List[AWSResourceTypeTagFilter], UnsetType] = unset,
tag_filters: Union[List[AWSNamespaceTagFilter], UnsetType] = unset,
**kwargs,
):
Expand Down Expand Up @@ -94,7 +99,11 @@ def __init__(
:param namespace_filters: AWS Metrics namespace filters. Defaults to ``exclude_only``.
:type namespace_filters: AWSNamespaceFilters, optional

:param resource_type_tag_filters: AWS Metrics collection resource type tag filters list. Defaults to ``[]``.
:type resource_type_tag_filters: [AWSResourceTypeTagFilter], optional

:param tag_filters: AWS Metrics collection tag filters list. Defaults to ``[]``.
Deprecated in favor of ``resource_type_tag_filters``. The two fields are mutually exclusive on an account. **Deprecated**.
:type tag_filters: [AWSNamespaceTagFilter], optional
"""
if automute_enabled is not unset:
Expand All @@ -111,6 +120,8 @@ def __init__(
kwargs["metric_name_filters"] = metric_name_filters
if namespace_filters is not unset:
kwargs["namespace_filters"] = namespace_filters
if resource_type_tag_filters is not unset:
kwargs["resource_type_tag_filters"] = resource_type_tag_filters
if tag_filters is not unset:
kwargs["tag_filters"] = tag_filters
super().__init__(kwargs)
70 changes: 70 additions & 0 deletions src/datadog_api_client/v2/model/aws_resource_type_tag_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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 AWSResourceTypeTagFilter(ModelNormal):
@cached_property
def openapi_types(_):
return {
"custom": (bool,),
"expression": (str,),
"resource_types": ([str],),
"service": (str,),
}

attribute_map = {
"custom": "custom",
"expression": "expression",
"resource_types": "resource_types",
"service": "service",
}

def __init__(
self_,
expression: str,
custom: Union[bool, UnsetType] = unset,
resource_types: Union[List[str], UnsetType] = unset,
service: Union[str, UnsetType] = unset,
**kwargs,
):
"""
AWS Metrics Collection resource type tag filter.
Each filter targets either a specific AWS service's resource types ( ``service`` and
``resource_types`` ) or custom metrics ( ``custom`` ). These two modes are mutually exclusive.
The ``expression`` defines a tag filter that Datadog uses when collecting metrics from the
resource types of a specified service. Wildcards, such as ``?`` (match a single character)
and ``*`` (match multiple characters), and exclusion using ``!`` before the tag are supported.
For example, ``env:production AND instance-type:c?.* AND !region:us-east-1``.

:param custom: Whether the tag filter applies to custom metrics. When ``true`` , ``service`` and ``resource_types`` must be omitted.
:type custom: bool, optional

:param expression: The tag filter expression to apply when collecting metrics for the matching resource types.
:type expression: str

:param resource_types: The AWS resource types of the service to which the tag filter applies. Required when ``service`` is set. Use ``*`` as the only entry to match all resource types of the service; ``*`` cannot be combined with specific resource types.
:type resource_types: [str], optional

:param service: The AWS service for which the tag filter defined in ``expression`` will be applied. Required unless ``custom`` is ``true`` , and must be set together with ``resource_types``.
:type service: str, optional
"""
if custom is not unset:
kwargs["custom"] = custom
if resource_types is not unset:
kwargs["resource_types"] = resource_types
if service is not unset:
kwargs["service"] = service
super().__init__(kwargs)

self_.expression = expression
2 changes: 2 additions & 0 deletions src/datadog_api_client/v2/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
from datadog_api_client.v2.model.aws_regions import AWSRegions
from datadog_api_client.v2.model.aws_regions_include_all import AWSRegionsIncludeAll
from datadog_api_client.v2.model.aws_regions_include_only import AWSRegionsIncludeOnly
from datadog_api_client.v2.model.aws_resource_type_tag_filter import AWSResourceTypeTagFilter
from datadog_api_client.v2.model.aws_resources_config import AWSResourcesConfig
from datadog_api_client.v2.model.aws_traces_config import AWSTracesConfig
from datadog_api_client.v2.model.access_token_list_item import AccessTokenListItem
Expand Down Expand Up @@ -13281,6 +13282,7 @@
"AWSRegions",
"AWSRegionsIncludeAll",
"AWSRegionsIncludeOnly",
"AWSResourceTypeTagFilter",
"AWSResourcesConfig",
"AWSTracesConfig",
"AccessTokenListItem",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
"collect_cloudwatch_alarms": true,
"collect_custom_metrics": true,
"enabled": true,
"tag_filters": [
"resource_type_tag_filters": [
{
"namespace": "AWS/EC2",
"tags": [
"key:value"
]
"expression": "env:staging",
"resource_types": [
"instance"
],
"service": "ec2"
}
]
},
Expand Down
Loading
Loading