Skip to content

Commit

Permalink
Fix specification for Azure metric filtering (#2327)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Dec 18, 2024
1 parent 27e6800 commit f8fc189
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 116 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-12-18 16:21:35.283327",
"spec_repo_commit": "e12aeab9"
"regenerated": "2024-12-18 17:18:32.703322",
"spec_repo_commit": "8cb3faac"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-12-18 16:21:35.297169",
"spec_repo_commit": "e12aeab9"
"regenerated": "2024-12-18 17:18:32.717421",
"spec_repo_commit": "8cb3faac"
}
}
}
55 changes: 32 additions & 23 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,15 @@ components:
Only hosts that match one of the defined tags are imported into Datadog.'
example: key:value,filter:example
type: string
metrics_config:
$ref: '#/components/schemas/AzureAccountMetricsConfig'
metrics_enabled:
description: Enable Azure metrics for your organization.
example: true
type: boolean
metrics_enabled_default:
description: Enable Azure metrics for your organization for resource providers
where no resource provider config is specified.
example: true
type: boolean
new_client_id:
description: Your New Azure web application ID.
example: new1c7f6-1234-5678-9101-3fcbf464test
Expand All @@ -860,37 +867,26 @@ components:
monitored by this app registration.
example: true
type: boolean
resource_provider_configs:
description: Configuration settings applied to resources from the specified
Azure resource providers.
items:
$ref: '#/components/schemas/ResourceProviderConfig'
type: array
tenant_name:
description: Your Azure Active Directory ID.
example: testc44-1234-5678-9101-cc00736ftest
type: string
usage_metrics_enabled:
description: Enable azure.usage metrics for your organization.
example: true
type: boolean
type: object
AzureAccountListResponse:
description: Accounts configured for your organization.
items:
$ref: '#/components/schemas/AzureAccount'
type: array
AzureAccountMetricsConfig:
description: 'Dictionary containing the key `excluded_resource_providers` which
has to be a list of Microsoft Azure Resource Provider names.

This feature is currently being beta tested.

In order to enable all resource providers for metric collection, pass:

`metrics_config: {"excluded_resource_providers": []}` (i.e., an empty list
for `excluded_resource_providers`).'
properties:
excluded_resource_providers:
description: List of Microsoft Azure Resource Providers to exclude from
metric collection.
example:
- Microsoft.Sql
- Microsoft.Cdn
items:
type: string
type: array
type: object
CancelDowntimesByScopeRequest:
description: Cancel downtimes according to scope.
properties:
Expand Down Expand Up @@ -10209,6 +10205,19 @@ components:
- lookup_enrichment_table
- type
type: object
ResourceProviderConfig:
description: Configuration settings applied to resources from the specified
Azure resource provider.
properties:
metrics_enabled:
description: Collect metrics for resources from this provider.
example: true
type: boolean
namespace:
description: The provider namespace to apply this configuration to.
example: Microsoft.Compute
type: string
type: object
ResponseMetaAttributes:
description: Object describing meta attributes of response.
properties:
Expand Down
14 changes: 7 additions & 7 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,6 @@ datadog\_api\_client.v1.model.azure\_account\_list\_response module
:members:
:show-inheritance:

datadog\_api\_client.v1.model.azure\_account\_metrics\_config module
--------------------------------------------------------------------

.. automodule:: datadog_api_client.v1.model.azure_account_metrics_config
:members:
:show-inheritance:

datadog\_api\_client.v1.model.cancel\_downtimes\_by\_scope\_request module
--------------------------------------------------------------------------

Expand Down Expand Up @@ -2839,6 +2832,13 @@ datadog\_api\_client.v1.model.reference\_table\_logs\_lookup\_processor module
:members:
:show-inheritance:

datadog\_api\_client.v1.model.resource\_provider\_config module
---------------------------------------------------------------

.. automodule:: datadog_api_client.v1.model.resource_provider_config
:members:
:show-inheritance:

datadog\_api\_client.v1.model.response\_meta\_attributes module
---------------------------------------------------------------

