Skip to content

Commit de95394

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add GetScheduleOnCallUser specs (#649)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent f23d160 commit de95394

19 files changed

+1362
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-05-12 09:40:10.231223",
8-
"spec_repo_commit": "c4d0aeef"
7+
"regenerated": "2025-05-13 01:19:31.172553",
8+
"spec_repo_commit": "dc3b522f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-12 09:40:10.247293",
13-
"spec_repo_commit": "c4d0aeef"
12+
"regenerated": "2025-05-13 01:19:31.189716",
13+
"spec_repo_commit": "dc3b522f"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36060,6 +36060,115 @@ components:
3606036060
description: Link to the Incident created on ServiceNow
3606136061
type: string
3606236062
type: object
36063+
Shift:
36064+
description: The definition of `Shift` object.
36065+
example:
36066+
data:
36067+
attributes:
36068+
end: '2025-05-07T03:53:01.206662873Z'
36069+
start: '2025-05-07T02:53:01.206662814Z'
36070+
id: 00000000-0000-0000-0000-000000000000
36071+
relationships:
36072+
user:
36073+
data:
36074+
id: 00000000-aba1-0000-0000-000000000000
36075+
type: users
36076+
type: shifts
36077+
included:
36078+
- attributes:
36079+
36080+
name: User 1
36081+
status: ''
36082+
id: 00000000-aba1-0000-0000-000000000000
36083+
type: users
36084+
properties:
36085+
data:
36086+
$ref: '#/components/schemas/ShiftData'
36087+
nullable: true
36088+
included:
36089+
description: The `Shift` `included`.
36090+
items:
36091+
$ref: '#/components/schemas/ShiftIncluded'
36092+
type: array
36093+
type: object
36094+
ShiftData:
36095+
description: The definition of `ShiftData` object.
36096+
properties:
36097+
attributes:
36098+
$ref: '#/components/schemas/ShiftDataAttributes'
36099+
id:
36100+
description: The `ShiftData` `id`.
36101+
type: string
36102+
relationships:
36103+
$ref: '#/components/schemas/ShiftDataRelationships'
36104+
type:
36105+
$ref: '#/components/schemas/ShiftDataType'
36106+
required:
36107+
- type
36108+
type: object
36109+
ShiftDataAttributes:
36110+
description: The definition of `ShiftDataAttributes` object.
36111+
properties:
36112+
end:
36113+
description: The end time of the shift.
36114+
format: date-time
36115+
type: string
36116+
start:
36117+
description: The start time of the shift.
36118+
format: date-time
36119+
type: string
36120+
type: object
36121+
ShiftDataRelationships:
36122+
description: The definition of `ShiftDataRelationships` object.
36123+
properties:
36124+
user:
36125+
$ref: '#/components/schemas/ShiftDataRelationshipsUser'
36126+
type: object
36127+
ShiftDataRelationshipsUser:
36128+
description: Defines the relationship between a shift and the user who is working
36129+
that shift.
36130+
properties:
36131+
data:
36132+
$ref: '#/components/schemas/ShiftDataRelationshipsUserData'
36133+
required:
36134+
- data
36135+
type: object
36136+
ShiftDataRelationshipsUserData:
36137+
description: Represents a reference to the user assigned to this shift, containing
36138+
the user's ID and resource type.
36139+
properties:
36140+
id:
36141+
description: Specifies the unique identifier of the user.
36142+
example: 00000000-0000-0000-0000-000000000000
36143+
type: string
36144+
type:
36145+
$ref: '#/components/schemas/ShiftDataRelationshipsUserDataType'
36146+
required:
36147+
- type
36148+
- id
36149+
type: object
36150+
ShiftDataRelationshipsUserDataType:
36151+
default: users
36152+
description: Indicates that the related resource is of type 'users'.
36153+
enum:
36154+
- users
36155+
example: users
36156+
type: string
36157+
x-enum-varnames:
36158+
- USERS
36159+
ShiftDataType:
36160+
default: shifts
36161+
description: Indicates that the resource is of type 'shifts'.
36162+
enum:
36163+
- shifts
36164+
example: shifts
36165+
type: string
36166+
x-enum-varnames:
36167+
- SHIFTS
36168+
ShiftIncluded:
36169+
description: The definition of `ShiftIncluded` object.
36170+
oneOf:
36171+
- $ref: '#/components/schemas/ScheduleUser'
3606336172
SingleAggregatedConnectionResponseArray:
3606436173
description: List of aggregated connections.
3606536174
example:
@@ -51922,6 +52031,56 @@ paths:
5192252031
operator: AND
5192352032
permissions:
5192452033
- on_call_write
52034+
/api/v2/on-call/schedules/{schedule_id}/on-call:
52035+
get:
52036+
description: Retrieves the user who is on-call for the specified schedule at
52037+
a given time.
52038+
operationId: GetScheduleOnCallUser
52039+
parameters:
52040+
- description: 'Specifies related resources to include in the response as a
52041+
comma-separated list. Allowed value: `user`.'
52042+
in: query
52043+
name: include
52044+
schema:
52045+
type: string
52046+
- description: The ID of the schedule.
52047+
in: path
52048+
name: schedule_id
52049+
required: true
52050+
schema:
52051+
example: 3653d3c6-0c75-11ea-ad28-fb5701eabc7d
52052+
type: string
52053+
- description: Retrieves the on-call user at the given timestamp (ISO-8601).
52054+
Defaults to the current time if omitted."
52055+
in: query
52056+
name: filter[at_ts]
52057+
schema:
52058+
example: '2025-05-07T02:53:01Z'
52059+
type: string
52060+
responses:
52061+
'200':
52062+
content:
52063+
application/json:
52064+
schema:
52065+
$ref: '#/components/schemas/Shift'
52066+
description: OK
52067+
'400':
52068+
$ref: '#/components/responses/BadRequestResponse'
52069+
'401':
52070+
$ref: '#/components/responses/UnauthorizedResponse'
52071+
'403':
52072+
$ref: '#/components/responses/ForbiddenResponse'
52073+
'404':
52074+
$ref: '#/components/responses/NotFoundResponse'
52075+
'429':
52076+
$ref: '#/components/responses/TooManyRequestsResponse'
52077+
security:
52078+
- apiKeyAuth: []
52079+
appKeyAuth: []
52080+
- AuthZ: []
52081+
summary: Get the schedule of an on-call user
52082+
tags:
52083+
- On-Call
5192552084
/api/v2/on-call/teams/{team_id}/routing-rules:
5192652085
get:
5192752086
description: Get a team's on-call routing rules
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get the schedule of an on-call user returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV2::api_on_call::GetScheduleOnCallUserOptionalParams;
4+
use datadog_api_client::datadogV2::api_on_call::OnCallAPI;
5+
6+
#[tokio::main]
7+
async fn main() {
8+
// there is a valid "schedule" in the system
9+
let schedule_data_id = std::env::var("SCHEDULE_DATA_ID").unwrap();
10+
let configuration = datadog::Configuration::new();
11+
let api = OnCallAPI::with_config(configuration);
12+
let resp = api
13+
.get_schedule_on_call_user(
14+
schedule_data_id.clone(),
15+
GetScheduleOnCallUserOptionalParams::default(),
16+
)
17+
.await;
18+
if let Ok(value) = resp {
19+
println!("{:#?}", value);
20+
} else {
21+
println!("{:#?}", resp.unwrap_err());
22+
}
23+
}

src/datadogV2/api/api_on_call.rs

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,29 @@ impl GetOnCallTeamRoutingRulesOptionalParams {
9090
}
9191
}
9292

