def _apply_nested_name()

in azext_edge/edge/providers/orchestration/clone.py [0:0]


    def _apply_nested_name(self):
        def _extract_suffix(path: str) -> str:
            return "/" + path.partition("/")[2]

        if "id" in self.resource_state:
            test: Dict[str, Union[str, int]] = parse_resource_id(self.resource_state["id"])
            target_name = test["name"]
            last_child_num = test.get("last_child_num", 0)
            if last_child_num:
                for i in range(1, last_child_num + 1):
                    target_name += f"/{test[f'child_name_{i}']}"
            self.resource_state["name"] = target_name
            if test["type"].lower() == "instances":
                suffix = _extract_suffix(target_name)
                if suffix == "/":
                    self.resource_state["name"] = TEMPLATE_EXPRESSION_MAP["instanceName"]
                else:
                    self.resource_state["name"] = TEMPLATE_EXPRESSION_MAP["instanceNestedName"].format(suffix)