|
| 1 | +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +# This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +# Copyright 2019-Present Datadog, Inc. |
| 4 | +from __future__ import annotations |
| 5 | + |
| 6 | +from typing import Any, Dict |
| 7 | + |
| 8 | +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint |
| 9 | +from datadog_api_client.configuration import Configuration |
| 10 | +from datadog_api_client.model_utils import ( |
| 11 | + UUID, |
| 12 | +) |
| 13 | +from datadog_api_client.v2.model.report_schedule_response import ReportScheduleResponse |
| 14 | +from datadog_api_client.v2.model.report_schedule_create_request import ReportScheduleCreateRequest |
| 15 | +from datadog_api_client.v2.model.report_schedule_patch_request import ReportSchedulePatchRequest |
| 16 | + |
| 17 | + |
| 18 | +class ReportSchedulesApi: |
| 19 | + """ |
| 20 | + Create and manage scheduled reports. A scheduled report renders a dashboard, integration |
| 21 | + dashboard, uniboard, or widget on a recurring cadence and delivers it to a set of |
| 22 | + recipients over email, Slack, or Microsoft Teams. |
| 23 | + """ |
| 24 | + |
| 25 | + def __init__(self, api_client=None): |
| 26 | + if api_client is None: |
| 27 | + api_client = ApiClient(Configuration()) |
| 28 | + self.api_client = api_client |
| 29 | + |
| 30 | + self._create_report_schedule_endpoint = _Endpoint( |
| 31 | + settings={ |
| 32 | + "response_type": (ReportScheduleResponse,), |
| 33 | + "auth": ["apiKeyAuth", "appKeyAuth"], |
| 34 | + "endpoint_path": "/api/v2/reporting/schedule", |
| 35 | + "operation_id": "create_report_schedule", |
| 36 | + "http_method": "POST", |
| 37 | + "version": "v2", |
| 38 | + }, |
| 39 | + params_map={ |
| 40 | + "body": { |
| 41 | + "required": True, |
| 42 | + "openapi_types": (ReportScheduleCreateRequest,), |
| 43 | + "location": "body", |
| 44 | + }, |
| 45 | + }, |
| 46 | + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, |
| 47 | + api_client=api_client, |
| 48 | + ) |
| 49 | + |
| 50 | + self._patch_report_schedule_endpoint = _Endpoint( |
| 51 | + settings={ |
| 52 | + "response_type": (ReportScheduleResponse,), |
| 53 | + "auth": ["apiKeyAuth", "appKeyAuth"], |
| 54 | + "endpoint_path": "/api/v2/reporting/schedule/{schedule_uuid}", |
| 55 | + "operation_id": "patch_report_schedule", |
| 56 | + "http_method": "PATCH", |
| 57 | + "version": "v2", |
| 58 | + }, |
| 59 | + params_map={ |
| 60 | + "schedule_uuid": { |
| 61 | + "required": True, |
| 62 | + "openapi_types": (UUID,), |
| 63 | + "attribute": "schedule_uuid", |
| 64 | + "location": "path", |
| 65 | + }, |
| 66 | + "body": { |
| 67 | + "required": True, |
| 68 | + "openapi_types": (ReportSchedulePatchRequest,), |
| 69 | + "location": "body", |
| 70 | + }, |
| 71 | + }, |
| 72 | + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, |
| 73 | + api_client=api_client, |
| 74 | + ) |
| 75 | + |
| 76 | + def create_report_schedule( |
| 77 | + self, |
| 78 | + body: ReportScheduleCreateRequest, |
| 79 | + ) -> ReportScheduleResponse: |
| 80 | + """Create a report schedule. |
| 81 | +
|
| 82 | + Create a new scheduled report. A schedule renders a dashboard, integration dashboard, |
| 83 | + uniboard, or widget on a recurring cadence and delivers |
| 84 | + it to the configured recipients over email, Slack, or Microsoft Teams. |
| 85 | + Requires a reporting write permission appropriate to the targeted resource type, such as |
| 86 | + ``generate_dashboard_reports`` for dashboards or ``generate_log_reports`` for log widgets. |
| 87 | +
|
| 88 | + :type body: ReportScheduleCreateRequest |
| 89 | + :rtype: ReportScheduleResponse |
| 90 | + """ |
| 91 | + kwargs: Dict[str, Any] = {} |
| 92 | + kwargs["body"] = body |
| 93 | + |
| 94 | + return self._create_report_schedule_endpoint.call_with_http_info(**kwargs) |
| 95 | + |
| 96 | + def patch_report_schedule( |
| 97 | + self, |
| 98 | + schedule_uuid: UUID, |
| 99 | + body: ReportSchedulePatchRequest, |
| 100 | + ) -> ReportScheduleResponse: |
| 101 | + """Update a report schedule. |
| 102 | +
|
| 103 | + Update an existing scheduled report by its identifier. The editable attributes |
| 104 | + are replaced with the supplied values; the targeted resource ( ``resource_id`` and |
| 105 | + ``resource_type`` ) cannot be changed after creation. PDF schedules support ``delivery_format`` ; |
| 106 | + CSV schedules support ``file_row_limit`` and ``inline_row_limit``. |
| 107 | + Requires a reporting write permission appropriate to the targeted resource type and schedule ownership, |
| 108 | + such as ``generate_dashboard_reports`` for dashboard schedules or ``generate_log_reports`` / ``manage_log_reports`` |
| 109 | + for log widget schedules. |
| 110 | +
|
| 111 | + :param schedule_uuid: The unique identifier of the report schedule to update. |
| 112 | + :type schedule_uuid: UUID |
| 113 | + :type body: ReportSchedulePatchRequest |
| 114 | + :rtype: ReportScheduleResponse |
| 115 | + """ |
| 116 | + kwargs: Dict[str, Any] = {} |
| 117 | + kwargs["schedule_uuid"] = schedule_uuid |
| 118 | + |
| 119 | + kwargs["body"] = body |
| 120 | + |
| 121 | + return self._patch_report_schedule_endpoint.call_with_http_info(**kwargs) |
0 commit comments