@@ -248,8 +248,8 @@ def _resolve_dataflow_name_and_id(
248248
249249
250250def get_dataflow_definition (
251- name : str , workspace : Optional [str ] = None , decode : bool = True
252- ) -> dict | pd .DataFrame :
251+ name : str , workspace : Optional [str ] = None , decode : bool = True , type : Optional [ str ] = 'gen2'
252+ ) -> pd .DataFrame :
253253 """
254254 Obtains the definition of a dataflow.
255255
@@ -259,32 +259,40 @@ def get_dataflow_definition(
259259 ----------
260260 name : str
261261 The name of the dataflow.
262- workspace : str, default=None
263- The Fabric workspace name.
264- Defaults to None which resolves to the workspace of the attached lakehouse
265- or if no lakehouse attached, resolves to the workspace of the notebook.
266- decode : bool, default=True
267- decode : bool, default=True
268- If True, decodes the dataflow definition file into .json format.
269- If False, obtains the dataflow definition file a pandas DataFrame format.
262+ workspace : str, optional
263+ The Fabric workspace name.
264+ Defaults to None, which resolves to the workspace of the attached lakehouse
265+ or if no lakehouse is attached, resolves to the workspace of the notebook.
266+ decode : bool, optional
267+ If True, decodes the dataflow definition file into JSON format.
268+ If False, obtains the dataflow definition file
269+ as a pandas DataFrame. Defaults to True.
270+ type : str, optional
271+ The generation type of the dataflow. Defaults to 'gen2'.
272+ Valid options include ['gen1', 'gen2'], ['1', '2'], or ['powerbi', 'fabric'].
270273
271274 Returns
272275 -------
273- dict | pandas.DataFrame
274- A pandas dataframe showing the data pipelines within a workspace.
276+ dict or pandas.DataFrame
277+ A pandas DataFrame showing the data pipelines within a workspace or a dictionary with the dataflow definition .
275278 """
276279
277280 workspace = fabric .resolve_workspace_name (workspace )
278281 workspace_id = fabric .resolve_workspace_id (workspace )
279- dataflow_name , item_id = _resolve_dataflow_name_and_id (
280- dataflow = name , workspace = workspace
281- )
282-
283- client = fabric .PowerBIRestClient ()
284- response = client .get (
285- f"v1.0/myorg/groups/{ workspace_id } /dataflows/{ item_id } "
286- )
287-
282+ dataflow_name , item_id = _resolve_dataflow_name_and_id (dataflow = name , workspace = workspace )
283+
284+ if type in ['gen1' , '1' , 'powerbi' ]:
285+ client = fabric .PowerBIRestClient ()
286+ response = client .get (f"v1.0/myorg/groups/{ workspace_id } /dataflows/{ item_id } " )
287+ elif type in ['gen2' , '2' , 'fabric' ]:
288+ # Placeholder for future API implementation
289+ client = {}
290+ response = {}
291+ else :
292+ raise ValueError (
293+ f"The dataflow type '{ type } ' is not a valid option."
294+ )
295+
288296 result = lro (client , response ).json ()
289297
290298 df = pd .json_normalize (result )
0 commit comments