Expand Down
17 changes: 10 additions & 7 deletions examples/v1/azure-integration/UpdateAzureHostFilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.azure_integration_api import AzureIntegrationApi
from datadog_api_client.v1.model.azure_account import AzureAccount
from datadog_api_client.v1.model.azure_account_metrics_config import AzureAccountMetricsConfig
from datadog_api_client.v1.model.resource_provider_config import ResourceProviderConfig

body = AzureAccount(
app_service_plan_filters="key:value,filter:example",
Expand All @@ -19,16 +19,19 @@
"*",
],
host_filters="key:value,filter:example",
metrics_config=AzureAccountMetricsConfig(
excluded_resource_providers=[
"Microsoft.Sql",
"Microsoft.Cdn",
],
),
metrics_enabled=True,
metrics_enabled_default=True,
new_client_id="new1c7f6-1234-5678-9101-3fcbf464test",
new_tenant_name="new1c44-1234-5678-9101-cc00736ftest",
resource_collection_enabled=True,
resource_provider_configs=[
ResourceProviderConfig(
metrics_enabled=True,
namespace="Microsoft.Compute",
),
],
tenant_name="testc44-1234-5678-9101-cc00736ftest",
usage_metrics_enabled=True,
)

configuration = Configuration()
Expand Down
7 changes: 0 additions & 7 deletions examples/v1/azure-integration/UpdateAzureIntegration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.azure_integration_api import AzureIntegrationApi
from datadog_api_client.v1.model.azure_account import AzureAccount
from datadog_api_client.v1.model.azure_account_metrics_config import AzureAccountMetricsConfig

body = AzureAccount(
app_service_plan_filters="key:value,filter:example",
Expand All @@ -22,12 +21,6 @@
new_client_id="9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
new_tenant_name="9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
resource_collection_enabled=True,
metrics_config=AzureAccountMetricsConfig(
excluded_resource_providers=[
"Microsoft.Sql",
"Microsoft.Cdn",
],
),
tenant_name="9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
)

Expand Down
45 changes: 33 additions & 12 deletions src/datadog_api_client/v1/model/azure_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@


if TYPE_CHECKING:
from datadog_api_client.v1.model.azure_account_metrics_config import AzureAccountMetricsConfig
from datadog_api_client.v1.model.resource_provider_config import ResourceProviderConfig


