msfabricpysdkcore 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -254,8 +254,104 @@ class FabricClientCore(FabricClient):
254
254
 
255
255
  # Deployment Pipelines
256
256
 
257
+ # POST https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/roleAssignments
258
+ def add_deployment_pipeline_role_assignment(self, deployment_pipeline_id, principal, role):
259
+ """Add a role assignment to a deployment pipeline
260
+ Args:
261
+ deployment_pipeline_id (str): The ID of the deployment pipeline
262
+ principal (str): The principal
263
+ role (str): The role
264
+ Returns:
265
+ dict: The role assignment
266
+ """
267
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/roleAssignments"
268
+
269
+ body = {
270
+ 'principal': principal,
271
+ 'role': role
272
+ }
273
+
274
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429],
275
+ error_message="Error adding deployment pipeline role assignment", return_format="response")
276
+ return response.status_code
277
+
278
+ # POST https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/stages/{stageId}/assignWorkspace
279
+ def assign_workspace_to_stage(self, deployment_pipeline_id, stage_id, workspace_id):
280
+ """Assign a workspace to a stage
281
+ Args:
282
+ deployment_pipeline_id (str): The ID of the deployment pipeline
283
+ stage_id (str): The ID of the stage
284
+ workspace_id (str): The ID of the workspace
285
+ Returns:
286
+ dict: The workspace assignment
287
+ """
288
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/stages/{stage_id}/assignWorkspace"
289
+
290
+ body = {
291
+ 'workspaceId': workspace_id
292
+ }
293
+
294
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429],
295
+ error_message="Error assigning workspace to stage", return_format="response")
296
+ return response.status_code
297
+
298
+ # POST https://api.fabric.microsoft.com/v1/deploymentPipelines
299
+ def create_deployment_pipeline(self, display_name, stages, description = None):
300
+ """Create a deployment pipeline
301
+ Args:
302
+ display_name (str): The display name of the deployment pipeline
303
+ stages (list): The stages of the deployment pipeline
304
+ description (str): The description of the deployment pipeline
305
+ Returns:
306
+ dict: The deployment pipeline
307
+ """
308
+ url = "https://api.fabric.microsoft.com/v1/deploymentPipelines"
309
+
310
+ body = {
311
+ 'displayName': display_name,
312
+ 'stages': stages
313
+ }
314
+ if description:
315
+ body['description'] = description
316
+
317
+ response_json = self.calling_routine(url, operation="POST", body=body, response_codes=[201, 429],
318
+ error_message="Error creating deployment pipeline", return_format="json")
319
+
320
+ from msfabricpysdkcore.deployment_pipeline import DeploymentPipeline
321
+ deployment_pipeline = DeploymentPipeline.from_dict(response_json, self)
322
+ return deployment_pipeline
323
+
324
+ # DELETE https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}
325
+ def delete_deployment_pipeline(self, deployment_pipeline_id):
326
+ """Delete a deployment pipeline
327
+ Args:
328
+ deployment_pipeline_id (str): The ID of the deployment pipeline
329
+ Returns:
330
+ int: The status code of the response
331
+ """
332
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}"
333
+
334
+ response = self.calling_routine(url, operation="DELETE", response_codes=[200, 429], return_format="response",
335
+ error_message="Error deleting deployment pipeline")
336
+ return response.status_code
337
+
338
+ # DELETE https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/roleAssignments/{principalId}
339
+ def delete_deployment_pipeline_role_assignment(self, deployment_pipeline_id, principal_id):
340
+ """Delete a role assignment for a deployment pipeline
341
+ Args:
342
+ deployment_pipeline_id (str): The ID of the deployment pipeline
343
+ principal_id (str): The ID of the principal
344
+ Returns:
345
+ int: The status code of the response
346
+ """
347
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/roleAssignments/{principal_id}"
348
+
349
+ response = self.calling_routine(url, operation="DELETE", response_codes=[200, 429], return_format="response",
350
+ error_message="Error deleting deployment pipeline role assignment")
351
+ return response.status_code
352
+
257
353
  def deploy_stage_content(self, deployment_pipeline_id, source_stage_id, target_stage_id, created_workspace_details = None,
258
- items = None, note = None, wait_for_completion = True):
354
+ items = None, note = None, options = None, wait_for_completion = True):
259
355
  """Deploy stage content
260
356
  Args:
261
357
  deployment_pipeline_id (str): The ID of the deployment pipeline
@@ -264,6 +360,7 @@ class FabricClientCore(FabricClient):
264
360
  created_workspace_details (list): A list of created workspace details
265
361
  items (list): A list of items
266
362
  note (str): A note
363
+ options (dict): A dictionary of options
267
364
  wait_for_completion (bool): Whether to wait for the deployment to complete
268
365
  Returns:
269
366
  Details about the dpeloyment
@@ -284,31 +381,127 @@ class FabricClientCore(FabricClient):
284
381
  body["items"] = items
285
382
  if note:
286
383
  body["note"] = note
384
+ if options:
385
+ body["options"] = options
287
386
 
288
387
  json_operation_result = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 202, 429], error_message="Error deploying stage content",
289
388
  return_format="json+operation_result", wait_for_completion=wait_for_completion)
290
389
 
291
390
  return json_operation_result
292
391
 
293
- def get_deployment_pipeline(self, deployment_pipeline_id):
392
+ def get_deployment_pipeline(self, deployment_pipeline_id = None, deployment_pipeline_name = None, with_details = False):
294
393
  """Get a deployment pipeline
295
394
  Args:
296
395
  deployment_pipeline_id (str): The ID of the deployment pipeline
297
396
  Returns:
298
397
  DeploymentPipeline: The deployment pipeline
