-
Notifications
You must be signed in to change notification settings - Fork 41
feat: enables backup retention and collation setting for SQL DB #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| kind: added | ||
| body: Add SQL Database creationPayload support for mkdir command with mode, backupRetentionDays, and collation parameters | ||
| time: 2026-03-13T00:00:00.000000000Z | ||
| custom: | ||
| Author: dzsquared | ||
| AuthorLink: https://github.com/dzsquared |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,3 +19,7 @@ def workspace_capacity_not_found() -> str: | |||||
| @staticmethod | ||||||
| def folder_name_exists() -> str: | ||||||
| return "A folder with the same name already exists" | ||||||
|
|
||||||
| @staticmethod | ||||||
| def invalid_parameter_format(invalidParam: str, expectedFormat: str) -> str: | ||||||
| return f"Invalid parameter format: '{invalidParam}'. Expected format: {expectedFormat}" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,6 +188,29 @@ def add_type_specific_payload(item: Item, args, payload): | |
| ] | ||
| } | ||
|
|
||
| case ItemType.SQL_DATABASE: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about restore creation payload? |
||
| _mode = params.get("mode") | ||
| _backup_retention_days = params.get("backupretentiondays") | ||
| _collation = params.get("collation") | ||
|
|
||
| if _mode or _backup_retention_days or _collation: | ||
| creation_payload: dict = {"creationMode": _mode if _mode else "new"} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we assume if creatIonmode not specified it should be 'new'? isn't it a required parameter for creationPayload? |
||
| if _backup_retention_days: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will not run the conversion if the value is "0" or 0, because both are falsy. That means: • "0" → skipped entirely use if _backup_retention_days is not None:
try:
creation_payload["backupRetentionDays"] = int(_backup_retention_days)
except (ValueError, TypeError):
raise FabricCLIError(
ErrorMessages.Mkdir.invalid_parameter_format(
_backup_retention_days, "integer"
),
fab_constant.ERROR_INVALID_INPUT,
) |
||
| try: | ||
| creation_payload["backupRetentionDays"] = int( | ||
| _backup_retention_days | ||
| ) | ||
| except ValueError: | ||
| raise FabricCLIError( | ||
| ErrorMessages.Mkdir.invalid_parameter_format( | ||
| _backup_retention_days, "integer" | ||
| ), | ||
| fab_constant.ERROR_INVALID_INPUT, | ||
| ) | ||
| if _collation: | ||
| creation_payload["collation"] = _collation | ||
| payload_dict["creationPayload"] = creation_payload | ||
|
|
||
| return payload_dict | ||
|
|
||
|
|
||
|
|
@@ -309,6 +332,8 @@ def get_params_per_item_type(item: Item): | |
| optional_params = ["semanticModelId"] | ||
| case ItemType.MOUNTED_DATA_FACTORY: | ||
| required_params = ["subscriptionId", "resourceGroup", "factoryName"] | ||
| case ItemType.SQL_DATABASE: | ||
| optional_params = ["mode", "backupRetentionDays", "collation"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why mode not required? |
||
|
|
||
| return required_params, optional_params | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Python, snake_case is the convention of writing names in all lowercase with words separated by underscores