Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9ed7aca
Supports DB creation with initial properties
v-alexmoraru Jun 18, 2026
febbc8b
Changelog
v-alexmoraru Jun 18, 2026
528af3b
Merge branch 'main' into v-alexmoraru/new-SQLDatabase-with-initial-pr…
v-alexmoraru Jun 18, 2026
5d3a27e
Review suggestions
v-alexmoraru Jun 18, 2026
7f81167
remove creation payload validation. add tests
Jun 25, 2026
3b607aa
fix conflicts
Jun 25, 2026
eea35f9
add changie
Jun 25, 2026
0e2a407
remove duplicate changie entry
Jun 25, 2026
d391050
remove unused import
Jun 25, 2026
0ac39f9
resolve comments
Jun 25, 2026
41d8462
Support creating sqlDatabase with optinal params
Jun 28, 2026
afd5e28
add tests recordings
Jun 28, 2026
c8c6daf
resolve PR comments
Jun 28, 2026
c0d062c
fix recording
Jun 28, 2026
c8a9876
revert support for Restore and RestoreDeleted
Jun 29, 2026
cf710c2
Support restore and restoreDeteledDatabase mode
Jun 29, 2026
d97161b
Support creationMode Resotre and RestoreDeletedDatabase
Jul 1, 2026
43791b8
resolve merge conflicts
Jul 1, 2026
5244079
add changie
Jul 1, 2026
80a63d6
Update src/fabric_cli/errors/mkdir.py
aviatco Jul 1, 2026
96e4e2d
update changie
Jul 1, 2026
074bedc
Merge branch 'dev/aviatcohen/create-sqlDatabase-creation-payload-rest…
Jul 1, 2026
ba51214
resolve PR commets
Jul 1, 2026
8415e27
fix recording
Jul 1, 2026
071a2d5
Potential fix for pull request finding
aviatco Jul 1, 2026
a14ff9b
revert is_record_mode False check
Jul 1, 2026
5d9ea27
Merge branch 'dev/aviatcohen/create-sqlDatabase-creation-payload-rest…
Jul 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changes/unreleased/added-20260625-145755.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kind: added
body: Support creating SQLDatabase with optional parameters. Only `CreationMode` of type `New` is supported.
body: Support creating SQLDatabase with optional parameters. Support `creationMode` of type `New`, `Restore` and `RestoreDeletedDatabase`.
time: 2026-06-25T14:57:55.03150683Z
custom:
Author: aviatco
Expand Down
2 changes: 2 additions & 0 deletions src/fabric_cli/core/fab_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,5 @@

# SQLDatabase creation modes
SQL_DATABASE_CREATION_MODE_NEW = "New"
SQL_DATABASE_CREATION_MODE_RESTORE = "Restore"
SQL_DATABASE_CREATION_MODE_RESTORE_DELETED = "RestoreDeletedDatabase"
18 changes: 17 additions & 1 deletion src/fabric_cli/errors/mkdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,27 @@ def workspace_capacity_not_found() -> str:
def folder_name_exists() -> str:
return "A folder with the same name already exists"

@staticmethod
def missing_restore_params() -> str:
return (
"Missing required parameter(s) for restore mode. "
"Required: restorePointInTime, itemId, workspaceId. "
"Example: -P creationMode=Restore,restorePointInTime=2024-01-15T10:30:00Z,itemId=<item-id>,workspaceId=<workspace-id>"
)

@staticmethod
def missing_restore_deleted_params() -> str:
return (
"Missing required parameter(s) for RestoreDeletedDatabase mode. "
"Required: restorableDeletedDatabaseName, restorePointInTime. "
"Example: -P creationMode=RestoreDeletedDatabase,restorableDeletedDatabaseName=<name>,restorePointInTime=2024-01-15T10:30:00Z"
)

@staticmethod
def unsupported_creation_mode(mode: str) -> str:
return (
f"Unsupported creation mode '{mode}'. "
"Supported modes: New"
"Supported modes: New, Restore, RestoreDeletedDatabase"
)

@staticmethod
Expand Down
65 changes: 64 additions & 1 deletion src/fabric_cli/utils/fab_cmd_mkdir_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ def get_params_per_item_type(item: Item):
"creationMode",
"backupRetentionDays",
"collation",
"restorePointInTime",
"itemId",
"workspaceId",
"referenceType",
"restorableDeletedDatabaseName",
]