299
398
  """
399
+ if deployment_pipeline_id is None and deployment_pipeline_name is not None:
400
+ deployment_pipelines = self.list_deployment_pipelines()
401
+ for deployment_pipeline in deployment_pipelines:
402
+ if deployment_pipeline["displayName"] == deployment_pipeline_name:
403
+ deployment_pipeline_id = deployment_pipeline["id"]
404
+ break
405
+
406
+ if deployment_pipeline_id is None:
407
+ raise Exception("No deployment_pipeline_id given and deployment_pipeline_name is not found")
408
+
409
+
300
410
  from msfabricpysdkcore.deployment_pipeline import DeploymentPipeline
301
411
  url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}"
302
412
 
303
413
  result_json = self.calling_routine(url, operation="GET", response_codes=[200, 429], error_message="Error getting deployment pipeline", return_format="json")
304
414
 
305
- return DeploymentPipeline.from_dict(result_json, self)
415
+ deply = DeploymentPipeline.from_dict(result_json, self)
416
+
417
+ if with_details:
418
+ stages_ = []
419
+ from msfabricpysdkcore.deployment_pipeline import DeploymentPipelineStage
420
+ for stage in deply.stages:
421
+ stage_items = self.list_deployment_pipeline_stage_items(deployment_pipeline_id, stage["id"])
422
+ stage["items"] = stage_items
423
+ stage["deploymentPipelineId"] = deployment_pipeline_id
424
+ depl_pipe_stage = DeploymentPipelineStage.from_dict(stage, self)
425
+ stages_.append(depl_pipe_stage)
426
+ deply.stages = stages_
427
+
428
+ return deply
429
+
430
+ # GET https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/operations/{operationId}
431
+ def get_deployment_pipeline_operation(self, deployment_pipeline_id, operation_id):
432
+ """Get a deployment pipeline operation
433
+ Args:
434
+ deployment_pipeline_id (str): The ID of the deployment pipeline
435
+ operation_id (str): The ID of the operation
436
+ Returns:
437
+ dict: The deployment pipeline operation
438
+ """
439
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/operations/{operation_id}"
440
+
441
+ response_json = self.calling_routine(url, operation="GET", response_codes=[200, 429],
442
+ error_message="Error getting deployment pipeline operation", return_format="json")
443
+ return response_json
444
+
445
+ # GET https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/stages/{stageId}
446
+ def get_deployment_pipeline_stage(self, deployment_pipeline_id, stage_id, with_details = False):
447
+ """Get a deployment pipeline stage
448
+ Args:
449
+ deployment_pipeline_id (str): The ID of the deployment pipeline
450
+ stage_id (str): The ID of the stage
451
+ Returns:
452
+ dict: The deployment pipeline stage
453
+ """
454
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/stages/{stage_id}"
455
+
456
+ stage = self.calling_routine(url, operation="GET", response_codes=[200, 429],
457
+ error_message="Error getting deployment pipeline stage", return_format="json")
458
+
459
+ if not with_details:
460
+ stage["items"] = []
461
+ else:
462
+ stage_items = self.list_deployment_pipeline_stage_items(deployment_pipeline_id, stage["id"])
463
+ stage["items"] = stage_items
464
+
465
+ stage["deploymentPipelineId"] = deployment_pipeline_id
466
+ from msfabricpysdkcore.deployment_pipeline import DeploymentPipelineStage
467
+
468
+ depl_pipe_stage = DeploymentPipelineStage.from_dict(stage, self)
469
+ return depl_pipe_stage
470
+
471
+
472
+ # GET https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/operations
473
+ def list_deployment_pipeline_operations(self, deployment_pipeline_id):
474
+ """List deployment pipeline operations
475
+ Args:
476
+ deployment_pipeline_id (str): The ID of the deployment pipeline
477
+ Returns:
478
+ list: The list of deployment pipeline operations
479
+ """
480
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/operations"
481
+
482
+ items = self.calling_routine(url, operation="GET", response_codes=[200, 429],
483
+ error_message="Error listing deployment pipeline operations", return_format="value_json", paging=True)
484
+
485
+ return items
486
+
487
+ # GET https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/roleAssignments
488
+ def list_deployment_pipeline_role_assignments(self, deployment_pipeline_id):
489
+ """List role assignments for a deployment pipeline
490
+ Args:
491
+ deployment_pipeline_id (str): The ID of the deployment pipeline
492
+ Returns:
493
+ list: The list of role assignments
494
+ """
495
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/roleAssignments"
496
+
497
+ items = self.calling_routine(url, operation="GET", response_codes=[200, 429],
498
+ error_message="Error listing deployment pipeline role assignments", return_format="value_json", paging=True)
499
+
500
+ return items
306
501
 
307
- def get_deployment_pipeline_stages_items(self, pipeline_id, stage_id = None, stage_name = None):
308
- warn("DEPRECATED: get_deployment_pipeline_stages_items. get_deployment_pipeline_stages_items. Use list_deployment_pipeline_stages_items instead", DeprecationWarning, stacklevel=2)
309
- return self.list_deployment_pipeline_stages_items(pipeline_id, stage_id, stage_name)
310
502
 
311
- def list_deployment_pipeline_stages_items(self, deployment_pipeline_id, stage_id = None, stage_name = None):
503
+
504
+ def list_deployment_pipeline_stage_items(self, deployment_pipeline_id, stage_id = None, stage_name = None):
312
505
  """List the items in a deployment stage
313
506
  Args:
314
507
  pipeline_id (str): The ID of the deployment pipeline
@@ -334,25 +527,15 @@ class FabricClientCore(FabricClient):
334
527
  error_message="Error getting deployment pipeline stage items", return_format="value_json", paging=True)
335
528
 
336
529
  return items
337
-
338
- def get_deployment_pipeline_stages(self, pipeline_id):
339
- """Get the stages of a deployment pipeline
340
- Args:
341
- pipeline_id (str): The ID of the deployment pipeline
342
- Returns:
343
- list: List of DeploymentPipelineStage objects
344
- """
345
- warn("DEPRECATED: get_deployment_pipeline_stages. Use list_deployment_pipeline_stages instead", DeprecationWarning, stacklevel=2)
346
- return self.list_deployment_pipeline_stages(pipeline_id)
347
-
348
- def list_deployment_pipeline_stages(self, deployment_pipeline_id):
530
+
531
+ def list_deployment_pipeline_stages(self, deployment_pipeline_id, with_details = False):
349
532
  """Get the stages of a deployment pipeline
350
533
  Args:
351
534
  pipeline_id (str): The ID of the deployment pipeline
352
535
  Returns:
353
536
  list: List of DeploymentPipelineStage objects
354
537
  """
355
- from msfabricpysdkcore.deployment_pipeline import Deployment_Pipeline_Stage
538
+ from msfabricpysdkcore.deployment_pipeline import DeploymentPipelineStage
356
539
 
357
540
  url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/stages"
358
541
 
@@ -361,28 +544,97 @@ class FabricClientCore(FabricClient):
361
544
 
362
545
  for item in items:
363
546
  item["deploymentPipelineId"] = deployment_pipeline_id
364
- stages = [Deployment_Pipeline_Stage.from_dict(item, self) for item in items]
547
+ item["items"] = []
548
+ if with_details:
549
+ items = self.list_deployment_pipeline_stage_items(deployment_pipeline_id, item["id"])
550
+ item["items"] = items
551
+
552
+ stages = [DeploymentPipelineStage.from_dict(item, self) for item in items]
553
+
365
554
 
366
555
  return stages
367
556
 
368
- def list_deployment_pipelines(self):
557
+ def list_deployment_pipelines(self, with_details = False):
369
558
  """List deployment pipelines
370
559
  Returns:
371
560
  list: List of DeploymentPipeline objects
372
561
  """
373
- from msfabricpysdkcore.deployment_pipeline import DeploymentPipeline
374
562
 
375
563
  url = "https://api.fabric.microsoft.com/v1/deploymentPipelines"
376
564
 
377
565
  items = self.calling_routine(url, operation="GET", response_codes=[200, 429],
378
566
  error_message="Error listing deployment pipelines", return_format="value_json", paging=True)
379
567
 
568
+ if with_details:
569
+ items = [self.get_deployment_pipeline(i["id"], with_details) for i in items]
380
570
 
381
- dep_pipes = [DeploymentPipeline.from_dict(i, core_client=self) for i in items]
571
+ return items
572
+
573
+ # POST https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/stages/{stageId}/unassignWorkspace
574
+ def unassign_workspace_from_stage(self, deployment_pipeline_id, stage_id):
575
+ """Unassign a workspace from a stage
576
+ Args:
577
+ deployment_pipeline_id (str): The ID of the deployment pipeline
578
+ stage_id (str): The ID of the stage
579
+ Returns:
580
+ dict: The workspace unassignment
581
+ """
582
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/stages/{stage_id}/unassignWorkspace"
583
+
584
+ response = self.calling_routine(url, operation="POST", response_codes=[200, 429],
585
+ error_message="Error unassigning workspace from stage", return_format="response")
586
+ return response.status_code
587
+
588
+ # PATCH https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}
589
+ def update_deployment_pipeline(self, deployment_pipeline_id, display_name = None, description = None):
590
+ """Update a deployment pipeline
591
+ Args:
592
+ deployment_pipeline_id (str): The ID of the deployment pipeline
593
+ display_name (str): The display name of the deployment pipeline
594
+ description (str): The description of the deployment pipeline
595
+ Returns:
596
+ dict: The updated deployment pipeline
597
+ """
598
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}"
599
+ body = {}
600
+ if display_name:
601
+ body['displayName'] = display_name
602
+ if description:
603
+ body['description'] = description
604
+
605
+ response_json = self.calling_routine(url, operation="PATCH", body=body, response_codes=[200, 429],
606
+ error_message="Error updating deployment pipeline", return_format="json")
607
+
608
+ from msfabricpysdkcore.deployment_pipeline import DeploymentPipeline
609
+ deployment_pipeline = DeploymentPipeline.from_dict(response_json, self)
610
+ return deployment_pipeline
611
+
612
+ # PATCH https://api.fabric.microsoft.com/v1/deploymentPipelines/{deploymentPipelineId}/stages/{stageId}
613
+ def update_deployment_pipeline_stage(self, deployment_pipeline_id, stage_id, display_name, description = None, is_public = None):
614
+ """Update a deployment pipeline stage
615
+ Args:
616
+ deployment_pipeline_id (str): The ID of the deployment pipeline
617
+ stage_id (str): The ID of the stage
618
+ display_name (str): The display name of the stage
619
+ description (str): The description of the stage
620
+ Returns:
621
+ dict: The updated deployment pipeline stage
622
+ """
623
+ url = f"https://api.fabric.microsoft.com/v1/deploymentPipelines/{deployment_pipeline_id}/stages/{stage_id}"
624
+
625
+ body = {}
626
+ body['displayName'] = display_name
627
+ if description:
628
+ body['description'] = description
629
+ if is_public is not None:
630
+ body['isPublic'] = is_public
382
631
 
