Skip to content

Commit b151f74

Browse files
author
Samuel Anudeep
committed
Non cmdlet layer changes
1 parent 59da16f commit b151f74

14 files changed

+120
-231
lines changed

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/Commands.RecoveryServices.Test.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
<SpecificVersion>False</SpecificVersion>
5050
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.4.2.0-preview\lib\net45\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
5151
</Reference>
52-
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
53-
<SpecificVersion>False</SpecificVersion>
54-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
55-
</Reference>
5652
<Reference Include="Microsoft.Azure.Test.Framework">
5753
<SpecificVersion>False</SpecificVersion>
5854
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.6179.26854-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
@@ -72,8 +68,8 @@
7268
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
7369
</Reference>
7470
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
75-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.5\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
76-
<Private>True</Private>
71+
<SpecificVersion>False</SpecificVersion>
72+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.6\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
7773
</Reference>
7874
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7975
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.2.2.9-preview\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/ScenarioTests/TestsBase.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,18 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System;
16+
using System.Collections.Generic;
1517
using System.IO;
16-
using System.Net;
17-
using System.Net.Security;
18-
using System.Runtime.Serialization;
19-
using System.Xml;
20-
using Microsoft.Azure.Test.HttpRecorder;
21-
using Microsoft.Azure.Portal.RecoveryServices.Models.Common;
22-
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using System.Linq;
19+
using Microsoft.Azure.Commands.Common.Authentication;
20+
using Microsoft.Azure.Management.Internal.Resources;
2321
using Microsoft.Azure.Management.RecoveryServices;
2422
using Microsoft.Azure.Test;
25-
using Microsoft.Azure.Commands.Common.Authentication;
26-
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
27-
using Microsoft.Azure.Commands.Common.Authentication.Models;
28-
using System;
29-
using System.Collections.Generic;
30-
using System.Net.Http;
31-
using System.Reflection;
32-
using Microsoft.Azure.Test.Authentication;
33-
using Microsoft.Rest;
23+
using Microsoft.Azure.Test.HttpRecorder;
3424
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
35-
using System.Linq;
36-
using Microsoft.Azure.Management.Resources;
25+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
26+
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
3727

3828
namespace Microsoft.Azure.Commands.RecoveryServices.Test.ScenarioTests
3929
{
@@ -62,17 +52,17 @@ public TestController()
6252
protected void SetupManagementClients(MockContext context)
6353
{
6454
RsClient = GetRsClient(context);
65-
RmClient = GetRmClient();
55+
RmClient = GetRmClient(context);
6656

6757
helper.SetupManagementClients(
6858
RsClient,
6959
RmClient);
7060
}
7161

72-
private ResourceManagementClient GetRmClient()
62+
private ResourceManagementClient GetRmClient(RestTestFramework.MockContext context)
7363
{
74-
return Azure.Test.TestBase.GetServiceClient<ResourceManagementClient>(
75-
this.csmTestFactory);
64+
return context.GetServiceClient<ResourceManagementClient>(
65+
RestTestFramework.TestEnvironmentFactory.GetTestEnvironment());
7666
}
7767

7868
public void RunPsTest(params string[] scripts)

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
66
<package id="Microsoft.Azure.Management.RecoveryServices" version="4.2.0-preview" targetFramework="net45" />
7-
<package id="Microsoft.Azure.Management.Resources" version="2.18.11-preview" targetFramework="net45" />
87
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
98
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
109
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1110
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
1211
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
1312
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.3" targetFramework="net45" />
1413
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
15-
<package id="Microsoft.Rest.ClientRuntime" version="2.3.5" targetFramework="net45" />
14+
<package id="Microsoft.Rest.ClientRuntime" version="2.3.6" targetFramework="net45" />
1615
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.9-preview" targetFramework="net45" />
1716
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
1817
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Commands.RecoveryServices.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
<SpecificVersion>False</SpecificVersion>
5252
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.4.2.0-preview\lib\net45\Microsoft.Azure.Management.RecoveryServices.dll</HintPath>
5353
</Reference>
54-
<Reference Include="Microsoft.Azure.ResourceManager">
55-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.1-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
56-
</Reference>
5754
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.28.3.860, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5855
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
5956
<Private>True</Private>
@@ -116,12 +113,10 @@
116113
<Reference Include="System.Xml" />
117114
</ItemGroup>
118115
<ItemGroup>
119-
<Compile Include="Common\ClientRequestIdHandler.cs" />
120116
<Compile Include="Common\PSRecoveryServicesClient.cs" />
121117
<Compile Include="Common\PSRecoveryServicesVaultClient.cs" />
122118
<Compile Include="Common\PSRecoveryServicesVaultExtendedInfoClient.cs" />
123119
<Compile Include="Common\RecoveryServicesCmdletBase.cs" />
124-
<Compile Include="Common\RpNamespaceHandler.cs" />
125120
<Compile Include="Models\PSContracts.cs" />
126121
<Compile Include="Models\PSObjects.cs" />
127122
<Compile Include="Models\PSParameterSets.cs" />
@@ -154,7 +149,6 @@
154149
<Link>AzureRM.RecoveryServices.psd1</Link>
155150
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
156151
</None>
157-
<None Include="ChangeLog.md" />
158152
<None Include="MSSharedLibKey.snk" />
159153
<None Include="packages.config">
160154
<SubType>Designer</SubType>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Common/ClientRequestIdHandler.cs

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Common/PSRecoveryServicesClient.cs

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using System.Collections.Generic;
17+
using System.Configuration;
1618
using System.Diagnostics.CodeAnalysis;
19+
using System.Net.Security;
1720
using Microsoft.Azure.Commands.Common.Authentication;
1821
using Microsoft.Azure.Commands.Common.Authentication.Models;
22+
using Microsoft.Azure.Management.Internal.Resources;
1923
using Microsoft.Azure.Management.RecoveryServices;
20-
using Microsoft.Azure.Management.RecoveryServices.Models;
2124
using Microsoft.Azure.Portal.RecoveryServices.Models.Common;
22-
using System.Configuration;
23-
using System.Net.Security;
24-
using Microsoft.Azure.Management.Resources;
2525

2626
namespace Microsoft.Azure.Commands.RecoveryServices
2727
{
@@ -56,14 +56,6 @@ public ResourceManagementClient RmClient
5656
}
5757
}
5858

