-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from almenscorner/refactor-classes
Refactor classes
- Loading branch information
Showing
348 changed files
with
14,728 additions
and
32,512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = IntuneCD | ||
version = 2.2.0 | ||
version = 2.3.0.rc1 | ||
author = Tobias Almén | ||
author_email = [email protected] | ||
description = Tool to backup and update configurations in Intune | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# -*- coding: utf-8 -*- | ||
from ...intunecdlib.BaseBackupModule import BaseBackupModule | ||
|
||
|
||
class ApplicationsBackupModule(BaseBackupModule): | ||
"""A class used to backup Entra Applications | ||
Attributes: | ||
CONFIG_ENDPOINT (str): The endpoint to get the data from | ||
LOG_MESSAGE (str): The message to log when backing up the data | ||
""" | ||
|
||
CONFIG_ENDPOINT = "/v1.0/myorganization/applications" | ||
LOG_MESSAGE = "Backing up Entra Application: " | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initializes the ApplicationsBackupModule class | ||
Args: | ||
*args: The positional arguments to pass to the base class's __init__ method. | ||
**kwargs: The keyword arguments to pass to the base class's __init__ method. | ||
""" | ||
super().__init__(*args, **kwargs) | ||
self.path = f"{self.path}/Entra/Applications/" | ||
self.handle_assignment = False | ||
|
||
def main(self) -> dict[str, any]: | ||
"""The main method to backup the Entra data | ||
Returns: | ||
dict[str, any]: The results of the backup | ||
""" | ||
|
||
try: | ||
self.entra_data = self.make_graph_request( | ||
endpoint=self.endpoint + self.CONFIG_ENDPOINT | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error getting Application data from {self.endpoint + self.CONFIG_ENDPOINT}: {e}", | ||
) | ||
return None | ||
|
||
try: | ||
self.results = self.process_data( | ||
data=self.entra_data["value"], | ||
filetype=self.filetype, | ||
path=self.path, | ||
name_key="displayName", | ||
log_message=self.LOG_MESSAGE, | ||
) | ||
except Exception as e: | ||
self.log(tag="error", msg=f"Error processing Application data: {e}") | ||
return None | ||
|
||
return self.results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
from ...intunecdlib.BaseBackupModule import BaseBackupModule | ||
|
||
|
||
class AuthenticationFlowsBackupModule(BaseBackupModule): | ||
"""A class used to backup Entra Authentication Flows | ||
Attributes: | ||
CONFIG_ENDPOINT (str): The endpoint to get the data from | ||
LOG_MESSAGE (str): The message to log when backing up the data | ||
""" | ||
|
||
CONFIG_ENDPOINT = "/beta/policies/authenticationFlowsPolicy" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initializes the AuthenticationFlowsBackupModule class | ||
Args: | ||
*args: The positional arguments to pass to the base class's __init__ method. | ||
**kwargs: The keyword arguments to pass to the base class's __init__ method. | ||
""" | ||
super().__init__(*args, **kwargs) | ||
self.path = f"{self.path}/Entra/Authentication Flows Policy/" | ||
self.preset_filename = "authentication_flows_policy" | ||
|
||
def main(self) -> dict[str, any]: | ||
"""The main method to backup the Entra data | ||
Returns: | ||
dict[str, any]: The results of the backup | ||
""" | ||
|
||
try: | ||
self.entra_data = self.make_graph_request( | ||
endpoint=self.endpoint + self.CONFIG_ENDPOINT | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error getting Authentication Flows data from {self.endpoint + self.CONFIG_ENDPOINT}: {e}", | ||
) | ||
return None | ||
|
||
self.log(msg="Backing up Entra Authentication Flows") | ||
|
||
try: | ||
self.results = self.process_data( | ||
data=self.entra_data, | ||
filetype=self.filetype, | ||
path=self.path, | ||
name_key="", | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", msg=f"Error processing Authentication Flows data: {e}" | ||
) | ||
return None | ||
|
||
return self.results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
from ...intunecdlib.BaseBackupModule import BaseBackupModule | ||
|
||
|
||
class AuthenticationMethodsBackupModule(BaseBackupModule): | ||
"""A class used to backup Entra Authentication Methods | ||
Attributes: | ||
CONFIG_ENDPOINT (str): The endpoint to get the data from | ||
LOG_MESSAGE (str): The message to log when backing up the data | ||
""" | ||
|
||
CONFIG_ENDPOINT = "/beta/policies/authenticationmethodspolicy" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initializes the AuthenticationMethodsBackupModule class | ||
Args: | ||
*args: The positional arguments to pass to the base class's __init__ method. | ||
**kwargs: The keyword arguments to pass to the base class's __init__ method. | ||
""" | ||
super().__init__(*args, **kwargs) | ||
self.path = f"{self.path}/Entra/Authentication Methods/" | ||
self.preset_filename = "authentication_methods" | ||
|
||
def main(self) -> dict[str, any]: | ||
"""The main method to backup the Entra data | ||
Returns: | ||
dict[str, any]: The results of the backup | ||
""" | ||
|
||
try: | ||
self.entra_data = self.make_graph_request( | ||
endpoint=self.endpoint + self.CONFIG_ENDPOINT | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error getting Authentication Methods data from {self.endpoint + self.CONFIG_ENDPOINT}: {e}", | ||
) | ||
return None | ||
|
||
self.log(msg="Backing up Entra Authentication Methods") | ||
|
||
try: | ||
self.results = self.process_data( | ||
data=self.entra_data, | ||
filetype=self.filetype, | ||
path=self.path, | ||
name_key="", | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", msg=f"Error processing Authentication Methods data: {e}" | ||
) | ||
return None | ||
|
||
return self.results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
from ...intunecdlib.BaseBackupModule import BaseBackupModule | ||
|
||
|
||
class AuthorizationPolicyBackupModule(BaseBackupModule): | ||
"""A class used to backup Entra Authorization Policy | ||
Attributes: | ||
CONFIG_ENDPOINT (str): The endpoint to get the data from | ||
LOG_MESSAGE (str): The message to log when backing up the data | ||
""" | ||
|
||
CONFIG_ENDPOINT = "/beta/policies/authorizationPolicy" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initializes the AuthorizationPolicyBackupModule class | ||
Args: | ||
*args: The positional arguments to pass to the base class's __init__ method. | ||
**kwargs: The keyword arguments to pass to the base class's __init__ method. | ||
""" | ||
super().__init__(*args, **kwargs) | ||
self.path = f"{self.path}/Entra/Authorization Policy/" | ||
self.preset_filename = "authorization_policy" | ||
|
||
def main(self) -> dict[str, any]: | ||
"""The main method to backup the Entra data | ||
Returns: | ||
dict[str, any]: The results of the backup | ||
""" | ||
|
||
try: | ||
self.entra_data = self.make_graph_request( | ||
endpoint=self.endpoint + self.CONFIG_ENDPOINT | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error getting Authorization Policy data from {self.endpoint + self.CONFIG_ENDPOINT}: {e}", | ||
) | ||
return None | ||
|
||
self.log(msg="Backing up Entra Authorization Policy") | ||
|
||
try: | ||
self.results = self.process_data( | ||
data=self.entra_data["value"], | ||
filetype=self.filetype, | ||
path=self.path, | ||
name_key="", | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", msg=f"Error processing Authorization Policy data: {e}" | ||
) | ||
return None | ||
|
||
return self.results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
from ...intunecdlib.BaseBackupModule import BaseBackupModule | ||
|
||
|
||
class B2BPolicyBackupModule(BaseBackupModule): | ||
"""A class used to backup Entra B2B Policy | ||
Attributes: | ||
CONFIG_ENDPOINT (str): The endpoint to get the data from | ||
LOG_MESSAGE (str): The message to log when backing up the data | ||
""" | ||
|
||
CONFIG_ENDPOINT = "B2B/b2bPolicy" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initializes the B2BPolicyBackupModule class | ||
Args: | ||
*args: The positional arguments to pass to the base class's __init__ method. | ||
**kwargs: The keyword arguments to pass to the base class's __init__ method. | ||
""" | ||
super().__init__(*args, **kwargs) | ||
self.path = f"{self.path}/Entra/External Collaboration Settings/" | ||
self.preset_filename = "b2b_policy" | ||
|
||
def main(self) -> dict[str, any]: | ||
"""The main method to backup the Entra data | ||
Returns: | ||
dict[str, any]: The results of the backup | ||
""" | ||
|
||
try: | ||
self.entra_data = self.make_azure_request(self.CONFIG_ENDPOINT) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error getting External Collaboration Settings data from {self.CONFIG_ENDPOINT}: {e}", | ||
) | ||
return None | ||
|
||
self.log(msg="Backing up Entra External Collaboration Settings B2B Policy") | ||
|
||
try: | ||
self.results = self.process_data( | ||
data=self.entra_data, | ||
filetype=self.filetype, | ||
path=self.path, | ||
name_key="", | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error processing External Collaboration Settings data: {e}", | ||
) | ||
return None | ||
|
||
return self.results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# -*- coding: utf-8 -*- | ||
from ...intunecdlib.BaseBackupModule import BaseBackupModule | ||
|
||
|
||
class DeviceRegistrationPolicyBackupModule(BaseBackupModule): | ||
"""A class used to backup Entra Device Registration Policy | ||
Attributes: | ||
CONFIG_ENDPOINT (str): The endpoint to get the data from | ||
LOG_MESSAGE (str): The message to log when backing up the data | ||
""" | ||
|
||
CONFIG_ENDPOINT = "/beta/policies/deviceRegistrationPolicy" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initializes the DeviceRegistrationPolicyBackupModule class | ||
Args: | ||
*args: The positional arguments to pass to the base class's __init__ method. | ||
**kwargs: The keyword arguments to pass to the base class's __init__ method. | ||
""" | ||
super().__init__(*args, **kwargs) | ||
self.path = f"{self.path}/Entra/Device Registration Policy/" | ||
self.preset_filename = "device_registration_policy" | ||
|
||
def main(self) -> dict[str, any]: | ||
"""The main method to backup the Entra data | ||
Returns: | ||
dict[str, any]: The results of the backup | ||
""" | ||
|
||
try: | ||
self.entra_data = self.make_graph_request( | ||
endpoint=self.endpoint + self.CONFIG_ENDPOINT | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error getting Device Registration Policy data from {self.endpoint + self.CONFIG_ENDPOINT}: {e}", | ||
) | ||
return None | ||
|
||
self.log(msg="Backing up Entra Device Registration Policy") | ||
|
||
try: | ||
self.results = self.process_data( | ||
data=self.entra_data, | ||
filetype=self.filetype, | ||
path=self.path, | ||
name_key="", | ||
) | ||
except Exception as e: | ||
self.log( | ||
tag="error", | ||
msg=f"Error processing Device Registration Policy data: {e}", | ||
) | ||
return None | ||
|
||
return self.results |
Oops, something went wrong.