383
- return dep_pipes
632
+ response_json = self.calling_routine(url, operation="PATCH", body=body, response_codes=[200, 429],
633
+ error_message="Error updating deployment pipeline stage", return_format="json")
634
+
635
+ return response_json
384
636
 
385
- # External Data Shares
637
+ # External Data Shares Provider
386
638
 
387
639
  # create
388
640
 
@@ -455,6 +707,173 @@ class FabricClientCore(FabricClient):
455
707
  response = self.calling_routine(url, operation="POST", response_codes=[200, 429], error_message="Error revoking external data share", return_format="response")
456
708
  return response.status_code
457
709
 
710
+ # External Data Shares Recipient
711
+
712
+ # POST https://api.fabric.microsoft.com/v1/externalDataShares/invitations/{invitationId}/accept
713
+ def accept_external_data_share_invitation(self, invitation_id, item_id, payload, provider_tenant_id, workspace_id):
714
+ """Accept an external data share invitation
715
+ Args:
716
+ invitation_id (str): The ID of the invitation
717
+ item_id (str): The ID of the item
718
+ payload (dict): The payload of the invitation
719
+ provider_tenant_id (str): The ID of the provider tenant
720
+ workspace_id (str): The ID of the workspace
721
+ Returns:
722
+ dict: The external data share invitation
723
+ """
724
+ url = f"https://api.fabric.microsoft.com/v1/externalDataShares/invitations/{invitation_id}/accept"
725
+
726
+ body = {
727
+ 'itemId': item_id,
728
+ 'payload': payload,
729
+ 'providerTenantId': provider_tenant_id,
730
+ 'workspaceId': workspace_id
731
+ }
732
+ response_json = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429],
733
+ error_message="Error accepting external data share invitation", return_format="value_json")
734
+ return response_json
735
+
736
+ # GET https://api.fabric.microsoft.com/v1/externalDataShares/invitations/{invitationId}?providerTenantId={providerTenantId}
737
+ def get_external_data_share_invitation(self, invitation_id, provider_tenant_id):
738
+ """Get an external data share invitation
739
+ Args:
740
+ invitation_id (str): The ID of the invitation
741
+ provider_tenant_id (str): The ID of the provider tenant
742
+ Returns:
743
+ dict: The external data share invitation
744
+ """
745
+ url = f"https://api.fabric.microsoft.com/v1/externalDataShares/invitations/{invitation_id}?providerTenantId={provider_tenant_id}"
746
+
747
+ response_json = self.calling_routine(url, operation="GET", response_codes=[200, 429],
748
+ error_message="Error getting external data share invitation", return_format="json")
749
+ return response_json
750
+
751
+ # Folders
752
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/folders
753
+ def create_folder(self, workspace_id, display_name, parent_folder_id = None):
754
+ """Create a folder
755
+ Args:
756
+ workspace_id (str): The ID of the workspace
757
+ display_name (str): The display name of the folder
758
+ parent_folder_id (str): The ID of the parent folder
759
+ Returns:
760
+ dict: The folder
761
+ """
762
+ from msfabricpysdkcore.folder import Folder
763
+
764
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/folders"
765
+
766
+ body = {
767
+ 'displayName': display_name
768
+ }
769
+ if parent_folder_id:
770
+ body['parentFolderId'] = parent_folder_id
771
+
772
+ response_json = self.calling_routine(url, operation="POST", body=body, response_codes=[201, 429],
773
+ error_message="Error creating folder", return_format="json")
774
+
775
+ folder = Folder.from_dict(response_json, self)
776
+ return folder
777
+
778
+ # DELETE https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/folders/{folderId}
779
+ def delete_folder(self, workspace_id, folder_id):
780
+ """Delete a folder
781
+ Args:
782
+ workspace_id (str): The ID of the workspace
783
+ folder_id (str): The ID of the folder
784
+ Returns:
785
+ int: The status code of the response
786
+ """
787
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/folders/{folder_id}"
788
+
789
+ response = self.calling_routine(url, operation="DELETE", response_codes=[200, 429], return_format="response",
790
+ error_message="Error deleting folder")
791
+ return response.status_code
792
+
793
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/folders/{folderId}
794
+ def get_folder(self, workspace_id, folder_id):
795
+ """Get a folder
796
+ Args:
797
+ workspace_id (str): The ID of the workspace
798
+ folder_id (str): The ID of the folder
799
+ Returns:
800
+ dict: The folder
801
+ """
802
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/folders/{folder_id}"
803
+
804
+ response_json = self.calling_routine(url, operation="GET", response_codes=[200, 429],
805
+ error_message="Error getting folder", return_format="json")
806
+
807
+ from msfabricpysdkcore.folder import Folder
808
+
809
+ folder = Folder.from_dict(response_json, self)
810
+ return folder
811
+
812
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/folders
813
+ def list_folders(self, workspace_id):
814
+ """List folders
815
+ Args:
816
+ workspace_id (str): The ID of the workspace
817
+ Returns:
818
+ list: The list of folders
819
+ """
820
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/folders"
821
+
822
+ items = self.calling_routine(url, operation="GET", response_codes=[200, 429],
823
+ error_message="Error listing folders", return_format="value_json", paging=True)
824
+
825
+ from msfabricpysdkcore.folder import Folder
826
+
827
+ folders = [Folder.from_dict(item, self) for item in items]
828
+ return folders
829
+
830
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/folders/{folderId}/move
831
+ def move_folder(self, workspace_id, folder_id, target_folder_id = None):
832
+ """Move a folder
833
+ Args:
834
+ workspace_id (str): The ID of the workspace
835
+ folder_id (str): The ID of the folder
836
+ parent_folder_id (str): The ID of the parent folder
837
+ Returns:
838
+ dict: The moved folder
839
+ """
840
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/folders/{folder_id}/move"
841
+
842
+ body = {
843
+ }
844
+ if target_folder_id:
845
+ body['targetFolderId'] = target_folder_id
846
+
847
+ response_json = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429],
848
+ error_message="Error moving folder", return_format="json")
849
+
850
+ from msfabricpysdkcore.folder import Folder
851
+
852
+ folder = Folder.from_dict(response_json, self)
853
+ return folder
854
+
855
+ # PATCH https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/folders/{folderId}
856
+ def update_folder(self, workspace_id, folder_id, display_name = None):
857
+ """Update a folder
858
+ Args:
859
+ workspace_id (str): The ID of the workspace
860
+ folder_id (str): The ID of the folder
861
+ display_name (str): The display name of the folder
862
+ Returns:
863
+ dict: The updated folder
864
+ """
865
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/folders/{folder_id}"
866
+
867
+ body = {'displayName' : display_name}
868
+
869
+
870
+ response_json = self.calling_routine(url, operation="PATCH", body=body, response_codes=[200, 429],
871
+ error_message="Error updating folder", return_format="json")
872
+ from msfabricpysdkcore.folder import Folder
873
+
874
+ folder = Folder.from_dict(response_json, self)
875
+ return folder
876
+
458
877
  # Gateways
