def get(self, resource_group_name: str, network_security_group_name: str) -> NetworkSecurityGroup: try: with open(self.path / resource_group_name / f"nsg-{network_security_group_name}.json", "r", encoding="utf-8") as file: return NetworkSecurityGroup.deserialize(json.load(file)) except FileNotFoundError: raise ResourceNotFoundError("Network security group not found") from None
def list(self, resource_group_name: str) -> List[NetworkSecurityGroup]: try: files = [file for file in os.listdir(self.path / resource_group_name) if file.startswith("nsg-")] except FileNotFoundError: raise ResourceNotFoundError("No resource group") from None elements = [] for file in files: with open(self.path / resource_group_name / file, "r", encoding="utf-8") as file: elements.append(NetworkSecurityGroup.deserialize(json.load(file))) return elements