Skip to content
Open
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
80 changes: 80 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7255,6 +7255,13 @@ components:
Monitor:
description: Object describing a monitor.
properties:
assets:
description: The list of monitor assets tied to a monitor which represents
key links for users to help take actions on monitor alerts (for example,
runbooks)
items:
$ref: '#/components/schemas/MonitorAsset'
type: array
created:
description: Timestamp of the monitor creation.
format: date-time
Expand Down Expand Up @@ -7338,6 +7345,64 @@ components:
- type
- query
type: object
MonitorAsset:
description: 'Represents key links tied to a monitor to help users take action
on alerts (Runbooks, Dashboards, Workflows)

This feature is in Preview and only available to users with the feature enabled.'
properties:
category:
$ref: '#/components/schemas/MonitorAssetCategory'
name:
description: Name for the monitor asset
example: Monitor Runbook
type: string
options:
description: Additional options that you can set on a monitor asset.
example:
hide_in_monitor_message: true
type: object
resource_key:
description: Represents the identifier of the internal datadog resource
that this asset represents. IDs in this field should be passed in as strings.
example: '12345'
type: string
resource_type:
$ref: '#/components/schemas/MonitorAssetResourceType'
template_variables:
description: Allows you to parameterize the url for the monitor asset.
example:
env: prod
region: us-east-1
type: object
url:
description: Url link for the asset
example: https://app.datadoghq.com
type: string
required:
- name
- url
- category
type: object
MonitorAssetCategory:
description: Indicates the type of asset this entity represents on a monitor
enum:
- dashboard
- workflow
- runbook
example: dashboard
type: string
x-enum-varnames:
- DASHBOARD
- WORKFLOW
- RUNBOOK
MonitorAssetResourceType:
description: Type of internal datadog resource associated with a monitor asset
enum:
- notebook
type: string
x-enum-varnames:
- NOTEBOOK
MonitorDeviceID:
description: ID of the device the Synthetics monitor is running on. Same as
`SyntheticsDeviceID`.
Expand Down Expand Up @@ -8452,6 +8517,14 @@ components:
MonitorUpdateRequest:
description: Object describing a monitor update request.
properties:
assets:
description: The list of monitor assets tied to a monitor, which represents
key links for users to help take actions on monitor alerts (for example,
runbooks)
items:
$ref: '#/components/schemas/MonitorAsset'
nullable: true
type: array
created:
description: Timestamp of the monitor creation.
format: date-time
Expand Down Expand Up @@ -31529,6 +31602,13 @@ paths:
required: false
schema:
type: boolean
- description: If this argument is set to `true`, then the returned data includes
all assets tied to this monitor.
in: query
name: with_assets
required: false
schema:
type: boolean
responses:
'200':
content:
Expand Down
21 changes: 21 additions & 0 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,27 @@ datadog\_api\_client.v1.model.monitor module
:members:
:show-inheritance:

datadog\_api\_client.v1.model.monitor\_asset module
---------------------------------------------------

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

datadog\_api\_client.v1.model.monitor\_asset\_category module
-------------------------------------------------------------

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

datadog\_api\_client.v1.model.monitor\_asset\_resource\_type module
-------------------------------------------------------------------

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

datadog\_api\_client.v1.model.monitor\_device\_id module
--------------------------------------------------------

