msfabricpysdkcore 0.2.3__py3-none-any.whl → 0.2.5__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
306
444
 
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)
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
+
310
471
 
311
- def list_deployment_pipeline_stages_items(self, deployment_pipeline_id, stage_id = None, stage_name = None):
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
501
+
502
+
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
382
572
 
383
- return dep_pipes
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"
384
583
 
385
- # External Data Shares
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
631
+
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
636
+
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):
@@ -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",
@@ -955,7 +1383,11 @@ class FabricClientCore(FabricClient):
955
1383
  "sparkJobDefinitions",
956
1384
  "SQLDatabases",
957
1385
  "warehouses"]:
958
-
1386
+
1387
+ if type == "lakehouses":
1388
+ if "creation_payload" in kwargs:
1389
+ body["creationPayload"] = kwargs["creation_payload"]
1390
+
959
1391
  if type == "kqlDatabases":
960
1392
  if "creation_payload" not in kwargs:
961
1393
  raise Exception("creation_payload is required for KQLDatabase")
@@ -975,7 +1407,10 @@ class FabricClientCore(FabricClient):
975
1407
  item = None
976
1408
  i = 0
977
1409
 
978
- type_mapping = {"dataPipelines": "DataPipeline",
1410
+ type_mapping = {"copyJobs": "CopyJob",
1411
+ "VariableLibraries": "VariableLibrary",
1412
+ "dataflows": "Dataflow",
1413
+ "dataPipelines": "DataPipeline",
979
1414
  "environments": "Environment",
980
1415
  "eventhouses": "Eventhouse",
981
1416
  "eventstreams": "Eventstream",
@@ -1614,6 +2049,62 @@ class FabricClientCore(FabricClient):
1614
2049
 
1615
2050
  return response.status_code
1616
2051
 
2052
+ ### Tags
2053
+ # GET https://api.fabric.microsoft.com/v1/tags
2054
+ def list_tags(self):
2055
+ """List all tags
2056
+ Returns:
2057
+ list: The list of tags
2058
+ """
2059
+ url = "https://api.fabric.microsoft.com/v1/tags"
2060
+
2061
+ response_json = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2062
+ error_message="Error listing tags", return_format="value_json", paging=True)
2063
+
2064
+ return response_json
2065
+
2066
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/items/{itemId}/applyTags
2067
+ def apply_tags(self, workspace_id, item_id, tags):
2068
+ """Apply tags to an item
2069
+ Args:
2070
+ workspace_id (str): The ID of the workspace
2071
+ item_id (str): The ID of the item
2072
+ tags (list): The list of tags to apply
2073
+ Returns:
2074
+ int: The status code of the response
2075
+ """
2076
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/items/{item_id}/applyTags"
2077
+
2078
+ payload = {
2079
+ 'tags': tags
2080
+ }
2081
+
2082
+ response = self.calling_routine(url, operation="POST", body=payload,
2083
+ response_codes=[200, 429], error_message="Error applying tags", return_format="response")
2084
+
2085
+ return response.status_code
2086
+
2087
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/items/{itemId}/unapplyTags
2088
+ def unapply_tags(self, workspace_id, item_id, tags):
2089
+ """Unapply tags from an item
2090
+ Args:
2091
+ workspace_id (str): The ID of the workspace
2092
+ item_id (str): The ID of the item
2093
+ tags (list): The list of tags to unapply
2094
+ Returns:
2095
+ int: The status code of the response
2096
+ """
2097
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/items/{item_id}/unapplyTags"
2098
+
2099
+ payload = {
2100
+ 'tags': tags
2101
+ }
2102
+
2103
+ response = self.calling_routine(url, operation="POST", body=payload,
2104
+ response_codes=[200, 429], error_message="Error unapplying tags", return_format="response")
2105
+
2106
+ return response.status_code
2107
+
1617
2108
  ### Workspaces
1618
2109
 
1619
2110
  def add_workspace_role_assignment(self, workspace_id, role, principal):
@@ -1882,36 +2373,353 @@ class FabricClientCore(FabricClient):
1882
2373
  role (str): The role to assign
1883
2374
  workspace_role_assignment_id (str): The ID of the role assignment
1884
2375
  Returns:
1885
- int: The status code of the response
2376
+ int: The status code of the response
2377
+ """
2378
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/roleAssignments/{workspace_role_assignment_id}"
2379
+ body = {
2380
+ 'role': role
2381
+ }
2382
+
2383
+ response = self.calling_routine(url, operation="PATCH", body=body, response_codes=[200, 429], error_message="Error updating role assignments", return_format="response")
2384
+
2385
+ return response.status_code
2386
+
2387
+
2388
+
2389
+ # list things
2390
+ def list_dashboards(self, workspace_id):
2391
+ """List dashboards in a workspace"""
2392
+ return self.list_items(workspace_id, type="dashboards")
2393
+
2394
+ def list_datamarts(self, workspace_id):
2395
+ """List datamarts in a workspace"""
2396
+ return self.list_items(workspace_id, type="datamarts")
2397
+
2398
+ def list_sql_endpoints(self, workspace_id):
2399
+ """List sql endpoints in a workspace"""
2400
+ return self.list_items(workspace_id, type="sqlEndpoints")
2401
+
2402
+ def list_mirrored_warehouses(self, workspace_id):
2403
+ """List mirrored warehouses in a workspace"""
2404
+ return self.list_items(workspace_id, type="mirroredWarehouses")
2405
+
2406
+ # copyJobs
2407
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/copyJobs
2408
+ def create_copy_job(self, workspace_id, display_name, definition = None, description = None):
2409
+ """Create a copy job in a workspace
2410
+ Args:
2411
+ workspace_id (str): The ID of the workspace
2412
+ display_name (str): The display name of the copy job
2413
+ definition (dict): The definition of the copy job
2414
+ description (str): The description of the copy job
2415
+ Returns:
2416
+ CopyJob: The copy job object
2417
+ """
2418
+ return self.create_item(workspace_id=workspace_id,
2419
+ display_name = display_name,
2420
+ type = "copyJobs",
2421
+ definition = definition,
2422
+ description = description)
2423
+
2424
+ def delete_copy_job(self, workspace_id, copy_job_id):
2425
+ """Delete a copy job from a workspace
2426
+ Args:
2427
+ workspace_id (str): The ID of the workspace
2428
+ copy_job_id (str): The ID of the copy job
2429
+ Returns:
2430
+ int: The status code of the response
2431
+ """
2432
+ return self.delete_item(workspace_id, item_id=copy_job_id, type="copyJobs")
2433
+
2434
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/copyJobs/{copyJobId}
2435
+ def get_copy_job(self, workspace_id, copy_job_id = None, copy_job_name = None):
2436
+ """Get a copy job from a workspace
2437
+ Args:
2438
+ workspace_id (str): The ID of the workspace
2439
+ copy_job_id (str): The ID of the copy job
2440
+ copy_job_name (str): The name of the copy job
2441
+ Returns:
2442
+ CopyJob: The copy job object
2443
+ """
2444
+ from msfabricpysdkcore.otheritems import CopyJob
2445
+
2446
+ if copy_job_id is None and copy_job_name is not None:
2447
+ copy_jobs = self.list_copy_jobs(workspace_id)
2448
+ cjs = [cj for cj in copy_jobs if cj.display_name == copy_job_name]
2449
+ if len(cjs) == 0:
2450
+ raise Exception(f"Copy job with name {copy_job_name} not found")
2451
+ copy_job_id = cjs[0].id
2452
+ elif copy_job_id is None:
2453
+ raise Exception("copy_job_id or the copy_job_name is required")
2454
+
2455
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/copyJobs/{copy_job_id}"
2456
+
2457
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2458
+ error_message="Error getting copy job", return_format="json")
2459
+
2460
+ cj = CopyJob.from_dict(item_dict, core_client=self)
2461
+ cj.get_definition()
2462
+ return cj
2463
+
2464
+ def get_copy_job_definition(self, workspace_id, copy_job_id, format = None):
2465
+ """Get the definition of an copy job
2466
+ Args:
2467
+ workspace_id (str): The ID of the workspace
2468
+ copy_job_id (str): The ID of the copy job
2469
+ format (str): The format of the definition
2470
+ Returns:
2471
+ dict: The copy job definition
2472
+ """
2473
+ return self.get_item_definition(workspace_id, copy_job_id, type="copyJobs", format=format)
2474
+
2475
+ def list_copy_jobs(self, workspace_id, with_properties = False):
2476
+ """List copy jobs in a workspace
2477
+ Args:
2478
+ workspace_id (str): The ID of the workspace
2479
+ Returns:
2480
+ list: The list of copy jobs
2481
+ """
2482
+ return self.list_items(workspace_id, type="copyJobs", with_properties=with_properties)
2483
+
2484
+ def update_copy_job(self, workspace_id, copy_job_id, display_name = None, description = None, return_item=False):
2485
+ """Update a copy job in a workspace
2486
+ Args:
2487
+ workspace_id (str): The ID of the workspace
2488
+ copy_job_id (str): The ID of the copy job
2489
+ display_name (str): The display name of the copy job
2490
+ description (str): The description of the copy job
2491
+ Returns:
2492
+ dict: The updated copy job or CopyJob object if return_item is True
2493
+ """
2494
+ return self.update_item(workspace_id, item_id=copy_job_id, display_name=display_name, description=description, type="copyJobs",
2495
+ return_item=return_item)
2496
+
2497
+ def update_copy_job_definition(self, workspace_id, copy_job_id, definition, update_metadata = None):
2498
+ """Update the definition of an copy job
2499
+ Args:
2500
+ workspace_id (str): The ID of the workspace
2501
+ copy_job_id (str): The ID of the copy job
2502
+ definition (dict): The definition of the copy job
2503
+ update_metadata (bool): Whether to update the metadata
2504
+ Returns:
2505
+ dict: The updated copy job definition
2506
+ """
2507
+ return self.update_item_definition(workspace_id, copy_job_id, type="copyJobs", definition=definition, update_metadata=update_metadata)
2508
+
2509
+
2510
+ # variable libary
2511
+ def create_variable_library(self, workspace_id, display_name, definition = None, description = None):
2512
+ """Create a copy job in a workspace
2513
+ Args:
2514
+ workspace_id (str): The ID of the workspace
2515
+ display_name (str): The display name of the copy job
2516
+ definition (dict): The definition of the copy job
2517
+ description (str): The description of the copy job
2518
+ Returns:
2519
+ VariableLibrary: The created variable library
2520
+ """
2521
+ return self.create_item(workspace_id=workspace_id,
2522
+ display_name=display_name,
2523
+ type="VariableLibraries",
2524
+ definition=definition,
2525
+ description=description)
2526
+
2527
+ def delete_variable_library(self, workspace_id, variable_library_id):
2528
+ """Delete a variable library from a workspace
2529
+ Args:
2530
+ workspace_id (str): The ID of the workspace
2531
+ variable_library_id (str): The ID of the variable library
2532
+ Returns:
2533
+ int: The status code of the response
2534
+ """
2535
+ return self.delete_item(workspace_id, item_id=variable_library_id, type="VariableLibraries")
2536
+
2537
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/VariableLibraries/{variableLibraryId}
2538
+ def get_variable_library(self, workspace_id, variable_library_id = None, variable_library_name = None):
2539
+ """Get a variable library from a workspace
2540
+ Args:
2541
+ workspace_id (str): The ID of the workspace
2542
+ variable_library_id (str): The ID of the variable library
2543
+ variable_library_name (str): The name of the variable library
2544
+ Returns:
2545
+ VariableLibrary: The variable library object
2546
+ """
2547
+ from msfabricpysdkcore.otheritems import VariableLibrary
2548
+
2549
+ if variable_library_id is None and variable_library_name is not None:
2550
+ variable_librarys = self.list_variable_librarys(workspace_id)
2551
+ cjs = [cj for cj in variable_librarys if cj.display_name == variable_library_name]
2552
+ if len(cjs) == 0:
2553
+ raise Exception(f"Variable library with name {variable_library_name} not found")
2554
+ variable_library_id = cjs[0].id
2555
+ elif variable_library_id is None:
2556
+ raise Exception("variable_library_id or the variable_library_name is required")
2557
+
2558
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/VariableLibraries/{variable_library_id}"
2559
+
2560
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2561
+ error_message="Error getting variable library", return_format="json")
2562
+
2563
+ vl = VariableLibrary.from_dict(item_dict, core_client=self)
2564
+ vl.get_definition()
2565
+ return vl
2566
+
2567
+ def get_variable_library_definition(self, workspace_id, variable_library_id, format = None):
2568
+ """Get the definition of an variable library
2569
+ Args:
2570
+ workspace_id (str): The ID of the workspace
2571
+ variable_library_id (str): The ID of the variable library
2572
+ format (str): The format of the definition
2573
+ Returns:
2574
+ dict: The variable library definition
2575
+ """
2576
+ return self.get_item_definition(workspace_id, variable_library_id, type="VariableLibraries", format=format)
2577
+
2578
+ def list_variable_libraries(self, workspace_id, with_properties = False):
2579
+ """List variable libraries in a workspace
2580
+ Args:
2581
+ workspace_id (str): The ID of the workspace
2582
+ Returns:
2583
+ list: The list of variable libraries
2584
+ """
2585
+ return self.list_items(workspace_id, type="VariableLibraries", with_properties=with_properties)
2586
+
2587
+ def update_variable_library(self, workspace_id, variable_library_id, display_name = None, description = None, return_item=False):
2588
+ """Update a variable library in a workspace
2589
+ Args:
2590
+ workspace_id (str): The ID of the workspace
2591
+ variable_library_id (str): The ID of the variable library
2592
+ display_name (str): The display name of the variable library
2593
+ description (str): The description of the variable library
2594
+ Returns:
2595
+ dict: The updated variable library or VariableLibrary object if return_item is True
2596
+ """
2597
+ return self.update_item(workspace_id, item_id=variable_library_id, display_name=display_name, description=description, type="VariableLibraries",
2598
+ return_item=return_item)
2599
+
2600
+ def update_variable_library_definition(self, workspace_id, variable_library_id, definition, update_metadata = None):
2601
+ """Update the definition of an variable library
2602
+ Args:
2603
+ workspace_id (str): The ID of the workspace
2604
+ variable_library_id (str): The ID of the variable library
2605
+ definition (dict): The definition of the variable library
2606
+ update_metadata (bool): Whether to update the metadata
2607
+ Returns:
2608
+ dict: The updated variable library definition
2609
+ """
2610
+ return self.update_item_definition(workspace_id, variable_library_id, type="VariableLibraries", definition=definition, update_metadata=update_metadata)
2611
+
2612
+
2613
+ # data flow
2614
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows
2615
+ def create_dataflow(self, workspace_id, display_name, definition = None, description = None):
2616
+ """Create a dataflow in a workspace
2617
+ Args:
2618
+ workspace_id (str): The ID of the workspace
2619
+ display_name (str): The display name of the dataflow
2620
+ definition (dict): The definition of the dataflow
2621
+ description (str): The description of the dataflow
2622
+ Returns:
2623
+ dict: The created dataflow
2624
+ """
2625
+ return self.create_item(workspace_id=workspace_id,
2626
+ display_name = display_name,
2627
+ type = "dataflows",
2628
+ definition = definition,
2629
+ description = description)
2630
+
2631
+ # DELETE https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}
2632
+ def delete_dataflow(self, workspace_id, dataflow_id):
2633
+ """Delete a dataflow from a workspace
2634
+ Args:
2635
+ workspace_id (str): The ID of the workspace
2636
+ dataflow_id (str): The ID of the dataflow
2637
+ Returns:
2638
+ int: The status code of the response
2639
+ """
2640
+ return self.delete_item(workspace_id, item_id=dataflow_id, type="dataflows")
2641
+
2642
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}
2643
+ def get_dataflow(self, workspace_id, dataflow_id = None, dataflow_name = None):
2644
+ """Get a dataflow from a workspace
2645
+ Args:
2646
+ workspace_id (str): The ID of the workspace
2647
+ dataflow_id (str): The ID of the dataflow
2648
+ dataflow_name (str): The name of the dataflow
2649
+ Returns:
2650
+ Dataflow: The dataflow object
1886
2651
  """
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")
2652
+ from msfabricpysdkcore.otheritems import Dataflow
1893
2653
 
1894
- return response.status_code
2654
+ if dataflow_id is None and dataflow_name is not None:
2655
+ dataflows = self.list_dataflows(workspace_id)
2656
+ dfs = [df for df in dataflows if df.display_name == dataflow_name]
2657
+ if len(dfs) == 0:
2658
+ raise Exception(f"Dataflow with name {dataflow_name} not found")
2659
+ dataflow_id = dfs[0].id
2660
+ elif dataflow_id is None:
2661
+ raise Exception("dataflow_id or the dataflow_name is required")
2662
+
2663
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/dataflows/{dataflow_id}"
1895
2664
 
2665
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
2666
+ error_message="Error getting data flow", return_format="json")
1896
2667
 
2668
+ df = Dataflow.from_dict(item_dict, core_client=self)
2669
+ df.get_definition()
2670
+ return df
1897
2671
 
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")
2672
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}/getDefinition
2673
+ def get_dataflow_definition(self, workspace_id, dataflow_id, format = None):
2674
+ """Get the definition of a dataflow
2675
+ Args:
2676
+ workspace_id (str): The ID of the workspace
2677
+ dataflow_id (str): The ID of the dataflow
2678
+ format (str): The format of the definition
2679
+ Returns:
2680
+ dict: The dataflow definition
2681
+ """
2682
+ return self.get_item_definition(workspace_id, dataflow_id, type="dataflows", format=format)
1902
2683
 
1903
- def list_datamarts(self, workspace_id):
1904
- """List datamarts in a workspace"""
1905
- return self.list_items(workspace_id, type="datamarts")
2684
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows
2685
+ def list_dataflows(self, workspace_id, with_properties = False):
2686
+ """List dataflows in a workspace
2687
+ Args:
2688
+ workspace_id (str): The ID of the workspace
2689
+ with_properties (bool): Whether to get the item object with properties
2690
+ Returns:
2691
+ list: The list of dataflows
2692
+ """
2693
+ return self.list_items(workspace_id, type="dataflows", with_properties=with_properties)
2694
+
2695
+ # PATCH https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}
2696
+ def update_dataflow(self, workspace_id, dataflow_id, display_name = None, description = None, return_item=False):
2697
+ """Update a dataflow in a workspace
2698
+ Args:
2699
+ workspace_id (str): The ID of the workspace
2700
+ dataflow_id (str): The ID of the dataflow
2701
+ display_name (str): The display name of the dataflow
2702
+ description (str): The description of the dataflow
2703
+ Returns:
2704
+ dict: The updated dataflow
2705
+ """
2706
+ return self.update_item(workspace_id, item_id=dataflow_id, display_name=display_name, description=description, type="dataflows",
2707
+ return_item=return_item)
2708
+
2709
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/dataflows/{dataflowId}/updateDefinition
2710
+ def update_dataflow_definition(self, workspace_id, dataflow_id, definition, update_metadata = None):
2711
+ """Update the definition of a dataflow
2712
+ Args:
2713
+ workspace_id (str): The ID of the workspace
2714
+ dataflow_id (str): The ID of the dataflow
2715
+ definition (dict): The definition of the dataflow
2716
+ update_metadata (bool): Whether to update the metadata
2717
+ Returns:
2718
+ dict: The updated dataflow definition
2719
+ """
2720
+ return self.update_item_definition(workspace_id, dataflow_id, type="dataflows", definition=definition, update_metadata=update_metadata)
1906
2721
 
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
2722
 
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
2723
  # dataPipelines
1916
2724
 
1917
2725
  def create_data_pipeline(self, workspace_id, display_name, definition = None, description = None):
@@ -1961,6 +2769,18 @@ class FabricClientCore(FabricClient):
1961
2769
  dp.get_definition()
1962
2770
  return dp
1963
2771
 
2772
+ def get_data_pipeline_definition(self, workspace_id, data_pipeline_id, format = None):
2773
+ """Get the definition of a data pipeline
2774
+ Args:
2775
+ workspace_id (str): The ID of the workspace
2776
+ data_pipeline_id (str): The ID of the data pipeline
2777
+ format (str): The format of the definition
2778
+ Returns:
2779
+ dict: The data pipeline definition
2780
+ """
2781
+ return self.get_item_definition(workspace_id, data_pipeline_id, type="dataPipelines", format=format)
2782
+
2783
+
1964
2784
  def list_data_pipelines(self, workspace_id, with_properties = False):
1965
2785
  """List data pipelines in a workspace
1966
2786
  Args:
@@ -1984,6 +2804,18 @@ class FabricClientCore(FabricClient):
1984
2804
  return self.update_item(workspace_id, item_id=data_pipeline_id, display_name=display_name, description=description, type="dataPipelines",
1985
2805
  return_item=return_item)
1986
2806
 
2807
+ def update_data_pipeline_definition(self, workspace_id, data_pipeline_id, definition, update_metadata = None):
2808
+ """Update the definition of a data pipeline
2809
+ Args:
2810
+ workspace_id (str): The ID of the workspace
2811
+ data_pipeline_id (str): The ID of the data pipeline
2812
+ definition (dict): The definition of the data pipeline
2813
+ update_metadata (bool): Whether to update the metadata
2814
+ Returns:
2815
+ dict: The updated data pipeline definition
2816
+ """
2817
+ return self.update_item_definition(workspace_id, data_pipeline_id, type="dataPipelines", definition=definition, update_metadata=update_metadata)
2818
+
1987
2819
 
1988
2820
  # environments
1989
2821
 
@@ -2349,7 +3181,7 @@ class FabricClientCore(FabricClient):
2349
3181
  Returns:
2350
3182
  Eventstream: The eventstream object
2351
3183
  """
2352
- from msfabricpysdkcore.otheritems import Eventstream
3184
+ from msfabricpysdkcore.eventstream import Eventstream
2353
3185
  if eventstream_id is None and eventstream_name is not None:
2354
3186
  evstreams = self.list_eventstreams(workspace_id)
2355
3187
  evstreams = [ev for ev in evstreams if ev.display_name == eventstream_name]
@@ -2426,6 +3258,216 @@ class FabricClientCore(FabricClient):
2426
3258
  """
2427
3259
  return self.update_item_definition(workspace_id, eventstream_id, type="eventstreams", definition=definition, update_metadata=update_metadata)
2428
3260
 
3261
+ # eventstream topology
3262
+
3263
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}
3264
+ def get_eventstream_destination(self, workspace_id, eventstream_id, destination_id):
3265
+ """Get the destination of an eventstream
3266
+ Args:
3267
+ workspace_id (str): The ID of the workspace
3268
+ eventstream_id (str): The ID of the eventstream
3269
+ destination_id (str): The ID of the destination
3270
+ Returns:
3271
+ dict: The eventstream destination
3272
+ """
3273
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}"
3274
+
3275
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3276
+ error_message="Error getting eventstream destination", return_format="json")
3277
+ return item_dict
3278
+
3279
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}/connection
3280
+ def get_eventstream_destination_connection(self, workspace_id, eventstream_id, destination_id):
3281
+ """Get the connection of an eventstream destination
3282
+ Args:
3283
+ workspace_id (str): The ID of the workspace
3284
+ eventstream_id (str): The ID of the eventstream
3285
+ destination_id (str): The ID of the destination
3286
+ Returns:
3287
+ dict: The eventstream destination connection
3288
+ """
3289
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}/connection"
3290
+
3291
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3292
+ error_message="Error getting eventstream destination connection", return_format="json")
3293
+ return item_dict
3294
+
3295
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}
3296
+ def get_eventstream_source(self, workspace_id, eventstream_id, source_id):
3297
+ """Get the source of an eventstream
3298
+ Args:
3299
+ workspace_id (str): The ID of the workspace
3300
+ eventstream_id (str): The ID of the eventstream
3301
+ source_id (str): The ID of the source
3302
+ Returns:
3303
+ dict: The eventstream source
3304
+ """
3305
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}"
3306
+
3307
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3308
+ error_message="Error getting eventstream source", return_format="json")
3309
+ return item_dict
3310
+
3311
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}/connection
3312
+ def get_eventstream_source_connection(self, workspace_id, eventstream_id, source_id):
3313
+ """Get the connection of an eventstream source
3314
+ Args:
3315
+ workspace_id (str): The ID of the workspace
3316
+ eventstream_id (str): The ID of the eventstream
3317
+ source_id (str): The ID of the source
3318
+ Returns:
3319
+ dict: The eventstream source connection
3320
+ """
3321
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}/connection"
3322
+
3323
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3324
+ error_message="Error getting eventstream source connection", return_format="json")
3325
+ return item_dict
3326
+
3327
+
3328
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/topology
3329
+ def get_eventstream_topology(self, workspace_id, eventstream_id):
3330
+ """Get the topology of an eventstream
3331
+ Args:
3332
+ workspace_id (str): The ID of the workspace
3333
+ eventstream_id (str): The ID of the eventstream
3334
+ Returns:
3335
+ dict: The eventstream topology
3336
+ """
3337
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/topology"
3338
+
3339
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
3340
+ error_message="Error getting eventstream topology", return_format="json")
3341
+ return item_dict
3342
+
3343
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/pause
3344
+ def pause_eventstream(self, workspace_id, eventstream_id):
3345
+ """Pause an eventstream
3346
+ Args:
3347
+ workspace_id (str): The ID of the workspace
3348
+ eventstream_id (str): The ID of the eventstream
3349
+ Returns:
3350
+ dict: The operation result or response value
3351
+ """
3352
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/pause"
3353
+
3354
+ response = self.calling_routine(url, operation="POST", response_codes=[200, 429], error_message="Error pausing eventstream",
3355
+ return_format="response")
3356
+
3357
+ return response.status_code
3358
+
3359
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}/pause
3360
+ def pause_eventstream_destination(self, workspace_id, eventstream_id, destination_id):
3361
+ """Pause an eventstream destination
3362
+ Args:
3363
+ workspace_id (str): The ID of the workspace
3364
+ eventstream_id (str): The ID of the eventstream
3365
+ destination_id (str): The ID of the destination
3366
+ Returns:
3367
+ dict: The operation result or response value
3368
+ """
3369
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}/pause"
3370
+
3371
+ response = self.calling_routine(url, operation="POST", response_codes=[200, 429], error_message="Error pausing eventstream destination",
3372
+ return_format="response")
3373
+
3374
+ return response.status_code
3375
+
3376
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}/pause
3377
+ def pause_eventstream_source(self, workspace_id, eventstream_id, source_id):
3378
+ """Pause an eventstream source
3379
+ Args:
3380
+ workspace_id (str): The ID of the workspace
3381
+ eventstream_id (str): The ID of the eventstream
3382
+ source_id (str): The ID of the source
3383
+ Returns:
3384
+ dict: The operation result or response value
3385
+ """
3386
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}/pause"
3387
+
3388
+ response = self.calling_routine(url, operation="POST", response_codes=[200, 429], error_message="Error pausing eventstream source",
3389
+ return_format="response")
3390
+
3391
+ return response.status_code
3392
+
3393
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/resume
3394
+ def resume_eventstream(self, workspace_id, eventstream_id, start_type, custom_start_date_time = None):
3395
+ """Resume an eventstream
3396
+ Args:
3397
+ workspace_id (str): The ID of the workspace
3398
+ eventstream_id (str): The ID of the eventstream
3399
+ start_type (str): The start type of the eventstream
3400
+ custom_start_date_time (str): The custom start date time of the eventstream
3401
+ Returns:
3402
+ dict: The operation result or response value
3403
+ """
3404
+
3405
+ body = {
3406
+ "startType": start_type
3407
+ }
3408
+
3409
+ if custom_start_date_time is not None:
3410
+ body["customStartDateTime"] = custom_start_date_time
3411
+
3412
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/resume"
3413
+
3414
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429], error_message="Error resuming eventstream",
3415
+ return_format="response")
3416
+
3417
+ return response.status_code
3418
+
3419
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/destinations/{destinationId}/resume
3420
+ def resume_eventstream_destination(self, workspace_id, eventstream_id, destination_id, start_type, custom_start_date_time = None):
3421
+ """Resume an eventstream destination
3422
+ Args:
3423
+ workspace_id (str): The ID of the workspace
3424
+ eventstream_id (str): The ID of the eventstream
3425
+ destination_id (str): The ID of the destination
3426
+ start_type (str): The start type of the eventstream destination
3427
+ custom_start_date_time (str): The custom start date time of the eventstream destination
3428
+ Returns:
3429
+ dict: The operation result or response value
3430
+ """
3431
+ body = {
3432
+ "startType": start_type
3433
+ }
3434
+
3435
+ if custom_start_date_time is not None:
3436
+ body["customStartDateTime"] = custom_start_date_time
3437
+
3438
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/destinations/{destination_id}/resume"
3439
+
3440
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429], error_message="Error resuming eventstream destination",
3441
+ return_format="response")
3442
+
3443
+ return response.status_code
3444
+
3445
+ # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/eventstreams/{eventstreamId}/sources/{sourceId}/resume
3446
+ def resume_eventstream_source(self, workspace_id, eventstream_id, source_id, start_type, custom_start_date_time = None):
3447
+ """Resume an eventstream source
3448
+ Args:
3449
+ workspace_id (str): The ID of the workspace
3450
+ eventstream_id (str): The ID of the eventstream
3451
+ source_id (str): The ID of the source
3452
+ start_type (str): The start type of the eventstream source
3453
+ custom_start_date_time (str): The custom start date time of the eventstream source
3454
+ Returns:
3455
+ dict: The operation result or response value
3456
+ """
3457
+ body = {
3458
+ "startType": start_type
3459
+ }
3460
+
3461
+ if custom_start_date_time is not None:
3462
+ body["customStartDateTime"] = custom_start_date_time
3463
+
3464
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/eventstreams/{eventstream_id}/sources/{source_id}/resume"
3465
+
3466
+ response = self.calling_routine(url, operation="POST", body=body, response_codes=[200, 429], error_message="Error resuming eventstream source",
3467
+ return_format="response")
3468
+
3469
+ return response.status_code
3470
+
2429
3471
  # graphqlapis