459
878
 
460
879
  def add_gateway_role_assignment(self, gateway_id, principal, role):
@@ -783,7 +1202,7 @@ class FabricClientCore(FabricClient):
783
1202
  """
784
1203
  url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/git/initializeConnection"
785
1204
 
786
- body = {'initializeGitConnectionRequest':initialization_strategy}
1205
+ body = {'initializationStrategy':initialization_strategy}
787
1206
 
788
1207
  response = self.calling_routine(url=url, operation="POST", body=body, response_codes=[200, 202, 429],
789
1208
  error_message="Error initializing connection", return_format="response")
@@ -861,6 +1280,12 @@ class FabricClientCore(FabricClient):
861
1280
  """
862
1281
  from msfabricpysdkcore.item import Item
863
1282
 
1283
+ if item_dict["type"] == "CopyJob":
1284
+ return self.get_copy_job(workspace_id, item_dict["id"])
1285
+ if item_dict["type"] == "VariableLibrary":
1286
+ return self.get_variable_library(workspace_id, item_dict["id"])
1287
+ if item_dict["type"] == "Dataflow":
1288
+ return self.get_dataflow(workspace_id, item_dict["id"])
864
1289
  if item_dict["type"] == "DataPipeline":
865
1290
  return self.get_data_pipeline(workspace_id, item_dict["id"])
866
1291
  if item_dict["type"] == "Eventstream":
@@ -935,7 +1360,10 @@ class FabricClientCore(FabricClient):
935
1360
  if description:
936
1361
  body['description'] = description
937
1362
 