93+
/// GetScheduleOnCallUserOptionalParams is a struct for passing parameters to the method [`OnCallAPI::get_schedule_on_call_user`]
94+
#[non_exhaustive]
95+
#[derive(Clone, Default, Debug)]
96+
pub struct GetScheduleOnCallUserOptionalParams {
97+
/// Specifies related resources to include in the response as a comma-separated list. Allowed value: `user`.
98+
pub include: Option<String>,
99+
/// Retrieves the on-call user at the given timestamp (ISO-8601). Defaults to the current time if omitted."
100+
pub filter_at_ts: Option<String>,
101+
}
102+
103+
impl GetScheduleOnCallUserOptionalParams {
104+
/// Specifies related resources to include in the response as a comma-separated list. Allowed value: `user`.
105+
pub fn include(mut self, value: String) -> Self {
106+
self.include = Some(value);
107+
self
108+
}
109+
/// Retrieves the on-call user at the given timestamp (ISO-8601). Defaults to the current time if omitted."
110+
pub fn filter_at_ts(mut self, value: String) -> Self {
111+
self.filter_at_ts = Some(value);
112+
self
113+
}
114+
}
115+
93116
/// SetOnCallTeamRoutingRulesOptionalParams is a struct for passing parameters to the method [`OnCallAPI::set_on_call_team_routing_rules`]
94117
#[non_exhaustive]
95118
#[derive(Clone, Default, Debug)]
@@ -194,6 +217,14 @@ pub enum GetOnCallTeamRoutingRulesError {
194217
UnknownValue(serde_json::Value),
195218
}
196219

220+
/// GetScheduleOnCallUserError is a struct for typed errors of method [`OnCallAPI::get_schedule_on_call_user`]
221+
#[derive(Debug, Clone, Serialize, Deserialize)]
222+
#[serde(untagged)]
223+
pub enum GetScheduleOnCallUserError {
224+
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
225+
UnknownValue(serde_json::Value),
226+
}
227+
197228
/// SetOnCallTeamRoutingRulesError is a struct for typed errors of method [`OnCallAPI::set_on_call_team_routing_rules`]
198229
#[derive(Debug, Clone, Serialize, Deserialize)]
199230
#[serde(untagged)]
@@ -1154,6 +1185,128 @@ impl OnCallAPI {
11541185
}
11551186
}
11561187

