Skip to content

Commit cdbb33b

Browse files
authored
Merge pull request #219 from almenscorner/dev
v2.3.7
2 parents e0a2695 + c1a8be6 commit cdbb33b

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = IntuneCD
3-
version = 2.3.6
3+
version = 2.3.7
44
author = Tobias Almén
55
author_email = [email protected]
66
description = Tool to backup and update configurations in Intune

src/IntuneCD/intunecdlib/BaseUpdateModule.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@ def process_update(
640640

641641
self.downstream_object = self.remove_keys(self.downstream_object)
642642

643+
def _add_schedule_action():
644+
if repo_scheduled_actions:
645+
repo_data["scheduledActionsForRule"] = repo_scheduled_actions
646+
643647
diffs = self.get_diffs(
644648
repo_data, self.downstream_object, self.exclude_paths
645649
)
@@ -664,6 +668,9 @@ def process_update(
664668
data=data,
665669
)
666670

671+
# Add scheduledActionsForRule back to the data if it was removed
672+
_add_schedule_action()
673+
667674
if self.handle_assignment:
668675
if self.config_type == "Windows Enrollment Profile":
669676
self.handle_iterable_assignments(
@@ -680,9 +687,9 @@ def process_update(
680687
self.downstream_id,
681688
)
682689

683-
# Add scheduledActionsForRule back to the data if it was removed
684-
if repo_scheduled_actions:
685-
repo_data["scheduledActionsForRule"] = repo_scheduled_actions
690+
# Add scheduledActionsForRule back to the data if it was removed
691+
_add_schedule_action()
692+
686693
else:
687694
data = create_data if create_data else repo_data
688695
if self.create_config:

src/IntuneCD/update/Intune/DeviceCompliance.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def _set_compliance_script_id(self, data: dict) -> dict[str, any]:
4646
},
4747
)
4848
if compliance_script_id.get("value"):
49-
data["deviceCompliancePolicyScript"][
50-
"deviceComplianceScriptId"
51-
] = compliance_script_id["value"][0]["id"]
49+
data["deviceCompliancePolicyScript"]["deviceComplianceScriptId"] = (
50+
compliance_script_id["value"][0]["id"]
51+
)
5252

5353
return data
5454

@@ -128,9 +128,9 @@ def _get_notification_template_id(self, rule: dict[str, any]) -> dict[str, any]:
128128
0
129129
]["id"]
130130
else:
131-
action[
132-
"notificationTemplateId"
133-
] = "00000000-0000-0000-0000-000000000000"
131+
action["notificationTemplateId"] = (
132+
"00000000-0000-0000-0000-000000000000"
133+
)
134134

135135
action.pop("notificationTemplateName")
136136

@@ -172,11 +172,21 @@ def main(self) -> dict[str, any]:
172172
for rule in repo_data.get("scheduledActionsForRule"):
173173
self._get_notification_template_id(rule)
174174

175-
for item in intune_data["value"]:
176-
for action in item["scheduledActionsForRule"][0][
177-
"scheduledActionConfigurations"
178-
]:
179-
self.remove_keys(action)
175+
for item in intune_data.get(
176+
"value", []
177+
): # Ensure "value" exists and is iterable
178+
actions = item.get("scheduledActionsForRule", [])
179+
180+
if actions: # Ensure actions is not None and not empty
181+
first_action = actions[0].get(
182+
"scheduledActionConfigurations", []
183+
)
184+
185+
if (
186+
first_action
187+
): # Ensure scheduledActionConfigurations is not None
188+
for action in first_action:
189+
self.remove_keys(action)
180190

181191
try:
182192
self.process_update(

0 commit comments

Comments
 (0)