Skip to content

Commit 36badf1

Browse files
authored
feat(grafanaplane/oncall): add helpers to set teamId on schedules and shifts (#93)
* feat(grafanaplane/oncall): add helpers to set teamId on schedules and shifts * docs
1 parent b4dd7b9 commit 36badf1

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

docs/oncall/schedule/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [`fn withShifts(shifts)`](#fn-calendarwithshifts)
1616
* [`fn withSlackChannelId(value)`](#fn-calendarwithslackchannelid)
1717
* [`fn withSlackUserGroup(value)`](#fn-calendarwithslackusergroup)
18+
* [`fn withTeamId(teamId)`](#fn-calendarwithteamid)
1819
* [`fn withTimeZone(value)`](#fn-calendarwithtimezone)
1920

2021
## Fields
@@ -131,6 +132,21 @@ PARAMETERS:
131132

132133
call users change.
133134
Slack user group id. Members of user group will be updated when on-call users change.
135+
#### fn calendar.withTeamId
136+
137+
```jsonnet
138+
calendar.withTeamId(teamId)
139+
```
140+
141+
PARAMETERS:
142+
143+
* **teamId** (`string`)
144+
145+
`withTeamId` configures the Team ID on the schedule and shifts.
146+
147+
Parameters:
148+
- `teamId` should be the ID of the team as a string.
149+
134150
#### fn calendar.withTimeZone
135151

136152
```jsonnet

grafanaplane/oncall/schedule.libsonnet

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ local forProvider = schedule.spec.parameters.forProvider;
8181
shift
8282
// Inject matching labels to identify Shifts as belonging to this Schedule.
8383
+ raw.oncall.v1alpha1.onCallShift.spec.parameters.withSelectorLabel('schedule-%s' % self.claimName)
84+
+ (if std.objectHas(self.schedule.spec.parameters.forProvider, 'teamId')
85+
then raw.oncall.v1alpha1.onCallShift.spec.parameters.forProvider.withTeamId(self.schedule.spec.parameters.forProvider.teamId)
86+
else {})
8487
for shift in self.shifts
8588
],
8689
},
@@ -93,6 +96,23 @@ local forProvider = schedule.spec.parameters.forProvider;
9396
claimName:: claimName,
9497
},
9598

99+
'#withTeamId':: d.func.new(
100+
|||
101+
`withTeamId` configures the Team ID on the schedule and shifts.
102+
103+
Parameters:
104+
- `teamId` should be the ID of the team as a string.
105+
|||,
106+
[
107+
d.argument.new('teamId', d.T.string),
108+
]
109+
),
110+
withTeamId(teamId):: {
111+
// Constructor nests the resource beneath the `chain` key, so we wrap the
112+
// raw function to do the same.
113+
schedule+: forProvider.withTeamId(teamId),
114+
},
115+
96116
'#withShifts':: d.func.new(
97117
|||
98118
`withShifts` sets an array of Shifts on a calendar-type Schedule.

0 commit comments

Comments
 (0)