Skip to content

Dataflows Gen2

create_dataflow_gen2(workspace, display_name, item_definition, *, description=None, folder=None, df=True)

Creates a new dataflow in the specified workspace.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
display_name str

The display name of the dataflow.

required
description str

A description for the dataflow.

None
folder str

The folder to create the dataflow in.

None
item_definition Dict[str, Any]

The definition of the dataflow.

required
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
dict

The created dataflow details.

Examples:

create_dataflow('MyProjectWorkspace', 'SalesDataModel', 'path/to/definition.json')
create_dataflow('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', 'path/to/definition.json', description='Sales data model')
Source code in src/pyfabricops/items/dataflows_gen2.py
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
@df
def create_dataflow_gen2(
    workspace: str,
    display_name: str,
    item_definition: Dict[str, Any],
    *,
    description: Optional[str] = None,
    folder: Optional[str] = None,
    df: Optional[bool] = True,
) -> Union[dict, None]:
    """
    Creates a new dataflow in the specified workspace.

    Args:
        workspace (str): The workspace name or ID.
        display_name (str): The display name of the dataflow.
        description (str, optional): A description for the dataflow.
        folder (str, optional): The folder to create the dataflow in.
        item_definition (Dict[str, Any]): The definition of the dataflow.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (dict): The created dataflow details.

    Examples:
        ```python
        create_dataflow('MyProjectWorkspace', 'SalesDataModel', 'path/to/definition.json')
        create_dataflow('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', 'path/to/definition.json', description='Sales data model')
        ```
    """
    workspace_id = resolve_workspace(workspace)

    payload = {'displayName': display_name, 'definition': item_definition}

    if description:
        payload['description'] = description

    if folder:
        folder_id = resolve_folder(workspace_id, folder)
        if folder_id:
            payload['folderId'] = folder_id

    return api_request(
        endpoint='/workspaces/' + workspace_id + '/dataflows',
        method='post',
        payload=payload,
        support_lro=True,
    )

delete_dataflow_gen2(workspace, dataflow)

Delete a dataflow from the specified workspace.

Parameters:

Name Type Description Default
workspace str

The name or ID of the workspace to delete.

required
dataflow str

The name or ID of the dataflow to delete.

required

Returns:

Name Type Description
None None

If the dataflow is successfully deleted.

Raises:

Type Description
ResourceNotFoundError

If the specified workspace is not found.

Examples:

delete_dataflow('MyProjectWorkspace', 'SalesDataflow')
delete_dataflow('123e4567-e89b-12d3-a456-426614174000', 'SalesDataflow')
Source code in src/pyfabricops/items/dataflows_gen2.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
def delete_dataflow_gen2(workspace: str, dataflow: str) -> None:
    """
    Delete a dataflow from the specified workspace.

    Args:
        workspace (str): The name or ID of the workspace to delete.
        dataflow (str): The name or ID of the dataflow to delete.

    Returns:
        None: If the dataflow is successfully deleted.

    Raises:
        ResourceNotFoundError: If the specified workspace is not found.

    Examples:
        ```python
        delete_dataflow('MyProjectWorkspace', 'SalesDataflow')
        delete_dataflow('123e4567-e89b-12d3-a456-426614174000', 'SalesDataflow')
        ```
    """
    workspace_id = resolve_workspace(workspace)

    dataflow_id = resolve_dataflow_gen2(workspace_id, dataflow)

    return api_request(
        endpoint='/workspaces/' + workspace_id + '/dataflows/' + dataflow_id,
        method='delete',
    )

get_dataflow_gen2(workspace, dataflow, *, df=True)

Gets a dataflow by its name or ID.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
dataflow str

The name or ID of the dataflow.

required
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[DataFrame, Dict[str, Any], None]

The dataflow details if found, otherwise None.

Examples:

get_dataflow('MyProjectWorkspace', 'SalesDataflow')
get_dataflow('123e4567-e89b-12d3-a456-426614174000', 'SalesDataflow')
Source code in src/pyfabricops/items/dataflows_gen2.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
@df
def get_dataflow_gen2(
    workspace: str,
    dataflow: str,
    *,
    df: Optional[bool] = True,
) -> Union[DataFrame, Dict[str, Any], None]:
    """
    Gets a dataflow by its name or ID.

    Args:
        workspace (str): The workspace name or ID.
        dataflow (str): The name or ID of the dataflow.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (Union[DataFrame, Dict[str, Any], None]): The dataflow details if found, otherwise None.

    Examples:
        ```python
        get_dataflow('MyProjectWorkspace', 'SalesDataflow')
        get_dataflow('123e4567-e89b-12d3-a456-426614174000', 'SalesDataflow')
        ```
    """
    workspace_id = resolve_workspace(workspace)

    dataflow_id = resolve_dataflow_gen2(workspace_id, dataflow)

    return api_request(
        endpoint='/workspaces/' + workspace_id + '/dataflows/' + dataflow_id,
    )

