Skip to content

Commit 9239d82

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Share timerestriction object (#650)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent e37a9a3 commit 9239d82

17 files changed

+118
-1296
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-09 02:41:24.488945",
8-
"spec_repo_commit": "39adb7c0"
7+
"regenerated": "2025-05-09 14:41:34.641463",
8+
"spec_repo_commit": "f0e5e32f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-09 02:41:24.505168",
13-
"spec_repo_commit": "39adb7c0"
12+
"regenerated": "2025-05-09 14:41:34.658616",
13+
"spec_repo_commit": "f0e5e32f"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 3 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -18663,7 +18663,7 @@ components:
1866318663
description: An optional list of time restrictions for when this layer is
1866418664
in effect.
1866518665
items:
18666-
$ref: '#/components/schemas/LayerAttributesRestrictionsItems'
18666+
$ref: '#/components/schemas/TimeRestriction'
1866718667
type: array
1866818668
rotation_start:
1866918669
description: The date/time when the rotation starts (ISO 8601).
@@ -18687,63 +18687,6 @@ components:
1868718687
maximum: 2592000
1868818688
type: integer
1868918689
type: object
18690-
LayerAttributesRestrictionsItems:
18691-
description: 'Represents a time restriction within a layer, specifying the days
18692-
and times
18693-
18694-
when this layer is active or inactive.'
18695-
properties:
18696-
end_day:
18697-
$ref: '#/components/schemas/LayerAttributesRestrictionsItemsEndDay'
18698-
end_time:
18699-
description: The time of day the restriction ends (hh:mm:ss).
18700-
example: '17:00:00'
18701-
type: string
18702-
start_day:
18703-
$ref: '#/components/schemas/LayerAttributesRestrictionsItemsStartDay'
18704-
start_time:
18705-
description: The time of day the restriction begins (hh:mm:ss).
18706-
example: 09:00:00
18707-
type: string
18708-
type: object
18709-
LayerAttributesRestrictionsItemsEndDay:
18710-
description: Defines the end day of the restriction within a Layer.
18711-
enum:
18712-
- monday
18713-
- tuesday
18714-
- wednesday
18715-
- thursday
18716-
- friday
18717-
- saturday
18718-
- sunday
18719-
type: string
18720-
x-enum-varnames:
18721-
- MONDAY
18722-
- TUESDAY
18723-
- WEDNESDAY
18724-
- THURSDAY
18725-
- FRIDAY
18726-
- SATURDAY
18727-
- SUNDAY
18728-
LayerAttributesRestrictionsItemsStartDay:
18729-
description: Defines the start day of the restriction within a Layer.
18730-
enum:
18731-
- monday
18732-
- tuesday
18733-
- wednesday
18734-
- thursday
18735-
- friday
18736-
- saturday
18737-
- sunday
18738-
type: string
18739-
x-enum-varnames:
18740-
- MONDAY
18741-
- TUESDAY
18742-
- WEDNESDAY
18743-
- THURSDAY
18744-
- FRIDAY
18745-
- SATURDAY
18746-
- SUNDAY
1874718690
LayerRelationships:
1874818691
description: Holds references to objects related to the Layer entity, such as
1874918692
its members.
@@ -31120,7 +31063,7 @@ components:
3112031063
description: Zero or more time-based restrictions (for example, only weekdays,
3112131064
during business hours).
3112231065
items:
31123-
$ref: '#/components/schemas/ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItems'
31066+
$ref: '#/components/schemas/TimeRestriction'
3112431067
type: array
3112531068
rotation_start:
3112631069
description: The date/time when the rotation for this layer starts (in ISO
@@ -31169,62 +31112,6 @@ components:
3116931112
example: 00000000-aba1-0000-0000-000000000000
3117031113
type: string
3117131114
type: object
31172-
ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItems:
31173-
description: 'Defines a time restriction for a schedule layer, including which
31174-
day of the week
31175-
31176-
it starts and ends, along with start/end times.'
31177-
properties:
31178-
end_day:
31179-
$ref: '#/components/schemas/ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsEndDay'
31180-
end_time:
31181-
description: The time of day when the restriction ends (hh:mm:ss).
31182-
type: string
31183-
start_day:
31184-
$ref: '#/components/schemas/ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsStartDay'
31185-
start_time:
31186-
description: The time of day when the restriction begins (hh:mm:ss).
31187-
type: string
31188-
type: object
31189-
ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsEndDay:
31190-
description: The weekday when the restriction period ends (Monday through Sunday).
31191-
enum:
31192-
- monday
31193-
- tuesday
31194-
- wednesday
31195-
- thursday
31196-
- friday
31197-
- saturday
31198-
- sunday
31199-
type: string
31200-
x-enum-varnames:
31201-
- MONDAY
31202-
- TUESDAY
31203-
- WEDNESDAY
31204-
- THURSDAY
31205-
- FRIDAY
31206-
- SATURDAY
31207-
- SUNDAY
31208-
ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsStartDay:
31209-
description: The weekday when the restriction period starts (Monday through
31210-
Sunday).
31211-
enum:
31212-
- monday
31213-
- tuesday
31214-
- wednesday
31215-
- thursday
31216-
- friday
31217-
- saturday
31218-
- sunday
31219-
type: string
31220-
x-enum-varnames:
31221-
- MONDAY
31222-
- TUESDAY
31223-
- WEDNESDAY
31224-
- THURSDAY
31225-
- FRIDAY
31226-
- SATURDAY
31227-
- SUNDAY
3122831115
ScheduleCreateRequestDataRelationships:
3122931116
description: Gathers relationship objects for the schedule creation request,
3123031117
including the teams to associate.
@@ -31628,7 +31515,7 @@ components:
3162831515
restrictions:
3162931516
description: Any time restrictions that define when this layer is active.
3163031517
items:
31631-
$ref: '#/components/schemas/ScheduleUpdateRequestDataAttributesLayersItemsRestrictionsItems'
31518+
$ref: '#/components/schemas/TimeRestriction'
3163231519
type: array
3163331520
rotation_start:
3163431521
description: The date/time at which the rotation begins (ISO 8601 format).
@@ -31678,63 +31565,6 @@ components:
3167831565
example: 00000000-aba1-0000-0000-000000000000
3167931566
type: string
3168031567
type: object
31681-
ScheduleUpdateRequestDataAttributesLayersItemsRestrictionsItems:
31682-
description: 'Defines a time restriction object for a layer within a schedule
31683-
update, including
31684-
31685-
start and end days, as well as times.'
31686-
properties:
31687-
end_day:
31688-
$ref: '#/components/schemas/ScheduleUpdateRequestDataAttributesLayersItemsRestrictionsItemsEndDay'
31689-
end_time:
31690-
description: The time at which this restriction ends (hh:mm:ss).
31691-
example: '17:00:00'
31692-
type: string
31693-
start_day:
31694-
$ref: '#/components/schemas/ScheduleUpdateRequestDataAttributesLayersItemsRestrictionsItemsStartDay'
31695-
start_time:
31696-
description: The time at which this restriction starts (hh:mm:ss).
31697-
example: 09:00:00
31698-
type: string
31699-
type: object
31700-
ScheduleUpdateRequestDataAttributesLayersItemsRestrictionsItemsEndDay:
31701-
description: Defines the day of the week on which the time restriction ends.
31702-
enum:
31703-
- monday
31704-
- tuesday
31705-
- wednesday
31706-
- thursday
31707-
- friday
31708-
- saturday
31709-
- sunday
31710-
type: string
31711-
x-enum-varnames:
31712-
- MONDAY
31713-
- TUESDAY
31714-
- WEDNESDAY
31715-
- THURSDAY
31716-
- FRIDAY
31717-
- SATURDAY
31718-
- SUNDAY
31719-
ScheduleUpdateRequestDataAttributesLayersItemsRestrictionsItemsStartDay:
31720-
description: Defines the day of the week on which the time restriction starts.
31721-
enum:
31722-
- monday
31723-
- tuesday
31724-
- wednesday
31725-
- thursday
31726-
- friday
31727-
- saturday
31728-
- sunday
31729-
type: string
31730-
x-enum-varnames:
31731-
- MONDAY
31732-
- TUESDAY
31733-
- WEDNESDAY
31734-
- THURSDAY
31735-
- FRIDAY
31736-
- SATURDAY
31737-
- SUNDAY
3173831568
ScheduleUpdateRequestDataRelationships:
3173931569
description: Houses relationships for the schedule update, typically referencing
3174031570
teams.

examples/v2_on-call_CreateOnCallSchedule.rs

Lines changed: 43 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataAttributesLay
1010
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataAttributesLayersItemsInterval;
1111
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataAttributesLayersItemsMembersItems;
1212
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataAttributesLayersItemsMembersItemsUser;
13-
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItems;
14-
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsEndDay;
15-
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsStartDay;
1613
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataRelationships;
1714
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataRelationshipsTeams;
1815
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataRelationshipsTeamsDataItems;
1916
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataRelationshipsTeamsDataItemsType;
2017
use datadog_api_client::datadogV2::model::ScheduleCreateRequestDataType;
18+
use datadog_api_client::datadogV2::model::TimeRestriction;
19+
use datadog_api_client::datadogV2::model::Weekday;
2120

2221
#[tokio::main]
2322
async fn main() {
@@ -26,68 +25,50 @@ async fn main() {
2625

2726
// there is a valid "dd_team" in the system
2827
let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap();
29-
let body =
30-
ScheduleCreateRequest::new(
31-
ScheduleCreateRequestData::new(
32-
ScheduleCreateRequestDataAttributes::new(
28+
let body = ScheduleCreateRequest::new(
29+
ScheduleCreateRequestData::new(
30+
ScheduleCreateRequestDataAttributes::new(
31+
vec![ScheduleCreateRequestDataAttributesLayersItems::new(
32+
DateTime::parse_from_rfc3339("2021-11-01T11:11:11+00:00")
33+
.expect("Failed to parse datetime")
34+
.with_timezone(&Utc),
35+
ScheduleCreateRequestDataAttributesLayersItemsInterval::new().days(1),
3336
vec![
34-
ScheduleCreateRequestDataAttributesLayersItems::new(
35-
DateTime::parse_from_rfc3339("2021-11-01T11:11:11+00:00")
36-
.expect("Failed to parse datetime")
37-
.with_timezone(&Utc),
38-
ScheduleCreateRequestDataAttributesLayersItemsInterval::new().days(1),
39-
vec![
40-
ScheduleCreateRequestDataAttributesLayersItemsMembersItems
41-
::new().user(
42-
ScheduleCreateRequestDataAttributesLayersItemsMembersItemsUser
43-
::new().id(user_data_id.clone()),
44-
)
45-
],
46-
"Layer 1".to_string(),
47-
DateTime::parse_from_rfc3339("2021-11-06T11:11:11+00:00")
48-
.expect("Failed to parse datetime")
49-
.with_timezone(&Utc),
50-
)
51-
.end_date(
52-
DateTime::parse_from_rfc3339("2021-11-21T11:11:11+00:00")
53-
.expect("Failed to parse datetime")
54-
.with_timezone(&Utc),
55-
)
56-
.restrictions(
57-
vec![
58-
ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItems::new()
59-
.end_day(
60-
ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsEndDay
61-
::FRIDAY,
62-
)
63-
.end_time("17:00:00".to_string())
64-
.start_day(
65-
ScheduleCreateRequestDataAttributesLayersItemsRestrictionsItemsStartDay
66-
::MONDAY,
67-
)
68-
.start_time("09:00:00".to_string())
69-
],
70-
)
37+
ScheduleCreateRequestDataAttributesLayersItemsMembersItems::new().user(
38+
ScheduleCreateRequestDataAttributesLayersItemsMembersItemsUser::new()
39+
.id(user_data_id.clone()),
40+
),
7141
],
72-
"Example-On-Call".to_string(),
73-
"America/New_York".to_string(),
74-
).tags(vec!["tag1".to_string(), "tag2".to_string()]),
75-
ScheduleCreateRequestDataType::SCHEDULES,
76-
).relationships(
77-
ScheduleCreateRequestDataRelationships
78-
::new().teams(
79-
ScheduleCreateRequestDataRelationshipsTeams
80-
::new().data(
81-
vec![
82-
ScheduleCreateRequestDataRelationshipsTeamsDataItems::new(
83-
dd_team_data_id.clone(),
84-
ScheduleCreateRequestDataRelationshipsTeamsDataItemsType::TEAMS,
85-
)
86-
],
87-
),
42+
"Layer 1".to_string(),
43+
DateTime::parse_from_rfc3339("2021-11-06T11:11:11+00:00")
44+
.expect("Failed to parse datetime")
45+
.with_timezone(&Utc),
46+
)
47+
.end_date(
48+
DateTime::parse_from_rfc3339("2021-11-21T11:11:11+00:00")
49+
.expect("Failed to parse datetime")
50+
.with_timezone(&Utc),
51+
)
52+
.restrictions(vec![TimeRestriction::new()
53+
.end_day(Weekday::FRIDAY)
54+
.end_time("17:00:00".to_string())
55+
.start_day(Weekday::MONDAY)
56+
.start_time("09:00:00".to_string())])],
57+
"Example-On-Call".to_string(),
58+
"America/New_York".to_string(),
59+
)
60+
.tags(vec!["tag1".to_string(), "tag2".to_string()]),
61+
ScheduleCreateRequestDataType::SCHEDULES,
62+
)
63+
.relationships(ScheduleCreateRequestDataRelationships::new().teams(
64+
ScheduleCreateRequestDataRelationshipsTeams::new().data(vec![
65+
ScheduleCreateRequestDataRelationshipsTeamsDataItems::new(
66+
dd_team_data_id.clone(),
67+
ScheduleCreateRequestDataRelationshipsTeamsDataItemsType::TEAMS,
8868
),
89-
),
90-
);
69+
]),
70+
)),
71+
);
9172
let configuration = datadog::Configuration::new();
9273
let api = OnCallAPI::with_config(configuration);
9374
let resp = api

0 commit comments

Comments
 (0)