1188+
/// Retrieves the user who is on-call for the specified schedule at a given time.
1189+
pub async fn get_schedule_on_call_user(
1190+
&self,
1191+
schedule_id: String,
1192+
params: GetScheduleOnCallUserOptionalParams,
1193+
) -> Result<crate::datadogV2::model::Shift, datadog::Error<GetScheduleOnCallUserError>> {
1194+
match self
1195+
.get_schedule_on_call_user_with_http_info(schedule_id, params)
1196+
.await
1197+
{
1198+
Ok(response_content) => {
1199+
if let Some(e) = response_content.entity {
1200+
Ok(e)
1201+
} else {
1202+
Err(datadog::Error::Serde(serde::de::Error::custom(
1203+
"response content was None",
1204+
)))
1205+
}
1206+
}
1207+
Err(err) => Err(err),
1208+
}
1209+
}
1210+
1211+
/// Retrieves the user who is on-call for the specified schedule at a given time.
1212+
pub async fn get_schedule_on_call_user_with_http_info(
1213+
&self,
1214+
schedule_id: String,
1215+
params: GetScheduleOnCallUserOptionalParams,
1216+
) -> Result<
1217+
datadog::ResponseContent<crate::datadogV2::model::Shift>,
1218+
datadog::Error<GetScheduleOnCallUserError>,
1219+
> {
1220+
let local_configuration = &self.config;
1221+
let operation_id = "v2.get_schedule_on_call_user";
1222+
1223+
// unbox and build optional parameters
1224+
let include = params.include;
1225+
let filter_at_ts = params.filter_at_ts;
1226+
1227+
let local_client = &self.client;
1228+
1229+
let local_uri_str = format!(
1230+
"{}/api/v2/on-call/schedules/{schedule_id}/on-call",
1231+
local_configuration.get_operation_host(operation_id),
1232+
schedule_id = datadog::urlencode(schedule_id)
1233+
);
1234+
let mut local_req_builder =
1235+
local_client.request(reqwest::Method::GET, local_uri_str.as_str());
1236+
1237+
if let Some(ref local_query_param) = include {
1238+
local_req_builder =
1239+
local_req_builder.query(&[("include", &local_query_param.to_string())]);
1240+
};
1241+
if let Some(ref local_query_param) = filter_at_ts {
1242+
local_req_builder =
1243+
local_req_builder.query(&[("filter[at_ts]", &local_query_param.to_string())]);
1244+
};
1245+
1246+
// build headers
1247+
let mut headers = HeaderMap::new();
1248+
headers.insert("Accept", HeaderValue::from_static("application/json"));
1249+
1250+
// build user agent
1251+
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
1252+
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
1253+
Err(e) => {
1254+
log::warn!("Failed to parse user agent header: {e}, falling back to default");
1255+
headers.insert(
1256+
reqwest::header::USER_AGENT,
1257+
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
1258+
)
1259+
}
1260+
};
1261+
1262+
// build auth
1263+
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
1264+
headers.insert(
1265+
"DD-API-KEY",
1266+
HeaderValue::from_str(local_key.key.as_str())
1267+
.expect("failed to parse DD-API-KEY header"),
1268+
);
1269+
};
1270+
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
1271+
headers.insert(
1272+
"DD-APPLICATION-KEY",
1273+
HeaderValue::from_str(local_key.key.as_str())
1274+
.expect("failed to parse DD-APPLICATION-KEY header"),
1275+
);
1276+
};
1277+
1278+
local_req_builder = local_req_builder.headers(headers);
1279+
let local_req = local_req_builder.build()?;
1280+
log::debug!("request content: {:?}", local_req.body());
1281+
let local_resp = local_client.execute(local_req).await?;
1282+
1283+
let local_status = local_resp.status();
1284+
let local_content = local_resp.text().await?;
1285+
log::debug!("response content: {}", local_content);
1286+
1287+
if !local_status.is_client_error() && !local_status.is_server_error() {
1288+
match serde_json::from_str::<crate::datadogV2::model::Shift>(&local_content) {
1289+
Ok(e) => {
1290+
return Ok(datadog::ResponseContent {
1291+
status: local_status,
1292+
content: local_content,
1293+
entity: Some(e),
1294+
})
1295+
}
1296+
Err(e) => return Err(datadog::Error::Serde(e)),
1297+
};
1298+
} else {
1299+
let local_entity: Option<GetScheduleOnCallUserError> =
1300+
serde_json::from_str(&local_content).ok();
1301+
let local_error = datadog::ResponseContent {
1302+
status: local_status,
1303+
content: local_content,
1304+
entity: local_entity,
1305+
};
1306+
Err(datadog::Error::ResponseError(local_error))
1307+
}
1308+
}
1309+
11571310
/// Set a team's on-call routing rules
11581311
pub async fn set_on_call_team_routing_rules(
11591312
&self,

0 commit comments

Comments
 (0)