return required_params, optional_params
Expand Down Expand Up @@ -789,8 +794,13 @@ def lowercase_keys(data):
def _build_sql_database_creation_payload_if_exists(params: dict) -> dict:
"""Build the optional creationPayload for SQLDatabase creation.

The payload is built based on the creation mode (params["creationmode"]):
The payload is built based on the creation mode (params["creationMode"]) and the provided parameters.
The supported modes are:
- New: creationMode, backupRetentionDays, collation
- Restore: creationMode, restorePointInTime, sourceDatabaseReference
Comment thread
aviatco marked this conversation as resolved.
(itemId, referenceType, workspaceId)
- RestoreDeletedDatabase: creationMode, restorableDeletedDatabaseName,
restorePointInTime

Returns an empty dict when no mode is provided, since the creationPayload
is optional.
Expand All @@ -805,12 +815,31 @@ def _build_sql_database_creation_payload_if_exists(params: dict) -> dict:
if mode_lower == fab_constant.SQL_DATABASE_CREATION_MODE_NEW.lower():
return _build_sql_database_new_payload(params)

if mode_lower == fab_constant.SQL_DATABASE_CREATION_MODE_RESTORE.lower():
return _build_sql_database_restore_payload(params)

if mode_lower == fab_constant.SQL_DATABASE_CREATION_MODE_RESTORE_DELETED.lower():
return _build_sql_database_restore_deleted_payload(params)


raise FabricCLIError(
ErrorMessages.Mkdir.unsupported_creation_mode(mode),
fab_constant.ERROR_INVALID_INPUT,
)


def _validate_required_params(
params: dict[str, object], required: list[str], error_message: str
) -> None:
"""Raise a FabricCLIError when any required param is missing or empty.

