Skip to content

Commit e15f4aa

Browse files
ROH-751: Add StartDay and EndDay configuration for Notification Policy resource
1 parent e50585b commit e15f4aa

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

docs/resources/notification_policy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,8 @@ Required:
140140
- `end_minute` (Number) End minute of the restriction period
141141
- `start_hour` (Number) Start hour of the restriction period
142142
- `start_minute` (Number) Start minute of the restriction period
143+
144+
Optional:
145+
146+
- `end_day` (Number) End day of the restriction period
147+
- `start_day` (Number) Start day of the restriction period

internal/dto/notification_policy_dto.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ type NotificationPolicyTimeRestrictionDto struct {
2424
}
2525

2626
type NotificationPolicyTimeRestrictionSettingsDto struct {
27-
StartHour int `json:"startHour"`
28-
EndHour int `json:"endHour"`
29-
StartMinute int `json:"startMinute"`
30-
EndMinute int `json:"endMinute"`
27+
StartDay *int64 `json:"startDay,omitempty"`
28+
StartHour int `json:"startHour"`
29+
EndDay *int64 `json:"endDay,omitempty"`
30+
EndHour int `json:"endHour"`
31+
StartMinute int `json:"startMinute"`
32+
EndMinute int `json:"endMinute"`
3133
}
3234

3335
type AutoRestartActionDto struct {

internal/provider/convertions.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,8 @@ func NotificationPolicyModelToDto(ctx context.Context, model *dataModels.Notific
17981798
StartMinute: int(period.StartMinute.ValueInt64()),
17991799
EndHour: int(period.EndHour.ValueInt64()),
18001800
EndMinute: int(period.EndMinute.ValueInt64()),
1801+
StartDay: period.StartDay.ValueInt64Pointer(),
1802+
EndDay: period.EndDay.ValueInt64Pointer(),
18011803
}
18021804
}
18031805
}
@@ -1988,12 +1990,16 @@ func NotificationPolicyDtoToModel(ctx context.Context, order float64, dto *dto.N
19881990
"start_minute": types.Int64Type,
19891991
"end_hour": types.Int64Type,
19901992
"end_minute": types.Int64Type,
1993+
"start_day": types.Int64Type,
1994+
"end_day": types.Int64Type,
19911995
},
19921996
map[string]attr.Value{
19931997
"start_hour": types.Int64Value(int64(period.StartHour)),
19941998
"start_minute": types.Int64Value(int64(period.StartMinute)),
19951999
"end_hour": types.Int64Value(int64(period.EndHour)),
19962000
"end_minute": types.Int64Value(int64(period.EndMinute)),
2001+
"start_day": types.Int64PointerValue(period.StartDay),
2002+
"end_day": types.Int64PointerValue(period.EndDay),
19972003
},
19982004
)
19992005
}
@@ -2006,6 +2012,8 @@ func NotificationPolicyDtoToModel(ctx context.Context, order float64, dto *dto.N
20062012
"start_minute": types.Int64Type,
20072013
"end_hour": types.Int64Type,
20082014
"end_minute": types.Int64Type,
2015+
"start_day": types.Int64Type,
2016+
"end_day": types.Int64Type,
20092017
}}},
20102018
},
20112019
map[string]attr.Value{
@@ -2015,6 +2023,8 @@ func NotificationPolicyDtoToModel(ctx context.Context, order float64, dto *dto.N
20152023
"start_minute": types.Int64Type,
20162024
"end_hour": types.Int64Type,
20172025
"end_minute": types.Int64Type,
2026+
"start_day": types.Int64Type,
2027+
"end_day": types.Int64Type,
20182028
}}, periods),
20192029
},
20202030
)
@@ -2026,6 +2036,8 @@ func NotificationPolicyDtoToModel(ctx context.Context, order float64, dto *dto.N
20262036
"start_minute": types.Int64Type,
20272037
"end_hour": types.Int64Type,
20282038
"end_minute": types.Int64Type,
2039+
"start_day": types.Int64Type,
2040+
"end_day": types.Int64Type,
20292041
}}},
20302042
})
20312043
}

internal/provider/dataModels/notification_policy_model.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type NotificationPolicyTimeRestrictionSettingsModel struct {
3131
EndHour types.Int64 `tfsdk:"end_hour"`
3232
StartMinute types.Int64 `tfsdk:"start_minute"`
3333
EndMinute types.Int64 `tfsdk:"end_minute"`
34+
StartDay types.Int64 `tfsdk:"start_day"`
35+
EndDay types.Int64 `tfsdk:"end_day"`
3436
}
3537

3638
type NotificationConditionModel struct {

internal/provider/schemaAttributes/notification_policy_resource_attributes.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ var NotificationPolicyResourceAttributes = map[string]schema.Attribute{
118118
Description: "List of time restriction periods",
119119
NestedObject: schema.NestedAttributeObject{
120120
Attributes: map[string]schema.Attribute{
121+
"start_day": schema.Int64Attribute{
122+
Required: false,
123+
Optional: true,
124+
Description: "Start day of the restriction period",
125+
Validators: []validator.Int64{
126+
int64validator.AtLeast(0),
127+
int64validator.AtMost(7),
128+
},
129+
},
121130
"start_hour": schema.Int64Attribute{
122131
Required: true,
123132
Description: "Start hour of the restriction period",
@@ -126,6 +135,15 @@ var NotificationPolicyResourceAttributes = map[string]schema.Attribute{
126135
Required: true,
127136
Description: "Start minute of the restriction period",
128137
},
138+
"end_day": schema.Int64Attribute{
139+
Required: false,
140+
Optional: true,
141+
Description: "End day of the restriction period",
142+
Validators: []validator.Int64{
143+
int64validator.AtLeast(0),
144+
int64validator.AtMost(7),
145+
},
146+
},
129147
"end_hour": schema.Int64Attribute{
130148
Required: true,
131149
Description: "End hour of the restriction period",

0 commit comments

Comments
 (0)