diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c1ace36c3..7cef48914 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -3851,6 +3851,276 @@ components: example: "90646597-5fdb-4a17-a240-647003f8c028" format: uuid type: string + ApmDependencyStatName: + description: The APM dependency statistic to query. + enum: + - avg_duration + - avg_root_duration + - avg_spans_per_trace + - error_rate + - pct_exec_time + - pct_of_traces + - total_traces_count + example: avg_duration + type: string + x-enum-varnames: + - AVG_DURATION + - AVG_ROOT_DURATION + - AVG_SPANS_PER_TRACE + - ERROR_RATE + - PCT_EXEC_TIME + - PCT_OF_TRACES + - TOTAL_TRACES_COUNT + ApmDependencyStatsDataSource: + default: apm_dependency_stats + description: A data source for APM dependency statistics queries. + enum: + - apm_dependency_stats + example: apm_dependency_stats + type: string + x-enum-varnames: + - APM_DEPENDENCY_STATS + ApmDependencyStatsQuery: + description: An individual APM dependency stats query. + properties: + data_source: + $ref: "#/components/schemas/ApmDependencyStatsDataSource" + env: + description: The environment to query. + example: prod + type: string + is_upstream: + description: Determines whether stats for upstream or downstream dependencies should be queried. + example: true + type: boolean + name: + description: The variable name for use in formulas. + example: query1 + type: string + operation_name: + description: The APM operation name. + example: web.request + type: string + primary_tag_name: + description: The name of the second primary tag used within APM; required when `primary_tag_value` is specified. See https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog. + example: datacenter + type: string + primary_tag_value: + description: Filter APM data by the second primary tag. `primary_tag_name` must also be specified. + example: us-east-1 + type: string + resource_name: + description: The resource name to filter by. + example: "" + type: string + service: + description: The service name to filter by. + example: web-store + type: string + stat: + $ref: "#/components/schemas/ApmDependencyStatName" + required: + - data_source + - name + - env + - operation_name + - resource_name + - service + - stat + type: object + ApmMetricsDataSource: + default: apm_metrics + description: A data source for APM metrics queries. + enum: + - apm_metrics + example: apm_metrics + type: string + x-enum-varnames: + - APM_METRICS + ApmMetricsQuery: + description: An individual APM metrics query. + properties: + data_source: + $ref: "#/components/schemas/ApmMetricsDataSource" + group_by: + description: Optional fields to group the query results by. + items: + description: A field to group results by. + example: service + type: string + type: array + name: + description: The variable name for use in formulas. + example: query1 + type: string + operation_mode: + description: Optional operation mode to aggregate across operation names. + example: "primary" + type: string + operation_name: + description: Name of operation on service. If not provided, the primary operation name is used. + example: web.request + type: string + peer_tags: + description: Tags to query for a specific downstream entity (peer.service, peer.db_instance, peer.s3, peer.s3.bucket, etc.). + items: + description: A peer tag value. + example: "peer.service:my-service" + type: string + type: array + query_filter: + description: Additional filters for the query using metrics query syntax (e.g., env, primary_tag). + example: "env:prod" + type: string + resource_hash: + description: The resource hash for exact matching. + example: "abc123" + type: string + resource_name: + description: The full name of a specific resource to filter by. + example: "GET /api/v1/users" + type: string + service: + description: The service name to filter by. + example: web-store + type: string + span_kind: + description: Describes the relationship between the span, its parents, and its children in a trace. Known values include consumer, server, client, producer, internal. + example: server + type: string + stat: + $ref: "#/components/schemas/ApmMetricsStat" + required: + - data_source + - name + - stat + type: object + ApmMetricsStat: + description: The APM metric statistic to query. + enum: + - error_rate + - errors + - errors_per_second + - hits + - hits_per_second + - apdex + - latency_avg + - latency_max + - latency_p50 + - latency_p75 + - latency_p90 + - latency_p95 + - latency_p99 + - latency_p999 + - latency_distribution + - total_time + example: latency_p99 + type: string + x-enum-varnames: + - ERROR_RATE + - ERRORS + - ERRORS_PER_SECOND + - HITS + - HITS_PER_SECOND + - APDEX + - LATENCY_AVG + - LATENCY_MAX + - LATENCY_P50 + - LATENCY_P75 + - LATENCY_P90 + - LATENCY_P95 + - LATENCY_P99 + - LATENCY_P999 + - LATENCY_DISTRIBUTION + - TOTAL_TIME + ApmResourceStatName: + description: The APM resource statistic to query. + enum: + - error_rate + - errors + - hits + - latency_avg + - latency_max + - latency_p50 + - latency_p75 + - latency_p90 + - latency_p95 + - latency_p99 + - latency_distribution + - total_time + example: latency_p95 + type: string + x-enum-varnames: + - ERROR_RATE + - ERRORS + - HITS + - LATENCY_AVG + - LATENCY_MAX + - LATENCY_P50 + - LATENCY_P75 + - LATENCY_P90 + - LATENCY_P95 + - LATENCY_P99 + - LATENCY_DISTRIBUTION + - TOTAL_TIME + ApmResourceStatsDataSource: + default: apm_resource_stats + description: A data source for APM resource statistics queries. + enum: + - apm_resource_stats + example: apm_resource_stats + type: string + x-enum-varnames: + - APM_RESOURCE_STATS + ApmResourceStatsQuery: + description: An individual APM resource stats query. + properties: + data_source: + $ref: "#/components/schemas/ApmResourceStatsDataSource" + env: + description: The environment to query. + example: prod + type: string + group_by: + description: Tag keys to group results by. + items: + description: A tag key to group by. + example: resource_name + type: string + type: array + name: + description: The variable name for use in formulas. + example: query1 + type: string + operation_name: + description: The APM operation name. + example: web.request + type: string + primary_tag_name: + description: Name of the second primary tag used within APM. Required when `primary_tag_value` is specified. See https://docs.datadoghq.com/tracing/guide/setting_primary_tags_to_scope/#add-a-second-primary-tag-in-datadog + example: datacenter + type: string + primary_tag_value: + description: Value of the second primary tag by which to filter APM data. `primary_tag_name` must also be specified. + example: us-east-1 + type: string + resource_name: + description: The resource name to filter by. + example: "Admin::ProductsController#create" + type: string + service: + description: The service name to filter by. + example: web-store + type: string + stat: + $ref: "#/components/schemas/ApmResourceStatName" + required: + - data_source + - name + - env + - service + - stat + type: object ApmRetentionFilterType: default: apm_retention_filter description: The type of the resource. @@ -13939,6 +14209,15 @@ components: type: string type: array type: object + ContainerDataSource: + default: container + description: A data source for container-level infrastructure metrics. + enum: + - container + example: container + type: string + x-enum-varnames: + - CONTAINER ContainerGroup: description: Container group object. properties: @@ -14350,6 +14629,86 @@ components: type: string x-enum-varnames: - CURSOR_LIMIT + ContainerScalarQuery: + description: An individual scalar container query. + properties: + aggregator: + description: The temporal reduction function to apply. + example: avg + type: string + data_source: + $ref: "#/components/schemas/ContainerDataSource" + is_normalized_cpu: + description: Whether CPU metrics should be normalized by core count. + type: boolean + limit: + description: Maximum number of timeseries to return. + format: int64 + type: integer + metric: + description: The container metric to query. + example: container.cpu.user + type: string + name: + description: The variable name for use in formulas. + example: query1 + type: string + sort: + description: Sort order for the results. + type: string + tag_filters: + description: Tag filters to narrow down containers. + items: + description: A tag filter value. + example: "env:prod" + type: string + type: array + text_filter: + description: A full-text search filter to match container names. + type: string + required: + - data_source + - name + - metric + type: object + ContainerTimeseriesQuery: + description: An individual timeseries container query. + properties: + data_source: + $ref: "#/components/schemas/ContainerDataSource" + is_normalized_cpu: + description: Whether CPU metrics should be normalized by core count. + type: boolean + limit: + description: Maximum number of timeseries to return. + format: int64 + type: integer + metric: + description: The container metric to query. + example: container.cpu.user + type: string + name: + description: The variable name for use in formulas. + example: query1 + type: string + sort: + description: Sort order for the results. + type: string + tag_filters: + description: Tag filters to narrow down containers. + items: + description: A tag filter value. + example: "env:prod" + type: string + type: array + text_filter: + description: A full-text search filter to match container names. + type: string + required: + - data_source + - name + - metric + type: object ContainerType: default: container description: Type of container. @@ -24959,13 +25318,35 @@ components: description: A data source that is powered by the Events Platform. enum: - logs + - spans + - network - rum + - security_signals + - profiles + - audit + - events + - ci_tests + - ci_pipelines + - incident_analytics + - product_analytics + - on_call_events - dora example: logs type: string x-enum-varnames: - LOGS + - SPANS + - NETWORK - RUM + - SECURITY_SIGNALS + - PROFILES + - AUDIT + - EVENTS + - CI_TESTS + - CI_PIPELINES + - INCIDENT_ANALYTICS + - PRODUCT_ANALYTICS + - ON_CALL_EVENTS - DORA EventsGroupBy: description: A dimension on which to split a query's results. @@ -50240,6 +50621,57 @@ components: required: - type type: object + ProcessDataSource: + default: process + description: A data source for process-level infrastructure metrics. + enum: + - process + example: process + type: string + x-enum-varnames: + - PROCESS + ProcessScalarQuery: + description: An individual scalar process query. + properties: + aggregator: + description: The temporal reduction function to apply. + example: avg + type: string + data_source: + $ref: "#/components/schemas/ProcessDataSource" + is_normalized_cpu: + description: Whether CPU metrics should be normalized by core count. + type: boolean + limit: + description: Maximum number of timeseries to return. + format: int64 + type: integer + metric: + description: The process metric to query. + example: process.cpu.user + type: string + name: + description: The variable name for use in formulas. + example: query1 + type: string + sort: + description: Sort order for the results. + type: string + tag_filters: + description: Tag filters to narrow down processes. + items: + description: A tag filter value. + example: "env:prod" + type: string + type: array + text_filter: + description: A full-text search filter to match process names or commands. + type: string + required: + - data_source + - name + - metric + type: object ProcessSummariesMeta: description: Response metadata object. properties: @@ -50326,6 +50758,44 @@ components: type: string x-enum-varnames: - PROCESS + ProcessTimeseriesQuery: + description: An individual timeseries process query. + properties: + data_source: + $ref: "#/components/schemas/ProcessDataSource" + is_normalized_cpu: + description: Whether CPU metrics should be normalized by core count. + type: boolean + limit: + description: Maximum number of timeseries to return. + format: int64 + type: integer + metric: + description: The process metric to query. + example: process.cpu.user + type: string + name: + description: The variable name for use in formulas. + example: query1 + type: string + sort: + description: Sort order for the results. + type: string + tag_filters: + description: Tag filters to narrow down processes. + items: + description: A tag filter value. + example: "env:prod" + type: string + type: array + text_filter: + description: A full-text search filter to match process names or commands. + type: string + required: + - data_source + - name + - metric + type: object ProductAnalyticsAnalyticsQuery: description: The analytics query definition containing a base query, compute rule, and optional grouping. properties: @@ -56529,6 +56999,12 @@ components: oneOf: - $ref: "#/components/schemas/MetricsScalarQuery" - $ref: "#/components/schemas/EventsScalarQuery" + - $ref: "#/components/schemas/ApmResourceStatsQuery" + - $ref: "#/components/schemas/ApmMetricsQuery" + - $ref: "#/components/schemas/ApmDependencyStatsQuery" + - $ref: "#/components/schemas/SloQuery" + - $ref: "#/components/schemas/ProcessScalarQuery" + - $ref: "#/components/schemas/ContainerScalarQuery" ScalarResponse: description: A message containing the response to a scalar query. properties: @@ -63816,6 +64292,51 @@ components: required: - slackTrigger type: object + SloDataSource: + default: slo + description: A data source for SLO queries. + enum: + - slo + example: slo + type: string + x-enum-varnames: + - SLO + SloQuery: + description: An individual SLO query. + example: + additional_query_filters: "*" + data_source: "slo" + group_mode: "overall" + measure: "good_events" + name: "my_slo" + slo_id: "12345678910" + slo_query_type: "metric" + properties: + additional_query_filters: + description: Additional filters applied to the SLO query. + example: "host:host_a,env:prod" + type: string + data_source: + $ref: "#/components/schemas/SloDataSource" + group_mode: + $ref: "#/components/schemas/SlosGroupMode" + measure: + $ref: "#/components/schemas/SlosMeasure" + name: + description: The variable name for use in formulas. + example: query1 + type: string + slo_id: + description: The unique identifier of the SLO to query. + example: "a]b123c45de6f78g90h" + type: string + slo_query_type: + $ref: "#/components/schemas/SlosQueryType" + required: + - data_source + - slo_id + - measure + type: object SloReportCreateRequest: description: The SLO report request body. properties: @@ -63923,6 +64444,54 @@ components: type: string x-enum-varnames: - SLO_STATUS + SlosGroupMode: + description: How SLO results are grouped in the response. + enum: + - overall + - components + example: overall + type: string + x-enum-varnames: + - OVERALL + - COMPONENTS + SlosMeasure: + description: The SLO measurement to retrieve. + enum: + - good_events + - bad_events + - slo_status + - error_budget_remaining + - error_budget_remaining_history + - error_budget_burndown + - burn_rate + - slo_status_history + - good_minutes + - bad_minutes + example: slo_status + type: string + x-enum-varnames: + - GOOD_EVENTS + - BAD_EVENTS + - SLO_STATUS + - ERROR_BUDGET_REMAINING + - ERROR_BUDGET_REMAINING_HISTORY + - ERROR_BUDGET_BURNDOWN + - BURN_RATE + - SLO_STATUS_HISTORY + - GOOD_MINUTES + - BAD_MINUTES + SlosQueryType: + description: The type of SLO definition being queried. + enum: + - metric + - time_slice + - monitor + example: metric + type: string + x-enum-varnames: + - METRIC + - TIME_SLICE + - MONITOR Snapshot: description: A single heatmap snapshot resource returned by create or update operations. properties: @@ -70703,6 +71272,12 @@ components: oneOf: - $ref: "#/components/schemas/MetricsTimeseriesQuery" - $ref: "#/components/schemas/EventsTimeseriesQuery" + - $ref: "#/components/schemas/ApmResourceStatsQuery" + - $ref: "#/components/schemas/ApmMetricsQuery" + - $ref: "#/components/schemas/ApmDependencyStatsQuery" + - $ref: "#/components/schemas/SloQuery" + - $ref: "#/components/schemas/ProcessTimeseriesQuery" + - $ref: "#/components/schemas/ContainerTimeseriesQuery" TimeseriesResponse: description: A message containing the response to a timeseries query. properties: diff --git a/examples/v2_metrics_QueryScalarData_1479548882.rs b/examples/v2_metrics_QueryScalarData_1479548882.rs new file mode 100644 index 000000000..1d0365c42 --- /dev/null +++ b/examples/v2_metrics_QueryScalarData_1479548882.rs @@ -0,0 +1,49 @@ +// Scalar cross product query with apm_resource_stats data source returns "OK" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ApmResourceStatName; +use datadog_api_client::datadogV2::model::ApmResourceStatsDataSource; +use datadog_api_client::datadogV2::model::ApmResourceStatsQuery; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::ScalarFormulaQueryRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestType; +use datadog_api_client::datadogV2::model::ScalarQuery; + +#[tokio::main] +async fn main() { + let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new( + ScalarFormulaRequestAttributes::new( + 1636625471000, + vec![ScalarQuery::ApmResourceStatsQuery(Box::new( + ApmResourceStatsQuery::new( + ApmResourceStatsDataSource::APM_RESOURCE_STATS, + "staging".to_string(), + "a".to_string(), + "azure-bill-import".to_string(), + ApmResourceStatName::HITS, + ) + .group_by(vec!["resource_name".to_string()]) + .operation_name("cassandra.query".to_string()) + .primary_tag_name("datacenter".to_string()) + .primary_tag_value("*".to_string()), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]), + ScalarFormulaRequestType::SCALAR_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_scalar_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryScalarData_1904811219.rs b/examples/v2_metrics_QueryScalarData_1904811219.rs new file mode 100644 index 000000000..427852975 --- /dev/null +++ b/examples/v2_metrics_QueryScalarData_1904811219.rs @@ -0,0 +1,45 @@ +// Scalar cross product query with apm_metrics data source returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ApmMetricsDataSource; +use datadog_api_client::datadogV2::model::ApmMetricsQuery; +use datadog_api_client::datadogV2::model::ApmMetricsStat; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::ScalarFormulaQueryRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestType; +use datadog_api_client::datadogV2::model::ScalarQuery; + +#[tokio::main] +async fn main() { + let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new( + ScalarFormulaRequestAttributes::new( + 1636625471000, + vec![ScalarQuery::ApmMetricsQuery(Box::new( + ApmMetricsQuery::new( + ApmMetricsDataSource::APM_METRICS, + "a".to_string(), + ApmMetricsStat::HITS, + ) + .group_by(vec!["resource_name".to_string()]) + .query_filter("env:prod".to_string()) + .service("web-store".to_string()), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]), + ScalarFormulaRequestType::SCALAR_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_scalar_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryScalarData_2298288525.rs b/examples/v2_metrics_QueryScalarData_2298288525.rs new file mode 100644 index 000000000..1bb925b33 --- /dev/null +++ b/examples/v2_metrics_QueryScalarData_2298288525.rs @@ -0,0 +1,48 @@ +// Scalar cross product query with slo data source returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::ScalarFormulaQueryRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestType; +use datadog_api_client::datadogV2::model::ScalarQuery; +use datadog_api_client::datadogV2::model::SloDataSource; +use datadog_api_client::datadogV2::model::SloQuery; +use datadog_api_client::datadogV2::model::SlosGroupMode; +use datadog_api_client::datadogV2::model::SlosMeasure; +use datadog_api_client::datadogV2::model::SlosQueryType; + +#[tokio::main] +async fn main() { + let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new( + ScalarFormulaRequestAttributes::new( + 1636625471000, + vec![ScalarQuery::SloQuery(Box::new( + SloQuery::new( + SloDataSource::SLO, + SlosMeasure::SLO_STATUS, + "12345678910".to_string(), + ) + .additional_query_filters("*".to_string()) + .group_mode(SlosGroupMode::OVERALL) + .name("a".to_string()) + .slo_query_type(SlosQueryType::METRIC), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]), + ScalarFormulaRequestType::SCALAR_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_scalar_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryScalarData_2533499017.rs b/examples/v2_metrics_QueryScalarData_2533499017.rs new file mode 100644 index 000000000..cd2cdb382 --- /dev/null +++ b/examples/v2_metrics_QueryScalarData_2533499017.rs @@ -0,0 +1,60 @@ +// Scalar cross product query with apm_dependency_stats data source returns "OK" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ApmDependencyStatName; +use datadog_api_client::datadogV2::model::ApmDependencyStatsDataSource; +use datadog_api_client::datadogV2::model::ApmDependencyStatsQuery; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::ScalarFormulaQueryRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestType; +use datadog_api_client::datadogV2::model::ScalarQuery; + +#[tokio::main] +async fn main() { + let body = + ScalarFormulaQueryRequest::new( + ScalarFormulaRequest::new( + ScalarFormulaRequestAttributes::new( + 1636625471000, + vec![ + ScalarQuery::ApmDependencyStatsQuery( + Box::new( + ApmDependencyStatsQuery::new( + ApmDependencyStatsDataSource::APM_DEPENDENCY_STATS, + "ci".to_string(), + "a".to_string(), + "cassandra.query".to_string(), + "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?".to_string(), + "cassandra".to_string(), + ApmDependencyStatName::AVG_DURATION, + ) + .primary_tag_name("datacenter".to_string()) + .primary_tag_value("edge-eu1.prod.dog".to_string()), + ), + ) + ], + 1636629071000, + ).formulas( + vec![ + QueryFormula::new( + "a".to_string(), + ).limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC)) + ], + ), + ScalarFormulaRequestType::SCALAR_REQUEST, + ), + ); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_scalar_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryScalarData_4230617918.rs b/examples/v2_metrics_QueryScalarData_4230617918.rs new file mode 100644 index 000000000..501d35690 --- /dev/null +++ b/examples/v2_metrics_QueryScalarData_4230617918.rs @@ -0,0 +1,47 @@ +// Scalar cross product query with process data source returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::ProcessDataSource; +use datadog_api_client::datadogV2::model::ProcessScalarQuery; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::ScalarFormulaQueryRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestType; +use datadog_api_client::datadogV2::model::ScalarQuery; + +#[tokio::main] +async fn main() { + let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new( + ScalarFormulaRequestAttributes::new( + 1636625471000, + vec![ScalarQuery::ProcessScalarQuery(Box::new( + ProcessScalarQuery::new( + ProcessDataSource::PROCESS, + "process.stat.cpu.total_pct".to_string(), + "a".to_string(), + ) + .aggregator("avg".to_string()) + .is_normalized_cpu(false) + .limit(10) + .sort("desc".to_string()) + .tag_filters(vec![]) + .text_filter("".to_string()), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]), + ScalarFormulaRequestType::SCALAR_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_scalar_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryScalarData_891952130.rs b/examples/v2_metrics_QueryScalarData_891952130.rs new file mode 100644 index 000000000..ccfb67c86 --- /dev/null +++ b/examples/v2_metrics_QueryScalarData_891952130.rs @@ -0,0 +1,45 @@ +// Scalar cross product query with container data source returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ContainerDataSource; +use datadog_api_client::datadogV2::model::ContainerScalarQuery; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::ScalarFormulaQueryRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequest; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::ScalarFormulaRequestType; +use datadog_api_client::datadogV2::model::ScalarQuery; + +#[tokio::main] +async fn main() { + let body = ScalarFormulaQueryRequest::new(ScalarFormulaRequest::new( + ScalarFormulaRequestAttributes::new( + 1636625471000, + vec![ScalarQuery::ContainerScalarQuery(Box::new( + ContainerScalarQuery::new( + ContainerDataSource::CONTAINER, + "process.stat.container.cpu.system_pct".to_string(), + "a".to_string(), + ) + .aggregator("avg".to_string()) + .limit(10) + .sort("desc".to_string()) + .tag_filters(vec![]), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]), + ScalarFormulaRequestType::SCALAR_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_scalar_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryTimeseriesData_108927825.rs b/examples/v2_metrics_QueryTimeseriesData_108927825.rs new file mode 100644 index 000000000..4eca8a11d --- /dev/null +++ b/examples/v2_metrics_QueryTimeseriesData_108927825.rs @@ -0,0 +1,49 @@ +// Timeseries cross product query with slo data source returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::SloDataSource; +use datadog_api_client::datadogV2::model::SloQuery; +use datadog_api_client::datadogV2::model::SlosGroupMode; +use datadog_api_client::datadogV2::model::SlosMeasure; +use datadog_api_client::datadogV2::model::SlosQueryType; +use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType; +use datadog_api_client::datadogV2::model::TimeseriesQuery; + +#[tokio::main] +async fn main() { + let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new( + TimeseriesFormulaRequestAttributes::new( + 1636625471000, + vec![TimeseriesQuery::SloQuery(Box::new( + SloQuery::new( + SloDataSource::SLO, + SlosMeasure::SLO_STATUS, + "12345678910".to_string(), + ) + .additional_query_filters("*".to_string()) + .group_mode(SlosGroupMode::OVERALL) + .name("a".to_string()) + .slo_query_type(SlosQueryType::METRIC), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]) + .interval(5000), + TimeseriesFormulaRequestType::TIMESERIES_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_timeseries_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryTimeseriesData_2159746306.rs b/examples/v2_metrics_QueryTimeseriesData_2159746306.rs new file mode 100644 index 000000000..529e751fb --- /dev/null +++ b/examples/v2_metrics_QueryTimeseriesData_2159746306.rs @@ -0,0 +1,47 @@ +// Timeseries cross product query with process data source returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::ProcessDataSource; +use datadog_api_client::datadogV2::model::ProcessTimeseriesQuery; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType; +use datadog_api_client::datadogV2::model::TimeseriesQuery; + +#[tokio::main] +async fn main() { + let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new( + TimeseriesFormulaRequestAttributes::new( + 1636625471000, + vec![TimeseriesQuery::ProcessTimeseriesQuery(Box::new( + ProcessTimeseriesQuery::new( + ProcessDataSource::PROCESS, + "process.stat.cpu.total_pct".to_string(), + "a".to_string(), + ) + .is_normalized_cpu(false) + .limit(10) + .sort("desc".to_string()) + .tag_filters(vec![]) + .text_filter("".to_string()), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]) + .interval(5000), + TimeseriesFormulaRequestType::TIMESERIES_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_timeseries_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryTimeseriesData_3174309318.rs b/examples/v2_metrics_QueryTimeseriesData_3174309318.rs new file mode 100644 index 000000000..cfb6f402d --- /dev/null +++ b/examples/v2_metrics_QueryTimeseriesData_3174309318.rs @@ -0,0 +1,45 @@ +// Timeseries cross product query with container data source returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ContainerDataSource; +use datadog_api_client::datadogV2::model::ContainerTimeseriesQuery; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType; +use datadog_api_client::datadogV2::model::TimeseriesQuery; + +#[tokio::main] +async fn main() { + let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new( + TimeseriesFormulaRequestAttributes::new( + 1636625471000, + vec![TimeseriesQuery::ContainerTimeseriesQuery(Box::new( + ContainerTimeseriesQuery::new( + ContainerDataSource::CONTAINER, + "process.stat.container.cpu.system_pct".to_string(), + "a".to_string(), + ) + .limit(10) + .sort("desc".to_string()) + .tag_filters(vec![]), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]) + .interval(5000), + TimeseriesFormulaRequestType::TIMESERIES_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_timeseries_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryTimeseriesData_4028506518.rs b/examples/v2_metrics_QueryTimeseriesData_4028506518.rs new file mode 100644 index 000000000..2026c0618 --- /dev/null +++ b/examples/v2_metrics_QueryTimeseriesData_4028506518.rs @@ -0,0 +1,50 @@ +// Timeseries cross product query with apm_resource_stats data source returns "OK" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ApmResourceStatName; +use datadog_api_client::datadogV2::model::ApmResourceStatsDataSource; +use datadog_api_client::datadogV2::model::ApmResourceStatsQuery; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType; +use datadog_api_client::datadogV2::model::TimeseriesQuery; + +#[tokio::main] +async fn main() { + let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new( + TimeseriesFormulaRequestAttributes::new( + 1636625471000, + vec![TimeseriesQuery::ApmResourceStatsQuery(Box::new( + ApmResourceStatsQuery::new( + ApmResourceStatsDataSource::APM_RESOURCE_STATS, + "staging".to_string(), + "a".to_string(), + "azure-bill-import".to_string(), + ApmResourceStatName::HITS, + ) + .group_by(vec!["resource_name".to_string()]) + .operation_name("cassandra.query".to_string()) + .primary_tag_name("datacenter".to_string()) + .primary_tag_value("*".to_string()), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]) + .interval(5000), + TimeseriesFormulaRequestType::TIMESERIES_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_timeseries_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryTimeseriesData_4246412951.rs b/examples/v2_metrics_QueryTimeseriesData_4246412951.rs new file mode 100644 index 000000000..98929e8b9 --- /dev/null +++ b/examples/v2_metrics_QueryTimeseriesData_4246412951.rs @@ -0,0 +1,47 @@ +// Timeseries cross product query with apm_metrics data source returns "OK" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ApmMetricsDataSource; +use datadog_api_client::datadogV2::model::ApmMetricsQuery; +use datadog_api_client::datadogV2::model::ApmMetricsStat; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType; +use datadog_api_client::datadogV2::model::TimeseriesQuery; + +#[tokio::main] +async fn main() { + let body = TimeseriesFormulaQueryRequest::new(TimeseriesFormulaRequest::new( + TimeseriesFormulaRequestAttributes::new( + 1636625471000, + vec![TimeseriesQuery::ApmMetricsQuery(Box::new( + ApmMetricsQuery::new( + ApmMetricsDataSource::APM_METRICS, + "a".to_string(), + ApmMetricsStat::HITS, + ) + .group_by(vec!["resource_name".to_string()]) + .query_filter("env:prod".to_string()) + .service("web-store".to_string()), + ))], + 1636629071000, + ) + .formulas(vec![QueryFormula::new("a".to_string()) + .limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC))]) + .interval(5000), + TimeseriesFormulaRequestType::TIMESERIES_REQUEST, + )); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_timeseries_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_metrics_QueryTimeseriesData_847716941.rs b/examples/v2_metrics_QueryTimeseriesData_847716941.rs new file mode 100644 index 000000000..c6f59834f --- /dev/null +++ b/examples/v2_metrics_QueryTimeseriesData_847716941.rs @@ -0,0 +1,62 @@ +// Timeseries cross product query with apm_dependency_stats data source returns +// "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_metrics::MetricsAPI; +use datadog_api_client::datadogV2::model::ApmDependencyStatName; +use datadog_api_client::datadogV2::model::ApmDependencyStatsDataSource; +use datadog_api_client::datadogV2::model::ApmDependencyStatsQuery; +use datadog_api_client::datadogV2::model::FormulaLimit; +use datadog_api_client::datadogV2::model::QueryFormula; +use datadog_api_client::datadogV2::model::QuerySortOrder; +use datadog_api_client::datadogV2::model::TimeseriesFormulaQueryRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequest; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestAttributes; +use datadog_api_client::datadogV2::model::TimeseriesFormulaRequestType; +use datadog_api_client::datadogV2::model::TimeseriesQuery; + +#[tokio::main] +async fn main() { + let body = + TimeseriesFormulaQueryRequest::new( + TimeseriesFormulaRequest::new( + TimeseriesFormulaRequestAttributes::new( + 1636625471000, + vec![ + TimeseriesQuery::ApmDependencyStatsQuery( + Box::new( + ApmDependencyStatsQuery::new( + ApmDependencyStatsDataSource::APM_DEPENDENCY_STATS, + "ci".to_string(), + "a".to_string(), + "cassandra.query".to_string(), + "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?".to_string(), + "cassandra".to_string(), + ApmDependencyStatName::AVG_DURATION, + ) + .primary_tag_name("datacenter".to_string()) + .primary_tag_value("edge-eu1.prod.dog".to_string()), + ), + ) + ], + 1636629071000, + ) + .formulas( + vec![ + QueryFormula::new( + "a".to_string(), + ).limit(FormulaLimit::new().count(10).order(QuerySortOrder::DESC)) + ], + ) + .interval(5000), + TimeseriesFormulaRequestType::TIMESERIES_REQUEST, + ), + ); + let configuration = datadog::Configuration::new(); + let api = MetricsAPI::with_config(configuration); + let resp = api.query_timeseries_data(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index f0689d162..bdcd50d89 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -6338,6 +6338,42 @@ pub mod model_events_sort_type; pub use self::model_events_sort_type::EventsSortType; pub mod model_events_search; pub use self::model_events_search::EventsSearch; +pub mod model_apm_resource_stats_query; +pub use self::model_apm_resource_stats_query::ApmResourceStatsQuery; +pub mod model_apm_resource_stats_data_source; +pub use self::model_apm_resource_stats_data_source::ApmResourceStatsDataSource; +pub mod model_apm_resource_stat_name; +pub use self::model_apm_resource_stat_name::ApmResourceStatName; +pub mod model_apm_metrics_query; +pub use self::model_apm_metrics_query::ApmMetricsQuery; +pub mod model_apm_metrics_data_source; +pub use self::model_apm_metrics_data_source::ApmMetricsDataSource; +pub mod model_apm_metrics_stat; +pub use self::model_apm_metrics_stat::ApmMetricsStat; +pub mod model_apm_dependency_stats_query; +pub use self::model_apm_dependency_stats_query::ApmDependencyStatsQuery; +pub mod model_apm_dependency_stats_data_source; +pub use self::model_apm_dependency_stats_data_source::ApmDependencyStatsDataSource; +pub mod model_apm_dependency_stat_name; +pub use self::model_apm_dependency_stat_name::ApmDependencyStatName; +pub mod model_slo_query; +pub use self::model_slo_query::SloQuery; +pub mod model_slo_data_source; +pub use self::model_slo_data_source::SloDataSource; +pub mod model_slos_group_mode; +pub use self::model_slos_group_mode::SlosGroupMode; +pub mod model_slos_measure; +pub use self::model_slos_measure::SlosMeasure; +pub mod model_slos_query_type; +pub use self::model_slos_query_type::SlosQueryType; +pub mod model_process_scalar_query; +pub use self::model_process_scalar_query::ProcessScalarQuery; +pub mod model_process_data_source; +pub use self::model_process_data_source::ProcessDataSource; +pub mod model_container_scalar_query; +pub use self::model_container_scalar_query::ContainerScalarQuery; +pub mod model_container_data_source; +pub use self::model_container_data_source::ContainerDataSource; pub mod model_scalar_query; pub use self::model_scalar_query::ScalarQuery; pub mod model_scalar_formula_request_type; @@ -6374,6 +6410,10 @@ pub mod model_metrics_timeseries_query; pub use self::model_metrics_timeseries_query::MetricsTimeseriesQuery; pub mod model_events_timeseries_query; pub use self::model_events_timeseries_query::EventsTimeseriesQuery; +pub mod model_process_timeseries_query; +pub use self::model_process_timeseries_query::ProcessTimeseriesQuery; +pub mod model_container_timeseries_query; +pub use self::model_container_timeseries_query::ContainerTimeseriesQuery; pub mod model_timeseries_query; pub use self::model_timeseries_query::TimeseriesQuery; pub mod model_timeseries_formula_request_type; diff --git a/src/datadogV2/model/model_apm_dependency_stat_name.rs b/src/datadogV2/model/model_apm_dependency_stat_name.rs new file mode 100644 index 000000000..5e3e7d2bb --- /dev/null +++ b/src/datadogV2/model/model_apm_dependency_stat_name.rs @@ -0,0 +1,66 @@ +// 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 ApmDependencyStatName { + AVG_DURATION, + AVG_ROOT_DURATION, + AVG_SPANS_PER_TRACE, + ERROR_RATE, + PCT_EXEC_TIME, + PCT_OF_TRACES, + TOTAL_TRACES_COUNT, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ApmDependencyStatName { + fn to_string(&self) -> String { + match self { + Self::AVG_DURATION => String::from("avg_duration"), + Self::AVG_ROOT_DURATION => String::from("avg_root_duration"), + Self::AVG_SPANS_PER_TRACE => String::from("avg_spans_per_trace"), + Self::ERROR_RATE => String::from("error_rate"), + Self::PCT_EXEC_TIME => String::from("pct_exec_time"), + Self::PCT_OF_TRACES => String::from("pct_of_traces"), + Self::TOTAL_TRACES_COUNT => String::from("total_traces_count"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ApmDependencyStatName { + 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 ApmDependencyStatName { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "avg_duration" => Self::AVG_DURATION, + "avg_root_duration" => Self::AVG_ROOT_DURATION, + "avg_spans_per_trace" => Self::AVG_SPANS_PER_TRACE, + "error_rate" => Self::ERROR_RATE, + "pct_exec_time" => Self::PCT_EXEC_TIME, + "pct_of_traces" => Self::PCT_OF_TRACES, + "total_traces_count" => Self::TOTAL_TRACES_COUNT, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_apm_dependency_stats_data_source.rs b/src/datadogV2/model/model_apm_dependency_stats_data_source.rs new file mode 100644 index 000000000..337930fb5 --- /dev/null +++ b/src/datadogV2/model/model_apm_dependency_stats_data_source.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 ApmDependencyStatsDataSource { + APM_DEPENDENCY_STATS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ApmDependencyStatsDataSource { + fn to_string(&self) -> String { + match self { + Self::APM_DEPENDENCY_STATS => String::from("apm_dependency_stats"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ApmDependencyStatsDataSource { + 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 ApmDependencyStatsDataSource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "apm_dependency_stats" => Self::APM_DEPENDENCY_STATS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_apm_dependency_stats_query.rs b/src/datadogV2/model/model_apm_dependency_stats_query.rs new file mode 100644 index 000000000..a821cc50d --- /dev/null +++ b/src/datadogV2/model/model_apm_dependency_stats_query.rs @@ -0,0 +1,237 @@ +// 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}; + +/// An individual APM dependency stats query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApmDependencyStatsQuery { + /// A data source for APM dependency statistics queries. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::ApmDependencyStatsDataSource, + /// The environment to query. + #[serde(rename = "env")] + pub env: String, + /// Determines whether stats for upstream or downstream dependencies should be queried. + #[serde(rename = "is_upstream")] + pub is_upstream: Option, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: String, + /// The APM operation name. + #[serde(rename = "operation_name")] + pub operation_name: String, + /// The name of the second primary tag used within APM; required when `primary_tag_value` is specified. See + #[serde(rename = "primary_tag_name")] + pub primary_tag_name: Option, + /// Filter APM data by the second primary tag. `primary_tag_name` must also be specified. + #[serde(rename = "primary_tag_value")] + pub primary_tag_value: Option, + /// The resource name to filter by. + #[serde(rename = "resource_name")] + pub resource_name: String, + /// The service name to filter by. + #[serde(rename = "service")] + pub service: String, + /// The APM dependency statistic to query. + #[serde(rename = "stat")] + pub stat: crate::datadogV2::model::ApmDependencyStatName, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApmDependencyStatsQuery { + pub fn new( + data_source: crate::datadogV2::model::ApmDependencyStatsDataSource, + env: String, + name: String, + operation_name: String, + resource_name: String, + service: String, + stat: crate::datadogV2::model::ApmDependencyStatName, + ) -> ApmDependencyStatsQuery { + ApmDependencyStatsQuery { + data_source, + env, + is_upstream: None, + name, + operation_name, + primary_tag_name: None, + primary_tag_value: None, + resource_name, + service, + stat, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn is_upstream(mut self, value: bool) -> Self { + self.is_upstream = Some(value); + self + } + + pub fn primary_tag_name(mut self, value: String) -> Self { + self.primary_tag_name = Some(value); + self + } + + pub fn primary_tag_value(mut self, value: String) -> Self { + self.primary_tag_value = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ApmDependencyStatsQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApmDependencyStatsQueryVisitor; + impl<'a> Visitor<'a> for ApmDependencyStatsQueryVisitor { + type Value = ApmDependencyStatsQuery; + + 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_source: Option = + None; + let mut env: Option = None; + let mut is_upstream: Option = None; + let mut name: Option = None; + let mut operation_name: Option = None; + let mut primary_tag_name: Option = None; + let mut primary_tag_value: Option = None; + let mut resource_name: Option = None; + let mut service: Option = None; + let mut stat: 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_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::ApmDependencyStatsDataSource::UnparsedObject(_data_source) => { + _unparsed = true; + }, + _ => {} + } + } + } + "env" => { + env = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_upstream" => { + if v.is_null() { + continue; + } + is_upstream = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "operation_name" => { + operation_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_tag_name" => { + if v.is_null() { + continue; + } + primary_tag_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_tag_value" => { + if v.is_null() { + continue; + } + primary_tag_value = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_name" => { + resource_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "service" => { + service = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "stat" => { + stat = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _stat) = stat { + match _stat { + crate::datadogV2::model::ApmDependencyStatName::UnparsedObject(_stat) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let env = env.ok_or_else(|| M::Error::missing_field("env"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let operation_name = + operation_name.ok_or_else(|| M::Error::missing_field("operation_name"))?; + let resource_name = + resource_name.ok_or_else(|| M::Error::missing_field("resource_name"))?; + let service = service.ok_or_else(|| M::Error::missing_field("service"))?; + let stat = stat.ok_or_else(|| M::Error::missing_field("stat"))?; + + let content = ApmDependencyStatsQuery { + data_source, + env, + is_upstream, + name, + operation_name, + primary_tag_name, + primary_tag_value, + resource_name, + service, + stat, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApmDependencyStatsQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_apm_metrics_data_source.rs b/src/datadogV2/model/model_apm_metrics_data_source.rs new file mode 100644 index 000000000..65cab4dcb --- /dev/null +++ b/src/datadogV2/model/model_apm_metrics_data_source.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 ApmMetricsDataSource { + APM_METRICS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ApmMetricsDataSource { + fn to_string(&self) -> String { + match self { + Self::APM_METRICS => String::from("apm_metrics"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ApmMetricsDataSource { + 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 ApmMetricsDataSource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "apm_metrics" => Self::APM_METRICS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_apm_metrics_query.rs b/src/datadogV2/model/model_apm_metrics_query.rs new file mode 100644 index 000000000..8201f810d --- /dev/null +++ b/src/datadogV2/model/model_apm_metrics_query.rs @@ -0,0 +1,294 @@ +// 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}; + +/// An individual APM metrics query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApmMetricsQuery { + /// A data source for APM metrics queries. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::ApmMetricsDataSource, + /// Optional fields to group the query results by. + #[serde(rename = "group_by")] + pub group_by: Option>, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: String, + /// Optional operation mode to aggregate across operation names. + #[serde(rename = "operation_mode")] + pub operation_mode: Option, + /// Name of operation on service. If not provided, the primary operation name is used. + #[serde(rename = "operation_name")] + pub operation_name: Option, + /// Tags to query for a specific downstream entity (peer.service, peer.db_instance, peer.s3, peer.s3.bucket, etc.). + #[serde(rename = "peer_tags")] + pub peer_tags: Option>, + /// Additional filters for the query using metrics query syntax (e.g., env, primary_tag). + #[serde(rename = "query_filter")] + pub query_filter: Option, + /// The resource hash for exact matching. + #[serde(rename = "resource_hash")] + pub resource_hash: Option, + /// The full name of a specific resource to filter by. + #[serde(rename = "resource_name")] + pub resource_name: Option, + /// The service name to filter by. + #[serde(rename = "service")] + pub service: Option, + /// Describes the relationship between the span, its parents, and its children in a trace. Known values include consumer, server, client, producer, internal. + #[serde(rename = "span_kind")] + pub span_kind: Option, + /// The APM metric statistic to query. + #[serde(rename = "stat")] + pub stat: crate::datadogV2::model::ApmMetricsStat, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApmMetricsQuery { + pub fn new( + data_source: crate::datadogV2::model::ApmMetricsDataSource, + name: String, + stat: crate::datadogV2::model::ApmMetricsStat, + ) -> ApmMetricsQuery { + ApmMetricsQuery { + data_source, + group_by: None, + name, + operation_mode: None, + operation_name: None, + peer_tags: None, + query_filter: None, + resource_hash: None, + resource_name: None, + service: None, + span_kind: None, + stat, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn group_by(mut self, value: Vec) -> Self { + self.group_by = Some(value); + self + } + + pub fn operation_mode(mut self, value: String) -> Self { + self.operation_mode = Some(value); + self + } + + pub fn operation_name(mut self, value: String) -> Self { + self.operation_name = Some(value); + self + } + + pub fn peer_tags(mut self, value: Vec) -> Self { + self.peer_tags = Some(value); + self + } + + pub fn query_filter(mut self, value: String) -> Self { + self.query_filter = Some(value); + self + } + + pub fn resource_hash(mut self, value: String) -> Self { + self.resource_hash = Some(value); + self + } + + pub fn resource_name(mut self, value: String) -> Self { + self.resource_name = Some(value); + self + } + + pub fn service(mut self, value: String) -> Self { + self.service = Some(value); + self + } + + pub fn span_kind(mut self, value: String) -> Self { + self.span_kind = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ApmMetricsQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApmMetricsQueryVisitor; + impl<'a> Visitor<'a> for ApmMetricsQueryVisitor { + type Value = ApmMetricsQuery; + + 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_source: Option = None; + let mut group_by: Option> = None; + let mut name: Option = None; + let mut operation_mode: Option = None; + let mut operation_name: Option = None; + let mut peer_tags: Option> = None; + let mut query_filter: Option = None; + let mut resource_hash: Option = None; + let mut resource_name: Option = None; + let mut service: Option = None; + let mut span_kind: Option = None; + let mut stat: 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_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::ApmMetricsDataSource::UnparsedObject(_data_source) => { + _unparsed = true; + }, + _ => {} + } + } + } + "group_by" => { + if v.is_null() { + continue; + } + group_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "operation_mode" => { + if v.is_null() { + continue; + } + operation_mode = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "operation_name" => { + if v.is_null() { + continue; + } + operation_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "peer_tags" => { + if v.is_null() { + continue; + } + peer_tags = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "query_filter" => { + if v.is_null() { + continue; + } + query_filter = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_hash" => { + if v.is_null() { + continue; + } + resource_hash = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_name" => { + if v.is_null() { + continue; + } + resource_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "service" => { + if v.is_null() { + continue; + } + service = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "span_kind" => { + if v.is_null() { + continue; + } + span_kind = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "stat" => { + stat = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _stat) = stat { + match _stat { + crate::datadogV2::model::ApmMetricsStat::UnparsedObject( + _stat, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let stat = stat.ok_or_else(|| M::Error::missing_field("stat"))?; + + let content = ApmMetricsQuery { + data_source, + group_by, + name, + operation_mode, + operation_name, + peer_tags, + query_filter, + resource_hash, + resource_name, + service, + span_kind, + stat, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApmMetricsQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_apm_metrics_stat.rs b/src/datadogV2/model/model_apm_metrics_stat.rs new file mode 100644 index 000000000..14bc8108a --- /dev/null +++ b/src/datadogV2/model/model_apm_metrics_stat.rs @@ -0,0 +1,93 @@ +// 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 ApmMetricsStat { + ERROR_RATE, + ERRORS, + ERRORS_PER_SECOND, + HITS, + HITS_PER_SECOND, + APDEX, + LATENCY_AVG, + LATENCY_MAX, + LATENCY_P50, + LATENCY_P75, + LATENCY_P90, + LATENCY_P95, + LATENCY_P99, + LATENCY_P999, + LATENCY_DISTRIBUTION, + TOTAL_TIME, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ApmMetricsStat { + fn to_string(&self) -> String { + match self { + Self::ERROR_RATE => String::from("error_rate"), + Self::ERRORS => String::from("errors"), + Self::ERRORS_PER_SECOND => String::from("errors_per_second"), + Self::HITS => String::from("hits"), + Self::HITS_PER_SECOND => String::from("hits_per_second"), + Self::APDEX => String::from("apdex"), + Self::LATENCY_AVG => String::from("latency_avg"), + Self::LATENCY_MAX => String::from("latency_max"), + Self::LATENCY_P50 => String::from("latency_p50"), + Self::LATENCY_P75 => String::from("latency_p75"), + Self::LATENCY_P90 => String::from("latency_p90"), + Self::LATENCY_P95 => String::from("latency_p95"), + Self::LATENCY_P99 => String::from("latency_p99"), + Self::LATENCY_P999 => String::from("latency_p999"), + Self::LATENCY_DISTRIBUTION => String::from("latency_distribution"), + Self::TOTAL_TIME => String::from("total_time"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ApmMetricsStat { + 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 ApmMetricsStat { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "error_rate" => Self::ERROR_RATE, + "errors" => Self::ERRORS, + "errors_per_second" => Self::ERRORS_PER_SECOND, + "hits" => Self::HITS, + "hits_per_second" => Self::HITS_PER_SECOND, + "apdex" => Self::APDEX, + "latency_avg" => Self::LATENCY_AVG, + "latency_max" => Self::LATENCY_MAX, + "latency_p50" => Self::LATENCY_P50, + "latency_p75" => Self::LATENCY_P75, + "latency_p90" => Self::LATENCY_P90, + "latency_p95" => Self::LATENCY_P95, + "latency_p99" => Self::LATENCY_P99, + "latency_p999" => Self::LATENCY_P999, + "latency_distribution" => Self::LATENCY_DISTRIBUTION, + "total_time" => Self::TOTAL_TIME, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_apm_resource_stat_name.rs b/src/datadogV2/model/model_apm_resource_stat_name.rs new file mode 100644 index 000000000..3762916af --- /dev/null +++ b/src/datadogV2/model/model_apm_resource_stat_name.rs @@ -0,0 +1,81 @@ +// 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 ApmResourceStatName { + ERROR_RATE, + ERRORS, + HITS, + LATENCY_AVG, + LATENCY_MAX, + LATENCY_P50, + LATENCY_P75, + LATENCY_P90, + LATENCY_P95, + LATENCY_P99, + LATENCY_DISTRIBUTION, + TOTAL_TIME, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ApmResourceStatName { + fn to_string(&self) -> String { + match self { + Self::ERROR_RATE => String::from("error_rate"), + Self::ERRORS => String::from("errors"), + Self::HITS => String::from("hits"), + Self::LATENCY_AVG => String::from("latency_avg"), + Self::LATENCY_MAX => String::from("latency_max"), + Self::LATENCY_P50 => String::from("latency_p50"), + Self::LATENCY_P75 => String::from("latency_p75"), + Self::LATENCY_P90 => String::from("latency_p90"), + Self::LATENCY_P95 => String::from("latency_p95"), + Self::LATENCY_P99 => String::from("latency_p99"), + Self::LATENCY_DISTRIBUTION => String::from("latency_distribution"), + Self::TOTAL_TIME => String::from("total_time"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ApmResourceStatName { + 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 ApmResourceStatName { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "error_rate" => Self::ERROR_RATE, + "errors" => Self::ERRORS, + "hits" => Self::HITS, + "latency_avg" => Self::LATENCY_AVG, + "latency_max" => Self::LATENCY_MAX, + "latency_p50" => Self::LATENCY_P50, + "latency_p75" => Self::LATENCY_P75, + "latency_p90" => Self::LATENCY_P90, + "latency_p95" => Self::LATENCY_P95, + "latency_p99" => Self::LATENCY_P99, + "latency_distribution" => Self::LATENCY_DISTRIBUTION, + "total_time" => Self::TOTAL_TIME, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_apm_resource_stats_data_source.rs b/src/datadogV2/model/model_apm_resource_stats_data_source.rs new file mode 100644 index 000000000..07138797c --- /dev/null +++ b/src/datadogV2/model/model_apm_resource_stats_data_source.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 ApmResourceStatsDataSource { + APM_RESOURCE_STATS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ApmResourceStatsDataSource { + fn to_string(&self) -> String { + match self { + Self::APM_RESOURCE_STATS => String::from("apm_resource_stats"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ApmResourceStatsDataSource { + 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 ApmResourceStatsDataSource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "apm_resource_stats" => Self::APM_RESOURCE_STATS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_apm_resource_stats_query.rs b/src/datadogV2/model/model_apm_resource_stats_query.rs new file mode 100644 index 000000000..9457682c4 --- /dev/null +++ b/src/datadogV2/model/model_apm_resource_stats_query.rs @@ -0,0 +1,246 @@ +// 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}; + +/// An individual APM resource stats query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApmResourceStatsQuery { + /// A data source for APM resource statistics queries. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::ApmResourceStatsDataSource, + /// The environment to query. + #[serde(rename = "env")] + pub env: String, + /// Tag keys to group results by. + #[serde(rename = "group_by")] + pub group_by: Option>, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: String, + /// The APM operation name. + #[serde(rename = "operation_name")] + pub operation_name: Option, + /// Name of the second primary tag used within APM. Required when `primary_tag_value` is specified. See + #[serde(rename = "primary_tag_name")] + pub primary_tag_name: Option, + /// Value of the second primary tag by which to filter APM data. `primary_tag_name` must also be specified. + #[serde(rename = "primary_tag_value")] + pub primary_tag_value: Option, + /// The resource name to filter by. + #[serde(rename = "resource_name")] + pub resource_name: Option, + /// The service name to filter by. + #[serde(rename = "service")] + pub service: String, + /// The APM resource statistic to query. + #[serde(rename = "stat")] + pub stat: crate::datadogV2::model::ApmResourceStatName, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApmResourceStatsQuery { + pub fn new( + data_source: crate::datadogV2::model::ApmResourceStatsDataSource, + env: String, + name: String, + service: String, + stat: crate::datadogV2::model::ApmResourceStatName, + ) -> ApmResourceStatsQuery { + ApmResourceStatsQuery { + data_source, + env, + group_by: None, + name, + operation_name: None, + primary_tag_name: None, + primary_tag_value: None, + resource_name: None, + service, + stat, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn group_by(mut self, value: Vec) -> Self { + self.group_by = Some(value); + self + } + + pub fn operation_name(mut self, value: String) -> Self { + self.operation_name = Some(value); + self + } + + pub fn primary_tag_name(mut self, value: String) -> Self { + self.primary_tag_name = Some(value); + self + } + + pub fn primary_tag_value(mut self, value: String) -> Self { + self.primary_tag_value = Some(value); + self + } + + pub fn resource_name(mut self, value: String) -> Self { + self.resource_name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ApmResourceStatsQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApmResourceStatsQueryVisitor; + impl<'a> Visitor<'a> for ApmResourceStatsQueryVisitor { + type Value = ApmResourceStatsQuery; + + 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_source: Option = + None; + let mut env: Option = None; + let mut group_by: Option> = None; + let mut name: Option = None; + let mut operation_name: Option = None; + let mut primary_tag_name: Option = None; + let mut primary_tag_value: Option = None; + let mut resource_name: Option = None; + let mut service: Option = None; + let mut stat: 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_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::ApmResourceStatsDataSource::UnparsedObject(_data_source) => { + _unparsed = true; + }, + _ => {} + } + } + } + "env" => { + env = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "group_by" => { + if v.is_null() { + continue; + } + group_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "operation_name" => { + if v.is_null() { + continue; + } + operation_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_tag_name" => { + if v.is_null() { + continue; + } + primary_tag_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_tag_value" => { + if v.is_null() { + continue; + } + primary_tag_value = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_name" => { + if v.is_null() { + continue; + } + resource_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "service" => { + service = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "stat" => { + stat = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _stat) = stat { + match _stat { + crate::datadogV2::model::ApmResourceStatName::UnparsedObject(_stat) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let env = env.ok_or_else(|| M::Error::missing_field("env"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let service = service.ok_or_else(|| M::Error::missing_field("service"))?; + let stat = stat.ok_or_else(|| M::Error::missing_field("stat"))?; + + let content = ApmResourceStatsQuery { + data_source, + env, + group_by, + name, + operation_name, + primary_tag_name, + primary_tag_value, + resource_name, + service, + stat, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApmResourceStatsQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_container_data_source.rs b/src/datadogV2/model/model_container_data_source.rs new file mode 100644 index 000000000..6c9c8e5b0 --- /dev/null +++ b/src/datadogV2/model/model_container_data_source.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 ContainerDataSource { + CONTAINER, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ContainerDataSource { + fn to_string(&self) -> String { + match self { + Self::CONTAINER => String::from("container"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ContainerDataSource { + 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 ContainerDataSource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "container" => Self::CONTAINER, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_container_scalar_query.rs b/src/datadogV2/model/model_container_scalar_query.rs new file mode 100644 index 000000000..331bdfe08 --- /dev/null +++ b/src/datadogV2/model/model_container_scalar_query.rs @@ -0,0 +1,231 @@ +// 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}; + +/// An individual scalar container query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ContainerScalarQuery { + /// The temporal reduction function to apply. + #[serde(rename = "aggregator")] + pub aggregator: Option, + /// A data source for container-level infrastructure metrics. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::ContainerDataSource, + /// Whether CPU metrics should be normalized by core count. + #[serde(rename = "is_normalized_cpu")] + pub is_normalized_cpu: Option, + /// Maximum number of timeseries to return. + #[serde(rename = "limit")] + pub limit: Option, + /// The container metric to query. + #[serde(rename = "metric")] + pub metric: String, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: String, + /// Sort order for the results. + #[serde(rename = "sort")] + pub sort: Option, + /// Tag filters to narrow down containers. + #[serde(rename = "tag_filters")] + pub tag_filters: Option>, + /// A full-text search filter to match container names. + #[serde(rename = "text_filter")] + pub text_filter: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ContainerScalarQuery { + pub fn new( + data_source: crate::datadogV2::model::ContainerDataSource, + metric: String, + name: String, + ) -> ContainerScalarQuery { + ContainerScalarQuery { + aggregator: None, + data_source, + is_normalized_cpu: None, + limit: None, + metric, + name, + sort: None, + tag_filters: None, + text_filter: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aggregator(mut self, value: String) -> Self { + self.aggregator = Some(value); + self + } + + pub fn is_normalized_cpu(mut self, value: bool) -> Self { + self.is_normalized_cpu = Some(value); + self + } + + pub fn limit(mut self, value: i64) -> Self { + self.limit = Some(value); + self + } + + pub fn sort(mut self, value: String) -> Self { + self.sort = Some(value); + self + } + + pub fn tag_filters(mut self, value: Vec) -> Self { + self.tag_filters = Some(value); + self + } + + pub fn text_filter(mut self, value: String) -> Self { + self.text_filter = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ContainerScalarQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ContainerScalarQueryVisitor; + impl<'a> Visitor<'a> for ContainerScalarQueryVisitor { + type Value = ContainerScalarQuery; + + 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 aggregator: Option = None; + let mut data_source: Option = None; + let mut is_normalized_cpu: Option = None; + let mut limit: Option = None; + let mut metric: Option = None; + let mut name: Option = None; + let mut sort: Option = None; + let mut tag_filters: Option> = None; + let mut text_filter: 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() { + "aggregator" => { + if v.is_null() { + continue; + } + aggregator = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "data_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::ContainerDataSource::UnparsedObject(_data_source) => { + _unparsed = true; + }, + _ => {} + } + } + } + "is_normalized_cpu" => { + if v.is_null() { + continue; + } + is_normalized_cpu = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "limit" => { + if v.is_null() { + continue; + } + limit = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metric" => { + metric = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sort" => { + if v.is_null() { + continue; + } + sort = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tag_filters" => { + if v.is_null() { + continue; + } + tag_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "text_filter" => { + if v.is_null() { + continue; + } + text_filter = + 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_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let metric = metric.ok_or_else(|| M::Error::missing_field("metric"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = ContainerScalarQuery { + aggregator, + data_source, + is_normalized_cpu, + limit, + metric, + name, + sort, + tag_filters, + text_filter, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ContainerScalarQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_container_timeseries_query.rs b/src/datadogV2/model/model_container_timeseries_query.rs new file mode 100644 index 000000000..e4562c5e5 --- /dev/null +++ b/src/datadogV2/model/model_container_timeseries_query.rs @@ -0,0 +1,214 @@ +// 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}; + +/// An individual timeseries container query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ContainerTimeseriesQuery { + /// A data source for container-level infrastructure metrics. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::ContainerDataSource, + /// Whether CPU metrics should be normalized by core count. + #[serde(rename = "is_normalized_cpu")] + pub is_normalized_cpu: Option, + /// Maximum number of timeseries to return. + #[serde(rename = "limit")] + pub limit: Option, + /// The container metric to query. + #[serde(rename = "metric")] + pub metric: String, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: String, + /// Sort order for the results. + #[serde(rename = "sort")] + pub sort: Option, + /// Tag filters to narrow down containers. + #[serde(rename = "tag_filters")] + pub tag_filters: Option>, + /// A full-text search filter to match container names. + #[serde(rename = "text_filter")] + pub text_filter: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ContainerTimeseriesQuery { + pub fn new( + data_source: crate::datadogV2::model::ContainerDataSource, + metric: String, + name: String, + ) -> ContainerTimeseriesQuery { + ContainerTimeseriesQuery { + data_source, + is_normalized_cpu: None, + limit: None, + metric, + name, + sort: None, + tag_filters: None, + text_filter: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn is_normalized_cpu(mut self, value: bool) -> Self { + self.is_normalized_cpu = Some(value); + self + } + + pub fn limit(mut self, value: i64) -> Self { + self.limit = Some(value); + self + } + + pub fn sort(mut self, value: String) -> Self { + self.sort = Some(value); + self + } + + pub fn tag_filters(mut self, value: Vec) -> Self { + self.tag_filters = Some(value); + self + } + + pub fn text_filter(mut self, value: String) -> Self { + self.text_filter = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ContainerTimeseriesQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ContainerTimeseriesQueryVisitor; + impl<'a> Visitor<'a> for ContainerTimeseriesQueryVisitor { + type Value = ContainerTimeseriesQuery; + + 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_source: Option = None; + let mut is_normalized_cpu: Option = None; + let mut limit: Option = None; + let mut metric: Option = None; + let mut name: Option = None; + let mut sort: Option = None; + let mut tag_filters: Option> = None; + let mut text_filter: 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_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::ContainerDataSource::UnparsedObject(_data_source) => { + _unparsed = true; + }, + _ => {} + } + } + } + "is_normalized_cpu" => { + if v.is_null() { + continue; + } + is_normalized_cpu = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "limit" => { + if v.is_null() { + continue; + } + limit = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metric" => { + metric = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sort" => { + if v.is_null() { + continue; + } + sort = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tag_filters" => { + if v.is_null() { + continue; + } + tag_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "text_filter" => { + if v.is_null() { + continue; + } + text_filter = + 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_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let metric = metric.ok_or_else(|| M::Error::missing_field("metric"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = ContainerTimeseriesQuery { + data_source, + is_normalized_cpu, + limit, + metric, + name, + sort, + tag_filters, + text_filter, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ContainerTimeseriesQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_events_data_source.rs b/src/datadogV2/model/model_events_data_source.rs index 56f37386d..46138cbe6 100644 --- a/src/datadogV2/model/model_events_data_source.rs +++ b/src/datadogV2/model/model_events_data_source.rs @@ -8,7 +8,18 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[derive(Clone, Debug, Eq, PartialEq)] pub enum EventsDataSource { LOGS, + SPANS, + NETWORK, RUM, + SECURITY_SIGNALS, + PROFILES, + AUDIT, + EVENTS, + CI_TESTS, + CI_PIPELINES, + INCIDENT_ANALYTICS, + PRODUCT_ANALYTICS, + ON_CALL_EVENTS, DORA, UnparsedObject(crate::datadog::UnparsedObject), } @@ -17,7 +28,18 @@ impl ToString for EventsDataSource { fn to_string(&self) -> String { match self { Self::LOGS => String::from("logs"), + Self::SPANS => String::from("spans"), + Self::NETWORK => String::from("network"), Self::RUM => String::from("rum"), + Self::SECURITY_SIGNALS => String::from("security_signals"), + Self::PROFILES => String::from("profiles"), + Self::AUDIT => String::from("audit"), + Self::EVENTS => String::from("events"), + Self::CI_TESTS => String::from("ci_tests"), + Self::CI_PIPELINES => String::from("ci_pipelines"), + Self::INCIDENT_ANALYTICS => String::from("incident_analytics"), + Self::PRODUCT_ANALYTICS => String::from("product_analytics"), + Self::ON_CALL_EVENTS => String::from("on_call_events"), Self::DORA => String::from("dora"), Self::UnparsedObject(v) => v.value.to_string(), } @@ -44,7 +66,18 @@ impl<'de> Deserialize<'de> for EventsDataSource { let s: String = String::deserialize(deserializer)?; Ok(match s.as_str() { "logs" => Self::LOGS, + "spans" => Self::SPANS, + "network" => Self::NETWORK, "rum" => Self::RUM, + "security_signals" => Self::SECURITY_SIGNALS, + "profiles" => Self::PROFILES, + "audit" => Self::AUDIT, + "events" => Self::EVENTS, + "ci_tests" => Self::CI_TESTS, + "ci_pipelines" => Self::CI_PIPELINES, + "incident_analytics" => Self::INCIDENT_ANALYTICS, + "product_analytics" => Self::PRODUCT_ANALYTICS, + "on_call_events" => Self::ON_CALL_EVENTS, "dora" => Self::DORA, _ => Self::UnparsedObject(crate::datadog::UnparsedObject { value: serde_json::Value::String(s.into()), diff --git a/src/datadogV2/model/model_process_data_source.rs b/src/datadogV2/model/model_process_data_source.rs new file mode 100644 index 000000000..d3158cd86 --- /dev/null +++ b/src/datadogV2/model/model_process_data_source.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 ProcessDataSource { + PROCESS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ProcessDataSource { + fn to_string(&self) -> String { + match self { + Self::PROCESS => String::from("process"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ProcessDataSource { + 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 ProcessDataSource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "process" => Self::PROCESS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_process_scalar_query.rs b/src/datadogV2/model/model_process_scalar_query.rs new file mode 100644 index 000000000..d927a300e --- /dev/null +++ b/src/datadogV2/model/model_process_scalar_query.rs @@ -0,0 +1,233 @@ +// 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}; + +/// An individual scalar process query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ProcessScalarQuery { + /// The temporal reduction function to apply. + #[serde(rename = "aggregator")] + pub aggregator: Option, + /// A data source for process-level infrastructure metrics. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::ProcessDataSource, + /// Whether CPU metrics should be normalized by core count. + #[serde(rename = "is_normalized_cpu")] + pub is_normalized_cpu: Option, + /// Maximum number of timeseries to return. + #[serde(rename = "limit")] + pub limit: Option, + /// The process metric to query. + #[serde(rename = "metric")] + pub metric: String, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: String, + /// Sort order for the results. + #[serde(rename = "sort")] + pub sort: Option, + /// Tag filters to narrow down processes. + #[serde(rename = "tag_filters")] + pub tag_filters: Option>, + /// A full-text search filter to match process names or commands. + #[serde(rename = "text_filter")] + pub text_filter: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ProcessScalarQuery { + pub fn new( + data_source: crate::datadogV2::model::ProcessDataSource, + metric: String, + name: String, + ) -> ProcessScalarQuery { + ProcessScalarQuery { + aggregator: None, + data_source, + is_normalized_cpu: None, + limit: None, + metric, + name, + sort: None, + tag_filters: None, + text_filter: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn aggregator(mut self, value: String) -> Self { + self.aggregator = Some(value); + self + } + + pub fn is_normalized_cpu(mut self, value: bool) -> Self { + self.is_normalized_cpu = Some(value); + self + } + + pub fn limit(mut self, value: i64) -> Self { + self.limit = Some(value); + self + } + + pub fn sort(mut self, value: String) -> Self { + self.sort = Some(value); + self + } + + pub fn tag_filters(mut self, value: Vec) -> Self { + self.tag_filters = Some(value); + self + } + + pub fn text_filter(mut self, value: String) -> Self { + self.text_filter = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ProcessScalarQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ProcessScalarQueryVisitor; + impl<'a> Visitor<'a> for ProcessScalarQueryVisitor { + type Value = ProcessScalarQuery; + + 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 aggregator: Option = None; + let mut data_source: Option = None; + let mut is_normalized_cpu: Option = None; + let mut limit: Option = None; + let mut metric: Option = None; + let mut name: Option = None; + let mut sort: Option = None; + let mut tag_filters: Option> = None; + let mut text_filter: 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() { + "aggregator" => { + if v.is_null() { + continue; + } + aggregator = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "data_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::ProcessDataSource::UnparsedObject( + _data_source, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "is_normalized_cpu" => { + if v.is_null() { + continue; + } + is_normalized_cpu = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "limit" => { + if v.is_null() { + continue; + } + limit = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metric" => { + metric = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sort" => { + if v.is_null() { + continue; + } + sort = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tag_filters" => { + if v.is_null() { + continue; + } + tag_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "text_filter" => { + if v.is_null() { + continue; + } + text_filter = + 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_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let metric = metric.ok_or_else(|| M::Error::missing_field("metric"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = ProcessScalarQuery { + aggregator, + data_source, + is_normalized_cpu, + limit, + metric, + name, + sort, + tag_filters, + text_filter, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ProcessScalarQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_process_timeseries_query.rs b/src/datadogV2/model/model_process_timeseries_query.rs new file mode 100644 index 000000000..586b08823 --- /dev/null +++ b/src/datadogV2/model/model_process_timeseries_query.rs @@ -0,0 +1,216 @@ +// 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}; + +/// An individual timeseries process query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ProcessTimeseriesQuery { + /// A data source for process-level infrastructure metrics. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::ProcessDataSource, + /// Whether CPU metrics should be normalized by core count. + #[serde(rename = "is_normalized_cpu")] + pub is_normalized_cpu: Option, + /// Maximum number of timeseries to return. + #[serde(rename = "limit")] + pub limit: Option, + /// The process metric to query. + #[serde(rename = "metric")] + pub metric: String, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: String, + /// Sort order for the results. + #[serde(rename = "sort")] + pub sort: Option, + /// Tag filters to narrow down processes. + #[serde(rename = "tag_filters")] + pub tag_filters: Option>, + /// A full-text search filter to match process names or commands. + #[serde(rename = "text_filter")] + pub text_filter: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ProcessTimeseriesQuery { + pub fn new( + data_source: crate::datadogV2::model::ProcessDataSource, + metric: String, + name: String, + ) -> ProcessTimeseriesQuery { + ProcessTimeseriesQuery { + data_source, + is_normalized_cpu: None, + limit: None, + metric, + name, + sort: None, + tag_filters: None, + text_filter: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn is_normalized_cpu(mut self, value: bool) -> Self { + self.is_normalized_cpu = Some(value); + self + } + + pub fn limit(mut self, value: i64) -> Self { + self.limit = Some(value); + self + } + + pub fn sort(mut self, value: String) -> Self { + self.sort = Some(value); + self + } + + pub fn tag_filters(mut self, value: Vec) -> Self { + self.tag_filters = Some(value); + self + } + + pub fn text_filter(mut self, value: String) -> Self { + self.text_filter = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ProcessTimeseriesQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ProcessTimeseriesQueryVisitor; + impl<'a> Visitor<'a> for ProcessTimeseriesQueryVisitor { + type Value = ProcessTimeseriesQuery; + + 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_source: Option = None; + let mut is_normalized_cpu: Option = None; + let mut limit: Option = None; + let mut metric: Option = None; + let mut name: Option = None; + let mut sort: Option = None; + let mut tag_filters: Option> = None; + let mut text_filter: 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_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::ProcessDataSource::UnparsedObject( + _data_source, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "is_normalized_cpu" => { + if v.is_null() { + continue; + } + is_normalized_cpu = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "limit" => { + if v.is_null() { + continue; + } + limit = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metric" => { + metric = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sort" => { + if v.is_null() { + continue; + } + sort = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tag_filters" => { + if v.is_null() { + continue; + } + tag_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "text_filter" => { + if v.is_null() { + continue; + } + text_filter = + 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_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let metric = metric.ok_or_else(|| M::Error::missing_field("metric"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = ProcessTimeseriesQuery { + data_source, + is_normalized_cpu, + limit, + metric, + name, + sort, + tag_filters, + text_filter, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ProcessTimeseriesQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_scalar_query.rs b/src/datadogV2/model/model_scalar_query.rs index e06ec3321..ddeb26eb6 100644 --- a/src/datadogV2/model/model_scalar_query.rs +++ b/src/datadogV2/model/model_scalar_query.rs @@ -10,6 +10,12 @@ use serde::{Deserialize, Deserializer, Serialize}; pub enum ScalarQuery { MetricsScalarQuery(Box), EventsScalarQuery(Box), + ApmResourceStatsQuery(Box), + ApmMetricsQuery(Box), + ApmDependencyStatsQuery(Box), + SloQuery(Box), + ProcessScalarQuery(Box), + ContainerScalarQuery(Box), UnparsedObject(crate::datadog::UnparsedObject), } @@ -33,6 +39,49 @@ impl<'de> Deserialize<'de> for ScalarQuery { return Ok(ScalarQuery::EventsScalarQuery(_v)); } } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(ScalarQuery::ApmResourceStatsQuery(_v)); + } + } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(ScalarQuery::ApmMetricsQuery(_v)); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(ScalarQuery::ApmDependencyStatsQuery(_v)); + } + } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(ScalarQuery::SloQuery(_v)); + } + } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(ScalarQuery::ProcessScalarQuery(_v)); + } + } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(ScalarQuery::ContainerScalarQuery(_v)); + } + } return Ok(ScalarQuery::UnparsedObject( crate::datadog::UnparsedObject { value }, diff --git a/src/datadogV2/model/model_slo_data_source.rs b/src/datadogV2/model/model_slo_data_source.rs new file mode 100644 index 000000000..7425a37ef --- /dev/null +++ b/src/datadogV2/model/model_slo_data_source.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 SloDataSource { + SLO, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SloDataSource { + fn to_string(&self) -> String { + match self { + Self::SLO => String::from("slo"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SloDataSource { + 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 SloDataSource { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "slo" => Self::SLO, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_slo_query.rs b/src/datadogV2/model/model_slo_query.rs new file mode 100644 index 000000000..a3078128a --- /dev/null +++ b/src/datadogV2/model/model_slo_query.rs @@ -0,0 +1,228 @@ +// 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}; + +/// An individual SLO query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct SloQuery { + /// Additional filters applied to the SLO query. + #[serde(rename = "additional_query_filters")] + pub additional_query_filters: Option, + /// A data source for SLO queries. + #[serde(rename = "data_source")] + pub data_source: crate::datadogV2::model::SloDataSource, + /// How SLO results are grouped in the response. + #[serde(rename = "group_mode")] + pub group_mode: Option, + /// The SLO measurement to retrieve. + #[serde(rename = "measure")] + pub measure: crate::datadogV2::model::SlosMeasure, + /// The variable name for use in formulas. + #[serde(rename = "name")] + pub name: Option, + /// The unique identifier of the SLO to query. + #[serde(rename = "slo_id")] + pub slo_id: String, + /// The type of SLO definition being queried. + #[serde(rename = "slo_query_type")] + pub slo_query_type: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl SloQuery { + pub fn new( + data_source: crate::datadogV2::model::SloDataSource, + measure: crate::datadogV2::model::SlosMeasure, + slo_id: String, + ) -> SloQuery { + SloQuery { + additional_query_filters: None, + data_source, + group_mode: None, + measure, + name: None, + slo_id, + slo_query_type: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_query_filters(mut self, value: String) -> Self { + self.additional_query_filters = Some(value); + self + } + + pub fn group_mode(mut self, value: crate::datadogV2::model::SlosGroupMode) -> Self { + self.group_mode = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn slo_query_type(mut self, value: crate::datadogV2::model::SlosQueryType) -> Self { + self.slo_query_type = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for SloQuery { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct SloQueryVisitor; + impl<'a> Visitor<'a> for SloQueryVisitor { + type Value = SloQuery; + + 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 additional_query_filters: Option = None; + let mut data_source: Option = None; + let mut group_mode: Option = None; + let mut measure: Option = None; + let mut name: Option = None; + let mut slo_id: Option = None; + let mut slo_query_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() { + "additional_query_filters" => { + if v.is_null() { + continue; + } + additional_query_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "data_source" => { + data_source = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _data_source) = data_source { + match _data_source { + crate::datadogV2::model::SloDataSource::UnparsedObject( + _data_source, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "group_mode" => { + if v.is_null() { + continue; + } + group_mode = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _group_mode) = group_mode { + match _group_mode { + crate::datadogV2::model::SlosGroupMode::UnparsedObject( + _group_mode, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "measure" => { + measure = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _measure) = measure { + match _measure { + crate::datadogV2::model::SlosMeasure::UnparsedObject( + _measure, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "slo_id" => { + slo_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "slo_query_type" => { + if v.is_null() { + continue; + } + slo_query_type = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _slo_query_type) = slo_query_type { + match _slo_query_type { + crate::datadogV2::model::SlosQueryType::UnparsedObject( + _slo_query_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data_source = + data_source.ok_or_else(|| M::Error::missing_field("data_source"))?; + let measure = measure.ok_or_else(|| M::Error::missing_field("measure"))?; + let slo_id = slo_id.ok_or_else(|| M::Error::missing_field("slo_id"))?; + + let content = SloQuery { + additional_query_filters, + data_source, + group_mode, + measure, + name, + slo_id, + slo_query_type, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(SloQueryVisitor) + } +} diff --git a/src/datadogV2/model/model_slos_group_mode.rs b/src/datadogV2/model/model_slos_group_mode.rs new file mode 100644 index 000000000..ea68c3bb7 --- /dev/null +++ b/src/datadogV2/model/model_slos_group_mode.rs @@ -0,0 +1,51 @@ +// 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 SlosGroupMode { + OVERALL, + COMPONENTS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SlosGroupMode { + fn to_string(&self) -> String { + match self { + Self::OVERALL => String::from("overall"), + Self::COMPONENTS => String::from("components"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SlosGroupMode { + 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 SlosGroupMode { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "overall" => Self::OVERALL, + "components" => Self::COMPONENTS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_slos_measure.rs b/src/datadogV2/model/model_slos_measure.rs new file mode 100644 index 000000000..bbf730b09 --- /dev/null +++ b/src/datadogV2/model/model_slos_measure.rs @@ -0,0 +1,75 @@ +// 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 SlosMeasure { + GOOD_EVENTS, + BAD_EVENTS, + SLO_STATUS, + ERROR_BUDGET_REMAINING, + ERROR_BUDGET_REMAINING_HISTORY, + ERROR_BUDGET_BURNDOWN, + BURN_RATE, + SLO_STATUS_HISTORY, + GOOD_MINUTES, + BAD_MINUTES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SlosMeasure { + fn to_string(&self) -> String { + match self { + Self::GOOD_EVENTS => String::from("good_events"), + Self::BAD_EVENTS => String::from("bad_events"), + Self::SLO_STATUS => String::from("slo_status"), + Self::ERROR_BUDGET_REMAINING => String::from("error_budget_remaining"), + Self::ERROR_BUDGET_REMAINING_HISTORY => String::from("error_budget_remaining_history"), + Self::ERROR_BUDGET_BURNDOWN => String::from("error_budget_burndown"), + Self::BURN_RATE => String::from("burn_rate"), + Self::SLO_STATUS_HISTORY => String::from("slo_status_history"), + Self::GOOD_MINUTES => String::from("good_minutes"), + Self::BAD_MINUTES => String::from("bad_minutes"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SlosMeasure { + 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 SlosMeasure { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "good_events" => Self::GOOD_EVENTS, + "bad_events" => Self::BAD_EVENTS, + "slo_status" => Self::SLO_STATUS, + "error_budget_remaining" => Self::ERROR_BUDGET_REMAINING, + "error_budget_remaining_history" => Self::ERROR_BUDGET_REMAINING_HISTORY, + "error_budget_burndown" => Self::ERROR_BUDGET_BURNDOWN, + "burn_rate" => Self::BURN_RATE, + "slo_status_history" => Self::SLO_STATUS_HISTORY, + "good_minutes" => Self::GOOD_MINUTES, + "bad_minutes" => Self::BAD_MINUTES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_slos_query_type.rs b/src/datadogV2/model/model_slos_query_type.rs new file mode 100644 index 000000000..43a80fb4d --- /dev/null +++ b/src/datadogV2/model/model_slos_query_type.rs @@ -0,0 +1,54 @@ +// 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 SlosQueryType { + METRIC, + TIME_SLICE, + MONITOR, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SlosQueryType { + fn to_string(&self) -> String { + match self { + Self::METRIC => String::from("metric"), + Self::TIME_SLICE => String::from("time_slice"), + Self::MONITOR => String::from("monitor"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SlosQueryType { + 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 SlosQueryType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "metric" => Self::METRIC, + "time_slice" => Self::TIME_SLICE, + "monitor" => Self::MONITOR, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_timeseries_query.rs b/src/datadogV2/model/model_timeseries_query.rs index 4c2b25be7..86c85d3c1 100644 --- a/src/datadogV2/model/model_timeseries_query.rs +++ b/src/datadogV2/model/model_timeseries_query.rs @@ -10,6 +10,12 @@ use serde::{Deserialize, Deserializer, Serialize}; pub enum TimeseriesQuery { MetricsTimeseriesQuery(Box), EventsTimeseriesQuery(Box), + ApmResourceStatsQuery(Box), + ApmMetricsQuery(Box), + ApmDependencyStatsQuery(Box), + SloQuery(Box), + ProcessTimeseriesQuery(Box), + ContainerTimeseriesQuery(Box), UnparsedObject(crate::datadog::UnparsedObject), } @@ -33,6 +39,50 @@ impl<'de> Deserialize<'de> for TimeseriesQuery { return Ok(TimeseriesQuery::EventsTimeseriesQuery(_v)); } } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(TimeseriesQuery::ApmResourceStatsQuery(_v)); + } + } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(TimeseriesQuery::ApmMetricsQuery(_v)); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(TimeseriesQuery::ApmDependencyStatsQuery(_v)); + } + } + if let Ok(_v) = + serde_json::from_value::>(value.clone()) + { + if !_v._unparsed { + return Ok(TimeseriesQuery::SloQuery(_v)); + } + } + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(TimeseriesQuery::ProcessTimeseriesQuery(_v)); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(TimeseriesQuery::ContainerTimeseriesQuery(_v)); + } + } return Ok(TimeseriesQuery::UnparsedObject( crate::datadog::UnparsedObject { value }, diff --git a/tests/scenarios/features/v2/metrics.feature b/tests/scenarios/features/v2/metrics.feature index 41e753dfb..c880fa0d2 100644 --- a/tests/scenarios/features/v2/metrics.feature +++ b/tests/scenarios/features/v2/metrics.feature @@ -344,6 +344,60 @@ Feature: Metrics And the response "data.type" is equal to "scalar_response" And the response "data.attributes.columns[0].name" is equal to "a" + @skip-validation @team:Datadog/timeseries-query + Scenario: Scalar cross product query with apm_dependency_stats data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "queries": [{"data_source": "apm_dependency_stats", "name": "a", "env": "ci", "service": "cassandra", "stat": "avg_duration", "operation_name": "cassandra.query", "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?", "primary_tag_name": "datacenter", "primary_tag_value": "edge-eu1.prod.dog"}], "to": {{ timestamp('now') }}000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "scalar_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Scalar cross product query with apm_metrics data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "queries": [{"data_source": "apm_metrics", "name": "a", "stat": "hits", "service": "web-store", "query_filter": "env:prod", "group_by": ["resource_name"]}], "to": {{ timestamp('now') }}000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "scalar_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Scalar cross product query with apm_resource_stats data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "queries": [{"data_source": "apm_resource_stats", "name": "a", "env": "staging", "service": "azure-bill-import", "stat": "hits", "operation_name": "cassandra.query", "group_by": ["resource_name"], "primary_tag_name": "datacenter", "primary_tag_value": "*"}], "to": {{ timestamp('now') }}000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "scalar_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Scalar cross product query with container data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "queries": [{"data_source": "container", "name": "a", "metric": "process.stat.container.cpu.system_pct", "aggregator": "avg", "tag_filters": [], "limit": 10, "sort": "desc"}], "to": {{ timestamp('now') }}000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "scalar_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Scalar cross product query with process data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "queries": [{"data_source": "process", "name": "a", "metric": "process.stat.cpu.total_pct", "aggregator": "avg", "text_filter": "", "tag_filters": [], "limit": 10, "sort": "desc", "is_normalized_cpu": false}], "to": {{ timestamp('now') }}000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "scalar_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Scalar cross product query with slo data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "queries": [{"data_source": "slo", "name": "a", "slo_id": "12345678910", "measure": "slo_status", "slo_query_type": "metric", "group_mode": "overall", "additional_query_filters": "*"}], "to": {{ timestamp('now') }}000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "scalar_response" + @generated @skip @team:DataDog/metrics-intake Scenario: Submit metrics returns "Bad Request" response Given new "SubmitMetrics" request @@ -415,6 +469,60 @@ Feature: Metrics Then the response status is 200 OK And the response "data.type" is equal to "timeseries_response" + @skip-validation @team:Datadog/timeseries-query + Scenario: Timeseries cross product query with apm_dependency_stats data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "apm_dependency_stats", "name": "a", "env": "ci", "service": "cassandra", "stat": "avg_duration", "operation_name": "cassandra.query", "resource_name": "DELETE FROM monitor_history.monitor_state_change_history WHERE org_id = ? AND monitor_id IN ? AND group = ?", "primary_tag_name": "datacenter", "primary_tag_value": "edge-eu1.prod.dog"}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "timeseries_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Timeseries cross product query with apm_metrics data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "apm_metrics", "name": "a", "stat": "hits", "service": "web-store", "query_filter": "env:prod", "group_by": ["resource_name"]}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "timeseries_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Timeseries cross product query with apm_resource_stats data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "apm_resource_stats", "name": "a", "env": "staging", "service": "azure-bill-import", "stat": "hits", "operation_name": "cassandra.query", "group_by": ["resource_name"], "primary_tag_name": "datacenter", "primary_tag_value": "*"}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "timeseries_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Timeseries cross product query with container data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "container", "name": "a", "metric": "process.stat.container.cpu.system_pct", "tag_filters": [], "limit": 10, "sort": "desc"}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "timeseries_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Timeseries cross product query with process data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "process", "name": "a", "metric": "process.stat.cpu.total_pct", "text_filter": "", "tag_filters": [], "limit": 10, "sort": "desc", "is_normalized_cpu": false}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "timeseries_response" + + @skip-validation @team:Datadog/timeseries-query + Scenario: Timeseries cross product query with slo data source returns "OK" response + Given a valid "appKeyAuth" key in the system + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}000, "interval": 5000, "queries": [{"data_source": "slo", "name": "a", "slo_id": "12345678910", "measure": "slo_status", "slo_query_type": "metric", "group_mode": "overall", "additional_query_filters": "*"}], "to": {{ timestamp('now') }}000}, "type": "timeseries_request"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "timeseries_response" + @generated @skip @team:DataDog/metrics-experience Scenario: Update a tag configuration returns "Bad Request" response Given a valid "appKeyAuth" key in the system