Skip to content

Commit 12fc173

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Update Get All Notification Rules API docs to include pagination, sorting, and filtering params (#894)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 5573c9c commit 12fc173

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58413,6 +58413,47 @@ paths:
5841358413
description: Returns a list of all monitor notification rules.
5841458414
operationId: GetMonitorNotificationRules
5841558415
parameters:
58416+
- description: The page to start paginating from. If `page` is not specified,
58417+
the argument defaults to the first page.
58418+
in: query
58419+
name: page
58420+
required: false
58421+
schema:
58422+
format: int32
58423+
maximum: 1000000
58424+
minimum: 0
58425+
type: integer
58426+
- description: The number of rules to return per page. If `per_page` is not
58427+
specified, the argument defaults to 100.
58428+
in: query
58429+
name: per_page
58430+
required: false
58431+
schema:
58432+
format: int32
58433+
maximum: 1000
58434+
minimum: 1
58435+
type: integer
58436+
- description: 'String for sort order, composed of field and sort order separated
58437+
by a colon, for example `name:asc`. Supported sort directions: `asc`, `desc`.
58438+
Supported fields: `name`, `created_at`.'
58439+
in: query
58440+
name: sort
58441+
required: false
58442+
schema:
58443+
type: string
58444+
- description: 'JSON-encoded filter object. Supported keys:
58445+
58446+
* `text`: Free-text query matched against rule name, tags, and recipients.
58447+
58448+
* `tags`: Array of strings. Return rules that have any of these tags.
58449+
58450+
* `recipients`: Array of strings. Return rules that have any of these recipients.'
58451+
example: '{"text":"error","tags":["env:prod","team:my-team"],"recipients":["slack-monitor-app","[email protected]"]}'
58452+
in: query
58453+
name: filters
58454+
required: false
58455+
schema:
58456+
type: string
5841658457
- description: 'Comma-separated list of resource paths for related resources
5841758458
to include in the response. Supported resource
5841858459

src/datadogV2/api/api_monitors.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,46 @@ impl GetMonitorNotificationRuleOptionalParams {
3333
#[non_exhaustive]
3434
#[derive(Clone, Default, Debug)]
3535
pub struct GetMonitorNotificationRulesOptionalParams {
36+
/// The page to start paginating from. If `page` is not specified, the argument defaults to the first page.
37+
pub page: Option<i32>,
38+
/// The number of rules to return per page. If `per_page` is not specified, the argument defaults to 100.
39+
pub per_page: Option<i32>,
40+
/// String for sort order, composed of field and sort order separated by a colon, for example `name:asc`. Supported sort directions: `asc`, `desc`. Supported fields: `name`, `created_at`.
41+
pub sort: Option<String>,
42+
/// JSON-encoded filter object. Supported keys:
43+
/// * `text`: Free-text query matched against rule name, tags, and recipients.
44+
/// * `tags`: Array of strings. Return rules that have any of these tags.
45+
/// * `recipients`: Array of strings. Return rules that have any of these recipients.
46+
pub filters: Option<String>,
3647
/// Comma-separated list of resource paths for related resources to include in the response. Supported resource
3748
/// path is `created_by`.
3849
pub include: Option<String>,
3950
}
4051

4152
impl GetMonitorNotificationRulesOptionalParams {
53+
/// The page to start paginating from. If `page` is not specified, the argument defaults to the first page.
54+
pub fn page(mut self, value: i32) -> Self {
55+
self.page = Some(value);
56+
self
57+
}
58+
/// The number of rules to return per page. If `per_page` is not specified, the argument defaults to 100.
59+
pub fn per_page(mut self, value: i32) -> Self {
60+
self.per_page = Some(value);
61+
self
62+
}
63+
/// String for sort order, composed of field and sort order separated by a colon, for example `name:asc`. Supported sort directions: `asc`, `desc`. Supported fields: `name`, `created_at`.
64+
pub fn sort(mut self, value: String) -> Self {
65+
self.sort = Some(value);
66+
self
67+
}
68+
/// JSON-encoded filter object. Supported keys:
69+
/// * `text`: Free-text query matched against rule name, tags, and recipients.
70+
/// * `tags`: Array of strings. Return rules that have any of these tags.
71+
/// * `recipients`: Array of strings. Return rules that have any of these recipients.
72+
pub fn filters(mut self, value: String) -> Self {
73+
self.filters = Some(value);
74+
self
75+
}
4276
/// Comma-separated list of resource paths for related resources to include in the response. Supported resource
4377
/// path is `created_by`.
4478
pub fn include(mut self, value: String) -> Self {
@@ -1294,6 +1328,10 @@ impl MonitorsAPI {
12941328
let operation_id = "v2.get_monitor_notification_rules";
12951329

12961330
// unbox and build optional parameters
1331+
let page = params.page;
1332+
let per_page = params.per_page;
1333+
let sort = params.sort;
1334+
let filters = params.filters;
12971335
let include = params.include;
12981336

12991337
let local_client = &self.client;
@@ -1305,6 +1343,22 @@ impl MonitorsAPI {
13051343
let mut local_req_builder =
13061344
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
13071345

1346+
if let Some(ref local_query_param) = page {
1347+
local_req_builder =
1348+
local_req_builder.query(&[("page", &local_query_param.to_string())]);
1349+
};
1350+
if let Some(ref local_query_param) = per_page {
1351+
local_req_builder =
1352+
local_req_builder.query(&[("per_page", &local_query_param.to_string())]);
1353+
};
1354+
if let Some(ref local_query_param) = sort {
1355+
local_req_builder =
1356+
local_req_builder.query(&[("sort", &local_query_param.to_string())]);
1357+
};
1358+
if let Some(ref local_query_param) = filters {
1359+
local_req_builder =
1360+
local_req_builder.query(&[("filters", &local_query_param.to_string())]);
1361+
};
13081362
if let Some(ref local_query_param) = include {
13091363
local_req_builder =
13101364
local_req_builder.query(&[("include", &local_query_param.to_string())]);

tests/scenarios/function_mappings.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23396,10 +23396,26 @@ fn test_v2_get_monitor_notification_rules(
2339623396
.v2_api_monitors
2339723397
.as_ref()
2339823398
.expect("api instance not found");
23399+
let page = _parameters
23400+
.get("page")
23401+
.and_then(|param| Some(serde_json::from_value(param.clone()).unwrap()));
23402+
let per_page = _parameters
23403+
.get("per_page")
23404+
.and_then(|param| Some(serde_json::from_value(param.clone()).unwrap()));
23405+
let sort = _parameters
23406+
.get("sort")
23407+
.and_then(|param| Some(serde_json::from_value(param.clone()).unwrap()));
23408+
let filters = _parameters
23409+
.get("filters")
23410+
.and_then(|param| Some(serde_json::from_value(param.clone()).unwrap()));
2339923411
let include = _parameters
2340023412
.get("include")
2340123413
.and_then(|param| Some(serde_json::from_value(param.clone()).unwrap()));
2340223414
let mut params = datadogV2::api_monitors::GetMonitorNotificationRulesOptionalParams::default();
23415+
params.page = page;
23416+
params.per_page = per_page;
23417+
params.sort = sort;
23418+
params.filters = filters;
2340323419
params.include = include;
2340423420
let response = match block_on(api.get_monitor_notification_rules_with_http_info(params)) {
2340523421
Ok(response) => response,

0 commit comments

Comments
 (0)