'required' is a list of (key) param names to look up in 'params'.
"""
missing = [key for key in required if not params.get(key)]
if missing:
raise FabricCLIError(error_message, fab_constant.ERROR_INVALID_INPUT)


def _build_sql_database_new_payload(params: dict) -> dict:
"""Build the creationPayload for the New SQLDatabase mode."""
backup_retention_days = params.get("backupretentiondays")
Expand All @@ -837,6 +866,40 @@ def _build_sql_database_new_payload(params: dict) -> dict:
return creation_payload


def _build_sql_database_restore_payload(params: dict) -> dict:
"""Build the creationPayload for the Restore SQLDatabase mode."""
_validate_required_params(
params,
["restorepointintime", "itemid", "workspaceid"],
ErrorMessages.Mkdir.missing_restore_params(),
)
Comment thread
aviatco marked this conversation as resolved.
Comment thread
aviatco marked this conversation as resolved.
Comment thread
aviatco marked this conversation as resolved.

return {
"creationMode": fab_constant.SQL_DATABASE_CREATION_MODE_RESTORE,
"restorePointInTime": params.get("restorepointintime"),
"sourceDatabaseReference": {
"itemId": params.get("itemid"),
"referenceType": params.get("referencetype", "ById"),
"workspaceId": params.get("workspaceid"),
},
Comment thread
aviatco marked this conversation as resolved.
}


def _build_sql_database_restore_deleted_payload(params: dict) -> dict:
"""Build the creationPayload for the RestoreDeletedDatabase SQLDatabase mode."""
_validate_required_params(
params,
["restorabledeleteddatabasename", "restorepointintime"],
ErrorMessages.Mkdir.missing_restore_deleted_params(),
)

return {
"creationMode": fab_constant.SQL_DATABASE_CREATION_MODE_RESTORE_DELETED,
"restorableDeletedDatabaseName": params.get("restorabledeleteddatabasename"),
"restorePointInTime": params.get("restorepointintime"),
}


def validate_spark_pool_params(params):
# Node size options
allowed_node_sizes = {"small", "medium", "large", "xlarge", "xxlarge"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '3372'
- '3467'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Jun 2026 12:23:57 GMT
- Wed, 01 Jul 2026 19:12:35 GMT
Pragma:
- no-cache
RequestId:
- 9cbe7895-a269-4c38-a8a0-b2aa7cab980b
- 4b9b4fe1-1e75-4960-92c1-057599bf87c5
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -75,15 +75,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '3372'
- '3467'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Jun 2026 12:23:59 GMT
- Wed, 01 Jul 2026 19:12:36 GMT
Pragma:
- no-cache
RequestId:
- b9f62560-ac92-47b2-843a-f328f8b81599
- 56b58f16-dd3d-4b8f-9c90-77a2d13b1077
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -129,11 +129,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Jun 2026 12:24:04 GMT
- Wed, 01 Jul 2026 19:12:40 GMT
Pragma:
- no-cache
RequestId:
- 8ec42234-820a-40cd-9777-83147381c1e8
- 12132078-71c1-48f2-89fc-361417ae2b27
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -167,7 +167,7 @@ interactions:
uri: https://api.fabric.microsoft.com/v1/workspaces
response:
body:
string: '{"id": "93e90efd-c518-46b5-ae56-9f3ed3244e19", "displayName": "fabriccli_WorkspacePerTestclass_000001",
string: '{"id": "f54ac349-b5a9-41bd-acd1-81f9ed9ec0f3", "displayName": "fabriccli_WorkspacePerTestclass_000001",
"description": "", "type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004",
"capacityRegion": "Central US"}'
headers:
Expand All @@ -178,17 +178,17 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '193'
- '196'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Jun 2026 12:24:12 GMT
- Wed, 01 Jul 2026 19:12:45 GMT
Location:
- https://api.fabric.microsoft.com/v1/workspaces/93e90efd-c518-46b5-ae56-9f3ed3244e19
- https://api.fabric.microsoft.com/v1/workspaces/f54ac349-b5a9-41bd-acd1-81f9ed9ec0f3
Pragma:
- no-cache
RequestId:
- eb1b48e3-5eac-4f95-8c80-adbc432c0114
- 69736420-636d-43f1-9f6b-9170a88f51e8
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -220,7 +220,7 @@ interactions:
response:
body:
string: '{"value": [{"id": "3634a139-2c9e-4205-910b-3b089a31be47", "displayName":
"My workspace", "description": "", "type": "Personal"}, {"id": "93e90efd-c518-46b5-ae56-9f3ed3244e19",
"My workspace", "description": "", "type": "Personal"}, {"id": "f54ac349-b5a9-41bd-acd1-81f9ed9ec0f3",
"displayName": "fabriccli_WorkspacePerTestclass_000001", "description": "",
"type": "Workspace", "capacityId": "00000000-0000-0000-0000-000000000004",
"capacityRegion": "Central US"}]}'
Expand All @@ -232,15 +232,15 @@ interactions:
Content-Encoding:
- gzip
Content-Length:
- '3407'
- '3500'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Jun 2026 12:25:27 GMT
- Wed, 01 Jul 2026 19:43:10 GMT
Pragma:
- no-cache
RequestId:
- 0609f127-38cc-4ea8-9921-5741cd1125e3
- 4a3e7063-a634-4061-9c9a-b2d7693272cc
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -268,7 +268,7 @@ interactions:
User-Agent:
- ms-fabric-cli/1.6.1 (mkdir; Linux/6.6.87.2-microsoft-standard-WSL2; Python/3.12.11)
method: GET
uri: https://api.fabric.microsoft.com/v1/workspaces/93e90efd-c518-46b5-ae56-9f3ed3244e19/items
uri: https://api.fabric.microsoft.com/v1/workspaces/f54ac349-b5a9-41bd-acd1-81f9ed9ec0f3/items
response:
body:
string: '{"value": []}'
Expand All @@ -284,11 +284,11 @@ interactions:
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 29 Jun 2026 12:25:29 GMT
- Wed, 01 Jul 2026 19:43:10 GMT
Pragma:
- no-cache
RequestId:
- 34a03b3e-7521-4bd5-9227-e008b722a65d
- 098c0e59-ef2c-4b31-a534-bc752bf28bef
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down Expand Up @@ -318,7 +318,7 @@ interactions:
User-Agent:
- ms-fabric-cli/1.6.1 (mkdir; Linux/6.6.87.2-microsoft-standard-WSL2; Python/3.12.11)
method: DELETE
uri: https://api.fabric.microsoft.com/v1/workspaces/93e90efd-c518-46b5-ae56-9f3ed3244e19
uri: https://api.fabric.microsoft.com/v1/workspaces/f54ac349-b5a9-41bd-acd1-81f9ed9ec0f3
response:
body:
string: ''
Expand All @@ -334,11 +334,11 @@ interactions:
Content-Type:
- application/octet-stream
Date:
- Mon, 29 Jun 2026 12:25:29 GMT
- Wed, 01 Jul 2026 19:43:10 GMT
Pragma:
- no-cache
RequestId:
- b4152520-4bef-46fc-80e3-64837c54808b
- c862cc56-bcd3-4573-ba39-175c3d756ba3
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
Expand Down
Loading
Loading