Skip to content

Commit ce5b2e1

Browse files
committed
fabric_sp
1 parent 3588e06 commit ce5b2e1

File tree

5 files changed

+88
-40
lines changed

5 files changed

+88
-40
lines changed

src/sempy_labs/_data_pipelines.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Optional
33
from sempy_labs._helper_functions import (
44
resolve_workspace_name_and_id,
5+
resolve_workspace_id,
56
_decode_b64,
67
_base_api,
78
resolve_item_id,
@@ -20,6 +21,8 @@ def list_data_pipelines(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
2021
2122
This is a wrapper function for the following API: `Items - List Data Pipelines <https://learn.microsoft.com/rest/api/fabric/datapipeline/items/list-data-pipelines>`_.
2223
24+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
25+
2326
Parameters
2427
----------
2528
workspace : str | uuid.UUID, default=None
@@ -40,20 +43,26 @@ def list_data_pipelines(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
4043
}
4144
df = _create_dataframe(columns=columns)
4245

43-
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
46+
workspace_id = resolve_workspace_id(workspace)
4447

4548
responses = _base_api(
46-
request=f"/v1/workspaces/{workspace_id}/dataPipelines", uses_pagination=True
49+
request=f"/v1/workspaces/{workspace_id}/dataPipelines",
50+
uses_pagination=True,
51+
client="fabric_sp",
4752
)
4853

54+
rows = []
4955
for r in responses:
5056
for v in r.get("value", []):
51-
new_data = {
52-
"Data Pipeline Name": v.get("displayName"),
53-
"Data Pipeline ID": v.get("id"),
54-
"Description": v.get("description"),
55-
}
56-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
57+
rows.append(
58+
{
59+
"Data Pipeline Name": v.get("displayName"),
60+
"Data Pipeline ID": v.get("id"),
61+
"Description": v.get("description"),
62+
}
63+
)
64+
if rows:
65+
df = pd.DataFrame(rows, columns=columns.keys())
5766

5867
return df
5968

@@ -67,6 +76,8 @@ def create_data_pipeline(
6776
6877
This is a wrapper function for the following API: `Items - Create Data Pipeline <https://learn.microsoft.com/rest/api/fabric/datapipeline/items/create-data-pipeline>`_.
6978
79+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
80+
7081
Parameters
7182
----------
7283
name: str
@@ -91,6 +102,8 @@ def delete_data_pipeline(name: str | UUID, workspace: Optional[str | UUID] = Non
91102
92103
This is a wrapper function for the following API: `Items - Delete Data Pipeline <https://learn.microsoft.com/rest/api/fabric/datapipeline/items/delete-data-pipeline>`_.
93104
105+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
106+
94107
Parameters
95108
----------
96109
name: str | uuid.UUID
@@ -130,14 +143,15 @@ def get_data_pipeline_definition(
130143
A pandas dataframe showing the data pipelines within a workspace.
131144
"""
132145

133-
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
146+
workspace_id = resolve_workspace_id(workspace)
134147

135148
item_id = resolve_item_id(item=name, type="DataPipeline", workspace=workspace)
136149
result = _base_api(
137150
request=f"/v1/workspaces/{workspace_id}/dataPipelines/{item_id}/getDefinition",
138151
method="post",
139152
lro_return_json=True,
140153
status_codes=None,
154+
client="fabric_sp",
141155
)
142156
df = pd.json_normalize(result["definition"]["parts"])
143157

src/sempy_labs/_dataflows.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ def get_dataflow_definition(
333333
result = _base_api(
334334
request=f"/v1.0/myorg/groups/{workspace_id}/dataflows/{dataflow_id}",
335335
client="fabric_sp",
336-
method="get",
337336
).json()
338337

339338
return result

src/sempy_labs/_deployment_pipelines.py

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def list_deployment_pipelines() -> pd.DataFrame:
1717
1818
This is a wrapper function for the following API: `Deployment Pipelines - List Deployment Pipelines <https://learn.microsoft.com/rest/api/fabric/core/deployment-pipelines/list-deployment-pipelines>`_.
1919
20+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
21+
2022
Returns
2123
-------
2224
pandas.DataFrame
@@ -34,16 +36,22 @@ def list_deployment_pipelines() -> pd.DataFrame:
3436
request="/v1/deploymentPipelines",
3537
status_codes=200,
3638
uses_pagination=True,
39+
client="fabric_sp",
3740
)
3841

42+
rows = []
3943
for r in responses:
4044
for v in r.get("value", []):
41-
new_data = {
42-
"Deployment Pipeline Id": v.get("id"),
43-
"Deployment Pipeline Name": v.get("displayName"),
44-
"Description": v.get("description"),
45-
}
46-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
45+
rows.append(
46+
{
47+
"Deployment Pipeline Id": v.get("id"),
48+
"Deployment Pipeline Name": v.get("displayName"),
49+
"Description": v.get("description"),
50+
}
51+
)
52+
53+
if rows:
54+
df = pd.DataFrame(rows, columns=columns.keys())
4755

4856
return df
4957

@@ -55,6 +63,8 @@ def list_deployment_pipeline_stages(deployment_pipeline: str | UUID) -> pd.DataF
5563
5664
This is a wrapper function for the following API: `Deployment Pipelines - List Deployment Pipeline Stages <https://learn.microsoft.com/rest/api/fabric/core/deployment-pipelines/list-deployment-pipeline-stages>`_.
5765
66+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
67+
5868
Parameters
5969
----------
6070
deployment_pipeline : str | uuid.UUID
@@ -87,22 +97,26 @@ def list_deployment_pipeline_stages(deployment_pipeline: str | UUID) -> pd.DataF
8797
request=f"/v1/deploymentPipelines/{deployment_pipeline_id}/stages",
8898
status_codes=200,
8999
uses_pagination=True,
100+
client="fabric_sp",
90101
)
91102

103+
rows = []
92104
for r in responses:
93105
for v in r.get("value", []):
94-
new_data = {
95-
"Deployment Pipeline Stage Id": v.get("id"),
96-
"Deployment Pipeline Stage Name": v.get("displayName"),
97-
"Description": v.get("description"),
98-
"Order": v.get("order"),
99-
"Workspace Id": v.get("workspaceId"),
100-
"Workspace Name": v.get("workspaceName"),
101-
"Public": v.get("isPublic"),
102-
}
103-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
104-
105-
_update_dataframe_datatypes(dataframe=df, column_map=columns)
106+
rows.append(
107+
{
108+
"Deployment Pipeline Stage Id": v.get("id"),
109+
"Deployment Pipeline Stage Name": v.get("displayName"),
110+
"Description": v.get("description"),
111+
"Order": v.get("order"),
112+
"Workspace Id": v.get("workspaceId"),
113+
"Workspace Name": v.get("workspaceName"),
114+
"Public": v.get("isPublic"),
115+
}
116+
)
117+
if rows:
118+
df = pd.DataFrame(rows, columns=list(columns.keys()))
119+
_update_dataframe_datatypes(df, columns)
106120

107121
return df
108122

@@ -117,6 +131,8 @@ def list_deployment_pipeline_stage_items(
117131
118132
This is a wrapper function for the following API: `Deployment Pipelines - List Deployment Pipeline Stage Items <https://learn.microsoft.com/rest/api/fabric/core/deployment-pipelines/list-deployment-pipeline-stage-items>`_.
119133
134+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
135+
120136
Parameters
121137
----------
122138
deployment_pipeline : str | uuid.UUID
@@ -170,18 +186,24 @@ def resolve_deployment_pipeline_stage_id(
170186
request=f"/v1/deploymentPipelines/{deployment_pipeline_id}/stages/{stage_id}/items",
171187
status_codes=200,
172188
uses_pagination=True,
189+
client="fabric_sp",
173190
)
174191

192+
rows = []
175193
for r in responses:
176194
for v in r.get("value", []):
177-
new_data = {
178-
"Deployment Pipeline Stage Item Id": v.get("itemId"),
179-
"Deployment Pipeline Stage Item Name": v.get("itemDisplayName"),
180-
"Item Type": v.get("itemType"),
181-
"Source Item Id": v.get("sourceItemId"),
182-
"Target Item Id": v.get("targetItemId"),
183-
"Last Deployment Time": v.get("lastDeploymentTime"),
184-
}
185-
df = pd.concat([df, pd.DataFrame(new_data, index=[0])], ignore_index=True)
195+
rows.append(
196+
{
197+
"Deployment Pipeline Stage Item Id": v.get("itemId"),
198+
"Deployment Pipeline Stage Item Name": v.get("itemDisplayName"),
199+
"Item Type": v.get("itemType"),
200+
"Source Item Id": v.get("sourceItemId"),
201+
"Target Item Id": v.get("targetItemId"),
202+
"Last Deployment Time": v.get("lastDeploymentTime"),
203+
}
204+
)
205+
206+
if rows:
207+
df = pd.DataFrame(rows, columns=list(columns.keys()))
186208

187209
return df

src/sempy_labs/_eventstreams.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def list_eventstreams(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
1919
2020
This is a wrapper function for the following API: `Items - List Eventstreams <https://learn.microsoft.com/rest/api/fabric/environment/items/list-eventstreams>`_.
2121
22+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
23+
2224
Parameters
2325
----------
2426
workspace : str | uuid.UUID, default=None
@@ -41,7 +43,9 @@ def list_eventstreams(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
4143

4244
workspace_id = resolve_workspace_id(workspace)
4345
responses = _base_api(
44-
request=f"/v1/workspaces/{workspace_id}/eventstreams", uses_pagination=True
46+
request=f"/v1/workspaces/{workspace_id}/eventstreams",
47+
uses_pagination=True,
48+
client="fabric_sp",
4549
)
4650

4751
rows = []
@@ -70,6 +74,8 @@ def create_eventstream(
7074
7175
This is a wrapper function for the following API: `Items - Create Eventstream <https://learn.microsoft.com/rest/api/fabric/environment/items/create-eventstream>`_.
7276
77+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
78+
7379
Parameters
7480
----------
7581
name: str
@@ -96,6 +102,8 @@ def delete_eventstream(
96102
97103
This is a wrapper function for the following API: `Items - Delete Eventstream <https://learn.microsoft.com/rest/api/fabric/environment/items/delete-eventstream>`_.
98104
105+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
106+
99107
Parameters
100108
----------
101109
eventstream: str | uuid.UUID

src/sempy_labs/_job_scheduler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def _get_item_job_instance(url: str) -> pd.DataFrame:
114114
}
115115
df = _create_dataframe(columns=columns)
116116

117-
response = _base_api(request=url)
117+
response = _base_api(request=url, client="fabric_sp")
118118

119119
rows = []
120120
for v in response.json().get("value", []):
@@ -198,7 +198,8 @@ def list_item_schedules(
198198
}
199199

200200
response = _base_api(
201-
request=f"v1/workspaces/{workspace_id}/items/{item_id}/jobs/{job_type}/schedules"
201+
request=f"v1/workspaces/{workspace_id}/items/{item_id}/jobs/{job_type}/schedules",
202+
client="fabric_sp",
202203
)
203204

204205
rows = []
@@ -292,6 +293,7 @@ def run_on_demand_item_job(
292293
method="post",
293294
lro_return_status_code=True,
294295
status_codes=202,
296+
client="fabric_sp",
295297
)
296298

297299
print(f"{icons.green_dot} The '{item_name}' {type.lower()} has been executed.")
@@ -359,6 +361,7 @@ def create_item_schedule_cron(
359361
method="post",
360362
payload=payload,
361363
status_codes=201,
364+
client="fabric_sp",
362365
)
363366

364367
print(
@@ -428,6 +431,7 @@ def create_item_schedule_daily(
428431
method="post",
429432
payload=payload,
430433
status_codes=201,
434+
client="fabric_sp",
431435
)
432436

433437
print(
@@ -517,6 +521,7 @@ def create_item_schedule_weekly(
517521
method="post",
518522
payload=payload,
519523
status_codes=201,
524+
client="fabric_sp",
520525
)
521526

522527
print(

0 commit comments

Comments
 (0)