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
15 changes: 13 additions & 2 deletions datadog_sync/model/downtime_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from dateutil.parser import parse

from datadog_sync.utils.base_resource import BaseResource, ResourceConfig
from datadog_sync.utils.custom_client import PaginationConfig
from datadog_sync.utils.resource_utils import DowntimeSchedulesDateOperator, SkipResource

if TYPE_CHECKING:
Expand All @@ -34,12 +35,22 @@ class DowntimeSchedules(BaseResource):
"custom_operators": [DowntimeSchedulesDateOperator()],
},
)
pagination_config = PaginationConfig(
page_size=100,
page_size_param="page[limit]",
page_number_param="page[offset]",
page_number_func=lambda idx, page_size, page_number: page_number + page_size,
remaining_func=lambda *args: 1,
)
# Additional DowntimeSchedules specific attributes

async def get_resources(self, client: CustomClient) -> List[Dict]:
resp = await client.get(self.resource_config.base_path)
resp = await client.paginated_request(client.get)(
self.resource_config.base_path,
pagination_config=self.pagination_config,
)

return resp.get("data", [])
return resp

async def import_resource(self, _id: Optional[str] = None, resource: Optional[Dict] = None) -> Tuple[str, Dict]:
if _id:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://api.datadoghq.eu/api/v2/downtime
uri: https://api.datadoghq.eu/api/v2/downtime?page%5Blimit%5D=100&page%5Boffset%5D=0
response:
body:
string: '{"data": [{"type": "downtime", "attributes": {"mute_first_recovery_notification":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://api.datadoghq.eu/api/v2/downtime
uri: https://api.datadoghq.eu/api/v2/downtime?page%5Blimit%5D=100&page%5Boffset%5D=0
response:
body:
string: '{"data": [{"type": "downtime", "attributes": {"message": "", "mute_first_recovery_notification":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://api.datadoghq.eu/api/v2/downtime
uri: https://api.datadoghq.eu/api/v2/downtime?page%5Blimit%5D=100&page%5Boffset%5D=0
response:
body:
string: '{"data": [{"type": "downtime", "attributes": {"monitor_identifier":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2309,7 +2309,7 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://api.datadoghq.eu/api/v2/downtime
uri: https://api.datadoghq.eu/api/v2/downtime?page%5Blimit%5D=100&page%5Boffset%5D=0
response:
body:
string: '{"data": [{"type": "downtime", "attributes": {"schedule": {"end": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-11-05T09:46:55.245920-05:00
2025-01-23T14:54:54.319396-05:00
Original file line number Diff line number Diff line change
Expand Up @@ -37,40 +37,4 @@ interactions:
status:
code: 200
message: OK
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.diffs.start", "type": 0, "points": [{"timestamp": 1730818015,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://api.datadoghq.eu/api/v2/series
response:
body:
string: '{"errors": []}'
headers:
Content-Type:
- application/json
status:
code: 202
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.diffs.start", "type": 0, "points": [{"timestamp": 1730818015,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://us5.datadoghq.com/api/v2/series
response:
body:
string: '{"errors": []}'
headers:
Content-Type:
- application/json
status:
code: 202
message: Accepted
version: 1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-11-05T09:46:55.966114-05:00
2025-01-23T14:54:54.783708-05:00
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ interactions:
message: OK
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1730818015,
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1737662094,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://api.datadoghq.eu/api/v2/series
uri: https://us5.datadoghq.com/api/v2/series
response:
body:
string: '{"errors": []}'
Expand All @@ -57,13 +57,13 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1730818015,
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1737662094,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://us5.datadoghq.com/api/v2/series
uri: https://api.datadoghq.eu/api/v2/series
response:
body:
string: '{"errors": []}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-11-05T09:46:50.076675-05:00
2025-01-23T14:54:49.463985-05:00
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interactions:
message: OK
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.import.start", "type": 0, "points": [{"timestamp": 1730818010,
"datadog.org-sync.import.start", "type": 0, "points": [{"timestamp": 1737662089,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
Expand All @@ -57,7 +57,7 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.import.start", "type": 0, "points": [{"timestamp": 1730818010,
"datadog.org-sync.import.start", "type": 0, "points": [{"timestamp": 1737662089,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
Expand All @@ -79,24 +79,24 @@ interactions:
Content-Type:
- application/json
method: GET
uri: https://api.datadoghq.eu/api/v2/downtime
uri: https://api.datadoghq.eu/api/v2/downtime?page%5Blimit%5D=100&page%5Boffset%5D=0
response:
body:
string: '{"data": [{"type": "downtime", "attributes": {"mute_first_recovery_notification":
false, "notify_end_types": ["canceled", "expired"], "status": "active", "monitor_identifier":
{"monitor_id": 20125252}, "schedule": {"start": "2024-10-28T19:03:20.783000+00:00",
"end": null}, "canceled": null, "created": "2024-10-28T19:03:37.269181+00:00",
"notify_end_states": ["no data", "warn", "alert"], "modified": "2024-10-28T19:03:37.269181+00:00",
"message": "", "display_timezone": "America/New_York", "scope": "*"}, "id":
"84867542-29d9-4c77-b9f8-117e19347a27"}, {"type": "downtime", "attributes":
{"mute_first_recovery_notification": false, "notify_end_types": ["canceled",
"expired"], "status": "scheduled", "monitor_identifier": {"monitor_id": 20046756},
"schedule": {"current_downtime": {"start": "2024-11-05T19:46:00+00:00", "end":
"2024-11-05T19:56:00+00:00"}, "recurrences": [{"rrule": "FREQ=DAILY;INTERVAL=1",
"start": "2024-10-28T14:46:00", "duration": "10m"}], "timezone": "America/New_York"},
"canceled": null, "created": "2024-10-28T18:47:00.157356+00:00", "notify_end_states":
["no data", "warn", "alert"], "modified": "2024-11-04T19:56:04.778566+00:00",
"message": "test", "display_timezone": "America/New_York", "scope": "agent_type:native"},
string: '{"data": [{"type": "downtime", "attributes": {"scope": "*", "modified":
"2024-10-28T19:03:37.269181+00:00", "schedule": {"end": null, "start": "2024-10-28T19:03:20.783000+00:00"},
"notify_end_states": ["no data", "alert", "warn"], "monitor_identifier": {"monitor_id":
20125252}, "notify_end_types": ["expired", "canceled"], "message": "", "created":
"2024-10-28T19:03:37.269181+00:00", "canceled": null, "display_timezone":
"America/New_York", "mute_first_recovery_notification": false, "status": "active"},
"id": "84867542-29d9-4c77-b9f8-117e19347a27"}, {"type": "downtime", "attributes":
{"scope": "agent_type:native", "modified": "2025-01-23T19:46:06.990749+00:00",
"schedule": {"current_downtime": {"end": "2025-01-23T19:56:00+00:00", "start":
"2025-01-23T19:46:00+00:00"}, "timezone": "America/New_York", "recurrences":
[{"rrule": "FREQ=DAILY;INTERVAL=1", "duration": "10m", "start": "2024-10-28T14:46:00"}]},
"notify_end_states": ["no data", "alert", "warn"], "monitor_identifier": {"monitor_id":
20046756}, "notify_end_types": ["expired", "canceled"], "message": "test",
"created": "2024-10-28T18:47:00.157356+00:00", "canceled": null, "display_timezone":
"America/New_York", "mute_first_recovery_notification": false, "status": "active"},
"id": "e7c79b6e-4c04-4540-ad20-0d1f71d79061"}], "meta": {"page": {"total_filtered_count":
2}}}'
headers:
Expand All @@ -107,7 +107,7 @@ interactions:
message: OK
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818010, "value":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662089, "value":
1}], "tags": ["id:84867542-29d9-4c77-b9f8-117e19347a27", "action_type:import",
"status:success", "resource_type:downtime_schedules", "client_type:destination"]}]}'
headers:
Expand All @@ -126,14 +126,14 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818010, "value":
1}], "tags": ["id:e7c79b6e-4c04-4540-ad20-0d1f71d79061", "action_type:import",
"status:success", "resource_type:downtime_schedules", "client_type:destination"]}]}'
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662089, "value":
1}], "tags": ["id:84867542-29d9-4c77-b9f8-117e19347a27", "action_type:import",
"status:success", "resource_type:downtime_schedules", "client_type:source"]}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://us5.datadoghq.com/api/v2/series
uri: https://api.datadoghq.eu/api/v2/series
response:
body:
string: '{"errors": []}'
Expand All @@ -145,14 +145,14 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818010, "value":
1}], "tags": ["id:84867542-29d9-4c77-b9f8-117e19347a27", "action_type:import",
"status:success", "resource_type:downtime_schedules", "client_type:source"]}]}'
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662089, "value":
1}], "tags": ["id:e7c79b6e-4c04-4540-ad20-0d1f71d79061", "action_type:import",
"status:success", "resource_type:downtime_schedules", "client_type:destination"]}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://api.datadoghq.eu/api/v2/series
uri: https://us5.datadoghq.com/api/v2/series
response:
body:
string: '{"errors": []}'
Expand All @@ -164,7 +164,7 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818010, "value":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662089, "value":
1}], "tags": ["id:e7c79b6e-4c04-4540-ad20-0d1f71d79061", "action_type:import",
"status:success", "resource_type:downtime_schedules", "client_type:source"]}]}'
headers:
Expand Down Expand Up @@ -219,40 +219,4 @@ interactions:
status:
code: 200
message: OK
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.diffs.start", "type": 0, "points": [{"timestamp": 1730818010,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://api.datadoghq.eu/api/v2/series
response:
body:
string: '{"errors": []}'
headers:
Content-Type:
- application/json
status:
code: 202
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.diffs.start", "type": 0, "points": [{"timestamp": 1730818010,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://us5.datadoghq.com/api/v2/series
response:
body:
string: '{"errors": []}'
headers:
Content-Type:
- application/json
status:
code: 202
message: Accepted
version: 1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-11-05T09:46:51.876394-05:00
2025-01-23T14:54:51.350875-05:00
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ interactions:
message: OK
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1730818011,
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1737662091,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://api.datadoghq.eu/api/v2/series
uri: https://us5.datadoghq.com/api/v2/series
response:
body:
string: '{"errors": []}'
Expand All @@ -57,13 +57,13 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1730818011,
"datadog.org-sync.sync.start", "type": 0, "points": [{"timestamp": 1737662091,
"value": 1}], "tags": null}]}'
headers:
Content-Type:
- application/json
method: POST
uri: https://us5.datadoghq.com/api/v2/series
uri: https://api.datadoghq.eu/api/v2/series
response:
body:
string: '{"errors": []}'
Expand All @@ -75,7 +75,7 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818011, "value":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662091, "value":
1}], "tags": ["reason:connection_error", "id:84867542-29d9-4c77-b9f8-117e19347a27",
"action_type:sync", "status:skipped", "resource_type:downtime_schedules", "client_type:destination"]}]}'
headers:
Expand All @@ -94,7 +94,7 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818011, "value":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662091, "value":
1}], "tags": ["reason:connection_error", "id:e7c79b6e-4c04-4540-ad20-0d1f71d79061",
"action_type:sync", "status:skipped", "resource_type:downtime_schedules", "client_type:destination"]}]}'
headers:
Expand All @@ -113,7 +113,7 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818011, "value":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662091, "value":
1}], "tags": ["reason:connection_error", "id:84867542-29d9-4c77-b9f8-117e19347a27",
"action_type:sync", "status:skipped", "resource_type:downtime_schedules", "client_type:source"]}]}'
headers:
Expand All @@ -132,7 +132,7 @@ interactions:
message: Accepted
- request:
body: '{"series": [{"metadata": {"origin": {"origin_product": 24}}, "metric":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1730818011, "value":
"datadog.org-sync.action", "type": 0, "points": [{"timestamp": 1737662091, "value":
1}], "tags": ["reason:connection_error", "id:e7c79b6e-4c04-4540-ad20-0d1f71d79061",
"action_type:sync", "status:skipped", "resource_type:downtime_schedules", "client_type:source"]}]}'
headers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-11-05T09:46:52.891137-05:00
2025-01-23T14:54:52.398624-05:00
Loading