59-
public string RpNamespace
60-
{
61-
get
62-
{
63-
return rpNamespace;
64-
}
65-
}
66-
6759
/// Azure profile
6860
/// </summary>
6961
public IAzureProfile Profile { get; set; }
@@ -92,8 +84,6 @@ public string RpNamespace
9284

9385
private ResourceManagementClient resourceManagementClient;
9486

95-
private string rpNamespace;
96-
9787
/// <summary>
9888
/// Initializes a new instance of the <see cref="PSRecoveryServicesClient" /> class with
9989
/// required current subscription.
@@ -104,39 +94,24 @@ public PSRecoveryServicesClient(IAzureProfile azureProfile, AzureContext default
10494
System.Configuration.Configuration recoveryServicesConfig = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExecutingAssembly().Location);
10595

10696
System.Configuration.AppSettingsSection appSettings = (System.Configuration.AppSettingsSection)recoveryServicesConfig.GetSection("appSettings");
107-
108-
var resourceProviderNamespace = string.Empty;
109-
string resourceType = string.Empty;
11097

98+
string resourceType = string.Empty;
99+
111100
// Get Resource provider namespace from config if needed to communicate with internal deployments
112101
if (string.IsNullOrEmpty(arsVaultCreds.ResourceNamespace))
113102
{
114-
if (appSettings.Settings.Count == 0)
115-
{
116-
resourceProviderNamespace = ProductionRpNamespace;
117-
}
118-
else
119-
{
120-
resourceProviderNamespace =
121-
null == appSettings.Settings["ProviderNamespace"]
122-
? ProductionRpNamespace
123-
: appSettings.Settings["ProviderNamespace"].Value;
124-
}
125-
126103
Utilities.UpdateCurrentVaultContext(new ASRVaultCreds()
127104
{
128-
ResourceNamespace = resourceProviderNamespace,
105+
ResourceNamespace = ProductionRpNamespace,
129106
ARMResourceType = resourceType
130107
});
131108
}
132109

133-
rpNamespace = string.Copy(resourceProviderNamespace);
134-
135-
this.recoveryServicesClient =
110+
this.recoveryServicesClient =
136111
AzureSession.ClientFactory.CreateArmClient<RecoveryServicesClient>(
137112
defaultContext, AzureEnvironment.Endpoint.ResourceManager);
138113

139-
resourceManagementClient = AzureSession.ClientFactory.CreateClient<ResourceManagementClient>(defaultContext, AzureEnvironment.Endpoint.ResourceManager);
114+
resourceManagementClient = AzureSession.ClientFactory.CreateArmClient<ResourceManagementClient>(defaultContext, AzureEnvironment.Endpoint.ResourceManager);
140115
}
141116

142117
private static bool IgnoreCertificateErrorHandler
@@ -168,22 +143,19 @@ public static string GetSubscriptionId(string resourceId)
168143
return resourceId.Substring(startIndex, endIndex - startIndex);
169144
}
170145

171-
///// <summary>
172-
///// Gets request headers.
173-
///// </summary>
174-
///// <param name="shouldSignRequest">specifies whether to sign the request or not</param>
175-
///// <returns>Custom request headers</returns>
176-
//public CustomRequestHeaders GetRequestHeaders()
177-
//{
178-
// this.ClientRequestId = Guid.NewGuid().ToString() + "-" + DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ssZ") + "-P";
179-
180-
// return new CustomRequestHeaders()
181-
// {
182-
// // ClientRequestId is a unique ID for every request.
183-
// // It is useful when diagnosing failures in API calls.
184-
// ClientRequestId = this.ClientRequestId,
185-
// AgentAuthenticationHeader = ""
186-
// };
187-
//}
146+
/// <summary>
147+
/// Gets request headers.
148+
/// </summary>
149+
/// <param name="shouldSignRequest">specifies whether to sign the request or not</param>
150+
/// <returns>Custom request headers</returns>
151+
public Dictionary<string, List<string>> GetRequestHeaders()
152+
{
153+
this.ClientRequestId = Guid.NewGuid().ToString() + "-" + DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ssZ") + "-P";
154+
155+
var dict = new Dictionary<string, List<string>>();
156+
dict["x-ms-client-request-id"] = new List<string>() { ClientRequestId };
157+
158+
return dict;
159+
}
188160
}
189161
}

0 commit comments

Comments
 (0)