Skip to content

Commit 954061d

Browse files
author
John Paul Kee
committed
Updating cmdlets based on feedback. use constants, remove unnecessary check
1 parent d4eaaf4 commit 954061d

File tree

7 files changed

+41
-27
lines changed

7 files changed

+41
-27
lines changed

src/ResourceManager/Sql/Commands.Sql/Database Backup/Cmdlet/RestoreAzureRMSqlDatabase.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public class RestoreAzureRmSqlDatabase
127127
HelpMessage = "The deletion DateTime of the deleted database to restore.")]
128128
public DateTime DeletionDate { get; set; }
129129

130-
/// <summary>
130+
/// <summary>
131131
/// The resource ID of the database to restore (deleted DB, geo backup DB, live DB, long term retention backup, etc.)
132132
/// </summary>
133133
[Alias("Id")]
@@ -136,9 +136,9 @@ public class RestoreAzureRmSqlDatabase
136136
HelpMessage = "The resource ID of the database to restore.")]
137137
public string ResourceId { get; set; }
138138

139-
/// <summary>
140-
/// Gets or sets the name of the database server to use.
141-
/// </summary>
139+
/// <summary>
140+
/// Gets or sets the name of the database server to use.
141+
/// </summary>
142142
[Parameter(Mandatory = true,
143143
ValueFromPipelineByPropertyName = true,
144144
HelpMessage = "The name of the Azure SQL Server to restore the database to.")]
@@ -268,7 +268,9 @@ public class RestoreAzureRmSqlDatabase
268268
/// Gets or sets the license type for the Azure Sql database
269269
/// </summary>
270270
[Parameter(Mandatory = false, HelpMessage = "The license type for the Azure Sql database")]
271-
[PSArgumentCompleter("LicenseIncluded", "BasePrice")]
271+
[PSArgumentCompleter(
272+
Management.Sql.Models.DatabaseLicenseType.LicenseIncluded,
273+
Management.Sql.Models.DatabaseLicenseType.BasePrice)]
272274
public string LicenseType { get; set; }
273275

274276
/// <summary>
@@ -333,7 +335,7 @@ protected override AzureSqlDatabaseModel GetEntity()
333335
RequestedServiceObjectiveName = ServiceObjectiveName,
334336
Edition = Edition,
335337
CreateMode = createMode,
336-
LicenseType = LicenseType ?? null
338+
LicenseType = LicenseType
337339
};
338340

339341
if (ParameterSetName == FromPointInTimeBackupWithVcoreSetName || ParameterSetName == FromDeletedDatabaseBackupWithVcoreSetName ||

src/ResourceManager/Sql/Commands.Sql/Database/Cmdlet/NewAzureSqlDatabase.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ public class NewAzureSqlDatabase : AzureSqlDatabaseCmdletBase<AzureSqlDatabaseCr
153153
/// Gets or sets the license type for the Azure Sql database
154154
/// </summary>
155155
[Parameter(Mandatory = false, HelpMessage = "The license type for the Azure Sql database")]
156-
[PSArgumentCompleter("LicenseIncluded", "BasePrice")]
156+
[PSArgumentCompleter(
157+
Management.Sql.Models.DatabaseLicenseType.LicenseIncluded,
158+
Management.Sql.Models.DatabaseLicenseType.BasePrice)]
157159
public string LicenseType { get; set; }
158160

159161
/// <summary>
@@ -215,7 +217,7 @@ protected override AzureSqlDatabaseCreateOrUpdateModel ApplyUserInputToModel(Azu
215217
ElasticPoolName = ElasticPoolName,
216218
ReadScale = ReadScale,
217219
ZoneRedundant = MyInvocation.BoundParameters.ContainsKey("ZoneRedundant") ? (bool?)ZoneRedundant.ToBool() : null,
218-
LicenseType = LicenseType ?? null // note: default license type is LicenseIncluded
220+
LicenseType = LicenseType // note: default license type is LicenseIncluded
219221
};
220222

221223
if(ParameterSetName == DtuDatabaseParameterSet)
@@ -229,7 +231,7 @@ protected override AzureSqlDatabaseCreateOrUpdateModel ApplyUserInputToModel(Azu
229231
newDbModel.Edition = Edition;
230232
newDbModel.Capacity = VCore;
231233
newDbModel.Family = ComputeGeneration;
232-
}
234+
}
233235

234236
dbCreateUpdateModel.Database = newDbModel;
235237
dbCreateUpdateModel.SampleName = SampleName;
@@ -246,7 +248,7 @@ protected override AzureSqlDatabaseCreateOrUpdateModel PersistChanges(AzureSqlDa
246248
{
247249
// Use AutoRest Sdk
248250
AzureSqlDatabaseModel upsertedDatabase = ModelAdapter.UpsertDatabaseWithNewSdk(this.ResourceGroupName, this.ServerName, entity);
249-
251+
250252
return new AzureSqlDatabaseCreateOrUpdateModel
251253
{
252254
Database = upsertedDatabase

src/ResourceManager/Sql/Commands.Sql/Database/Cmdlet/SetAzureSqlDatabase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public class SetAzureSqlDatabase : AzureSqlDatabaseCmdletBase<IEnumerable<AzureS
155155
/// <summary>
156156
/// Gets or sets the ComputeGeneration for the Azure Sql database.
157157
/// </summary>
158-
[Parameter(ParameterSetName = VcoreDatabaseParameterSet, Mandatory = false,
158+
[Parameter(ParameterSetName = VcoreDatabaseParameterSet, Mandatory = false,
159159
HelpMessage = "The Compute generation for the Azure Sql database.")]
160160
[Alias("Family")]
161161
[PSArgumentCompleter("Gen4", "Gen5")]
@@ -170,7 +170,9 @@ public class SetAzureSqlDatabase : AzureSqlDatabaseCmdletBase<IEnumerable<AzureS
170170
[Parameter(Mandatory = false,
171171
HelpMessage = "The tags to associate with the Azure Sql Database",
172172
ParameterSetName = VcoreDatabaseParameterSet)]
173-
[PSArgumentCompleter("LicenseIncluded", "BasePrice")]
173+
[PSArgumentCompleter(
174+
Management.Sql.Models.DatabaseLicenseType.LicenseIncluded,
175+
Management.Sql.Models.DatabaseLicenseType.BasePrice)]
174176
public string LicenseType { get; set; }
175177

176178
/// <summary>

src/ResourceManager/Sql/Commands.Sql/Elastic Pools/Cmdlet/NewAzureSqlElasticPool.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ public class NewAzureSqlElasticPool : AzureSqlElasticPoolCmdletBase
145145
/// Gets or sets the license type for the Azure Sql database
146146
/// </summary>
147147
[Parameter(Mandatory = false, HelpMessage = "The license type for the Azure Sql database")]
148-
[PSArgumentCompleter("LicenseIncluded", "BasePrice")]
148+
[PSArgumentCompleter(
149+
Management.Sql.Models.DatabaseLicenseType.LicenseIncluded,
150+
Management.Sql.Models.DatabaseLicenseType.BasePrice)]
149151
public string LicenseType { get; set; }
150152

151153
/// <summary>
@@ -209,10 +211,10 @@ protected override IEnumerable<AzureSqlElasticPoolModel> ApplyUserInputToModel(I
209211
Location = location,
210212
ZoneRedundant = MyInvocation.BoundParameters.ContainsKey("ZoneRedundant") ? (bool?)ZoneRedundant.ToBool() : null,
211213
MaxSizeBytes = MyInvocation.BoundParameters.ContainsKey("StorageMB") ? (long?)(StorageMB * Megabytes) : null,
212-
LicenseType = LicenseType ?? null
214+
LicenseType = LicenseType
213215
};
214216

215-
217+
216218
if (ParameterSetName == DtuPoolParameterSet)
217219
{
218220
string edition = string.IsNullOrWhiteSpace(Edition) ? null : Edition;
@@ -225,7 +227,7 @@ protected override IEnumerable<AzureSqlElasticPoolModel> ApplyUserInputToModel(I
225227
}
226228

227229
newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") ? (double?)DatabaseDtuMin : null;
228-
newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax") ? (double?)DatabaseDtuMax : null;
230+
newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax") ? (double?)DatabaseDtuMax : null;
229231
}
230232
else
231233
{

src/ResourceManager/Sql/Commands.Sql/Elastic Pools/Cmdlet/SetAzureSqlElasticPool.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ public class SetAzureSqlElasticPool : AzureSqlElasticPoolCmdletBase
146146
/// Gets or sets the license type for the Azure Sql database
147147
/// </summary>
148148
[Parameter(Mandatory = false, HelpMessage = "The license type for the Azure Sql database")]
149-
[PSArgumentCompleter("LicenseIncluded", "BasePrice")]
149+
[PSArgumentCompleter(
150+
Management.Sql.Models.DatabaseLicenseType.LicenseIncluded,
151+
Management.Sql.Models.DatabaseLicenseType.BasePrice)]
150152
public string LicenseType { get; set; }
151153

152154
/// <summary>
@@ -196,10 +198,10 @@ protected override IEnumerable<AzureSqlElasticPoolModel> ApplyUserInputToModel(I
196198
};
197199

198200
var elasticPool = ModelAdapter.GetElasticPool(ResourceGroupName, ServerName, ElasticPoolName);
199-
201+
200202
Management.Sql.Models.Sku poolCurrentSku = new Management.Sql.Models.Sku()
201203
{
202-
Name = elasticPool.SkuName,
204+
Name = elasticPool.SkuName,
203205
Tier = elasticPool.Edition,
204206
Family = elasticPool.Family,
205207
Capacity = elasticPool.Capacity
@@ -220,12 +222,12 @@ protected override IEnumerable<AzureSqlElasticPoolModel> ApplyUserInputToModel(I
220222
newModel.Edition = edition;
221223
newModel.Capacity = MyInvocation.BoundParameters.ContainsKey("Dtu") ? (int?)Dtu : null;
222224
}
223-
225+
224226
if(MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") || MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax"))
225227
{
226228
newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMin") ? (double?)DatabaseDtuMin : null;
227229
newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseDtuMax") ? (double?)DatabaseDtuMax : null;
228-
}
230+
}
229231
}
230232
else
231233
{
@@ -237,13 +239,13 @@ protected override IEnumerable<AzureSqlElasticPoolModel> ApplyUserInputToModel(I
237239
newModel.Edition = skuTier;
238240
newModel.Capacity = MyInvocation.BoundParameters.ContainsKey("VCore") ? VCore : poolCurrentSku.Capacity;
239241
newModel.Family = string.IsNullOrWhiteSpace(ComputeGeneration) ? poolCurrentSku.Family : ComputeGeneration;
240-
}
242+
}
241243

242244
if (MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMin") || MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMax"))
243245
{
244246
newModel.DatabaseCapacityMin = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMin") ? (double?)DatabaseVCoreMin : null;
245247
newModel.DatabaseCapacityMax = MyInvocation.BoundParameters.ContainsKey("DatabaseVCoreMax") ? (double?)DatabaseVCoreMax : null;
246-
}
248+
}
247249
}
248250

249251
newEntity.Add(newModel);

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/NewAzureSqlDatabaseCopy.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public class NewAzureSqlDatabaseCopy : AzureSqlDatabaseCopyCmdletBase
122122
/// Gets or sets the license type for the Azure Sql database
123123
/// </summary>
124124
[Parameter(Mandatory = false, HelpMessage = "The license type for the Azure Sql database")]
125-
[PSArgumentCompleter("LicenseIncluded", "BasePrice")]
125+
[PSArgumentCompleter(
126+
Management.Sql.Models.DatabaseLicenseType.LicenseIncluded,
127+
Management.Sql.Models.DatabaseLicenseType.BasePrice)]
126128
public string LicenseType { get; set; }
127129

128130
/// <summary>
@@ -193,7 +195,7 @@ protected override IEnumerable<AzureSqlDatabaseCopyModel> ApplyUserInputToModel(
193195
ServiceObjectiveName = ServiceObjectiveName,
194196
ElasticPoolName = ElasticPoolName,
195197
Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
196-
LicenseType = LicenseType ?? null // note: default license type is LicenseIncluded
198+
LicenseType = LicenseType // note: default license type is LicenseIncluded
197199
};
198200

199201
if(ParameterSetName == DtuDatabaseParameterSet)

src/ResourceManager/Sql/Commands.Sql/Replication/Cmdlet/NewAzureSqlDatabaseSecondary.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public class NewAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
122122
/// Gets or sets the license type for the Azure Sql database
123123
/// </summary>
124124
[Parameter(Mandatory = false, HelpMessage = "The license type for the Azure Sql database")]
125-
[PSArgumentCompleter("LicenseIncluded", "BasePrice")]
125+
[PSArgumentCompleter(
126+
Management.Sql.Models.DatabaseLicenseType.LicenseIncluded,
127+
Management.Sql.Models.DatabaseLicenseType.BasePrice)]
126128
public string LicenseType { get; set; }
127129

128130
/// <summary>
@@ -184,7 +186,7 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
184186
SecondaryElasticPoolName = this.SecondaryElasticPoolName,
185187
AllowConnections = this.AllowConnections,
186188
Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
187-
LicenseType = LicenseType ?? null
189+
LicenseType = LicenseType
188190
};
189191

190192
if(ParameterSetName == DtuDatabaseParameterSet)

0 commit comments

Comments
 (0)