Skip to content

Commit

Permalink
Regenerate client from commit d3111007 of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Oct 4, 2023
1 parent 4c53cf6 commit cfa4f34
Show file tree
Hide file tree
Showing 9 changed files with 233 additions and 6 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": "2023-10-02 18:58:17.933721",
"spec_repo_commit": "aee9e14a"
"regenerated": "2023-10-04 17:31:50.479893",
"spec_repo_commit": "d3111007"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-10-02 18:58:17.947416",
"spec_repo_commit": "aee9e14a"
"regenerated": "2023-10-04 17:31:50.493796",
"spec_repo_commit": "d3111007"
}
}
}
29 changes: 29 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6839,6 +6839,33 @@ components:
type: string
readOnly: true
type: object
MonitorOptionsCustomSchedule:
description: Configuration options for the custom schedule. **This feature is
in private beta.**
properties:
recurrences:
description: Array of custom schedule recurrences.
items:
$ref: '#/components/schemas/MonitorOptionsCustomScheduleRecurrence'
type: array
type: object
MonitorOptionsCustomScheduleRecurrence:
description: Configuration for a recurrence set on the monitor options for custom
schedule.
properties:
rrule:
description: Defines the recurrence rule (RRULE) for a given schedule.
example: FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
type: string
start:
description: Defines the start date and time of the recurring schedule.
example: '2023-08-31T16:30:00'
type: string
timezone:
description: Defines the timezone the schedule runs on.
example: Europe/Paris
type: string
type: object
MonitorOptionsNotificationPresets:
default: show_all
description: Toggles the display of additional content sent in the monitor notification.
Expand All @@ -6856,6 +6883,8 @@ components:
MonitorOptionsSchedulingOptions:
description: Configuration options for scheduling.
properties:
custom_schedule:
$ref: '#/components/schemas/MonitorOptionsCustomSchedule'
evaluation_window:
$ref: '#/components/schemas/MonitorOptionsSchedulingOptionsEvaluationWindow'
type: object
Expand Down
14 changes: 14 additions & 0 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,20 @@ monitor\_options\_aggregation
:members:
:show-inheritance:

monitor\_options\_custom\_schedule
----------------------------------

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

monitor\_options\_custom\_schedule\_recurrence
----------------------------------------------

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

monitor\_options\_notification\_presets
---------------------------------------

Expand Down
53 changes: 53 additions & 0 deletions examples/v1/monitors/CreateMonitor_1539578087.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
Create a metric monitor with a custom schedule returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi
from datadog_api_client.v1.model.monitor import Monitor
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
MonitorOptionsCustomScheduleRecurrence,
)
from datadog_api_client.v1.model.monitor_options_scheduling_options import MonitorOptionsSchedulingOptions
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
MonitorOptionsSchedulingOptionsEvaluationWindow,
)
from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds
from datadog_api_client.v1.model.monitor_type import MonitorType

body = Monitor(
name="Example-Monitor",
type=MonitorType.METRIC_ALERT,
query="avg(current_1mo):avg:system.load.5{*} > 0.5",
message="some message Notify: @hipchat-channel",
options=MonitorOptions(
thresholds=MonitorThresholds(
critical=0.5,
),
scheduling_options=MonitorOptionsSchedulingOptions(
custom_schedule=MonitorOptionsCustomSchedule(
recurrences=[
MonitorOptionsCustomScheduleRecurrence(
rrule="FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR",
start="2024-08-31T16:30:00",
timezone="Europe/Paris",
),
],
),
evaluation_window=MonitorOptionsSchedulingOptionsEvaluationWindow(
day_starts="04:00",
hour_starts=0,
month_starts=1,
),
),
),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = MonitorsApi(api_client)
response = api_instance.create_monitor(body=body)

print(response)
46 changes: 46 additions & 0 deletions src/datadog_api_client/v1/model/monitor_options_custom_schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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, TYPE_CHECKING

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


if TYPE_CHECKING:
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
MonitorOptionsCustomScheduleRecurrence,
)