2430
3472
 
2431
3473
  # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/GraphQLApis
@@ -2849,6 +3891,22 @@ class FabricClientCore(FabricClient):
2849
3891
  type = "lakehouses",
2850
3892
  description = description)
2851
3893
 
3894
+ def create_lakehouse_with_schema(self, workspace_id, display_name, creation_payload, description = None):
3895
+ """Create a lakehouse in a workspace
3896
+ Args:
3897
+ workspace_id (str): The ID of the workspace
3898
+ creation_payload (dict): The creation payload
3899
+ display_name (str): The display name of the lakehouse
3900
+ description (str): The description of the lakehouse
3901
+ Returns:
3902
+ dict: The created lakehouse
3903
+ """
3904
+ return self.create_item(workspace_id = workspace_id,
3905
+ display_name = display_name,
3906
+ type = "lakehouses",
3907
+ creation_payload = creation_payload,
3908
+ description = description)
3909
+
2852
3910
  def delete_lakehouse(self, workspace_id, lakehouse_id):
2853
3911
  """Delete a lakehouse from a workspace
2854
3912
  Args:
@@ -2989,6 +4047,88 @@ class FabricClientCore(FabricClient):
2989
4047
  else:
2990
4048
  self._logger.info("Table created")
2991
4049
  return response.status_code
4050
+
4051
+ # lakehouse livy sessions
4052
+
4053
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId}/livySessions
4054
+ def list_lakehouse_livy_sessions(self, workspace_id, lakehouse_id):
4055
+ """List all livy sessions for a lakehouse
4056
+ Args:
4057
+ workspace_id (str): The ID of the workspace
4058
+ lakehouse_id (str): The ID of the lakehouse
4059
+ Returns:
4060
+ list: The list of livy sessions
4061
+ """
4062
+ return self.list_livy_sessions(workspace_id=workspace_id, item_id=lakehouse_id, item_type="lakehouses")
4063
+
4064
+ # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId}/livySessions/{livyId}
4065
+ def get_lakehouse_livy_session(self, workspace_id, lakehouse_id, livy_id):
4066
+ """Get a livy session for a lakehouse
4067
+ Args:
4068
+ workspace_id (str): The ID of the workspace
4069
+ lakehouse_id (str): The ID of the lakehouse
4070
+ livy_id (str): The ID of the livy session
4071
+ Returns:
4072
+ dict: The livy session
4073
+ """
4074
+ return self.get_livy_session(workspace_id=workspace_id,
4075
+ item_id=lakehouse_id, item_type="lakehouses", livy_id=livy_id)
4076
+
4077
+ # Livy sessions
4078
+
4079
+
4080
+ def get_livy_session(self, workspace_id, item_id, item_type = None, livy_id = None):
4081
+ """Get a livy session for a lakehouse
4082
+ Args:
4083
+ workspace_id (str): The ID of the workspace
4084
+ item_id (str): The ID of the item
4085
+ item_type (str): The type of the item
4086
+ livy_id (str): The ID of the livy session
4087
+ Returns:
4088
+ dict: The livy session
4089
+ """
4090
+
4091
+ if "lakehouse" in item_type.lower():
4092
+ item_type = "lakehouses"
4093
+ elif "notebook" in item_type.lower():
4094
+ item_type = "notebooks"
4095
+ elif "sparkjobdef" in item_type.lower() or "sjd" in item_type.lower():
4096
+ item_type = "sparkJobDefinitions"
4097
+
4098
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/{item_type}/{item_id}/livySessions/{livy_id}"
4099
+
4100
+ item_dict = self.calling_routine(url, operation="GET", response_codes=[200, 429],
4101
+ error_message="Error getting livy session", return_format="json")
4102
+ return item_dict
4103
+
4104
+ def list_livy_sessions(self, workspace_id, item_id = None, item_type = None):
4105
+ """List all livy sessions for a lakehouse
4106
+ Args:
4107
+ workspace_id (str): The ID of the workspace
4108
+ item_id (str): The ID of the item
4109
+ item_type (str): The type of the item
4110
+ Returns:
4111
+ list: The list of livy sessions
4112
+ """
4113
+ if item_id is None:
4114
+ item_type = "spark"
4115
+ elif "lakehouse" in item_type.lower():
4116
+ item_type = "lakehouses"
4117
+ elif "notebook" in item_type.lower():
4118
+ item_type = "notebooks"
4119
+ elif "sparkjobdef" in item_type.lower() or "sjd" in item_type.lower():
4120
+ item_type = "sparkJobDefinitions"
4121
+
4122
+ if item_id is None:
4123
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/spark/livySessions"
4124
+ else:
4125
+ url = f"https://api.fabric.microsoft.com/v1/workspaces/{workspace_id}/{item_type}/{item_id}/livySessions"
4126
+
4127
+ items = self.calling_routine(url, operation="GET", response_codes=[200, 429],
4128
+ error_message="Error listing livy sessions", return_format="value_json", paging=True)
4129
+
4130
+ return items
4131
+
2992
4132
 
2993
4133
  # mirrored_database
2994
4134
 
@@ -3486,7 +4626,29 @@ class FabricClientCore(FabricClient):
3486
4626
  dict: The updated notebook
3487
4627
  """
