Skip to content

Commit 423f32c

Browse files
committed
Fixed review comments
1 parent caf1888 commit 423f32c

File tree

7 files changed

+26
-31
lines changed

7 files changed

+26
-31
lines changed

src/Sql/Sql/Server/Cmdlet/NewAzureSqlServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public override void ExecuteCmdlet()
189189
}
190190

191191
// SoftDeleteRetentionDays depends on EnableSoftDeleteRetention; if days are provided but soft-delete is not enabled, fail early.
192-
if (this.SoftDeleteRetentionDays.HasValue && this.SoftDeleteRetentionDays > 0 && !this.EnableSoftDeleteRetention)
192+
if (this.SoftDeleteRetentionDays.HasValue && !this.EnableSoftDeleteRetention)
193193
{
194194
throw new PSArgumentException(Properties.Resources.MissingEnableSoftDeleteRetention, "EnableSoftDeleteRetention");
195195
}

src/Sql/Sql/Server/Cmdlet/RestoreAzureSqlServer.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public class RestoreAzureSqlServer : AzureSqlServerCmdletBase
5858
// First check if a live server already exists
5959
try
6060
{
61-
bool serverExists = ModelAdapter.ListServers().Any(s =>
62-
string.Equals(s.ResourceGroupName, this.ResourceGroupName, StringComparison.OrdinalIgnoreCase) &&
61+
bool serverExists = ModelAdapter.ListServersByResourceGroup(this.ResourceGroupName).Any(s =>
6362
string.Equals(s.ServerName, this.ServerName, StringComparison.OrdinalIgnoreCase));
6463

6564
if (serverExists)
@@ -83,8 +82,7 @@ public class RestoreAzureSqlServer : AzureSqlServerCmdletBase
8382
// Now check if there's a deleted server to restore
8483
try
8584
{
86-
var deletedServer = ModelAdapter.GetDeletedServer(this.ResourceGroupName, this.ServerName);
87-
if (deletedServer == null)
85+
if (ModelAdapter.GetDeletedServer(this.Location, this.ServerName) == null)
8886
{
8987
throw new PSArgumentException(
9088
string.Format(Properties.Resources.DeletedServerNotFound,
@@ -117,20 +115,16 @@ public class RestoreAzureSqlServer : AzureSqlServerCmdletBase
117115
/// <returns>The generated model from user input</returns>
118116
protected override IEnumerable<Model.AzureSqlServerModel> ApplyUserInputToModel(IEnumerable<Model.AzureSqlServerModel> model)
119117
{
120-
if (!Sql.Services.Util.ValidateServerName(this.ServerName))
118+
return new List<Model.AzureSqlServerModel>
121119
{
122-
throw new PSArgumentException(string.Format(Properties.Resources.ServerNameInvalid, this.ServerName), "ServerName");
123-
}
124-
125-
List<Model.AzureSqlServerModel> newEntity = new List<Model.AzureSqlServerModel>();
126-
newEntity.Add(new Model.AzureSqlServerModel()
127-
{
128-
Location = this.Location,
129-
ResourceGroupName = this.ResourceGroupName,
130-
ServerName = this.ServerName,
131-
CreateMode = "Restore"
132-
});
133-
return newEntity;
120+
new Model.AzureSqlServerModel
121+
{
122+
Location = this.Location,
123+
ResourceGroupName = this.ResourceGroupName,
124+
ServerName = this.ServerName,
125+
CreateMode = "Restore"
126+
}
127+
};
134128
}
135129

136130
/// <summary>

src/Sql/Sql/Server/Cmdlet/SetAzureSqlServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public class SetAzureSqlServer : AzureSqlServerCmdletBase
131131
[Parameter(Mandatory = false,
132132
HelpMessage = "Specify whether to enable soft-delete retention for the server. When enabled, a dropped server can be restored within the retention window (defaults to 7 days if not specified). To set a custom retention period use -SoftDeleteRetentionDays.")]
133133
[PSArgumentCompleter("true", "false")]
134-
public bool EnableSoftDeleteRetention { get; set; } = false;
134+
public bool EnableSoftDeleteRetention { get; set; }
135135

136136
/// <summary>
137137
/// Value for soft-delete retention days for the server.

src/Sql/Sql/Server/Services/AzureSqlServerAdapter.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,17 @@ protected Guid GetTenantId()
412412

413413
return tenantIdGuid;
414414
}
415+
415416
/// <summary>
416-
/// Gets a deleted server in a resource group
417+
/// Gets a deleted Azure SQL server by location and server name.
417418
/// </summary>
418-
/// <param name="resourceGroupName">The name of the resource group</param>
419-
/// <param name="serverName">The name of the deleted server</param>
420-
/// <param name="subscriptionId">The subscription id of the server.</param>
421-
/// <returns>The deleted server information</returns>
422-
public Management.Sql.Models.DeletedServer GetDeletedServer(string resourceGroupName, string serverName, string subscriptionId = null)
419+
/// <param name="location">The Azure region (location) where the deleted server resided.</param>
420+
/// <param name="serverName">The name of the deleted SQL server.</param>
421+
/// <param name="subscriptionId">Optional. The subscription ID associated with the server. If null, uses the current context.</param>
422+
/// <returns>The deleted server information if found; otherwise, null.</returns>
423+
public Management.Sql.Models.DeletedServer GetDeletedServer(string location, string serverName, string subscriptionId = null)
423424
{
424-
return Communicator.GetDeleted(resourceGroupName, serverName, subscriptionId);
425+
return Communicator.GetDeleted(location, serverName, subscriptionId);
425426
}
426427
}
427428
}

src/Sql/Sql/Server/Services/AzureSqlServerCommunicator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public void Remove(string resourceGroupName, string serverName)
9797
/// <summary>
9898
/// Gets the deleted Azure Sql Database Server
9999
/// </summary>
100-
public Management.Sql.Models.DeletedServer GetDeleted(string resourceGroupName, string serverName, string subscriptionId = null)
100+
public Management.Sql.Models.DeletedServer GetDeleted(string location, string serverName, string subscriptionId = null)
101101
{
102-
return GetCurrentSqlClient(subscriptionId).DeletedServers.Get(resourceGroupName, serverName);
102+
return GetCurrentSqlClient(subscriptionId).DeletedServers.Get(location, serverName);
103103
}
104104

105105
/// <summary>

src/Sql/Sql/help/Restore-AzSqlServer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ RestrictOutboundNetworkAccess : Disabled
4444
Administrators :
4545
PrimaryUserAssignedIdentityId :
4646
KeyId :
47-
FederatedClientId :
47+
FederatedClientId :
4848
SoftDeleteRetentionDays : 7
4949
```
5050

src/Sql/Sql/help/Set-AzSqlServer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Accept wildcard characters: False
118118
```
119119
120120
### -EnableSoftDeleteRetention
121-
Boolean value for whether or not to enable soft-delete for the server such that the server can be restored for a default of 7 days after dropping. If you want to specify a different retention period, use the RetentionDays parameter.
121+
Boolean value for whether or not to enable soft-delete for the server such that the server can be restored for a default of 7 days after dropping. If you want to specify a different retention period, use the SoftDeleteRetentionDays parameter.
122122
123123
```yaml
124124
Type: System.Boolean
@@ -301,7 +301,7 @@ Accept wildcard characters: False
301301
```
302302
303303
### -SoftDeleteRetentionDays
304-
Value for soft-delete retention days for the server such that the server can be restored for the specified number of days after dropping. Only valid values are from 0 to 35. If set to 0, soft-delete retention is disabled.
304+
Value for soft-delete retention days for the server such that the server can be restored for the specified number of days after dropping. Only valid values are from 0-35. If set to 0, soft-delete retention is disabled.
305305
306306
```yaml
307307
Type: System.Nullable`1[System.Int32]

0 commit comments

Comments
 (0)