938
- if type in ["dataPipelines",
1363
+ if type in ["copyJobs",
1364
+ "VariableLibraries",
1365
+ "dataflows",
1366
+ "dataPipelines",
939
1367
  "environments",
940
1368
  "eventhouses",
941
1369
  "eventstreams",
@@ -975,7 +1403,10 @@ class FabricClientCore(FabricClient):
975
1403
  item = None
976
1404
  i = 0
977
1405
 
978
- type_mapping = {"dataPipelines": "DataPipeline",
1406
+ type_mapping = {"copyJobs": "CopyJob",
1407
+ "VariableLibraries": "VariableLibrary",
1408
+ "dataflows": "Dataflow",
1409
+ "dataPipelines": "DataPipeline",
979
1410
  "environments": "Environment",
980
1411
  "eventhouses": "Eventhouse",
981
1412
  "eventstreams": "Eventstream",
@@ -1614,6 +2045,62 @@ class FabricClientCore(FabricClient):
1614
2045
 
1615
2046
  return response.status_code
1616
2047
 
2048
+ ### Tags
2049
+ # GET https://api.fabric.microsoft.com/v1/tags
2050
+ def list_tags(self):
2051
+ """List all tags
2052
+ Returns:
2053
+ list: The list of tags
2054
+ """
2055
+ url = "https://api.fabric.microsoft.com/v1/tags"
2056
+
2057
+ response_json = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2058
+ error_message="Error listing tags", return_format="value_json", paging=True)
2059
+
2060
+ return response_json
2061
+
2062
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/items/{itemId}/applyTags
2063
+ def apply_tags(self, workspace_id, item_id, tags):
2064
+ """Apply tags to an item
2065
+ Args:
2066
+ workspace_id (str): The ID of the workspace
2067
+ item_id (str): The ID of the item
2068
+ tags (list): The list of tags to apply
2069
+ Returns:
2070
+ int: The status code of the response
2071
+ """
2072
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/items/{item_id}/applyTags"
2073
+
2074
+ payload = {
2075
+ 'tags': tags
2076
+ }
2077
+
2078
+ response = self.calling_routine(url, operation="POST", body=payload,
2079
+ response_codes=[200, 429], error_message="Error applying tags", return_format="response")
2080
+
2081
+ return response.status_code
2082
+
2083
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/items/{itemId}/unapplyTags
2084
+ def unapply_tags(self, workspace_id, item_id, tags):
2085
+ """Unapply tags from an item
2086
+ Args:
2087
+ workspace_id (str): The ID of the workspace
2088
+ item_id (str): The ID of the item
2089
+ tags (list): The list of tags to unapply
2090
+ Returns:
2091
+ int: The status code of the response
2092
+ """
2093
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/items/{item_id}/unapplyTags"
2094
+
2095
+ payload = {
2096
+ 'tags': tags
2097
+ }
2098
+
2099
+ response = self.calling_routine(url, operation="POST", body=payload,
2100
+ response_codes=[200, 429], error_message="Error unapplying tags", return_format="response")
2101
+
2102
+ return response.status_code
2103
+
1617
2104
  ### Workspaces
1618
2105
 
1619
2106
  def add_workspace_role_assignment(self, workspace_id, role, principal):
@@ -1879,39 +2366,356 @@ class FabricClientCore(FabricClient):
1879
2366
  """Update a role assignment for a workspace
1880
2367
  Args:
1881
2368
  workspace_id (str): The ID of the workspace
1882
- role (str): The role to assign
1883
- workspace_role_assignment_id (str): The ID of the role assignment
2369
+ role (str): The role to assign
2370
+ workspace_role_assignment_id (str): The ID of the role assignment
2371
+ Returns:
2372
+ int: The status code of the response
2373
+ """
2374
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/roleAssignments/{workspace_role_assignment_id}"
2375
+ body = {
2376
+ 'role': role
2377
+ }
2378
+
2379
+ response = self.calling_routine(url, operation="PATCH", body=body, response_codes=[200, 429], error_message="Error updating role assignments", return_format="response")
2380
+
2381
+ return response.status_code
2382
+
2383
+
2384
+
2385
+ # list things
2386
+ def list_dashboards(self, workspace_id):
2387
+ """List dashboards in a workspace"""
2388
+ return self.list_items(workspace_id, type="dashboards")
2389
+
2390
+ def list_datamarts(self, workspace_id):
2391
+ """List datamarts in a workspace"""
2392
+ return self.list_items(workspace_id, type="datamarts")
2393
+
2394
+ def list_sql_endpoints(self, workspace_id):
2395
+ """List sql endpoints in a workspace"""
2396
+ return self.list_items(workspace_id, type="sqlEndpoints")
2397
+
2398
+ def list_mirrored_warehouses(self, workspace_id):
2399
+ """List mirrored warehouses in a workspace"""
2400
+ return self.list_items(workspace_id, type="mirroredWarehouses")
2401
+
2402
+ # copyJobs
2403
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/copyJobs
2404
+ def create_copy_job(self, workspace_id, display_name, definition = None, description = None):
2405
+ """Create a copy job in a workspace
2406
+ Args:
2407
+ workspace_id (str): The ID of the workspace
2408
+ display_name (str): The display name of the copy job
2409
+ definition (dict): The definition of the copy job
2410
+ description (str): The description of the copy job
2411
+ Returns:
2412
+ CopyJob: The copy job object
2413
+ """
2414
+ return self.create_item(workspace_id=workspace_id,
2415
+ display_name = display_name,
2416
+ type = "copyJobs",
2417
+ definition = definition,
2418
+ description = description)
2419
+
2420
+ def delete_copy_job(self, workspace_id, copy_job_id):
2421
+ """Delete a copy job from a workspace
2422
+ Args:
2423
+ workspace_id (str): The ID of the workspace
2424
+ copy_job_id (str): The ID of the copy job
2425
+ Returns:
2426
+ int: The status code of the response
2427
+ """
2428
+ return self.delete_item(workspace_id, item_id=copy_job_id, type="copyJobs")
2429
+
2430
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/copyJobs/{copyJobId}
2431
+ def get_copy_job(self, workspace_id, copy_job_id = None, copy_job_name = None):
2432
+ """Get a copy job from a workspace
2433
+ Args:
2434
+ workspace_id (str): The ID of the workspace
2435
+ copy_job_id (str): The ID of the copy job
2436
+ copy_job_name (str): The name of the copy job
2437
+ Returns:
2438
+ CopyJob: The copy job object
2439
+ """
2440
+ from msfabricpysdkcore.otheritems import CopyJob
2441
+
2442
+ if copy_job_id is None and copy_job_name is not None:
2443
+ copy_jobs = self.list_copy_jobs(workspace_id)
2444
+ cjs = [cj for cj in copy_jobs if cj.display_name == copy_job_name]
2445
+ if len(cjs) == 0:
2446
+ raise Exception(f"Copy job with name {copy_job_name} not found")
2447
+ copy_job_id = cjs[0].id
2448
+ elif copy_job_id is None:
2449
+ raise Exception("copy_job_id or the copy_job_name is required")
2450
+
2451
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/copyJobs/{copy_job_id}"
2452
+
2453
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2454
+ error_message="Error getting copy job", return_format="json")
2455
+
2456
+ cj = CopyJob.from_dict(item_dict, core_client=self)
2457
+ cj.get_definition()
2458
+ return cj
2459
+
2460
+ def get_copy_job_definition(self, workspace_id, copy_job_id, format = None):
2461
+ """Get the definition of an copy job
2462
+ Args:
2463
+ workspace_id (str): The ID of the workspace
2464
+ copy_job_id (str): The ID of the copy job
2465
+ format (str): The format of the definition
2466
+ Returns:
2467
+ dict: The copy job definition
2468
+ """
2469
+ return self.get_item_definition(workspace_id, copy_job_id, type="copyJobs", format=format)
2470
+
2471
+ def list_copy_jobs(self, workspace_id, with_properties = False):
2472
+ """List copy jobs in a workspace
2473
+ Args:
2474
+ workspace_id (str): The ID of the workspace
2475
+ Returns:
2476
+ list: The list of copy jobs
2477
+ """
2478
+ return self.list_items(workspace_id, type="copyJobs", with_properties=with_properties)
2479
+
2480
+ def update_copy_job(self, workspace_id, copy_job_id, display_name = None, description = None, return_item=False):
2481
+ """Update a copy job in a workspace
2482
+ Args:
2483
+ workspace_id (str): The ID of the workspace
2484
+ copy_job_id (str): The ID of the copy job
2485
+ display_name (str): The display name of the copy job
2486
+ description (str): The description of the copy job
2487
+ Returns:
2488
+ dict: The updated copy job or CopyJob object if return_item is True
2489
+ """
2490
+ return self.update_item(workspace_id, item_id=copy_job_id, display_name=display_name, description=description, type="copyJobs",
2491
+ return_item=return_item)
2492
+
2493
+ def update_copy_job_definition(self, workspace_id, copy_job_id, definition, update_metadata = None):
2494
+ """Update the definition of an copy job
2495
+ Args:
2496
+ workspace_id (str): The ID of the workspace
2497
+ copy_job_id (str): The ID of the copy job
2498
+ definition (dict): The definition of the copy job
2499
+ update_metadata (bool): Whether to update the metadata
2500
+ Returns:
2501
+ dict: The updated copy job definition
2502
+ """
2503
+ return self.update_item_definition(workspace_id, copy_job_id, type="copyJobs", definition=definition, update_metadata=update_metadata)
2504
+
2505
+
2506
+ # variable libary
2507
+ def create_variable_library(self, workspace_id, display_name, definition = None, description = None):
2508
+ """Create a copy job in a workspace
2509
+ Args:
2510
+ workspace_id (str): The ID of the workspace
2511
+ display_name (str): The display name of the copy job
2512
+ definition (dict): The definition of the copy job
2513
+ description (str): The description of the copy job
2514
+ Returns:
2515
+ VariableLibrary: The created variable library
2516
+ """
2517
+ return self.create_item(workspace_id=workspace_id,
2518
+ display_name=display_name,
2519
+ type="VariableLibraries",
2520
+ definition=definition,
2521
+ description=description)
2522
+
2523
+ def delete_variable_library(self, workspace_id, variable_library_id):
2524
+ """Delete a variable library from a workspace
2525
+ Args:
2526
+ workspace_id (str): The ID of the workspace
2527
+ variable_library_id (str): The ID of the variable library
2528
+ Returns:
2529
+ int: The status code of the response
2530
+ """
2531
+ return self.delete_item(workspace_id, item_id=variable_library_id, type="VariableLibraries")
2532
+
2533
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/VariableLibraries/{variableLibraryId}
2534
+ def get_variable_library(self, workspace_id, variable_library_id = None, variable_library_name = None):
2535
+ """Get a variable library from a workspace
2536
+ Args:
2537
+ workspace_id (str): The ID of the workspace
2538
+ variable_library_id (str): The ID of the variable library
2539
+ variable_library_name (str): The name of the variable library
2540
+ Returns:
2541
+ VariableLibrary: The variable library object
2542
+ """
2543
+ from msfabricpysdkcore.otheritems import VariableLibrary
2544
+
2545
+ if variable_library_id is None and variable_library_name is not None:
2546
+ variable_librarys = self.list_variable_librarys(workspace_id)
2547
+ cjs = [cj for cj in variable_librarys if cj.display_name == variable_library_name]
2548
+ if len(cjs) == 0:
2549
+ raise Exception(f"Variable library with name {variable_library_name} not found")
2550
+ variable_library_id = cjs[0].id
2551
+ elif variable_library_id is None:
2552
+ raise Exception("variable_library_id or the variable_library_name is required")
2553
+
2554
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/VariableLibraries/{variable_library_id}"
2555
+
2556
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2557
+ error_message="Error getting variable library", return_format="json")
2558
+
2559
+ vl = VariableLibrary.from_dict(item_dict, core_client=self)
2560
+ vl.get_definition()
2561
+ return vl
2562
+
2563
+ def get_variable_library_definition(self, workspace_id, variable_library_id, format = None):
2564
+ """Get the definition of an variable library
2565
+ Args:
2566
+ workspace_id (str): The ID of the workspace
2567
+ variable_library_id (str): The ID of the variable library
2568
+ format (str): The format of the definition
2569
+ Returns:
2570
+ dict: The variable library definition
2571
+ """
2572
+ return self.get_item_definition(workspace_id, variable_library_id, type="VariableLibraries", format=format)
2573
+
2574
+ def list_variable_libraries(self, workspace_id, with_properties = False):
2575
+ """List variable libraries in a workspace
2576
+ Args:
2577
+ workspace_id (str): The ID of the workspace
2578
+ Returns:
2579
+ list: The list of variable libraries
2580
+ """
2581
+ return self.list_items(workspace_id, type="VariableLibraries", with_properties=with_properties)
2582
+
2583
+ def update_variable_library(self, workspace_id, variable_library_id, display_name = None, description = None, return_item=False):
2584
+ """Update a variable library in a workspace
2585
+ Args:
2586
+ workspace_id (str): The ID of the workspace
2587
+ variable_library_id (str): The ID of the variable library
2588
+ display_name (str): The display name of the variable library
2589
+ description (str): The description of the variable library
2590
+ Returns:
2591
+ dict: The updated variable library or VariableLibrary object if return_item is True
2592
+ """
2593
+ return self.update_item(workspace_id, item_id=variable_library_id, display_name=display_name, description=description, type="VariableLibraries",
2594
+ return_item=return_item)
2595
+
2596
+ def update_variable_library_definition(self, workspace_id, variable_library_id, definition, update_metadata = None):
2597
+ """Update the definition of an variable library
2598
+ Args:
2599
+ workspace_id (str): The ID of the workspace
2600
+ variable_library_id (str): The ID of the variable library
2601
+ definition (dict): The definition of the variable library
2602
+ update_metadata (bool): Whether to update the metadata
2603
+ Returns:
2604
+ dict: The updated variable library definition
2605
+ """
2606
+ return self.update_item_definition(workspace_id, variable_library_id, type="VariableLibraries", definition=definition, update_metadata=update_metadata)
2607
+
2608
+
2609
+ # data flow
2610
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows
2611
+ def create_dataflow(self, workspace_id, display_name, definition = None, description = None):
2612
+ """Create a dataflow in a workspace
2613
+ Args:
2614
+ workspace_id (str): The ID of the workspace
2615
+ display_name (str): The display name of the dataflow
2616
+ definition (dict): The definition of the dataflow
2617
+ description (str): The description of the dataflow
2618
+ Returns:
2619
+ dict: The created dataflow
2620
+ """
2621
+ return self.create_item(workspace_id=workspace_id,
2622
+ display_name = display_name,
2623
+ type = "dataflows",
2624
+ definition = definition,
2625
+ description = description)
2626
+
2627
+ # DELETE https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}
2628
+ def delete_dataflow(self, workspace_id, dataflow_id):
2629
+ """Delete a dataflow from a workspace
2630
+ Args:
2631
+ workspace_id (str): The ID of the workspace
2632
+ dataflow_id (str): The ID of the dataflow
1884
2633
  Returns:
1885
2634
  int: The status code of the response
1886
2635
  """
1887
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/roleAssignments/{workspace_role_assignment_id}"
1888
- body = {
1889
- 'role': role
1890
- }
1891
-
1892
- response = self.calling_routine(url, operation="PATCH", body=body, response_codes=[200, 429], error_message="Error updating role assignments", return_format="response")
2636
+ return self.delete_item(workspace_id, item_id=dataflow_id, type="dataflows")
2637
+
2638
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}
2639
+ def get_dataflow(self, workspace_id, dataflow_id = None, dataflow_name = None):
2640
+ """Get a dataflow from a workspace
2641
+ Args:
2642
+ workspace_id (str): The ID of the workspace
2643
+ dataflow_id (str): The ID of the dataflow
2644
+ dataflow_name (str): The name of the dataflow
2645
+ Returns:
2646
+ Dataflow: The dataflow object
2647
+ """
2648
+ from msfabricpysdkcore.otheritems import Dataflow
1893
2649
 
