@@ -392,7 +392,7 @@ def resolve_lakehouse_name_and_id(
392392 lakehouse : Optional [str | UUID ] = None , workspace : Optional [str | UUID ] = None
393393) -> Tuple [str , UUID ]:
394394
395- ( workspace_name , workspace_id ) = resolve_workspace_name_and_id (workspace )
395+ workspace_id = resolve_workspace_id (workspace )
396396 type = "Lakehouse"
397397
398398 if lakehouse is None :
@@ -896,113 +896,6 @@ def resolve_workspace_name_and_id(
896896 return workspace_name , workspace_id
897897
898898
899- def resolve_item_id (
900- item : str | UUID , type : Optional [str ] = None , workspace : Optional [str | UUID ] = None
901- ) -> UUID :
902-
903- (workspace_name , workspace_id ) = resolve_workspace_name_and_id (workspace )
904- item_id = None
905-
906- if _is_valid_uuid (item ):
907- # Check (optional)
908- item_id = item
909- try :
910- _base_api (
911- request = f"/v1/workspaces/{ workspace_id } /items/{ item_id } " ,
912- client = "fabric_sp" ,
913- )
914- except FabricHTTPException :
915- raise ValueError (
916- f"{ icons .red_dot } The '{ item_id } ' item was not found in the '{ workspace_name } ' workspace."
917- )
918- else :
919- if type is None :
920- raise ValueError (
921- f"{ icons .red_dot } The 'type' parameter is required if specifying an item name."
922- )
923- responses = _base_api (
924- request = f"/v1/workspaces/{ workspace_id } /items?type={ type } " ,
925- client = "fabric_sp" ,
926- uses_pagination = True ,
927- )
928- for r in responses :
929- for v in r .get ("value" , []):
930- display_name = v .get ("displayName" )
931- if display_name == item :
932- item_id = v .get ("id" )
933- break
934-
935- if item_id is None :
936- raise ValueError (
937- f"{ icons .red_dot } There's no item '{ item } ' of type '{ type } ' in the '{ workspace_name } ' workspace."
938- )
939-
940- return item_id
941-
942-
943- def resolve_item_name_and_id (
944- item : str | UUID , type : Optional [str ] = None , workspace : Optional [str | UUID ] = None
945- ) -> Tuple [str , UUID ]:
946-
947- workspace_id = resolve_workspace_id (workspace )
948- item_id = resolve_item_id (item = item , type = type , workspace = workspace_id )
949- item_name = (
950- _base_api (
951- request = f"/v1/workspaces/{ workspace_id } /items/{ item_id } " , client = "fabric_sp"
952- )
953- .json ()
954- .get ("displayName" )
955- )
956-
957- return item_name , item_id
958-
959-
960- def resolve_item_name (item_id : UUID , workspace : Optional [str | UUID ] = None ) -> str :
961-
962- workspace_id = resolve_workspace_id (workspace )
963- try :
964- item_name = (
965- _base_api (
966- request = f"/v1/workspaces/{ workspace_id } /items/{ item_id } " ,
967- client = "fabric_sp" ,
968- )
969- .json ()
970- .get ("displayName" )
971- )
972- except FabricHTTPException :
973- raise ValueError (
974- f"{ icons .red_dot } The '{ item_id } ' item was not found in the '{ workspace_id } ' workspace."
975- )
976-
977- return item_name
978-
979-
980- def resolve_lakehouse_name_and_id (
981- lakehouse : Optional [str | UUID ] = None , workspace : Optional [str | UUID ] = None
982- ) -> Tuple [str , UUID ]:
983-
984- (workspace_name , workspace_id ) = resolve_workspace_name_and_id (workspace )
985- type = "Lakehouse"
986-
987- if lakehouse is None :
988- lakehouse_id = fabric .get_lakehouse_id ()
989- lakehouse_name = fabric .resolve_item_name (
990- item_id = lakehouse_id , type = type , workspace = workspace_id
991- )
992- elif _is_valid_uuid (lakehouse ):
993- lakehouse_id = lakehouse
994- lakehouse_name = fabric .resolve_item_name (
995- item_id = lakehouse_id , type = type , workspace = workspace_id
996- )
997- else :
998- lakehouse_name = lakehouse
999- lakehouse_id = fabric .resolve_item_id (
1000- item_name = lakehouse , type = type , workspace = workspace_id
1001- )
1002-
1003- return lakehouse_name , lakehouse_id
1004-
1005-
1006899def _extract_json (dataframe : pd .DataFrame ) -> dict :
1007900
1008901 payload = dataframe ["payload" ].iloc [0 ]
0 commit comments