get_dataflow_gen2_definition(workspace, dataflow)

Retrieves the definition of a dataflow by its name or ID from the specified workspace.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
dataflow str

The name or ID of the dataflow.

required

Returns:

Type Description
Union[Dict[str, Any], None]

The dataflow definition if found, otherwise None.

Examples:

get_dataflow_definition('MyProjectWorkspace', 'Salesdataflow')
get_dataflow_definition('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
Source code in src/pyfabricops/items/dataflows_gen2.py
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
def get_dataflow_gen2_definition(
    workspace: str, dataflow: str
) -> Union[Dict[str, Any], None]:
    """
    Retrieves the definition of a dataflow by its name or ID from the specified workspace.

    Args:
        workspace (str): The workspace name or ID.
        dataflow (str): The name or ID of the dataflow.

    Returns:
        (Union[Dict[str, Any], None]): The dataflow definition if found, otherwise None.

    Examples:
        ```python
        get_dataflow_definition('MyProjectWorkspace', 'Salesdataflow')
        get_dataflow_definition('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
        ```
    """
    # Resolving IDs
    workspace_id = resolve_workspace(workspace)

    dataflow_id = resolve_dataflow_gen2(workspace_id, dataflow)

    return api_request(
        endpoint='/workspaces/'
        + workspace_id
        + '/dataflows/'
        + dataflow_id
        + '/getDefinition',
        method='post',
        support_lro=True,
    )

get_dataflow_gen2_id(workspace, dataflow_gen2_name)

Retrieves the ID of a dataflow by its name.

Parameters:

Name Type Description Default
dataflow_gen2_name str

The name of the dataflow.

required

Returns:

Type Description
Union[str, None]

The ID of the dataflow if found, otherwise None.

Source code in src/pyfabricops/items/dataflows_gen2.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def get_dataflow_gen2_id(
    workspace: str, dataflow_gen2_name: str
) -> Union[str, None]:
    """
    Retrieves the ID of a dataflow by its name.

    Args:
        dataflow_gen2_name (str): The name of the dataflow.

    Returns:
        (Union[str, None]): The ID of the dataflow if found, otherwise None.
    """
    dataflows = list_dataflows_gen2(
        workspace=resolve_workspace(workspace),
        df=False,
    )

    for _dataflow in dataflows:
        if _dataflow['displayName'] == dataflow_gen2_name:
            return _dataflow['id']
    logger.warning(
        f"Dataflow '{dataflow_gen2_name}' not found in workspace '{workspace}'."
    )
    return None

list_dataflows_gen2(workspace, *, df=True)

Lists all dataflows in a workspace.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[DataFrame, List[Dict[str, Any]], None]

list | pandas.DataFrame | None: A list of dataflows if successful, otherwise None.

Source code in src/pyfabricops/items/dataflows_gen2.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
@df
def list_dataflows_gen2(
    workspace: str,
    *,
    df: Optional[bool] = True,
) -> Union[DataFrame, List[Dict[str, Any]], None]:
    """
    Lists all dataflows in a workspace.

    Args:
        workspace (str): The workspace name or ID.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        list | pandas.DataFrame | None: A list of dataflows if successful, otherwise None.
    """
    workspace_id = resolve_workspace(workspace)

    return api_request(
        endpoint='/workspaces/' + workspace_id + '/dataflows',
        support_pagination=True,
    )

resolve_dataflow_gen2(workspace, dataflow)

Resolves a dataflow name to its ID.

Parameters:

Name Type Description Default
workspace str

The ID of the workspace.

required
dataflow str

The name of the dataflow.

required

Returns:

Type Description
Union[str, None]

The ID of the dataflow, or None if not found.

Examples:

resolve_dataflow('MyProjectWorkspace', 'SalesDataflow')
resolve_dataflow('123e4567-e89b-12d3-a456-426614174000', 'SalesDataflow')
Source code in src/pyfabricops/items/dataflows_gen2.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def resolve_dataflow_gen2(
    workspace: str,
    dataflow: str,
) -> Union[str, None]:
    """
    Resolves a dataflow name to its ID.

    Args:
        workspace (str): The ID of the workspace.
        dataflow (str): The name of the dataflow.

    Returns:
        (Union[str, None]): The ID of the dataflow, or None if not found.

    Examples:
        ```python
        resolve_dataflow('MyProjectWorkspace', 'SalesDataflow')
        resolve_dataflow('123e4567-e89b-12d3-a456-426614174000', 'SalesDataflow')
        ```
    """
    if is_valid_uuid(dataflow):
        return dataflow
    else:
        return get_dataflow_gen2_id(resolve_workspace(workspace), dataflow)

update_dataflow_gen2(workspace, dataflow, *, display_name=None, description=None, df=True)

Updates the properties of the specified dataflow.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
dataflow str

The name or ID of the dataflow to update.

required
display_name str

The new display name for the dataflow.

None
description str

The new description for the dataflow.

None
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[DataFrame, Dict[str, Any], None]

The updated dataflow details if successful, otherwise None.

Examples:

update_dataflow('MyProjectWorkspace', 'SalesDataModel', display_name='UpdatedSalesDataModel')
update_dataflow('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', description='Updated description')
Source code in src/pyfabricops/items/dataflows_gen2.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@df
def update_dataflow_gen2(
    workspace: str,
    dataflow: str,
    *,
    display_name: str = None,
    description: str = None,
    df: Optional[bool] = True,
) -> Union[DataFrame, Dict[str, Any], None]:
    """
    Updates the properties of the specified dataflow.

    Args:
        workspace (str): The workspace name or ID.
        dataflow (str): The name or ID of the dataflow to update.
        display_name (str, optional): The new display name for the dataflow.
        description (str, optional): The new description for the dataflow.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (Union[DataFrame, Dict[str, Any], None]): The updated dataflow details if successful, otherwise None.

    Examples:
        ```python
        update_dataflow('MyProjectWorkspace', 'SalesDataModel', display_name='UpdatedSalesDataModel')
        update_dataflow('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', description='Updated description')
        ```
    """
    workspace_id = resolve_workspace(workspace)

    dataflow_id = resolve_dataflow_gen2(workspace_id, dataflow)

    payload = {}

    if display_name:
        payload['displayName'] = display_name

    if description:
        payload['description'] = description

    return api_request(
        endpoint='/workspaces/' + workspace_id + '/dataflows/' + dataflow_id,
        method='patch',
        payload=payload,
    )

update_dataflow_gen2_definition(workspace, dataflow, item_definition, df=True)

Updates the definition of an existing dataflow in the specified workspace. If the dataflow does not exist, it returns None.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
dataflow str

The name or ID of the dataflow to update.

required
item_definition Dict[str, Any]

The updated item definition.

required
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[Dict[str, Any], None]

The updated dataflow details if successful, otherwise None.

Examples:

update_dataflow('MyProjectWorkspace', 'SalesDataModel', display_name='UpdatedSalesDataModel')
update_dataflow('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', description='Updated description')
Source code in src/pyfabricops/items/dataflows_gen2.py
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
@df
def update_dataflow_gen2_definition(
    workspace: str,
    dataflow: str,
    item_definition: Dict[str, Any],
    df: Optional[bool] = True,
) -> Union[Dict[str, Any], None]:
    """
    Updates the definition of an existing dataflow in the specified workspace.
    If the dataflow does not exist, it returns None.

    Args:
        workspace (str): The workspace name or ID.
        dataflow (str): The name or ID of the dataflow to update.
        item_definition (Dict[str, Any]): The updated item definition.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (Union[Dict[str, Any], None]): The updated dataflow details if successful, otherwise None.

    Examples:
        ```python
        update_dataflow('MyProjectWorkspace', 'SalesDataModel', display_name='UpdatedSalesDataModel')
        update_dataflow('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', description='Updated description')
        ```
    """
    workspace_id = resolve_workspace(workspace)

    dataflow_id = resolve_dataflow_gen2(workspace_id, dataflow)

    payload = {'definition': item_definition}

    params = {'updateMetadata': True}

    return api_request(
        endpoint='/workspaces/'
        + workspace_id
        + '/dataflows/'
        + dataflow_id
        + '/updateDefinition',
        method='patch',
        payload=payload,
        params=params,
        support_lro=True,
    )