1894
- return response.status_code
2650
+ if dataflow_id is None and dataflow_name is not None:
2651
+ dataflows = self.list_dataflows(workspace_id)
2652
+ dfs = [df for df in dataflows if df.display_name == dataflow_name]
2653
+ if len(dfs) == 0:
2654
+ raise Exception(f"Dataflow with name {dataflow_name} not found")
2655
+ dataflow_id = dfs[0].id
2656
+ elif dataflow_id is None:
2657
+ raise Exception("dataflow_id or the dataflow_name is required")
2658
+
2659
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/dataflows/{dataflow_id}"
1895
2660
 
2661
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2662
+ error_message="Error getting data flow", return_format="json")
1896
2663
 
2664
+ df = Dataflow.from_dict(item_dict, core_client=self)
2665
+ df.get_definition()
2666
+ return df
1897
2667
 
1898
- # list things
1899
- def list_dashboards(self, workspace_id):
1900
- """List dashboards in a workspace"""
1901
- return self.list_items(workspace_id, type="dashboards")
2668
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}/getDefinition
2669
+ def get_dataflow_definition(self, workspace_id, dataflow_id, format = None):
2670
+ """Get the definition of a dataflow
2671
+ Args:
2672
+ workspace_id (str): The ID of the workspace
2673
+ dataflow_id (str): The ID of the dataflow
2674
+ format (str): The format of the definition
2675
+ Returns:
2676
+ dict: The dataflow definition
2677
+ """
2678
+ return self.get_item_definition(workspace_id, dataflow_id, type="dataflows", format=format)
1902
2679
 
1903
- def list_datamarts(self, workspace_id):
1904
- """List datamarts in a workspace"""
1905
- return self.list_items(workspace_id, type="datamarts")
2680
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows
2681
+ def list_dataflows(self, workspace_id, with_properties = False):
2682
+ """List dataflows in a workspace
2683
+ Args:
2684
+ workspace_id (str): The ID of the workspace
2685
+ with_properties (bool): Whether to get the item object with properties
2686
+ Returns:
2687
+ list: The list of dataflows
2688
+ """
2689
+ return self.list_items(workspace_id, type="dataflows", with_properties=with_properties)
2690
+
2691
+ # PATCH https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}
2692
+ def update_dataflow(self, workspace_id, dataflow_id, display_name = None, description = None, return_item=False):
2693
+ """Update a dataflow in a workspace
2694
+ Args:
2695
+ workspace_id (str): The ID of the workspace
2696
+ dataflow_id (str): The ID of the dataflow
2697
+ display_name (str): The display name of the dataflow
2698
+ description (str): The description of the dataflow
2699
+ Returns:
2700
+ dict: The updated dataflow
2701
+ """
2702
+ return self.update_item(workspace_id, item_id=dataflow_id, display_name=display_name, description=description, type="dataflows",
2703
+ return_item=return_item)
2704
+
2705
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}/updateDefinition
2706
+ def update_dataflow_definition(self, workspace_id, dataflow_id, definition, update_metadata = None):
2707
+ """Update the definition of a dataflow
2708
+ Args:
2709
+ workspace_id (str): The ID of the workspace
2710
+ dataflow_id (str): The ID of the dataflow
2711
+ definition (dict): The definition of the dataflow
2712
+ update_metadata (bool): Whether to update the metadata
2713
+ Returns:
2714
+ dict: The updated dataflow definition
2715
+ """
2716
+ return self.update_item_definition(workspace_id, dataflow_id, type="dataflows", definition=definition, update_metadata=update_metadata)
1906
2717
 
1907
- def list_sql_endpoints(self, workspace_id):
1908
- """List sql endpoints in a workspace"""
1909
- return self.list_items(workspace_id, type="sqlEndpoints")
1910
2718
 
1911
- def list_mirrored_warehouses(self, workspace_id):
1912
- """List mirrored warehouses in a workspace"""
1913
- return self.list_items(workspace_id, type="mirroredWarehouses")
1914
-
1915
2719
  # dataPipelines
1916
2720
 
1917
2721
  def create_data_pipeline(self, workspace_id, display_name, definition = None, description = None):
@@ -1961,6 +2765,18 @@ class FabricClientCore(FabricClient):
1961
2765
  dp.get_definition()
1962
2766
  return dp
1963
2767
 
2768
+ def get_data_pipeline_definition(self, workspace_id, data_pipeline_id, format = None):
2769
+ """Get the definition of a data pipeline
2770
+ Args:
2771
+ workspace_id (str): The ID of the workspace
2772
+ data_pipeline_id (str): The ID of the data pipeline
2773
+ format (str): The format of the definition
2774
+ Returns:
2775
+ dict: The data pipeline definition
2776
+ """
2777
+ return self.get_item_definition(workspace_id, data_pipeline_id, type="dataPipelines", format=format)
2778
+
2779
+
1964
2780
  def list_data_pipelines(self, workspace_id, with_properties = False):
1965
2781
  """List data pipelines in a workspace
1966
2782
  Args:
@@ -1984,6 +2800,18 @@ class FabricClientCore(FabricClient):
1984
2800
  return self.update_item(workspace_id, item_id=data_pipeline_id, display_name=display_name, description=description, type="dataPipelines",
1985
2801
  return_item=return_item)
1986
2802
 
2803
+ def update_data_pipeline_definition(self, workspace_id, data_pipeline_id, definition, update_metadata = None):
2804
+ """Update the definition of a data pipeline
2805
+ Args:
2806
+ workspace_id (str): The ID of the workspace
2807
+ data_pipeline_id (str): The ID of the data pipeline
2808
+ definition (dict): The definition of the data pipeline
2809
+ update_metadata (bool): Whether to update the metadata
2810
+ Returns:
2811
+ dict: The updated data pipeline definition
2812
+ """
2813
+ return self.update_item_definition(workspace_id, data_pipeline_id, type="dataPipelines", definition=definition, update_metadata=update_metadata)
2814
+
1987
2815
 
1988
2816
  # environments
1989
2817
 
@@ -2349,7 +3177,7 @@ class FabricClientCore(FabricClient):
2349
3177
  Returns:
2350
3178
  Eventstream: The eventstream object
2351
3179
  """