class MonitorOptionsCustomSchedule(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
MonitorOptionsCustomScheduleRecurrence,
)

return {
"recurrences": ([MonitorOptionsCustomScheduleRecurrence],),
}

attribute_map = {
"recurrences": "recurrences",
}

def __init__(self_, recurrences: Union[List[MonitorOptionsCustomScheduleRecurrence], UnsetType] = unset, **kwargs):
"""
Configuration options for the custom schedule. **This feature is in private beta.**
:param recurrences: Array of custom schedule recurrences.
:type recurrences: [MonitorOptionsCustomScheduleRecurrence], optional
"""
if recurrences is not unset:
kwargs["recurrences"] = recurrences
super().__init__(kwargs)
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 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 MonitorOptionsCustomScheduleRecurrence(ModelNormal):
@cached_property
def openapi_types(_):
return {
"rrule": (str,),
"start": (str,),
"timezone": (str,),
}

attribute_map = {
"rrule": "rrule",
"start": "start",
"timezone": "timezone",
}

def __init__(
self_,
rrule: Union[str, UnsetType] = unset,
start: Union[str, UnsetType] = unset,
timezone: Union[str, UnsetType] = unset,
**kwargs,
):
"""
Configuration for a recurrence set on the monitor options for custom schedule.
:param rrule: Defines the recurrence rule (RRULE) for a given schedule.
:type rrule: str, optional
:param start: Defines the start date and time of the recurring schedule.
:type start: str, optional
:param timezone: Defines the timezone the schedule runs on.
:type timezone: str, optional
"""
if rrule is not unset:
kwargs["rrule"] = rrule
if start is not unset:
kwargs["start"] = start
if timezone is not unset:
kwargs["timezone"] = timezone
super().__init__(kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


if TYPE_CHECKING:
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
MonitorOptionsSchedulingOptionsEvaluationWindow,
)
Expand All @@ -22,27 +23,38 @@
class MonitorOptionsSchedulingOptions(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
MonitorOptionsSchedulingOptionsEvaluationWindow,
)

return {
"custom_schedule": (MonitorOptionsCustomSchedule,),
"evaluation_window": (MonitorOptionsSchedulingOptionsEvaluationWindow,),
}

attribute_map = {
"custom_schedule": "custom_schedule",
"evaluation_window": "evaluation_window",
}

