def enable_all_policy_types()

in src/org_setup/resources/organizations.py [0:0]


    def enable_all_policy_types(self) -> None:
        """
        Enables all policy types in an organization
        """
        logger.info(f"[{self.region}] Enabling all policy types in organization")

        for root in self.list_roots():
            root_id = root["Id"]
            disabled_types = [
                policy_type.get("Type")
                for policy_type in root.get("PolicyTypes", [])
                if policy_type.get("Status") != "ENABLED"
            ]

            for disabled_type in disabled_types:
                logger.info(
                    f"[{self.region}] Enabling policy type {disabled_type} on root {root_id}"
                )
                try:
                    self.client.enable_policy_type(
                        RootId=root_id, PolicyType=disabled_type
                    )
                    logger.debug(
                        f"[{self.region}] Enabled policy type {disabled_type} on root {root_id}"
                    )
                except botocore.exceptions.ClientError as error:
                    if (
                        error.response["Error"]["Code"]
                        != "PolicyTypeAlreadyEnabledException"
                    ):
                        logger.exception(
                            f"[{self.region}] Unable to enable policy type"
                        )
                        raise error

        logger.debug(f"[{self.region}] Enabled all policy types in organization")