2352
- from msfabricpysdkcore.otheritems import Eventstream
3180
+ from msfabricpysdkcore.eventstream import Eventstream
2353
3181
  if eventstream_id is None and eventstream_name is not None:
2354
3182
  evstreams = self.list_eventstreams(workspace_id)
2355
3183
  evstreams = [ev for ev in evstreams if ev.display_name == eventstream_name]
@@ -2426,6 +3254,216 @@ class FabricClientCore(FabricClient):
2426
3254
  """
2427
3255
  return self.update_item_definition(workspace_id, eventstream_id, type="eventstreams", definition=definition, update_metadata=update_metadata)
2428
3256
 
3257
+ # eventstream topology
3258
+
3259
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}
3260
+ def get_eventstream_destination(self, workspace_id, eventstream_id, destination_id):
3261
+ """Get the destination of an eventstream
3262
+ Args:
3263
+ workspace_id (str): The ID of the workspace
3264
+ eventstream_id (str): The ID of the eventstream
3265
+ destination_id (str): The ID of the destination
3266
+ Returns:
3267
+ dict: The eventstream destination
3268
+ """
3269
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}"
3270
+
3271
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3272
+ error_message="Error getting eventstream destination", return_format="json")
3273
+ return item_dict
3274
+
3275
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}/connection
3276
+ def get_eventstream_destination_connection(self, workspace_id, eventstream_id, destination_id):
3277
+ """Get the connection of an eventstream destination
3278
+ Args:
3279
+ workspace_id (str): The ID of the workspace
3280
+ eventstream_id (str): The ID of the eventstream
3281
+ destination_id (str): The ID of the destination
3282
+ Returns:
3283
+ dict: The eventstream destination connection
3284
+ """
3285
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}/connection"
3286
+
3287
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3288
+ error_message="Error getting eventstream destination connection", return_format="json")
3289
+ return item_dict
3290
+
3291
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}
3292
+ def get_eventstream_source(self, workspace_id, eventstream_id, source_id):
3293
+ """Get the source of an eventstream
3294
+ Args:
3295
+ workspace_id (str): The ID of the workspace
3296
+ eventstream_id (str): The ID of the eventstream
3297
+ source_id (str): The ID of the source
3298
+ Returns:
3299
+ dict: The eventstream source
3300
+ """
3301
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}"
3302
+
3303
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3304
+ error_message="Error getting eventstream source", return_format="json")
3305
+ return item_dict
3306
+
3307
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}/connection
3308
+ def get_eventstream_source_connection(self, workspace_id, eventstream_id, source_id):
3309
+ """Get the connection of an eventstream source
3310
+ Args:
3311
+ workspace_id (str): The ID of the workspace
3312
+ eventstream_id (str): The ID of the eventstream
3313
+ source_id (str): The ID of the source
3314
+ Returns:
3315
+ dict: The eventstream source connection
3316
+ """
3317
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}/connection"
3318
+
3319
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3320
+ error_message="Error getting eventstream source connection", return_format="json")
3321
+ return item_dict
3322
+
3323
+
3324
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/topology
3325
+ def get_eventstream_topology(self, workspace_id, eventstream_id):
3326
+ """Get the topology of an eventstream
3327
+ Args:
3328
+ workspace_id (str): The ID of the workspace
3329
+ eventstream_id (str): The ID of the eventstream
3330
+ Returns:
3331
+ dict: The eventstream topology
3332
+ """
3333
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/topology"
3334
+
3335
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3336
+ error_message="Error getting eventstream topology", return_format="json")
3337
+ return item_dict
3338
+
3339
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/pause
3340
+ def pause_eventstream(self, workspace_id, eventstream_id):
3341
+ """Pause an eventstream
3342
+ Args:
3343
+ workspace_id (str): The ID of the workspace
3344
+ eventstream_id (str): The ID of the eventstream
3345
+ Returns:
3346
+ dict: The operation result or response value
3347
+ """
3348
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/pause"
3349
+
3350
+ response = self.calling_routine(url, operation="POST", response_codes=[200, 429], error_message="Error pausing eventstream",
3351
+ return_format="response")
3352
+
3353
+ return response.status_code
3354
+
3355
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}/pause
3356
+ def pause_eventstream_destination(self, workspace_id, eventstream_id, destination_id):
3357
+ """Pause an eventstream destination
3358
+ Args:
3359
+ workspace_id (str): The ID of the workspace
3360
+ eventstream_id (str): The ID of the eventstream
3361
+ destination_id (str): The ID of the destination
3362
+ Returns:
3363
+ dict: The operation result or response value
3364
+ """
3365
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}/pause"
3366
+
3367
+ response = self.calling_routine(url, operation="POST", response_codes=[200, 429], error_message="Error pausing eventstream destination",
3368
+ return_format="response")
3369
+
3370
+ return response.status_code
3371
+
3372
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}/pause
3373
+ def pause_eventstream_source(self, workspace_id, eventstream_id, source_id):
3374
+ """Pause an eventstream source
3375
+ Args:
3376
+ workspace_id (str): The ID of the workspace
3377
+ eventstream_id (str): The ID of the eventstream
3378
+ source_id (str): The ID of the source
3379
+ Returns:
3380
+ dict: The operation result or response value
3381
+ """
3382
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}/pause"
3383
+
3384
+ response = self.calling_routine(url, operation="POST", response_codes=[200, 429], error_message="Error pausing eventstream source",
3385
+ return_format="response")
3386
+
3387
+ return response.status_code
3388
+
3389
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/resume
3390
+ def resume_eventstream(self, workspace_id, eventstream_id, start_type, custom_start_date_time = None):
3391
+ """Resume an eventstream
3392
+ Args:
3393
+ workspace_id (str): The ID of the workspace
3394
+ eventstream_id (str): The ID of the eventstream
3395
+ start_type (str): The start type of the eventstream
3396
+ custom_start_date_time (str): The custom start date time of the eventstream
3397
+ Returns:
3398
+ dict: The operation result or response value
3399
+ """
3400
+
3401
+ body = {
3402
+ "startType": start_type
3403
+ }
3404
+
3405
+ if custom_start_date_time is not None:
3406
+ body["customStartDateTime"] = custom_start_date_time
3407
+
3408
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/resume"
3409
+
3410
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429], error_message="Error resuming eventstream",
3411
+ return_format="response")
3412
+
3413
+ return response.status_code
3414
+
3415
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}/resume
3416
+ def resume_eventstream_destination(self, workspace_id, eventstream_id, destination_id, start_type, custom_start_date_time = None):
3417
+ """Resume an eventstream destination
3418
+ Args:
3419
+ workspace_id (str): The ID of the workspace
3420
+ eventstream_id (str): The ID of the eventstream
3421
+ destination_id (str): The ID of the destination
3422
+ start_type (str): The start type of the eventstream destination
3423
+ custom_start_date_time (str): The custom start date time of the eventstream destination
3424
+ Returns:
3425
+ dict: The operation result or response value
3426
+ """
3427
+ body = {
3428
+ "startType": start_type
3429
+ }
3430
+
3431
+ if custom_start_date_time is not None:
3432
+ body["customStartDateTime"] = custom_start_date_time
3433
+
3434
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}/resume"
3435
+
3436
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429], error_message="Error resuming eventstream destination",
3437
+ return_format="response")
3438
+
3439
+ return response.status_code
3440
+
3441
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}/resume
3442
+ def resume_eventstream_source(self, workspace_id, eventstream_id, source_id, start_type, custom_start_date_time = None):
3443
+ """Resume an eventstream source
3444
+ Args:
3445
+ workspace_id (str): The ID of the workspace
3446
+ eventstream_id (str): The ID of the eventstream
3447
+ source_id (str): The ID of the source
3448
+ start_type (str): The start type of the eventstream source
3449
+ custom_start_date_time (str): The custom start date time of the eventstream source
3450
+ Returns:
3451
+ dict: The operation result or response value
3452
+ """
3453
+ body = {
3454
+ "startType": start_type
3455
+ }
3456
+
3457
+ if custom_start_date_time is not None:
3458
+ body["customStartDateTime"] = custom_start_date_time
3459
+
3460
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}/resume"
3461
+
3462
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429], error_message="Error resuming eventstream source",
3463
+ return_format="response")
3464
+
3465
+ return response.status_code
3466
+
2429
3467
  # graphqlapis
2430
3468
 
2431
3469
  # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/GraphQLApis
@@ -2989,6 +4027,88 @@ class FabricClientCore(FabricClient):
2989
4027
  else:
2990
4028
  self._logger.info("Table created")
2991
4029
  return response.status_code
4030
+
4031
+ # lakehouse livy sessions
4032
+
4033
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId}/livySessions
4034
+ def list_lakehouse_livy_sessions(self, workspace_id, lakehouse_id):
4035
+ """List all livy sessions for a lakehouse
4036
+ Args:
4037
+ workspace_id (str): The ID of the workspace
4038
+ lakehouse_id (str): The ID of the lakehouse
4039
+ Returns:
4040
+ list: The list of livy sessions
4041
+ """
4042
+ return self.list_livy_sessions(workspace_id=workspace_id, item_id=lakehouse_id, item_type="lakehouses")
4043
+
4044
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId}/livySessions/{livyId}
4045
+ def get_lakehouse_livy_session(self, workspace_id, lakehouse_id, livy_id):
4046
+ """Get a livy session for a lakehouse
4047
+ Args:
4048
+ workspace_id (str): The ID of the workspace
4049
+ lakehouse_id (str): The ID of the lakehouse
4050
+ livy_id (str): The ID of the livy session
4051
+ Returns:
4052
+ dict: The livy session
4053
+ """
4054
+ return self.get_livy_session(workspace_id=workspace_id,
4055
+ item_id=lakehouse_id, item_type="lakehouses", livy_id=livy_id)
4056
+
4057
+ # Livy sessions
4058
+
4059
+
4060
+ def get_livy_session(self, workspace_id, item_id, item_type = None, livy_id = None):
4061
+ """Get a livy session for a lakehouse
4062
+ Args:
4063
+ workspace_id (str): The ID of the workspace
4064
+ item_id (str): The ID of the item
4065
+ item_type (str): The type of the item
4066
+ livy_id (str): The ID of the livy session
4067
+ Returns:
4068
+ dict: The livy session
4069
+ """
4070
+
4071
+ if "lakehouse" in item_type.lower():
4072
+ item_type = "lakehouses"
4073
+ elif "notebook" in item_type.lower():
4074
+ item_type = "notebooks"
4075
+ elif "sparkjobdef" in item_type.lower() or "sjd" in item_type.lower():
4076
+ item_type = "sparkJobDefinitions"
4077
+
4078
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/{item_type}/{item_id}/livySessions/{livy_id}"
4079
+
4080
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
4081
+ error_message="Error getting livy session", return_format="json")
4082
+ return item_dict
4083
+
4084
+ def list_livy_sessions(self, workspace_id, item_id = None, item_type = None):
4085
+ """List all livy sessions for a lakehouse
4086
+ Args:
4087
+ workspace_id (str): The ID of the workspace
4088
+ item_id (str): The ID of the item
4089
+ item_type (str): The type of the item
4090
+ Returns:
4091
+ list: The list of livy sessions
4092
+ """
4093
+ if item_id is None:
4094
+ item_type = "spark"
4095
+ elif "lakehouse" in item_type.lower():
4096
+ item_type = "lakehouses"
4097
+ elif "notebook" in item_type.lower():
4098
+ item_type = "notebooks"
4099
+ elif "sparkjobdef" in item_type.lower() or "sjd" in item_type.lower():
4100
+ item_type = "sparkJobDefinitions"
4101
+
4102
+ if item_id is None:
4103
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/spark/livySessions"
4104
+ else:
4105
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/{item_type}/{item_id}/livySessions"
4106
+
4107
+ items = self.calling_routine(url, operation="GET", response_codes=[200, 429],
4108
+ error_message="Error listing livy sessions", return_format="value_json", paging=True)
4109
+
4110
+ return items
4111
+
2992
4112
 
2993
4113
  # mirrored_database
2994
4114
 
@@ -3486,7 +4606,29 @@ class FabricClientCore(FabricClient):
3486
4606
  dict: The updated notebook
3487
4607
  """