def __init__(
self_, evaluation_window: Union[MonitorOptionsSchedulingOptionsEvaluationWindow, UnsetType] = unset, **kwargs
self_,
custom_schedule: Union[MonitorOptionsCustomSchedule, UnsetType] = unset,
evaluation_window: Union[MonitorOptionsSchedulingOptionsEvaluationWindow, UnsetType] = unset,
**kwargs,
):
"""
Configuration options for scheduling.
:param custom_schedule: Configuration options for the custom schedule. **This feature is in private beta.**
:type custom_schedule: MonitorOptionsCustomSchedule, optional
:param evaluation_window: Configuration options for the evaluation window. If ``hour_starts`` is set, no other fields may be set. Otherwise, ``day_starts`` and ``month_starts`` must be set together.
:type evaluation_window: MonitorOptionsSchedulingOptionsEvaluationWindow, optional
"""
if custom_schedule is not unset:
kwargs["custom_schedule"] = custom_schedule
if evaluation_window is not unset:
kwargs["evaluation_window"] = evaluation_window
super().__init__(kwargs)
6 changes: 6 additions & 0 deletions src/datadog_api_client/v1/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@
from datadog_api_client.v1.model.monitor_group_search_result import MonitorGroupSearchResult
from datadog_api_client.v1.model.monitor_options import MonitorOptions
from datadog_api_client.v1.model.monitor_options_aggregation import MonitorOptionsAggregation
from datadog_api_client.v1.model.monitor_options_custom_schedule import MonitorOptionsCustomSchedule
from datadog_api_client.v1.model.monitor_options_custom_schedule_recurrence import (
MonitorOptionsCustomScheduleRecurrence,
)
from datadog_api_client.v1.model.monitor_options_notification_presets import MonitorOptionsNotificationPresets
from datadog_api_client.v1.model.monitor_options_scheduling_options import MonitorOptionsSchedulingOptions
from datadog_api_client.v1.model.monitor_options_scheduling_options_evaluation_window import (
Expand Down Expand Up @@ -1218,6 +1222,8 @@
"MonitorGroupSearchResult",
"MonitorOptions",
"MonitorOptionsAggregation",
"MonitorOptionsCustomSchedule",
"MonitorOptionsCustomScheduleRecurrence",
"MonitorOptionsNotificationPresets",
"MonitorOptionsSchedulingOptions",
"MonitorOptionsSchedulingOptionsEvaluationWindow",
Expand Down
13 changes: 12 additions & 1 deletion tests/v1/features/monitors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ Feature: Monitors
And the response "name" is equal to "{{ unique }}"
And the response "query" is equal to "avg(current_1mo):avg:system.load.5{*} > 0.5"

@team:DataDog/monitor-app
Scenario: Create a metric monitor with a custom schedule returns "OK" response
Given new "CreateMonitor" request
And body with value {"name": "{{ unique }}", "type": "metric alert", "query": "avg(current_1mo):avg:system.load.5{*} > 0.5", "message": "some message Notify: @hipchat-channel", "options":{"thresholds":{"critical":0.5}, "scheduling_options":{"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2024-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1}}}}
When the request is sent
Then the response status is 200 OK
And the response "name" is equal to "{{ unique }}"
And the response "options.scheduling_options.custom_schedule.recurrences[0].rrule" is equal to "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"
And the response "options.scheduling_options.custom_schedule.recurrences[0].start" is equal to "2024-08-31T16:30:00"
And the response "options.scheduling_options.custom_schedule.recurrences[0].timezone" is equal to "Europe/Paris"

@team:DataDog/monitor-app
Scenario: Create a monitor returns "Bad Request" response
Given new "CreateMonitor" request
Expand Down Expand Up @@ -146,7 +157,7 @@ Feature: Monitors
Scenario: Edit a monitor returns "Bad Request" response
Given new "UpdateMonitor" request
And request contains "monitor_id" parameter from "REPLACE.ME"
And body with value {"options": {"escalation_message": "none", "evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "notify_no_data": false, "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "restricted_roles": [], "tags": [], "type": "query alert"}
And body with value {"options": {"escalation_message": "none", "evaluation_delay": null, "include_tags": true, "min_failure_duration": 0, "min_location_failed": 1, "new_group_delay": null, "new_host_delay": 300, "no_data_timeframe": null, "notification_preset_name": "show_all", "notify_audit": false, "notify_by": [], "notify_no_data": false, "on_missing_data": "default", "renotify_interval": null, "renotify_occurrences": null, "renotify_statuses": ["alert"], "scheduling_options": {"custom_schedule": {"recurrences": [{"rrule": "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "start": "2023-08-31T16:30:00", "timezone": "Europe/Paris"}]}, "evaluation_window": {"day_starts": "04:00", "hour_starts": 0, "month_starts": 1}}, "synthetics_check_id": null, "threshold_windows": {"recovery_window": null, "trigger_window": null}, "thresholds": {"critical_recovery": null, "ok": null, "unknown": null, "warning": null, "warning_recovery": null}, "timeout_h": null, "variables": [{"compute": {"aggregation": "avg", "interval": 60000, "metric": "@duration"}, "data_source": "rum", "group_by": [{"facet": "status", "limit": 10, "sort": {"aggregation": "avg", "order": "desc"}}], "indexes": ["days-3", "days-7"], "name": "query_errors", "search": {"query": "service:query"}}]}, "restricted_roles": [], "tags": [], "type": "query alert"}
When the request is sent
Then the response status is 400 Bad Request

Expand Down

0 comments on commit cfa4f34

Please sign in to comment.