3488
4628
  return self.update_item_definition(workspace_id, notebook_id, definition, type="notebooks")
4629
+
4630
+ def get_notebook_livy_session(self, workspace_id, notebook_id, livy_id):
4631
+ """Get a livy session for a notebook
4632
+ Args:
4633
+ workspace_id (str): The ID of the workspace
4634
+ notebook_id (str): The ID of the notebook
4635
+ livy_id (str): The ID of the livy session
4636
+ Returns:
4637
+ dict: The livy session
4638
+ """
4639
+ return self.get_livy_session(workspace_id=workspace_id, item_id=notebook_id, item_type="notebooks", livy_id=livy_id)
3489
4640
 
4641
+ def list_notebook_livy_sessions(self, workspace_id, notebook_id):
4642
+ """List all livy sessions for a notebook
4643
+ Args:
4644
+ workspace_id (str): The ID of the workspace
4645
+ notebook_id (str): The ID of the notebook
4646
+ Returns:
4647
+ list: The list of livy sessions
4648
+ """
4649
+
4650
+ return self.list_livy_sessions(workspace_id=workspace_id, item_id=notebook_id, item_type="notebooks")
4651
+
3490
4652
  # paginatedReports
3491
4653
 
3492
4654
  def list_paginated_reports(self, workspace_id):