3488
4608
  return self.update_item_definition(workspace_id, notebook_id, definition, type="notebooks")
4609
+
4610
+ def get_notebook_livy_session(self, workspace_id, notebook_id, livy_id):
4611
+ """Get a livy session for a notebook
4612
+ Args:
4613
+ workspace_id (str): The ID of the workspace
4614
+ notebook_id (str): The ID of the notebook
4615
+ livy_id (str): The ID of the livy session
4616
+ Returns:
4617
+ dict: The livy session
4618
+ """
4619
+ return self.get_livy_session(workspace_id=workspace_id, item_id=notebook_id, item_type="notebooks", livy_id=livy_id)
3489
4620
 
4621
+ def list_notebook_livy_sessions(self, workspace_id, notebook_id):
4622
+ """List all livy sessions for a notebook
4623
+ Args:
4624
+ workspace_id (str): The ID of the workspace
4625
+ notebook_id (str): The ID of the notebook
4626
+ Returns:
4627
+ list: The list of livy sessions
4628
+ """
4629
+
4630
+ return self.list_livy_sessions(workspace_id=workspace_id, item_id=notebook_id, item_type="notebooks")
4631
+
3490
4632
  # paginatedReports
3491
4633
 
3492
4634
  def list_paginated_reports(self, workspace_id):
@@ -4083,6 +5225,27 @@ class FabricClientCore(FabricClient):
4083
5225
  return self.get_item_job_instance(workspace_id = workspace_id,
4084
5226
  item_id = spark_job_definition_id,
4085
5227
  job_instance_id = job_instance_id)
5228
+
5229
+ def list_spark_job_definition_livy_sessions(self, workspace_id, spark_job_definition_id):
5230
+ """List all livy sessions for a spark job definition
5231
+ Args:
5232
+ workspace_id (str): The ID of the workspace
5233
+ spark_job_definition_id (str): The ID of the spark job definition
5234
+ Returns:
5235
+ list: The list of livy sessions
5236
+ """
5237
+ return self.list_livy_sessions(workspace_id=workspace_id, item_id=spark_job_definition_id, item_type="sparkJobDefinitions")
5238
+
5239
+ def get_spark_job_definition_livy_session(self, workspace_id, spark_job_definition_id, livy_id):
5240
+ """Get a livy session for a spark job definition
5241
+ Args:
5242
+ workspace_id (str): The ID of the workspace
5243
+ spark_job_definition_id (str): The ID of the spark job definition
5244
+ livy_id (str): The ID of the livy session
5245
+ Returns:
5246
+ dict: The livy session
5247
+ """
5248
+ return self.get_livy_session(workspace_id=workspace_id, item_id=spark_job_definition_id, item_type="sparkJobDefinitions", livy_id=livy_id)
4086
5249
 
4087
5250
  # sql database
4088
5251