def get(self, resource_group_name: str, network_interface_name: str) -> NetworkInterface: try: with open(self.path / resource_group_name / f"nic-{network_interface_name}.json", "r", encoding="utf-8") as file: return NetworkInterface.deserialize(json.load(file)) except FileNotFoundError: raise ResourceNotFoundError("NIC not found") from None
def list(self, resource_group_name: str) -> List[NetworkInterface]: try: files = [file for file in os.listdir(self.path / resource_group_name) if file.startswith("nic-")] 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(NetworkInterface.deserialize(json.load(file))) return elements