@@ -4083,6 +5245,27 @@ class FabricClientCore(FabricClient):
4083
5245
  return self.get_item_job_instance(workspace_id = workspace_id,
4084
5246
  item_id = spark_job_definition_id,
4085
5247
  job_instance_id = job_instance_id)
5248
+
5249
+ def list_spark_job_definition_livy_sessions(self, workspace_id, spark_job_definition_id):
5250
+ """List all livy sessions for a spark job definition
5251
+ Args:
5252
+ workspace_id (str): The ID of the workspace
5253
+ spark_job_definition_id (str): The ID of the spark job definition
5254
+ Returns:
5255
+ list: The list of livy sessions
5256
+ """
5257
+ return self.list_livy_sessions(workspace_id=workspace_id, item_id=spark_job_definition_id, item_type="sparkJobDefinitions")
5258
+
5259
+ def get_spark_job_definition_livy_session(self, workspace_id, spark_job_definition_id, livy_id):
5260
+ """Get a livy session for a spark job definition
5261
+ Args:
5262
+ workspace_id (str): The ID of the workspace
5263
+ spark_job_definition_id (str): The ID of the spark job definition
5264
+ livy_id (str): The ID of the livy session
5265
+ Returns:
5266
+ dict: The livy session
5267
+ """
5268
+ return self.get_livy_session(workspace_id=workspace_id, item_id=spark_job_definition_id, item_type="sparkJobDefinitions", livy_id=livy_id)
4086
5269
 
4087
5270
  # sql database
4088
5271