Expand Down
11 changes: 11 additions & 0 deletions src/datadog_api_client/v1/api/monitors_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ def __init__(self, api_client=None):
"attribute": "with_downtimes",
"location": "query",
},
"with_assets": {
"openapi_types": (bool,),
"attribute": "with_assets",
"location": "query",
},
},
headers_map={
"accept": ["application/json"],
Expand Down Expand Up @@ -640,6 +645,7 @@ def get_monitor(
*,
group_states: Union[str, UnsetType] = unset,
with_downtimes: Union[bool, UnsetType] = unset,
with_assets: Union[bool, UnsetType] = unset,
) -> Monitor:
"""Get a monitor's details.

Expand All @@ -651,6 +657,8 @@ def get_monitor(
:type group_states: str, optional
:param with_downtimes: If this argument is set to true, then the returned data includes all current active downtimes for the monitor.
:type with_downtimes: bool, optional
:param with_assets: If this argument is set to ``true`` , then the returned data includes all assets tied to this monitor.
:type with_assets: bool, optional
:rtype: Monitor
"""
kwargs: Dict[str, Any] = {}
Expand All @@ -662,6 +670,9 @@ def get_monitor(
if with_downtimes is not unset:
kwargs["with_downtimes"] = with_downtimes

if with_assets is not unset:
kwargs["with_assets"] = with_assets

return self._get_monitor_endpoint.call_with_http_info(**kwargs)

def list_monitors(
Expand Down
10 changes: 10 additions & 0 deletions src/datadog_api_client/v1/model/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


if TYPE_CHECKING:
from datadog_api_client.v1.model.monitor_asset import MonitorAsset
from datadog_api_client.v1.model.creator import Creator
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.matching_downtime import MatchingDowntime
Expand All @@ -28,6 +29,7 @@
class Monitor(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.monitor_asset import MonitorAsset
from datadog_api_client.v1.model.creator import Creator
from datadog_api_client.v1.model.monitor_draft_status import MonitorDraftStatus
from datadog_api_client.v1.model.matching_downtime import MatchingDowntime
Expand All @@ -37,6 +39,7 @@ def openapi_types(_):
from datadog_api_client.v1.model.monitor_type import MonitorType

return {
"assets": ([MonitorAsset],),
"created": (datetime,),
"creator": (Creator,),
"deleted": (datetime, none_type),
Expand All @@ -58,6 +61,7 @@ def openapi_types(_):
}

attribute_map = {
"assets": "assets",
"created": "created",
"creator": "creator",
"deleted": "deleted",
Expand Down Expand Up @@ -92,6 +96,7 @@ def __init__(
self_,
query: str,
type: MonitorType,
assets: Union[List[MonitorAsset], UnsetType] = unset,
created: Union[datetime, UnsetType] = unset,
creator: Union[Creator, UnsetType] = unset,
deleted: Union[datetime, none_type, UnsetType] = unset,
Expand All @@ -113,6 +118,9 @@ def __init__(
"""
Object describing a monitor.

:param assets: The list of monitor assets tied to a monitor which represents key links for users to help take actions on monitor alerts (for example, runbooks)
:type assets: [MonitorAsset], optional

:param created: Timestamp of the monitor creation.
:type created: datetime, optional

Expand Down Expand Up @@ -172,6 +180,8 @@ def __init__(
:param type: The type of the monitor. For more information about ``type`` , see the `monitor options <https://docs.datadoghq.com/monitors/guide/monitor_api_options/>`_ docs.
:type type: MonitorType
"""
if assets is not unset:
kwargs["assets"] = assets
if created is not unset:
kwargs["created"] = created
if creator is not unset:
Expand Down
95 changes: 95 additions & 0 deletions src/datadog_api_client/v1/model/monitor_asset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# 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, TYPE_CHECKING

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


if TYPE_CHECKING:
from datadog_api_client.v1.model.monitor_asset_category import MonitorAssetCategory
from datadog_api_client.v1.model.monitor_asset_resource_type import MonitorAssetResourceType


class MonitorAsset(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.monitor_asset_category import MonitorAssetCategory
from datadog_api_client.v1.model.monitor_asset_resource_type import MonitorAssetResourceType

return {
"category": (MonitorAssetCategory,),
"name": (str,),
"options": (dict,),
"resource_key": (str,),
"resource_type": (MonitorAssetResourceType,),
"template_variables": (dict,),
"url": (str,),
}

attribute_map = {
"category": "category",
"name": "name",
"options": "options",
"resource_key": "resource_key",
"resource_type": "resource_type",
"template_variables": "template_variables",
"url": "url",
}

def __init__(
self_,
category: MonitorAssetCategory,
name: str,
url: str,
options: Union[dict, UnsetType] = unset,
resource_key: Union[str, UnsetType] = unset,
resource_type: Union[MonitorAssetResourceType, UnsetType] = unset,
template_variables: Union[dict, UnsetType] = unset,
**kwargs,
):
"""
Represents key links tied to a monitor to help users take action on alerts (Runbooks, Dashboards, Workflows)
This feature is in Preview and only available to users with the feature enabled.

:param category: Indicates the type of asset this entity represents on a monitor
:type category: MonitorAssetCategory

:param name: Name for the monitor asset
:type name: str

:param options: Additional options that you can set on a monitor asset.
:type options: dict, optional

:param resource_key: Represents the identifier of the internal datadog resource that this asset represents. IDs in this field should be passed in as strings.
:type resource_key: str, optional

:param resource_type: Type of internal datadog resource associated with a monitor asset
:type resource_type: MonitorAssetResourceType, optional

:param template_variables: Allows you to parameterize the url for the monitor asset.
:type template_variables: dict, optional

:param url: Url link for the asset
:type url: str
"""
if options is not unset:
kwargs["options"] = options
if resource_key is not unset:
kwargs["resource_key"] = resource_key
if resource_type is not unset:
kwargs["resource_type"] = resource_type
if template_variables is not unset:
kwargs["template_variables"] = template_variables
super().__init__(kwargs)

self_.category = category
self_.name = name
self_.url = url
41 changes: 41 additions & 0 deletions src/datadog_api_client/v1/model/monitor_asset_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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 datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class MonitorAssetCategory(ModelSimple):
"""
Indicates the type of asset this entity represents on a monitor

:param value: Must be one of ["dashboard", "workflow", "runbook"].
:type value: str
"""

allowed_values = {
"dashboard",
"workflow",
"runbook",
}
DASHBOARD: ClassVar["MonitorAssetCategory"]
WORKFLOW: ClassVar["MonitorAssetCategory"]
RUNBOOK: ClassVar["MonitorAssetCategory"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


MonitorAssetCategory.DASHBOARD = MonitorAssetCategory("dashboard")
MonitorAssetCategory.WORKFLOW = MonitorAssetCategory("workflow")
MonitorAssetCategory.RUNBOOK = MonitorAssetCategory("runbook")
Loading