class AzureAccount(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.azure_account_metrics_config import AzureAccountMetricsConfig
from datadog_api_client.v1.model.resource_provider_config import ResourceProviderConfig

return {
"app_service_plan_filters": (str,),
Expand All @@ -32,11 +32,14 @@ def openapi_types(_):
"custom_metrics_enabled": (bool,),
"errors": ([str],),
"host_filters": (str,),
"metrics_config": (AzureAccountMetricsConfig,),
"metrics_enabled": (bool,),
"metrics_enabled_default": (bool,),
"new_client_id": (str,),
"new_tenant_name": (str,),
"resource_collection_enabled": (bool,),
"resource_provider_configs": ([ResourceProviderConfig],),
"tenant_name": (str,),
"usage_metrics_enabled": (bool,),
}

attribute_map = {
Expand All @@ -49,11 +52,14 @@ def openapi_types(_):
"custom_metrics_enabled": "custom_metrics_enabled",
"errors": "errors",
"host_filters": "host_filters",
"metrics_config": "metrics_config",
"metrics_enabled": "metrics_enabled",
"metrics_enabled_default": "metrics_enabled_default",
"new_client_id": "new_client_id",
"new_tenant_name": "new_tenant_name",
"resource_collection_enabled": "resource_collection_enabled",
"resource_provider_configs": "resource_provider_configs",
"tenant_name": "tenant_name",
"usage_metrics_enabled": "usage_metrics_enabled",
}

def __init__(
Expand All @@ -67,11 +73,14 @@ def __init__(
custom_metrics_enabled: Union[bool, UnsetType] = unset,
errors: Union[List[str], UnsetType] = unset,
host_filters: Union[str, UnsetType] = unset,
metrics_config: Union[AzureAccountMetricsConfig, UnsetType] = unset,
metrics_enabled: Union[bool, UnsetType] = unset,
metrics_enabled_default: Union[bool, UnsetType] = unset,
new_client_id: Union[str, UnsetType] = unset,
new_tenant_name: Union[str, UnsetType] = unset,
resource_collection_enabled: Union[bool, UnsetType] = unset,
resource_provider_configs: Union[List[ResourceProviderConfig], UnsetType] = unset,
tenant_name: Union[str, UnsetType] = unset,
usage_metrics_enabled: Union[bool, UnsetType] = unset,
**kwargs,
):
"""
Expand Down Expand Up @@ -108,11 +117,11 @@ def __init__(
Only hosts that match one of the defined tags are imported into Datadog.
:type host_filters: str, optional
:param metrics_config: Dictionary containing the key ``excluded_resource_providers`` which has to be a list of Microsoft Azure Resource Provider names.
This feature is currently being beta tested.
In order to enable all resource providers for metric collection, pass:
``metrics_config: {"excluded_resource_providers": []}`` (i.e., an empty list for ``excluded_resource_providers`` ).
:type metrics_config: AzureAccountMetricsConfig, optional
:param metrics_enabled: Enable Azure metrics for your organization.
:type metrics_enabled: bool, optional
:param metrics_enabled_default: Enable Azure metrics for your organization for resource providers where no resource provider config is specified.
:type metrics_enabled_default: bool, optional
:param new_client_id: Your New Azure web application ID.
:type new_client_id: str, optional
Expand All @@ -123,8 +132,14 @@ def __init__(
:param resource_collection_enabled: When enabled, Datadog collects metadata and configuration info from cloud resources (compute instances, databases, load balancers, etc.) monitored by this app registration.
:type resource_collection_enabled: bool, optional
:param resource_provider_configs: Configuration settings applied to resources from the specified Azure resource providers.
:type resource_provider_configs: [ResourceProviderConfig], optional
:param tenant_name: Your Azure Active Directory ID.
:type tenant_name: str, optional
:param usage_metrics_enabled: Enable azure.usage metrics for your organization.
:type usage_metrics_enabled: bool, optional
"""
if app_service_plan_filters is not unset:
kwargs["app_service_plan_filters"] = app_service_plan_filters
Expand All @@ -144,14 +159,20 @@ def __init__(
kwargs["errors"] = errors
if host_filters is not unset:
kwargs["host_filters"] = host_filters
if metrics_config is not unset:
kwargs["metrics_config"] = metrics_config
if metrics_enabled is not unset:
kwargs["metrics_enabled"] = metrics_enabled
if metrics_enabled_default is not unset:
kwargs["metrics_enabled_default"] = metrics_enabled_default
if new_client_id is not unset:
kwargs["new_client_id"] = new_client_id
if new_tenant_name is not unset:
kwargs["new_tenant_name"] = new_tenant_name
if resource_collection_enabled is not unset:
kwargs["resource_collection_enabled"] = resource_collection_enabled
if resource_provider_configs is not unset:
kwargs["resource_provider_configs"] = resource_provider_configs
if tenant_name is not unset:
kwargs["tenant_name"] = tenant_name
if usage_metrics_enabled is not unset:
kwargs["usage_metrics_enabled"] = usage_metrics_enabled
super().__init__(kwargs)
39 changes: 0 additions & 39 deletions src/datadog_api_client/v1/model/azure_account_metrics_config.py

This file was deleted.

45 changes: 45 additions & 0 deletions src/datadog_api_client/v1/model/resource_provider_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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 Union

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


class ResourceProviderConfig(ModelNormal):
@cached_property
def openapi_types(_):
return {
"metrics_enabled": (bool,),
"namespace": (str,),
}

attribute_map = {
"metrics_enabled": "metrics_enabled",
"namespace": "namespace",
}

def __init__(
self_, metrics_enabled: Union[bool, UnsetType] = unset, namespace: Union[str, UnsetType] = unset, **kwargs
):
"""
Configuration settings applied to resources from the specified Azure resource provider.
:param metrics_enabled: Collect metrics for resources from this provider.
:type metrics_enabled: bool, optional
:param namespace: The provider namespace to apply this configuration to.
:type namespace: str, optional
"""
if metrics_enabled is not unset:
kwargs["metrics_enabled"] = metrics_enabled
if namespace is not unset:
kwargs["namespace"] = namespace
super().__init__(kwargs)
Loading

0 comments on commit f8fc189

Please sign in to comment.