Skip to content

Commit 186428a

Browse files
committed
removed validation of restorable resources
1 parent 4254e54 commit 186428a

File tree

1 file changed

+0
-57
lines changed
  • src/azure-cli/azure/cli/command_modules/cosmosdb

1 file changed

+0
-57
lines changed

src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,13 +1848,11 @@ def cli_cosmosdb_restore(cmd,
18481848
if restore_timestamp_datetime_utc > current_dateTime:
18491849
raise CLIError("Restore timestamp {} should be less than current timestamp {}".format(restore_timestamp_datetime_utc, current_dateTime))
18501850

1851-
is_source_restorable_account_deleted = False
18521851
for account in restorable_database_accounts_list:
18531852
if account.account_name == account_name:
18541853
if account.deletion_time is not None:
18551854
if account.deletion_time >= restore_timestamp_datetime_utc >= account.creation_time:
18561855
target_restorable_account = account
1857-
is_source_restorable_account_deleted = True
18581856
break
18591857
else:
18601858
if restore_timestamp_datetime_utc >= account.creation_time:
@@ -1864,61 +1862,6 @@ def cli_cosmosdb_restore(cmd,
18641862
if target_restorable_account is None:
18651863
raise CLIError("Cannot find a database account with name {} that is online at {}".format(account_name, restore_timestamp))
18661864

1867-
# Validate if source account is empty only for live account restores. For deleted account restores the api will not work
1868-
if not is_source_restorable_account_deleted:
1869-
restorable_resources = None
1870-
api_type = target_restorable_account.api_type.lower()
1871-
arm_location_normalized = target_restorable_account.location.lower().replace(" ", "")
1872-
if api_type == "sql":
1873-
try:
1874-
from azure.cli.command_modules.cosmosdb._client_factory import cf_restorable_sql_resources
1875-
restorable_sql_resources_client = cf_restorable_sql_resources(cmd.cli_ctx, [])
1876-
restorable_resources = restorable_sql_resources_client.list(
1877-
arm_location_normalized,
1878-
target_restorable_account.name,
1879-
location,
1880-
restore_timestamp_datetime_utc)
1881-
except ResourceNotFoundError:
1882-
raise CLIError("Cannot find a database account with name {} that is online at {} in location {}".format(account_name, restore_timestamp, location))
1883-
elif api_type == "mongodb":
1884-
try:
1885-
from azure.cli.command_modules.cosmosdb._client_factory import cf_restorable_mongodb_resources
1886-
restorable_mongodb_resources_client = cf_restorable_mongodb_resources(cmd.cli_ctx, [])
1887-
restorable_resources = restorable_mongodb_resources_client.list(
1888-
arm_location_normalized,
1889-
target_restorable_account.name,
1890-
location,
1891-
restore_timestamp_datetime_utc)
1892-
except ResourceNotFoundError:
1893-
raise CLIError("Cannot find a database account with name {} that is online at {} in location {}".format(account_name, restore_timestamp, location))
1894-
elif "sql" in api_type and "gremlin" in api_type:
1895-
try:
1896-
from azure.cli.command_modules.cosmosdb._client_factory import cf_restorable_gremlin_resources
1897-
restorable_gremlin_resources_client = cf_restorable_gremlin_resources(cmd.cli_ctx, [])
1898-
restorable_resources = restorable_gremlin_resources_client.list(
1899-
target_restorable_account.location,
1900-
target_restorable_account.name,
1901-
location,
1902-
restore_timestamp_datetime_utc)
1903-
except ResourceNotFoundError:
1904-
raise CLIError("Cannot find a database account with name {} that is online at {} in location {}".format(account_name, restore_timestamp, location))
1905-
elif "sql" in api_type and "table" in api_type:
1906-
try:
1907-
from azure.cli.command_modules.cosmosdb._client_factory import cf_restorable_table_resources
1908-
restorable_table_resources_client = cf_restorable_table_resources(cmd.cli_ctx, [])
1909-
restorable_resources = restorable_table_resources_client.list(
1910-
target_restorable_account.location,
1911-
target_restorable_account.name,
1912-
location,
1913-
restore_timestamp_datetime_utc)
1914-
except ResourceNotFoundError:
1915-
raise CLIError("Cannot find a database account with name {} that is online at {} in location {}".format(account_name, restore_timestamp, location))
1916-
else:
1917-
raise CLIError("Provided API Type {} is not supported for account {}".format(target_restorable_account.api_type, account_name))
1918-
1919-
if restorable_resources is None or not any(restorable_resources):
1920-
raise CLIError("Database account {} contains no restorable resources in location {} at given restore timestamp {}".format(target_restorable_account, location, restore_timestamp_datetime_utc))
1921-
19221865
# Trigger restore
19231866
locations = []
19241867
locations.append(Location(location_name=location, failover_priority=0))

0 commit comments

Comments
 (0)