diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 49e923cae4..a67c3bf1fd 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -30514,6 +30514,146 @@ components: required: - data type: object + DatasetReportScheduleListResponse: + description: Response containing a list of report schedules for a published dataset. + properties: + data: + description: A list of report schedules for the dataset. + items: + $ref: "#/components/schemas/DatasetReportScheduleResponseData" + type: array + included: + description: Related resources included with the report schedules, such as authors. + items: + $ref: "#/components/schemas/ReportScheduleIncludedResource" + type: array + required: + - data + type: object + DatasetReportScheduleResourceType: + description: The type of resource targeted by a dataset report schedule. + enum: + - widget_dataset_list + example: widget_dataset_list + type: string + x-enum-varnames: + - WIDGET_DATASET_LIST + DatasetReportScheduleResponseAttributes: + description: The configuration and derived state of a report schedule for a published dataset. + properties: + cell_id: + description: The identifier of the notebook cell that published the dataset, or `null` if not set. + example: "sevhjcis" + nullable: true + type: string + dataset_id: + description: The identifier of the dataset, or `null` if not set. + example: "MW5vdGVib29rX2NlbGw6ZDI0ZTM2MWMtZDFlNC00NDYwLWIyOWUtNTg3YTczMzA3MDFm" + nullable: true + type: string + description: + description: The description of the report. + example: "This is a scheduled notebook dataset report." + type: string + file_row_limit: + description: The maximum number of rows included in the attached CSV file, or `null` if not set. + example: 5000 + format: int64 + nullable: true + type: integer + inline_row_limit: + description: The maximum number of rows included inline in the email body, or `null` if not set. + example: 10 + format: int64 + nullable: true + type: integer + next_recurrence: + description: |- + The Unix timestamp, in milliseconds, of the next scheduled delivery, or + `null` if none is scheduled. + example: 1725859200000 + format: int64 + nullable: true + type: integer + notebook_id: + description: The identifier of the notebook containing the dataset cell, or `null` if not set. + example: 1 + format: int64 + nullable: true + type: integer + recipients: + description: |- + The recipients of the report (email addresses, Slack channel references, or + Microsoft Teams channel references). + example: + - "test@datadoghq.com" + items: + description: |- + A single recipient (email address, Slack channel reference, or Microsoft + Teams channel reference). + type: string + type: array + resource_id: + description: The identifier of the widget containing the dataset. + example: "aaaabbbb-1111-2222-3333-444455556666" + type: string + resource_type: + $ref: "#/components/schemas/DatasetReportScheduleResourceType" + rrule: + description: The recurrence rule for the schedule, expressed as an iCalendar `RRULE` string. + example: "DTSTART;TZID=America/New_York:20240912T090000\nRRULE:FREQ=DAILY;BYHOUR=9;BYMINUTE=0" + type: string + status: + $ref: "#/components/schemas/ReportScheduleStatus" + timeframe: + description: The relative timeframe of data included in the report. + example: "calendar_day" + type: string + timezone: + description: The IANA time zone identifier the recurrence rule is evaluated in. + example: "America/New_York" + type: string + title: + description: The title of the report. + example: "My Cool Dataset Report" + type: string + required: + - status + - resource_id + - resource_type + - recipients + - rrule + - timezone + - title + - description + - timeframe + - file_row_limit + - inline_row_limit + - next_recurrence + - notebook_id + - cell_id + - dataset_id + type: object + DatasetReportScheduleResponseData: + description: The JSON:API data object representing a dataset report schedule. + properties: + attributes: + $ref: "#/components/schemas/DatasetReportScheduleResponseAttributes" + id: + description: The unique identifier of the dataset report schedule. + example: "e1234567-1234-1234-1234-123456789012" + format: uuid + type: string + relationships: + $ref: "#/components/schemas/ReportScheduleResponseRelationships" + type: + $ref: "#/components/schemas/ReportScheduleType" + required: + - id + - type + - attributes + - relationships + type: object DatasetRequest: description: |- **Datasets Object Constraints** @@ -70492,6 +70632,8 @@ components: $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit" maxItems: 100 type: array + tracking_mode: + $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode" type: $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorType" value_limit: @@ -70506,6 +70648,7 @@ components: - type - include - limit_exceeded_action + - tracking_mode - value_limit - enabled type: object @@ -70520,6 +70663,16 @@ components: x-enum-varnames: - DROP_TAG - DROP_EVENT + ObservabilityPipelineTagCardinalityLimitProcessorOverrideType: + description: How the override is applied. `limit_override` enforces a custom limit; `excluded` omits the metric or tag from cardinality tracking. + enum: + - limit_override + - excluded + example: limit_override + type: string + x-enum-varnames: + - LIMIT_OVERRIDE + - EXCLUDED ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit: description: A cardinality override applied to a specific metric. properties: @@ -70529,16 +70682,16 @@ components: description: The name of the metric this override applies to. example: "system.cpu.user" type: string - mode: - $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode" + override_type: + $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorOverrideType" per_tag_limits: - description: A list of per-tag cardinality overrides that apply within this metric. Must be omitted when `mode` is `excluded`. + description: A list of per-tag cardinality overrides that apply within this metric. Must be omitted when `override_type` is `excluded`. items: $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit" maxItems: 50 type: array value_limit: - description: The maximum number of distinct tag value combinations allowed for this metric. Required when `mode` is `tracked`. Must be omitted when `mode` is `excluded`. + description: The maximum number of distinct tag value combinations allowed for this metric. Required when `override_type` is `limit_override`. Must be omitted when `override_type` is `excluded`. example: 10000 format: int64 maximum: 1000000 @@ -70546,29 +70699,19 @@ components: type: integer required: - metric_name - - mode + - override_type type: object - ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode: - description: How the per-metric override is applied. `tracked` enforces a custom limit; `excluded` skips the metric entirely. - enum: - - tracked - - excluded - example: tracked - type: string - x-enum-varnames: - - TRACKED - - EXCLUDED ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit: description: A cardinality override for a specific tag key within a per-metric limit. properties: - mode: - $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode" + override_type: + $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorOverrideType" tag_key: description: The tag key this override applies to. example: "host" type: string value_limit: - description: The maximum number of distinct values allowed for this tag. Required when `mode` is `limit_override`. Must be omitted when `mode` is `excluded`. + description: The maximum number of distinct values allowed for this tag. Required when `override_type` is `limit_override`. Must be omitted when `override_type` is `excluded`. example: 5000 format: int64 maximum: 1000000 @@ -70576,18 +70719,26 @@ components: type: integer required: - tag_key + - override_type + type: object + ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode: + description: Controls whether the processor uses exact or probabilistic tag tracking. + properties: + mode: + $ref: "#/components/schemas/ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode" + required: - mode type: object - ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode: - description: How the per-tag override is applied. `limit_override` enforces a custom limit on the tag; `excluded` skips the tag from cardinality tracking. + ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode: + description: The cardinality tracking algorithm to use. enum: - - limit_override - - excluded - example: limit_override + - exact_fingerprint + - probabilistic + example: exact_fingerprint type: string x-enum-varnames: - - LIMIT_OVERRIDE - - EXCLUDED + - EXACT_FINGERPRINT + - PROBABILISTIC ObservabilityPipelineTagCardinalityLimitProcessorType: default: tag_cardinality_limit description: The processor type. The value must be `tag_cardinality_limit`. @@ -75913,6 +76064,149 @@ components: required: - type type: object + PrintReportRequest: + description: Request body for initiating a print-only report. + properties: + data: + $ref: "#/components/schemas/PrintReportRequestData" + required: + - data + type: object + PrintReportRequestAttributes: + description: |- + The configuration for a print-only report. Specify exactly one of `timeframe` (for a + relative time window) or both `from_ts` and `to_ts` (for an absolute time range). + properties: + from_ts: + description: |- + The start of an absolute time range, as a Unix timestamp in milliseconds. + Required when `timeframe` is omitted. + example: 1780318800000 + format: int64 + type: integer + resource_id: + description: The identifier of the dashboard or integration dashboard to render. + example: "abc-def-ghi" + type: string + resource_type: + $ref: "#/components/schemas/ReportScheduleResourceType" + template_variables: + description: The dashboard template variables applied when rendering the report. + items: + $ref: "#/components/schemas/ReportScheduleTemplateVariable" + type: array + timeframe: + description: |- + A relative time window (for example `1w` or `calendar_month`). Mutually + exclusive with `from_ts` and `to_ts`. + example: "1w" + type: string + timezone: + description: The IANA time zone identifier used to evaluate the time window. + example: "America/New_York" + type: string + to_ts: + description: |- + The end of an absolute time range, as a Unix timestamp in milliseconds. + Required when `timeframe` is omitted. + example: 1780923600000 + format: int64 + type: integer + required: + - resource_id + - resource_type + - timezone + - template_variables + type: object + PrintReportRequestData: + description: The JSON:API data object for a print report request. + properties: + attributes: + $ref: "#/components/schemas/PrintReportRequestAttributes" + type: + $ref: "#/components/schemas/PrintReportType" + required: + - type + - attributes + type: object + PrintReportResponse: + description: Response containing the initiated print-only report. + properties: + data: + $ref: "#/components/schemas/PrintReportResponseData" + required: + - data + type: object + PrintReportResponseAttributes: + description: The configuration and download URL for the initiated print-only report. + properties: + download_url: + description: The URL from which the rendered PDF report can be downloaded. + example: "https://app.datadoghq.com/..." + type: string + from_ts: + description: The start of the rendered time range, as a Unix timestamp in milliseconds. + example: 1780318800000 + format: int64 + type: integer + resource_id: + description: The identifier of the dashboard or integration dashboard. + example: "abc-def-ghi" + type: string + resource_type: + $ref: "#/components/schemas/ReportScheduleResourceType" + template_variables: + description: The dashboard template variables applied when rendering the report. + items: + $ref: "#/components/schemas/ReportScheduleTemplateVariable" + type: array + timeframe: + description: The relative time window used, if one was specified in the request. + example: "1w" + type: string + timezone: + description: The IANA time zone identifier used when rendering the report. + example: "America/New_York" + type: string + to_ts: + description: The end of the rendered time range, as a Unix timestamp in milliseconds. + example: 1780923600000 + format: int64 + type: integer + required: + - resource_id + - resource_type + - timezone + - template_variables + - from_ts + - to_ts + - download_url + type: object + PrintReportResponseData: + description: The JSON:API data object for a print-only report. + properties: + attributes: + $ref: "#/components/schemas/PrintReportResponseAttributes" + id: + description: The unique identifier of the report. + example: "11111111-2222-3333-4444-555555555555" + format: uuid + type: string + type: + $ref: "#/components/schemas/PrintReportType" + required: + - id + - type + - attributes + type: object + PrintReportType: + description: JSON:API resource type for a print-only report. + enum: + - report + example: report + type: string + x-enum-varnames: + - REPORT ProcessDataSource: default: process description: A data source for process-level infrastructure metrics. @@ -168146,6 +168440,167 @@ paths: summary: Update replay heatmap snapshot tags: - Rum Replay Heatmaps + /api/v2/reporting/dataset/{dataset_id}/schedules: + get: + description: |- + Retrieve all report schedules for a given published dataset. + Returns report schedules belonging to the authenticated user's organization that target the specified dataset. + Requires the `generate_log_reports` or `manage_log_reports` permission. + operationId: ListDatasetReportSchedules + parameters: + - description: The identifier of the published dataset to retrieve report schedules for. + example: "MW5vdGVib29rX2NlbGw6ZDI0ZTM2MWMtZDFlNC00NDYwLWIyOWUtNTg3YTczMzA3MDFm" + in: path + name: dataset_id + required: true + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + cell_id: "sevhjcis" + dataset_id: "MW5vdGVib29rX2NlbGw6ZDI0ZTM2MWMtZDFlNC00NDYwLWIyOWUtNTg3YTczMzA3MDFm" + description: "This is a scheduled notebook dataset report." + file_row_limit: 5000 + inline_row_limit: 10 + next_recurrence: 1725859200000 + notebook_id: 1 + recipients: + - "test@datadoghq.com" + resource_id: "aaaabbbb-1111-2222-3333-444455556666" + resource_type: widget_dataset_list + rrule: "DTSTART;TZID=America/New_York:20240912T090000\nRRULE:FREQ=DAILY;BYHOUR=9;BYMINUTE=0" + status: active + timeframe: "calendar_day" + timezone: "America/New_York" + title: "My Cool Dataset Report" + id: "e1234567-1234-1234-1234-123456789012" + relationships: + author: + data: + id: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" + type: users + type: schedule + included: + - attributes: + email: "user@example.com" + name: "Example User" + id: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" + type: users + schema: + $ref: "#/components/schemas/DatasetReportScheduleListResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List dataset report schedules + tags: + - Report Schedules + /api/v2/reporting/print: + post: + description: |- + Initiate a one-off, print-only report for a dashboard or integration dashboard. + The report is rendered as a PDF and made available for download through the URL returned in the response. + Requires a reporting permission appropriate to the targeted resource type. + operationId: PrintReport + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + resource_id: "abc-def-ghi" + resource_type: dashboard + template_variables: + - name: "env" + values: + - "prod" + timeframe: "1w" + timezone: "America/New_York" + type: report + schema: + $ref: "#/components/schemas/PrintReportRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + download_url: "https://app.datadoghq.com/..." + from_ts: 1780318800000 + resource_id: "abc-def-ghi" + resource_type: dashboard + template_variables: + - name: "env" + values: + - "prod" + timeframe: "1w" + timezone: "America/New_York" + to_ts: 1780923600000 + id: "11111111-2222-3333-4444-555555555555" + type: report + schema: + $ref: "#/components/schemas/PrintReportResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "422": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unprocessable Entity + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Print a report + tags: + - Report Schedules + x-codegen-request-body-name: body /api/v2/reporting/schedule: post: description: |- diff --git a/examples/v2_report-schedules_ListDatasetReportSchedules.rs b/examples/v2_report-schedules_ListDatasetReportSchedules.rs new file mode 100644 index 0000000000..e09d97a3af --- /dev/null +++ b/examples/v2_report-schedules_ListDatasetReportSchedules.rs @@ -0,0 +1,17 @@ +// List dataset report schedules returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_report_schedules::ReportSchedulesAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ReportSchedulesAPI::with_config(configuration); + let resp = api + .list_dataset_report_schedules("dataset_id".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_report-schedules_PrintReport.rs b/examples/v2_report-schedules_PrintReport.rs new file mode 100644 index 0000000000..8954d3ed1e --- /dev/null +++ b/examples/v2_report-schedules_PrintReport.rs @@ -0,0 +1,36 @@ +// Print a report returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_report_schedules::ReportSchedulesAPI; +use datadog_api_client::datadogV2::model::PrintReportRequest; +use datadog_api_client::datadogV2::model::PrintReportRequestAttributes; +use datadog_api_client::datadogV2::model::PrintReportRequestData; +use datadog_api_client::datadogV2::model::PrintReportType; +use datadog_api_client::datadogV2::model::ReportScheduleResourceType; +use datadog_api_client::datadogV2::model::ReportScheduleTemplateVariable; + +#[tokio::main] +async fn main() { + let body = PrintReportRequest::new(PrintReportRequestData::new( + PrintReportRequestAttributes::new( + "abc-def-ghi".to_string(), + ReportScheduleResourceType::DASHBOARD, + vec![ReportScheduleTemplateVariable::new( + "env".to_string(), + vec!["prod".to_string()], + )], + "America/New_York".to_string(), + ) + .from_ts(1780318800000) + .timeframe("1w".to_string()) + .to_ts(1780923600000), + PrintReportType::REPORT, + )); + let configuration = datadog::Configuration::new(); + let api = ReportSchedulesAPI::with_config(configuration); + let resp = api.print_report(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_report_schedules.rs b/src/datadogV2/api/api_report_schedules.rs index fbf6f790d8..fdffaed01d 100644 --- a/src/datadogV2/api/api_report_schedules.rs +++ b/src/datadogV2/api/api_report_schedules.rs @@ -91,6 +91,15 @@ pub enum GetReportSchedulesForResourceError { UnknownValue(serde_json::Value), } +/// ListDatasetReportSchedulesError is a struct for typed errors of method [`ReportSchedulesAPI::list_dataset_report_schedules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListDatasetReportSchedulesError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListReportSchedulesError is a struct for typed errors of method [`ReportSchedulesAPI::list_report_schedules`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -109,6 +118,15 @@ pub enum PatchReportScheduleError { UnknownValue(serde_json::Value), } +/// PrintReportError is a struct for typed errors of method [`ReportSchedulesAPI::print_report`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PrintReportError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ToggleReportScheduleError is a struct for typed errors of method [`ReportSchedulesAPI::toggle_report_schedule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -705,6 +723,122 @@ impl ReportSchedulesAPI { } } + /// Retrieve all report schedules for a given published dataset. + /// Returns report schedules belonging to the authenticated user's organization that target the specified dataset. + /// Requires the `generate_log_reports` or `manage_log_reports` permission. + pub async fn list_dataset_report_schedules( + &self, + dataset_id: String, + ) -> Result< + crate::datadogV2::model::DatasetReportScheduleListResponse, + datadog::Error, + > { + match self + .list_dataset_report_schedules_with_http_info(dataset_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Retrieve all report schedules for a given published dataset. + /// Returns report schedules belonging to the authenticated user's organization that target the specified dataset. + /// Requires the `generate_log_reports` or `manage_log_reports` permission. + pub async fn list_dataset_report_schedules_with_http_info( + &self, + dataset_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_dataset_report_schedules"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reporting/dataset/{dataset_id}/schedules", + local_configuration.get_operation_host(operation_id), + dataset_id = datadog::urlencode(dataset_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// List dashboard and integration dashboard report schedules for the organization. /// The response is paginated and can be filtered by title, author UUID, or recipients. /// Requires the `generate_dashboard_reports` permission. @@ -1020,6 +1154,162 @@ impl ReportSchedulesAPI { } } + /// Initiate a one-off, print-only report for a dashboard or integration dashboard. + /// The report is rendered as a PDF and made available for download through the URL returned in the response. + /// Requires a reporting permission appropriate to the targeted resource type. + pub async fn print_report( + &self, + body: crate::datadogV2::model::PrintReportRequest, + ) -> Result> + { + match self.print_report_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Initiate a one-off, print-only report for a dashboard or integration dashboard. + /// The report is rendered as a PDF and made available for download through the URL returned in the response. + /// Requires a reporting permission appropriate to the targeted resource type. + pub async fn print_report_with_http_info( + &self, + body: crate::datadogV2::model::PrintReportRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.print_report"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/reporting/print", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Activate or pause a report schedule by setting its status to `active` or `inactive`. /// Requires a reporting write permission appropriate to the targeted resource type and schedule ownership. pub async fn toggle_report_schedule( diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 971f8cc86d..9e8c535d63 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -7658,12 +7658,14 @@ pub mod model_observability_pipeline_tag_cardinality_limit_processor_action; pub use self::model_observability_pipeline_tag_cardinality_limit_processor_action::ObservabilityPipelineTagCardinalityLimitProcessorAction; pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit; pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit::ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit; -pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_metric_mode; -pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_metric_mode::ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode; +pub mod model_observability_pipeline_tag_cardinality_limit_processor_override_type; +pub use self::model_observability_pipeline_tag_cardinality_limit_processor_override_type::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType; pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit; pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit::ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit; -pub mod model_observability_pipeline_tag_cardinality_limit_processor_per_tag_mode; -pub use self::model_observability_pipeline_tag_cardinality_limit_processor_per_tag_mode::ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode; +pub mod model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode; +pub use self::model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode::ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode; +pub mod model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode_mode; +pub use self::model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode_mode::ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode; pub mod model_observability_pipeline_tag_cardinality_limit_processor_type; pub use self::model_observability_pipeline_tag_cardinality_limit_processor_type::ObservabilityPipelineTagCardinalityLimitProcessorType; pub mod model_observability_pipeline_config_processor_item; @@ -9368,28 +9370,14 @@ pub mod model_snapshot_update_request_data; pub use self::model_snapshot_update_request_data::SnapshotUpdateRequestData; pub mod model_snapshot_update_request_data_attributes; pub use self::model_snapshot_update_request_data_attributes::SnapshotUpdateRequestDataAttributes; -pub mod model_report_schedule_create_request; -pub use self::model_report_schedule_create_request::ReportScheduleCreateRequest; -pub mod model_report_schedule_create_request_data; -pub use self::model_report_schedule_create_request_data::ReportScheduleCreateRequestData; -pub mod model_report_schedule_create_request_attributes; -pub use self::model_report_schedule_create_request_attributes::ReportScheduleCreateRequestAttributes; -pub mod model_report_schedule_delivery_format; -pub use self::model_report_schedule_delivery_format::ReportScheduleDeliveryFormat; -pub mod model_report_schedule_resource_type; -pub use self::model_report_schedule_resource_type::ReportScheduleResourceType; -pub mod model_report_schedule_template_variable; -pub use self::model_report_schedule_template_variable::ReportScheduleTemplateVariable; -pub mod model_report_schedule_type; -pub use self::model_report_schedule_type::ReportScheduleType; -pub mod model_report_schedule_response; -pub use self::model_report_schedule_response::ReportScheduleResponse; -pub mod model_report_schedule_response_data; -pub use self::model_report_schedule_response_data::ReportScheduleResponseData; -pub mod model_report_schedule_response_attributes; -pub use self::model_report_schedule_response_attributes::ReportScheduleResponseAttributes; -pub mod model_report_schedule_response_attributes_delivery_format; -pub use self::model_report_schedule_response_attributes_delivery_format::ReportScheduleResponseAttributesDeliveryFormat; +pub mod model_dataset_report_schedule_list_response; +pub use self::model_dataset_report_schedule_list_response::DatasetReportScheduleListResponse; +pub mod model_dataset_report_schedule_response_data; +pub use self::model_dataset_report_schedule_response_data::DatasetReportScheduleResponseData; +pub mod model_dataset_report_schedule_response_attributes; +pub use self::model_dataset_report_schedule_response_attributes::DatasetReportScheduleResponseAttributes; +pub mod model_dataset_report_schedule_resource_type; +pub use self::model_dataset_report_schedule_resource_type::DatasetReportScheduleResourceType; pub mod model_report_schedule_status; pub use self::model_report_schedule_status::ReportScheduleStatus; pub mod model_report_schedule_response_relationships; @@ -9400,6 +9388,8 @@ pub mod model_report_schedule_author_relationship_data; pub use self::model_report_schedule_author_relationship_data::ReportScheduleAuthorRelationshipData; pub mod model_report_schedule_author_type; pub use self::model_report_schedule_author_type::ReportScheduleAuthorType; +pub mod model_report_schedule_type; +pub use self::model_report_schedule_type::ReportScheduleType; pub mod model_report_schedule_author; pub use self::model_report_schedule_author::ReportScheduleAuthor; pub mod model_report_schedule_author_attributes; @@ -9408,12 +9398,46 @@ pub mod model_report_schedule_resource; pub use self::model_report_schedule_resource::ReportScheduleResource; pub mod model_report_schedule_resource_attributes; pub use self::model_report_schedule_resource_attributes::ReportScheduleResourceAttributes; +pub mod model_report_schedule_resource_type; +pub use self::model_report_schedule_resource_type::ReportScheduleResourceType; pub mod model_report_schedule_index_template_variable; pub use self::model_report_schedule_index_template_variable::ReportScheduleIndexTemplateVariable; pub mod model_report_schedule_included_resource_type; pub use self::model_report_schedule_included_resource_type::ReportScheduleIncludedResourceType; pub mod model_report_schedule_included_resource; pub use self::model_report_schedule_included_resource::ReportScheduleIncludedResource; +pub mod model_print_report_request; +pub use self::model_print_report_request::PrintReportRequest; +pub mod model_print_report_request_data; +pub use self::model_print_report_request_data::PrintReportRequestData; +pub mod model_print_report_request_attributes; +pub use self::model_print_report_request_attributes::PrintReportRequestAttributes; +pub mod model_report_schedule_template_variable; +pub use self::model_report_schedule_template_variable::ReportScheduleTemplateVariable; +pub mod model_print_report_type; +pub use self::model_print_report_type::PrintReportType; +pub mod model_print_report_response; +pub use self::model_print_report_response::PrintReportResponse; +pub mod model_print_report_response_data; +pub use self::model_print_report_response_data::PrintReportResponseData; +pub mod model_print_report_response_attributes; +pub use self::model_print_report_response_attributes::PrintReportResponseAttributes; +pub mod model_report_schedule_create_request; +pub use self::model_report_schedule_create_request::ReportScheduleCreateRequest; +pub mod model_report_schedule_create_request_data; +pub use self::model_report_schedule_create_request_data::ReportScheduleCreateRequestData; +pub mod model_report_schedule_create_request_attributes; +pub use self::model_report_schedule_create_request_attributes::ReportScheduleCreateRequestAttributes; +pub mod model_report_schedule_delivery_format; +pub use self::model_report_schedule_delivery_format::ReportScheduleDeliveryFormat; +pub mod model_report_schedule_response; +pub use self::model_report_schedule_response::ReportScheduleResponse; +pub mod model_report_schedule_response_data; +pub use self::model_report_schedule_response_data::ReportScheduleResponseData; +pub mod model_report_schedule_response_attributes; +pub use self::model_report_schedule_response_attributes::ReportScheduleResponseAttributes; +pub mod model_report_schedule_response_attributes_delivery_format; +pub use self::model_report_schedule_response_attributes_delivery_format::ReportScheduleResponseAttributesDeliveryFormat; pub mod model_report_schedule_list_response; pub use self::model_report_schedule_list_response::ReportScheduleListResponse; pub mod model_report_schedule_list_response_data; diff --git a/src/datadogV2/model/model_dataset_report_schedule_list_response.rs b/src/datadogV2/model/model_dataset_report_schedule_list_response.rs new file mode 100644 index 0000000000..149fd71716 --- /dev/null +++ b/src/datadogV2/model/model_dataset_report_schedule_list_response.rs @@ -0,0 +1,118 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a list of report schedules for a published dataset. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DatasetReportScheduleListResponse { + /// A list of report schedules for the dataset. + #[serde(rename = "data")] + pub data: Vec, + /// Related resources included with the report schedules, such as authors. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DatasetReportScheduleListResponse { + pub fn new( + data: Vec, + ) -> DatasetReportScheduleListResponse { + DatasetReportScheduleListResponse { + data, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn included( + mut self, + value: Vec, + ) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DatasetReportScheduleListResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DatasetReportScheduleListResponseVisitor; + impl<'a> Visitor<'a> for DatasetReportScheduleListResponseVisitor { + type Value = DatasetReportScheduleListResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + Vec, + > = None; + let mut included: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DatasetReportScheduleListResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DatasetReportScheduleListResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_dataset_report_schedule_resource_type.rs b/src/datadogV2/model/model_dataset_report_schedule_resource_type.rs new file mode 100644 index 0000000000..962e5105c1 --- /dev/null +++ b/src/datadogV2/model/model_dataset_report_schedule_resource_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum DatasetReportScheduleResourceType { + WIDGET_DATASET_LIST, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DatasetReportScheduleResourceType { + fn to_string(&self) -> String { + match self { + Self::WIDGET_DATASET_LIST => String::from("widget_dataset_list"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DatasetReportScheduleResourceType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for DatasetReportScheduleResourceType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "widget_dataset_list" => Self::WIDGET_DATASET_LIST, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_dataset_report_schedule_response_attributes.rs b/src/datadogV2/model/model_dataset_report_schedule_response_attributes.rs new file mode 100644 index 0000000000..ab488cd3bb --- /dev/null +++ b/src/datadogV2/model/model_dataset_report_schedule_response_attributes.rs @@ -0,0 +1,288 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The configuration and derived state of a report schedule for a published dataset. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DatasetReportScheduleResponseAttributes { + /// The identifier of the notebook cell that published the dataset, or `null` if not set. + #[serialize_always] + #[serde(rename = "cell_id")] + pub cell_id: Option, + /// The identifier of the dataset, or `null` if not set. + #[serialize_always] + #[serde(rename = "dataset_id")] + pub dataset_id: Option, + /// The description of the report. + #[serde(rename = "description")] + pub description: String, + /// The maximum number of rows included in the attached CSV file, or `null` if not set. + #[serialize_always] + #[serde(rename = "file_row_limit")] + pub file_row_limit: Option, + /// The maximum number of rows included inline in the email body, or `null` if not set. + #[serialize_always] + #[serde(rename = "inline_row_limit")] + pub inline_row_limit: Option, + /// The Unix timestamp, in milliseconds, of the next scheduled delivery, or + /// `null` if none is scheduled. + #[serialize_always] + #[serde(rename = "next_recurrence")] + pub next_recurrence: Option, + /// The identifier of the notebook containing the dataset cell, or `null` if not set. + #[serialize_always] + #[serde(rename = "notebook_id")] + pub notebook_id: Option, + /// The recipients of the report (email addresses, Slack channel references, or + /// Microsoft Teams channel references). + #[serde(rename = "recipients")] + pub recipients: Vec, + /// The identifier of the widget containing the dataset. + #[serde(rename = "resource_id")] + pub resource_id: String, + /// The type of resource targeted by a dataset report schedule. + #[serde(rename = "resource_type")] + pub resource_type: crate::datadogV2::model::DatasetReportScheduleResourceType, + /// The recurrence rule for the schedule, expressed as an iCalendar `RRULE` string. + #[serde(rename = "rrule")] + pub rrule: String, + /// Whether the schedule is currently delivering reports (`active`) or paused (`inactive`). + #[serde(rename = "status")] + pub status: crate::datadogV2::model::ReportScheduleStatus, + /// The relative timeframe of data included in the report. + #[serde(rename = "timeframe")] + pub timeframe: String, + /// The IANA time zone identifier the recurrence rule is evaluated in. + #[serde(rename = "timezone")] + pub timezone: String, + /// The title of the report. + #[serde(rename = "title")] + pub title: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DatasetReportScheduleResponseAttributes { + pub fn new( + cell_id: Option, + dataset_id: Option, + description: String, + file_row_limit: Option, + inline_row_limit: Option, + next_recurrence: Option, + notebook_id: Option, + recipients: Vec, + resource_id: String, + resource_type: crate::datadogV2::model::DatasetReportScheduleResourceType, + rrule: String, + status: crate::datadogV2::model::ReportScheduleStatus, + timeframe: String, + timezone: String, + title: String, + ) -> DatasetReportScheduleResponseAttributes { + DatasetReportScheduleResponseAttributes { + cell_id, + dataset_id, + description, + file_row_limit, + inline_row_limit, + next_recurrence, + notebook_id, + recipients, + resource_id, + resource_type, + rrule, + status, + timeframe, + timezone, + title, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DatasetReportScheduleResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DatasetReportScheduleResponseAttributesVisitor; + impl<'a> Visitor<'a> for DatasetReportScheduleResponseAttributesVisitor { + type Value = DatasetReportScheduleResponseAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut cell_id: Option> = None; + let mut dataset_id: Option> = None; + let mut description: Option = None; + let mut file_row_limit: Option> = None; + let mut inline_row_limit: Option> = None; + let mut next_recurrence: Option> = None; + let mut notebook_id: Option> = None; + let mut recipients: Option> = None; + let mut resource_id: Option = None; + let mut resource_type: Option< + crate::datadogV2::model::DatasetReportScheduleResourceType, + > = None; + let mut rrule: Option = None; + let mut status: Option = None; + let mut timeframe: Option = None; + let mut timezone: Option = None; + let mut title: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "cell_id" => { + cell_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dataset_id" => { + dataset_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "file_row_limit" => { + file_row_limit = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "inline_row_limit" => { + inline_row_limit = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "next_recurrence" => { + next_recurrence = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "notebook_id" => { + notebook_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "recipients" => { + recipients = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_id" => { + resource_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_type" => { + resource_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _resource_type) = resource_type { + match _resource_type { + crate::datadogV2::model::DatasetReportScheduleResourceType::UnparsedObject(_resource_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "rrule" => { + rrule = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::ReportScheduleStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + "timeframe" => { + timeframe = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "timezone" => { + timezone = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "title" => { + title = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let cell_id = cell_id.ok_or_else(|| M::Error::missing_field("cell_id"))?; + let dataset_id = dataset_id.ok_or_else(|| M::Error::missing_field("dataset_id"))?; + let description = + description.ok_or_else(|| M::Error::missing_field("description"))?; + let file_row_limit = + file_row_limit.ok_or_else(|| M::Error::missing_field("file_row_limit"))?; + let inline_row_limit = + inline_row_limit.ok_or_else(|| M::Error::missing_field("inline_row_limit"))?; + let next_recurrence = + next_recurrence.ok_or_else(|| M::Error::missing_field("next_recurrence"))?; + let notebook_id = + notebook_id.ok_or_else(|| M::Error::missing_field("notebook_id"))?; + let recipients = recipients.ok_or_else(|| M::Error::missing_field("recipients"))?; + let resource_id = + resource_id.ok_or_else(|| M::Error::missing_field("resource_id"))?; + let resource_type = + resource_type.ok_or_else(|| M::Error::missing_field("resource_type"))?; + let rrule = rrule.ok_or_else(|| M::Error::missing_field("rrule"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + let timeframe = timeframe.ok_or_else(|| M::Error::missing_field("timeframe"))?; + let timezone = timezone.ok_or_else(|| M::Error::missing_field("timezone"))?; + let title = title.ok_or_else(|| M::Error::missing_field("title"))?; + + let content = DatasetReportScheduleResponseAttributes { + cell_id, + dataset_id, + description, + file_row_limit, + inline_row_limit, + next_recurrence, + notebook_id, + recipients, + resource_id, + resource_type, + rrule, + status, + timeframe, + timezone, + title, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DatasetReportScheduleResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_dataset_report_schedule_response_data.rs b/src/datadogV2/model/model_dataset_report_schedule_response_data.rs new file mode 100644 index 0000000000..7ed9dbf97d --- /dev/null +++ b/src/datadogV2/model/model_dataset_report_schedule_response_data.rs @@ -0,0 +1,143 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The JSON:API data object representing a dataset report schedule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DatasetReportScheduleResponseData { + /// The configuration and derived state of a report schedule for a published dataset. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::DatasetReportScheduleResponseAttributes, + /// The unique identifier of the dataset report schedule. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Relationships for the report schedule. + #[serde(rename = "relationships")] + pub relationships: crate::datadogV2::model::ReportScheduleResponseRelationships, + /// JSON:API resource type for report schedules. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ReportScheduleType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DatasetReportScheduleResponseData { + pub fn new( + attributes: crate::datadogV2::model::DatasetReportScheduleResponseAttributes, + id: uuid::Uuid, + relationships: crate::datadogV2::model::ReportScheduleResponseRelationships, + type_: crate::datadogV2::model::ReportScheduleType, + ) -> DatasetReportScheduleResponseData { + DatasetReportScheduleResponseData { + attributes, + id, + relationships, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DatasetReportScheduleResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DatasetReportScheduleResponseDataVisitor; + impl<'a> Visitor<'a> for DatasetReportScheduleResponseDataVisitor { + type Value = DatasetReportScheduleResponseData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::DatasetReportScheduleResponseAttributes, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::ReportScheduleResponseRelationships, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ReportScheduleType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let relationships = + relationships.ok_or_else(|| M::Error::missing_field("relationships"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DatasetReportScheduleResponseData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DatasetReportScheduleResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor.rs b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor.rs index 233b7b31a7..d2aa9a4f71 100644 --- a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor.rs +++ b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor.rs @@ -31,6 +31,9 @@ pub struct ObservabilityPipelineTagCardinalityLimitProcessor { /// A list of per-metric cardinality overrides that take precedence over the default `value_limit`. #[serde(rename = "per_metric_limits")] pub per_metric_limits: Option>, + /// Controls whether the processor uses exact or probabilistic tag tracking. + #[serde(rename = "tracking_mode")] + pub tracking_mode: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode, /// The processor type. The value must be `tag_cardinality_limit`. #[serde(rename = "type")] pub type_: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorType, @@ -50,6 +53,7 @@ impl ObservabilityPipelineTagCardinalityLimitProcessor { id: String, include: String, limit_exceeded_action: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorAction, + tracking_mode: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode, type_: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorType, value_limit: i64, ) -> ObservabilityPipelineTagCardinalityLimitProcessor { @@ -60,6 +64,7 @@ impl ObservabilityPipelineTagCardinalityLimitProcessor { include, limit_exceeded_action, per_metric_limits: None, + tracking_mode, type_, value_limit, additional_properties: std::collections::BTreeMap::new(), @@ -112,6 +117,7 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor let mut include: Option = None; let mut limit_exceeded_action: Option = None; let mut per_metric_limits: Option> = None; + let mut tracking_mode: Option = None; let mut type_: Option< crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorType, > = None; @@ -159,6 +165,10 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor per_metric_limits = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "tracking_mode" => { + tracking_mode = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -186,6 +196,8 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor let include = include.ok_or_else(|| M::Error::missing_field("include"))?; let limit_exceeded_action = limit_exceeded_action .ok_or_else(|| M::Error::missing_field("limit_exceeded_action"))?; + let tracking_mode = + tracking_mode.ok_or_else(|| M::Error::missing_field("tracking_mode"))?; let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; let value_limit = value_limit.ok_or_else(|| M::Error::missing_field("value_limit"))?; @@ -197,6 +209,7 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor include, limit_exceeded_action, per_metric_limits, + tracking_mode, type_, value_limit, additional_properties, diff --git a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_tag_mode.rs b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_override_type.rs similarity index 92% rename from src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_tag_mode.rs rename to src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_override_type.rs index 7569b6a927..9376554f7b 100644 --- a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_tag_mode.rs +++ b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_override_type.rs @@ -6,13 +6,13 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode { +pub enum ObservabilityPipelineTagCardinalityLimitProcessorOverrideType { LIMIT_OVERRIDE, EXCLUDED, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode { +impl ToString for ObservabilityPipelineTagCardinalityLimitProcessorOverrideType { fn to_string(&self) -> String { match self { Self::LIMIT_OVERRIDE => String::from("limit_override"), @@ -22,7 +22,7 @@ impl ToString for ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode { } } -impl Serialize for ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode { +impl Serialize for ObservabilityPipelineTagCardinalityLimitProcessorOverrideType { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -34,7 +34,7 @@ impl Serialize for ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode { } } -impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode { +impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessorOverrideType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, diff --git a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit.rs b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit.rs index 5ccdc6de0c..4fe124a371 100644 --- a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit.rs +++ b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_metric_limit.rs @@ -18,16 +18,16 @@ pub struct ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit { /// The name of the metric this override applies to. #[serde(rename = "metric_name")] pub metric_name: String, - /// How the per-metric override is applied. `tracked` enforces a custom limit; `excluded` skips the metric entirely. - #[serde(rename = "mode")] - pub mode: - crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode, - /// A list of per-tag cardinality overrides that apply within this metric. Must be omitted when `mode` is `excluded`. + /// How the override is applied. `limit_override` enforces a custom limit; `excluded` omits the metric or tag from cardinality tracking. + #[serde(rename = "override_type")] + pub override_type: + crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType, + /// A list of per-tag cardinality overrides that apply within this metric. Must be omitted when `override_type` is `excluded`. #[serde(rename = "per_tag_limits")] pub per_tag_limits: Option< Vec, >, - /// The maximum number of distinct tag value combinations allowed for this metric. Required when `mode` is `tracked`. Must be omitted when `mode` is `excluded`. + /// The maximum number of distinct tag value combinations allowed for this metric. Required when `override_type` is `limit_override`. Must be omitted when `override_type` is `excluded`. #[serde(rename = "value_limit")] pub value_limit: Option, #[serde(flatten)] @@ -40,12 +40,12 @@ pub struct ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit { impl ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit { pub fn new( metric_name: String, - mode: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode, + override_type: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType, ) -> ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit { ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit { limit_exceeded_action: None, metric_name, - mode, + override_type, per_tag_limits: None, value_limit: None, additional_properties: std::collections::BTreeMap::new(), @@ -104,7 +104,7 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor { let mut limit_exceeded_action: Option = None; let mut metric_name: Option = None; - let mut mode: Option = None; + let mut override_type: Option = None; let mut per_tag_limits: Option> = None; let mut value_limit: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -134,11 +134,12 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor metric_name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } - "mode" => { - mode = Some(serde_json::from_value(v).map_err(M::Error::custom)?); - if let Some(ref _mode) = mode { - match _mode { - crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode::UnparsedObject(_mode) => { + "override_type" => { + override_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _override_type) = override_type { + match _override_type { + crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType::UnparsedObject(_override_type) => { _unparsed = true; }, _ => {} @@ -168,12 +169,13 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor } let metric_name = metric_name.ok_or_else(|| M::Error::missing_field("metric_name"))?; - let mode = mode.ok_or_else(|| M::Error::missing_field("mode"))?; + let override_type = + override_type.ok_or_else(|| M::Error::missing_field("override_type"))?; let content = ObservabilityPipelineTagCardinalityLimitProcessorPerMetricLimit { limit_exceeded_action, metric_name, - mode, + override_type, per_tag_limits, value_limit, additional_properties, diff --git a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit.rs b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit.rs index 18255f0aa4..22d142feb3 100644 --- a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit.rs +++ b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_tag_limit.rs @@ -11,13 +11,14 @@ use std::fmt::{self, Formatter}; #[skip_serializing_none] #[derive(Clone, Debug, PartialEq, Serialize)] pub struct ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit { - /// How the per-tag override is applied. `limit_override` enforces a custom limit on the tag; `excluded` skips the tag from cardinality tracking. - #[serde(rename = "mode")] - pub mode: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode, + /// How the override is applied. `limit_override` enforces a custom limit; `excluded` omits the metric or tag from cardinality tracking. + #[serde(rename = "override_type")] + pub override_type: + crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType, /// The tag key this override applies to. #[serde(rename = "tag_key")] pub tag_key: String, - /// The maximum number of distinct values allowed for this tag. Required when `mode` is `limit_override`. Must be omitted when `mode` is `excluded`. + /// The maximum number of distinct values allowed for this tag. Required when `override_type` is `limit_override`. Must be omitted when `override_type` is `excluded`. #[serde(rename = "value_limit")] pub value_limit: Option, #[serde(flatten)] @@ -29,11 +30,11 @@ pub struct ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit { impl ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit { pub fn new( - mode: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode, + override_type: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType, tag_key: String, ) -> ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit { ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit { - mode, + override_type, tag_key, value_limit: None, additional_properties: std::collections::BTreeMap::new(), @@ -72,7 +73,7 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor where M: MapAccess<'a>, { - let mut mode: Option = None; + let mut override_type: Option = None; let mut tag_key: Option = None; let mut value_limit: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -83,11 +84,12 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor while let Some((k, v)) = map.next_entry::()? { match k.as_str() { - "mode" => { - mode = Some(serde_json::from_value(v).map_err(M::Error::custom)?); - if let Some(ref _mode) = mode { - match _mode { - crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorPerTagMode::UnparsedObject(_mode) => { + "override_type" => { + override_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _override_type) = override_type { + match _override_type { + crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorOverrideType::UnparsedObject(_override_type) => { _unparsed = true; }, _ => {} @@ -111,11 +113,12 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessor } } } - let mode = mode.ok_or_else(|| M::Error::missing_field("mode"))?; + let override_type = + override_type.ok_or_else(|| M::Error::missing_field("override_type"))?; let tag_key = tag_key.ok_or_else(|| M::Error::missing_field("tag_key"))?; let content = ObservabilityPipelineTagCardinalityLimitProcessorPerTagLimit { - mode, + override_type, tag_key, value_limit, additional_properties, diff --git a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode.rs b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode.rs new file mode 100644 index 0000000000..0630fcc389 --- /dev/null +++ b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode.rs @@ -0,0 +1,104 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Controls whether the processor uses exact or probabilistic tag tracking. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode { + /// The cardinality tracking algorithm to use. + #[serde(rename = "mode")] + pub mode: + crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode { + pub fn new( + mode: crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode, + ) -> ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode { + ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode { + mode, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeVisitor; + impl<'a> Visitor<'a> for ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeVisitor { + type Value = ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut mode: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "mode" => { + mode = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _mode) = mode { + match _mode { + crate::datadogV2::model::ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode::UnparsedObject(_mode) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let mode = mode.ok_or_else(|| M::Error::missing_field("mode"))?; + + let content = ObservabilityPipelineTagCardinalityLimitProcessorTrackingMode { + mode, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeVisitor) + } +} diff --git a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_metric_mode.rs b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode_mode.rs similarity index 75% rename from src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_metric_mode.rs rename to src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode_mode.rs index 7b75bb138e..0ca902235f 100644 --- a/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_per_metric_mode.rs +++ b/src/datadogV2/model/model_observability_pipeline_tag_cardinality_limit_processor_tracking_mode_mode.rs @@ -6,23 +6,23 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[non_exhaustive] #[derive(Clone, Debug, Eq, PartialEq)] -pub enum ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode { - TRACKED, - EXCLUDED, +pub enum ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode { + EXACT_FINGERPRINT, + PROBABILISTIC, UnparsedObject(crate::datadog::UnparsedObject), } -impl ToString for ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode { +impl ToString for ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode { fn to_string(&self) -> String { match self { - Self::TRACKED => String::from("tracked"), - Self::EXCLUDED => String::from("excluded"), + Self::EXACT_FINGERPRINT => String::from("exact_fingerprint"), + Self::PROBABILISTIC => String::from("probabilistic"), Self::UnparsedObject(v) => v.value.to_string(), } } } -impl Serialize for ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode { +impl Serialize for ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -34,15 +34,15 @@ impl Serialize for ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMod } } -impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessorPerMetricMode { +impl<'de> Deserialize<'de> for ObservabilityPipelineTagCardinalityLimitProcessorTrackingModeMode { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { - "tracked" => Self::TRACKED, - "excluded" => Self::EXCLUDED, + "exact_fingerprint" => Self::EXACT_FINGERPRINT, + "probabilistic" => Self::PROBABILISTIC, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), }), diff --git a/src/datadogV2/model/model_print_report_request.rs b/src/datadogV2/model/model_print_report_request.rs new file mode 100644 index 0000000000..ebae209bbc --- /dev/null +++ b/src/datadogV2/model/model_print_report_request.rs @@ -0,0 +1,92 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request body for initiating a print-only report. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PrintReportRequest { + /// The JSON:API data object for a print report request. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::PrintReportRequestData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PrintReportRequest { + pub fn new(data: crate::datadogV2::model::PrintReportRequestData) -> PrintReportRequest { + PrintReportRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PrintReportRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PrintReportRequestVisitor; + impl<'a> Visitor<'a> for PrintReportRequestVisitor { + type Value = PrintReportRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = PrintReportRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PrintReportRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_print_report_request_attributes.rs b/src/datadogV2/model/model_print_report_request_attributes.rs new file mode 100644 index 0000000000..5034d6d1a5 --- /dev/null +++ b/src/datadogV2/model/model_print_report_request_attributes.rs @@ -0,0 +1,199 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The configuration for a print-only report. Specify exactly one of `timeframe` (for a +/// relative time window) or both `from_ts` and `to_ts` (for an absolute time range). +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PrintReportRequestAttributes { + /// The start of an absolute time range, as a Unix timestamp in milliseconds. + /// Required when `timeframe` is omitted. + #[serde(rename = "from_ts")] + pub from_ts: Option, + /// The identifier of the dashboard or integration dashboard to render. + #[serde(rename = "resource_id")] + pub resource_id: String, + /// The type of dashboard resource the report schedule targets. + #[serde(rename = "resource_type")] + pub resource_type: crate::datadogV2::model::ReportScheduleResourceType, + /// The dashboard template variables applied when rendering the report. + #[serde(rename = "template_variables")] + pub template_variables: Vec, + /// A relative time window (for example `1w` or `calendar_month`). Mutually + /// exclusive with `from_ts` and `to_ts`. + #[serde(rename = "timeframe")] + pub timeframe: Option, + /// The IANA time zone identifier used to evaluate the time window. + #[serde(rename = "timezone")] + pub timezone: String, + /// The end of an absolute time range, as a Unix timestamp in milliseconds. + /// Required when `timeframe` is omitted. + #[serde(rename = "to_ts")] + pub to_ts: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PrintReportRequestAttributes { + pub fn new( + resource_id: String, + resource_type: crate::datadogV2::model::ReportScheduleResourceType, + template_variables: Vec, + timezone: String, + ) -> PrintReportRequestAttributes { + PrintReportRequestAttributes { + from_ts: None, + resource_id, + resource_type, + template_variables, + timeframe: None, + timezone, + to_ts: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn from_ts(mut self, value: i64) -> Self { + self.from_ts = Some(value); + self + } + + pub fn timeframe(mut self, value: String) -> Self { + self.timeframe = Some(value); + self + } + + pub fn to_ts(mut self, value: i64) -> Self { + self.to_ts = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PrintReportRequestAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PrintReportRequestAttributesVisitor; + impl<'a> Visitor<'a> for PrintReportRequestAttributesVisitor { + type Value = PrintReportRequestAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut from_ts: Option = None; + let mut resource_id: Option = None; + let mut resource_type: Option = + None; + let mut template_variables: Option< + Vec, + > = None; + let mut timeframe: Option = None; + let mut timezone: Option = None; + let mut to_ts: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "from_ts" => { + if v.is_null() { + continue; + } + from_ts = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_id" => { + resource_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_type" => { + resource_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _resource_type) = resource_type { + match _resource_type { + crate::datadogV2::model::ReportScheduleResourceType::UnparsedObject(_resource_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "template_variables" => { + template_variables = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "timeframe" => { + if v.is_null() { + continue; + } + timeframe = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "timezone" => { + timezone = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "to_ts" => { + if v.is_null() { + continue; + } + to_ts = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let resource_id = + resource_id.ok_or_else(|| M::Error::missing_field("resource_id"))?; + let resource_type = + resource_type.ok_or_else(|| M::Error::missing_field("resource_type"))?; + let template_variables = template_variables + .ok_or_else(|| M::Error::missing_field("template_variables"))?; + let timezone = timezone.ok_or_else(|| M::Error::missing_field("timezone"))?; + + let content = PrintReportRequestAttributes { + from_ts, + resource_id, + resource_type, + template_variables, + timeframe, + timezone, + to_ts, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PrintReportRequestAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_print_report_request_data.rs b/src/datadogV2/model/model_print_report_request_data.rs new file mode 100644 index 0000000000..60c38c129e --- /dev/null +++ b/src/datadogV2/model/model_print_report_request_data.rs @@ -0,0 +1,117 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The JSON:API data object for a print report request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PrintReportRequestData { + /// The configuration for a print-only report. Specify exactly one of `timeframe` (for a + /// relative time window) or both `from_ts` and `to_ts` (for an absolute time range). + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::PrintReportRequestAttributes, + /// JSON:API resource type for a print-only report. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PrintReportType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PrintReportRequestData { + pub fn new( + attributes: crate::datadogV2::model::PrintReportRequestAttributes, + type_: crate::datadogV2::model::PrintReportType, + ) -> PrintReportRequestData { + PrintReportRequestData { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PrintReportRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PrintReportRequestDataVisitor; + impl<'a> Visitor<'a> for PrintReportRequestDataVisitor { + type Value = PrintReportRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PrintReportType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PrintReportRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PrintReportRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_print_report_response.rs b/src/datadogV2/model/model_print_report_response.rs new file mode 100644 index 0000000000..9db6e741e3 --- /dev/null +++ b/src/datadogV2/model/model_print_report_response.rs @@ -0,0 +1,92 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing the initiated print-only report. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PrintReportResponse { + /// The JSON:API data object for a print-only report. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::PrintReportResponseData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PrintReportResponse { + pub fn new(data: crate::datadogV2::model::PrintReportResponseData) -> PrintReportResponse { + PrintReportResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PrintReportResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PrintReportResponseVisitor; + impl<'a> Visitor<'a> for PrintReportResponseVisitor { + type Value = PrintReportResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = PrintReportResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PrintReportResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_print_report_response_attributes.rs b/src/datadogV2/model/model_print_report_response_attributes.rs new file mode 100644 index 0000000000..a042a6632e --- /dev/null +++ b/src/datadogV2/model/model_print_report_response_attributes.rs @@ -0,0 +1,196 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The configuration and download URL for the initiated print-only report. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PrintReportResponseAttributes { + /// The URL from which the rendered PDF report can be downloaded. + #[serde(rename = "download_url")] + pub download_url: String, + /// The start of the rendered time range, as a Unix timestamp in milliseconds. + #[serde(rename = "from_ts")] + pub from_ts: i64, + /// The identifier of the dashboard or integration dashboard. + #[serde(rename = "resource_id")] + pub resource_id: String, + /// The type of dashboard resource the report schedule targets. + #[serde(rename = "resource_type")] + pub resource_type: crate::datadogV2::model::ReportScheduleResourceType, + /// The dashboard template variables applied when rendering the report. + #[serde(rename = "template_variables")] + pub template_variables: Vec, + /// The relative time window used, if one was specified in the request. + #[serde(rename = "timeframe")] + pub timeframe: Option, + /// The IANA time zone identifier used when rendering the report. + #[serde(rename = "timezone")] + pub timezone: String, + /// The end of the rendered time range, as a Unix timestamp in milliseconds. + #[serde(rename = "to_ts")] + pub to_ts: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PrintReportResponseAttributes { + pub fn new( + download_url: String, + from_ts: i64, + resource_id: String, + resource_type: crate::datadogV2::model::ReportScheduleResourceType, + template_variables: Vec, + timezone: String, + to_ts: i64, + ) -> PrintReportResponseAttributes { + PrintReportResponseAttributes { + download_url, + from_ts, + resource_id, + resource_type, + template_variables, + timeframe: None, + timezone, + to_ts, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn timeframe(mut self, value: String) -> Self { + self.timeframe = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PrintReportResponseAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PrintReportResponseAttributesVisitor; + impl<'a> Visitor<'a> for PrintReportResponseAttributesVisitor { + type Value = PrintReportResponseAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut download_url: Option = None; + let mut from_ts: Option = None; + let mut resource_id: Option = None; + let mut resource_type: Option = + None; + let mut template_variables: Option< + Vec, + > = None; + let mut timeframe: Option = None; + let mut timezone: Option = None; + let mut to_ts: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "download_url" => { + download_url = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "from_ts" => { + from_ts = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_id" => { + resource_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_type" => { + resource_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _resource_type) = resource_type { + match _resource_type { + crate::datadogV2::model::ReportScheduleResourceType::UnparsedObject(_resource_type) => { + _unparsed = true; + }, + _ => {} + } + } + } + "template_variables" => { + template_variables = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "timeframe" => { + if v.is_null() { + continue; + } + timeframe = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "timezone" => { + timezone = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "to_ts" => { + to_ts = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let download_url = + download_url.ok_or_else(|| M::Error::missing_field("download_url"))?; + let from_ts = from_ts.ok_or_else(|| M::Error::missing_field("from_ts"))?; + let resource_id = + resource_id.ok_or_else(|| M::Error::missing_field("resource_id"))?; + let resource_type = + resource_type.ok_or_else(|| M::Error::missing_field("resource_type"))?; + let template_variables = template_variables + .ok_or_else(|| M::Error::missing_field("template_variables"))?; + let timezone = timezone.ok_or_else(|| M::Error::missing_field("timezone"))?; + let to_ts = to_ts.ok_or_else(|| M::Error::missing_field("to_ts"))?; + + let content = PrintReportResponseAttributes { + download_url, + from_ts, + resource_id, + resource_type, + template_variables, + timeframe, + timezone, + to_ts, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PrintReportResponseAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_print_report_response_data.rs b/src/datadogV2/model/model_print_report_response_data.rs new file mode 100644 index 0000000000..a4b9676836 --- /dev/null +++ b/src/datadogV2/model/model_print_report_response_data.rs @@ -0,0 +1,127 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The JSON:API data object for a print-only report. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PrintReportResponseData { + /// The configuration and download URL for the initiated print-only report. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::PrintReportResponseAttributes, + /// The unique identifier of the report. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// JSON:API resource type for a print-only report. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PrintReportType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PrintReportResponseData { + pub fn new( + attributes: crate::datadogV2::model::PrintReportResponseAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::PrintReportType, + ) -> PrintReportResponseData { + PrintReportResponseData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PrintReportResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PrintReportResponseDataVisitor; + impl<'a> Visitor<'a> for PrintReportResponseDataVisitor { + type Value = PrintReportResponseData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PrintReportType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PrintReportResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PrintReportResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_print_report_type.rs b/src/datadogV2/model/model_print_report_type.rs new file mode 100644 index 0000000000..ec9272b338 --- /dev/null +++ b/src/datadogV2/model/model_print_report_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum PrintReportType { + REPORT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for PrintReportType { + fn to_string(&self) -> String { + match self { + Self::REPORT => String::from("report"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for PrintReportType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for PrintReportType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "report" => Self::REPORT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/report_schedules.feature b/tests/scenarios/features/v2/report_schedules.feature index aa62a5e350..0404548871 100644 --- a/tests/scenarios/features/v2/report_schedules.feature +++ b/tests/scenarios/features/v2/report_schedules.feature @@ -99,6 +99,27 @@ Feature: Report Schedules When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: List dataset report schedules returns "Bad Request" response + Given new "ListDatasetReportSchedules" request + And request contains "dataset_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: List dataset report schedules returns "Not Found" response + Given new "ListDatasetReportSchedules" request + And request contains "dataset_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: List dataset report schedules returns "OK" response + Given new "ListDatasetReportSchedules" request + And request contains "dataset_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/reporting-and-sharing Scenario: List report schedules returns "Bad Request" response Given new "ListReportSchedules" request @@ -117,6 +138,34 @@ Feature: Report Schedules When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: Print a report returns "Bad Request" response + Given new "PrintReport" request + And body with value {"data": {"attributes": {"from_ts": 1780318800000, "resource_id": "abc-def-ghi", "resource_type": "dashboard", "template_variables": [{"name": "env", "values": ["prod"]}], "timeframe": "1w", "timezone": "America/New_York", "to_ts": 1780923600000}, "type": "report"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: Print a report returns "Not Found" response + Given new "PrintReport" request + And body with value {"data": {"attributes": {"from_ts": 1780318800000, "resource_id": "abc-def-ghi", "resource_type": "dashboard", "template_variables": [{"name": "env", "values": ["prod"]}], "timeframe": "1w", "timezone": "America/New_York", "to_ts": 1780923600000}, "type": "report"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: Print a report returns "OK" response + Given new "PrintReport" request + And body with value {"data": {"attributes": {"from_ts": 1780318800000, "resource_id": "abc-def-ghi", "resource_type": "dashboard", "template_variables": [{"name": "env", "values": ["prod"]}], "timeframe": "1w", "timezone": "America/New_York", "to_ts": 1780923600000}, "type": "report"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: Print a report returns "Unprocessable Entity" response + Given new "PrintReport" request + And body with value {"data": {"attributes": {"from_ts": 1780318800000, "resource_id": "abc-def-ghi", "resource_type": "dashboard", "template_variables": [{"name": "env", "values": ["prod"]}], "timeframe": "1w", "timezone": "America/New_York", "to_ts": 1780923600000}, "type": "report"}} + When the request is sent + Then the response status is 422 Unprocessable Entity + @generated @skip @team:DataDog/reporting-and-sharing Scenario: Toggle a report schedule returns "Bad Request" response Given new "ToggleReportSchedule" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 22089f0ece..36d5bd4d94 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -6470,6 +6470,18 @@ "type": "idempotent" } }, + "ListDatasetReportSchedules": { + "tag": "Report Schedules", + "undo": { + "type": "safe" + } + }, + "PrintReport": { + "tag": "Report Schedules", + "undo": { + "type": "unsafe" + } + }, "CreateReportSchedule": { "tag": "Report Schedules", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 26024f8b3c..3e7240efd0 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -6677,6 +6677,13 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.UpdateReplayHeatmapSnapshot".into(), test_v2_update_replay_heatmap_snapshot, ); + world.function_mappings.insert( + "v2.ListDatasetReportSchedules".into(), + test_v2_list_dataset_report_schedules, + ); + world + .function_mappings + .insert("v2.PrintReport".into(), test_v2_print_report); world.function_mappings.insert( "v2.CreateReportSchedule".into(), test_v2_create_report_schedule, @@ -52161,6 +52168,60 @@ fn test_v2_update_replay_heatmap_snapshot( world.response.code = response.status.as_u16(); } +fn test_v2_list_dataset_report_schedules( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_report_schedules + .as_ref() + .expect("api instance not found"); + let dataset_id = + serde_json::from_value(_parameters.get("dataset_id").unwrap().clone()).unwrap(); + let response = match block_on(api.list_dataset_report_schedules_with_http_info(dataset_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_print_report(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_report_schedules + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.print_report_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_create_report_schedule(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances