Skip to content

Commit 6e6e445

Browse files
committed
Fixed build errors
1 parent cfea476 commit 6e6e445

File tree

5 files changed

+18
-46
lines changed

5 files changed

+18
-46
lines changed

src/ResourceManager/Sql/Commands.Sql/JobAccount/Cmdlet/AzureSqlJobAccountCmdletBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.Common.Authentication.Models;
15+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1616
using Microsoft.Azure.Commands.Sql.Common;
1717
using Microsoft.Azure.Commands.Sql.JobAccount.Adapter;
1818
using Microsoft.Azure.Commands.Sql.JobAccount.Model;
@@ -27,7 +27,7 @@ public abstract class AzureSqlJobAccountCmdletBase : AzureSqlCmdletBase<IEnumera
2727
/// </summary>
2828
/// <param name="subscription">The subscription the cmdlets are operation under</param>
2929
/// <returns>The server adapter</returns>
30-
protected override AzureSqlJobAccountAdapter InitModelAdapter(AzureSubscription subscription)
30+
protected override AzureSqlJobAccountAdapter InitModelAdapter(IAzureSubscription subscription)
3131
{
3232
return new AzureSqlJobAccountAdapter(DefaultContext);
3333
}

src/ResourceManager/Sql/Commands.Sql/JobAccount/Cmdlet/GetAzureSqlJobAccount.cs

-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public class GetAzureSqlJobAccount : AzureSqlJobAccountCmdletBase
5050
/// <returns>A single server</returns>
5151
protected override IEnumerable<AzureSqlJobAccountModel> GetEntity()
5252
{
53-
ModelAdapter.ThrowIfJobAccountNotSupportedByServer(this.ResourceGroupName, this.ServerName, this.clientRequestId);
54-
5553
if (this.MyInvocation.BoundParameters.ContainsKey("JobAccountName"))
5654
{
5755
return new List<AzureSqlJobAccountModel>

src/ResourceManager/Sql/Commands.Sql/JobAccount/Cmdlet/RemoveAzureSqlJobAccount.cs

-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public class RemoveAzureSqlJobAccount : AzureSqlJobAccountCmdletBase
5858
/// <returns>The entity going to be deleted</returns>
5959
protected override IEnumerable<Model.AzureSqlJobAccountModel> GetEntity()
6060
{
61-
ModelAdapter.ThrowIfJobAccountNotSupportedByServer(this.ResourceGroupName, this.ServerName, this.clientRequestId);
62-
6361
return new List<Model.AzureSqlJobAccountModel>
6462
{
6563
ModelAdapter.GetJobAccount(this.ResourceGroupName, this.ServerName, this.JobAccountName, this.clientRequestId)

src/ResourceManager/Sql/Commands.Sql/JobAccount/Services/AzureSqlJobAccountAdapter.cs

+6-30
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.Common.Authentication.Models;
15+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1616
using Microsoft.Azure.Commands.Sql.JobAccount.Model;
1717
using Microsoft.Azure.Commands.Sql.JobAccount.Services;
18-
using Microsoft.Azure.Management.Sql.Models;
18+
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
1919
using System;
2020
using System.Collections.Generic;
2121
using System.Linq;
@@ -36,13 +36,13 @@ public class AzureSqlJobAccountAdapter
3636
/// <summary>
3737
/// Gets or sets the Azure profile
3838
/// </summary>
39-
public AzureContext Context { get; set; }
39+
public IAzureContext Context { get; set; }
4040

4141
/// <summary>
4242
/// Constructs a server adapter
4343
/// </summary>
4444
/// <param name="context">The current azure profile</param>
45-
public AzureSqlJobAccountAdapter(AzureContext context)
45+
public AzureSqlJobAccountAdapter(IAzureContext context)
4646
{
4747
Context = context;
4848
Communicator = new AzureSqlJobAccountCommunicator(Context);
@@ -122,13 +122,13 @@ public void RemoveJobAccount(string resourceGroupName, string serverName, string
122122
}
123123

124124
/// <summary>
125-
/// Convert a Management.Sql.Models.JobAccount to AzureSqlDatabaseServerModel
125+
/// Convert a Management.Sql.LegacySdk.Models.JobAccount to AzureSqlDatabaseServerModel
126126
/// </summary>
127127
/// <param name="resourceGroupName">The resource group the server is in</param>
128128
/// <param name="serverName">The server the job account is in</param>
129129
/// <param name="resp">The management client server response to convert</param>
130130
/// <returns>The converted job account model</returns>
131-
private static AzureSqlJobAccountModel CreateJobAccountModelFromResponse(string resourceGroupName, string serverName, Management.Sql.Models.JobAccount resp)
131+
private static AzureSqlJobAccountModel CreateJobAccountModelFromResponse(string resourceGroupName, string serverName, Management.Sql.LegacySdk.Models.JobAccount resp)
132132
{
133133
// Parse database name from database id
134134
// This is not expected to ever fail, but in case we have a bug here it's better to provide a more detailed error message
@@ -161,31 +161,7 @@ public string GetServerLocationAndThrowIfJobAccountNotSupportedByServer(string r
161161
{
162162
AzureSqlServerCommunicator serverCommunicator = new AzureSqlServerCommunicator(Context);
163163
var server = serverCommunicator.Get(resourceGroupName, serverName, clientId);
164-
165-
ThrowIfJobAccountNotSupportedByServer(server);
166-
167164
return server.Location;
168165
}
169-
170-
/// <summary>
171-
/// Throws an exception if the server does not support job accounts.
172-
/// </summary>
173-
public void ThrowIfJobAccountNotSupportedByServer(string resourceGroupName, string serverName, string clientId)
174-
{
175-
AzureSqlServerCommunicator serverCommunicator = new AzureSqlServerCommunicator(Context);
176-
Management.Sql.Models.Server server = serverCommunicator.Get(resourceGroupName, serverName, clientId);
177-
ThrowIfJobAccountNotSupportedByServer(server);
178-
}
179-
180-
/// <summary>
181-
/// Throws an exception if the server does not support job accounts.
182-
/// </summary>
183-
private static void ThrowIfJobAccountNotSupportedByServer(Management.Sql.Models.Server server)
184-
{
185-
if (server.Properties.Version != "12.0")
186-
{
187-
throw new InvalidOperationException(string.Format(Properties.Resources.ServerNotApplicableForJobAccount, server.Name));
188-
}
189-
}
190166
}
191167
}

src/ResourceManager/Sql/Commands.Sql/JobAccount/Services/AzureSqlJobAccountCommunicator.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Commands.Common.Authentication;
16-
using Microsoft.Azure.Commands.Common.Authentication.Models;
16+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
1717
using Microsoft.Azure.Commands.Sql.Common;
18-
using Microsoft.Azure.Management.Sql;
19-
using Microsoft.Azure.Management.Sql.Models;
18+
using Microsoft.Azure.Management.Sql.LegacySdk;
19+
using Microsoft.Azure.Management.Sql.LegacySdk.Models;
2020
using System;
2121
using System.Collections.Generic;
2222

@@ -35,18 +35,18 @@ public class AzureSqlJobAccountCommunicator
3535
/// <summary>
3636
/// Gets or set the Azure subscription
3737
/// </summary>
38-
internal static AzureSubscription Subscription { get; private set; }
38+
internal static IAzureSubscription Subscription { get; private set; }
3939

4040
/// <summary>
4141
/// Gets or sets the Azure profile
4242
/// </summary>
43-
public AzureContext Context { get; set; }
43+
public IAzureContext Context { get; set; }
4444

4545
/// <summary>
4646
/// Creates a communicator for Azure Sql Job Accounts
4747
/// </summary>
4848
/// <param name="context">The context.</param>
49-
public AzureSqlJobAccountCommunicator(AzureContext context)
49+
public AzureSqlJobAccountCommunicator(IAzureContext context)
5050
{
5151
Context = context;
5252
if (context.Subscription != Subscription)
@@ -59,23 +59,23 @@ public AzureSqlJobAccountCommunicator(AzureContext context)
5959
/// <summary>
6060
/// Gets the Azure Sql Database SErver
6161
/// </summary>
62-
public Management.Sql.Models.JobAccount Get(string resourceGroupName, string serverName, string jobAccountName, string clientRequestId)
62+
public Management.Sql.LegacySdk.Models.JobAccount Get(string resourceGroupName, string serverName, string jobAccountName, string clientRequestId)
6363
{
6464
return GetCurrentSqlClient(clientRequestId).JobAccounts.Get(resourceGroupName, serverName, jobAccountName).JobAccount;
6565
}
6666

6767
/// <summary>
6868
/// Lists Azure Sql Database Servers
6969
/// </summary>
70-
public IList<Management.Sql.Models.JobAccount> List(string resourceGroupName, string serverName, string clientRequestId)
70+
public IList<Management.Sql.LegacySdk.Models.JobAccount> List(string resourceGroupName, string serverName, string clientRequestId)
7171
{
7272
return GetCurrentSqlClient(clientRequestId).JobAccounts.List(resourceGroupName, serverName).JobAccounts;
7373
}
7474

7575
/// <summary>
7676
/// Creates or updates a Azure Sql Database SErver
7777
/// </summary>
78-
public Management.Sql.Models.JobAccount CreateOrUpdate(string resourceGroupName, string serverName, string jobAccountName, string clientRequestId, JobAccountCreateOrUpdateParameters parameters)
78+
public Management.Sql.LegacySdk.Models.JobAccount CreateOrUpdate(string resourceGroupName, string serverName, string jobAccountName, string clientRequestId, JobAccountCreateOrUpdateParameters parameters)
7979
{
8080
return GetCurrentSqlClient(clientRequestId).JobAccounts.CreateOrUpdate(resourceGroupName, serverName, jobAccountName, parameters).JobAccount;
8181
}
@@ -98,7 +98,7 @@ private SqlManagementClient GetCurrentSqlClient(String clientRequestId)
9898
// Get the SQL management client for the current subscription
9999
if (SqlClient == null)
100100
{
101-
SqlClient = AzureSession.ClientFactory.CreateClient<SqlManagementClient>(Context, AzureEnvironment.Endpoint.ResourceManager);
101+
SqlClient = AzureSession.Instance.ClientFactory.CreateClient<SqlManagementClient>(Context, AzureEnvironment.Endpoint.ResourceManager);
102102
}
103103
SqlClient.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
104104
SqlClient.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, clientRequestId);

0 commit comments

Comments
 (0)