Skip to content

Commit 8c5d5f8

Browse files
merge from no-sdk
2 parents 572b642 + 1f2e6b7 commit 8c5d5f8

22 files changed

+746
-91
lines changed

src/ResourceManager/Common/Commands.Common.Strategies/Commands.Common.Strategies.csproj

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@
3333
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
3434
</PropertyGroup>
3535
<ItemGroup>
36-
<Reference Include="Microsoft.Azure.Management.Compute, Version=16.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
37-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.16.3.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
38-
<Private>True</Private>
39-
</Reference>
40-
<Reference Include="Microsoft.Azure.Management.Network, Version=15.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
41-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.15.1.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
42-
<Private>True</Private>
43-
</Reference>
44-
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
45-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.6.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
46-
<Private>True</Private>
47-
</Reference>
4836
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
4937
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
5038
<Private>True</Private>
@@ -67,20 +55,14 @@
6755
<Reference Include="System.Xml" />
6856
</ItemGroup>
6957
<ItemGroup>
70-
<Compile Include="Compute\Image.cs" />
71-
<Compile Include="Compute\Images.cs" />
72-
<Compile Include="Compute\VirtualMachineScaleSetStrategy.cs" />
7358
<Compile Include="IReportProgress.cs" />
7459
<Compile Include="IResourceConfig.cs" />
7560
<Compile Include="IResourceConfigVisitor.cs" />
7661
<Compile Include="IResourceStrategy.cs" />
7762
<Compile Include="IShouldProcess.cs" />
78-
<Compile Include="Network\LoadBalancerStrategy.cs" />
7963
<Compile Include="ProgressMap.cs" />
8064
<Compile Include="TimeSlot.cs" />
8165
<Compile Include="StateOperationContext.cs" />
82-
<Compile Include="Compute\ComputeStrategy.cs" />
83-
<Compile Include="Compute\VirtualMachineStrategy.cs" />
8466
<Compile Include="SyncTaskScheduler.cs" />
8567
<Compile Include="TimeSlotExtensions.cs" />
8668
<Compile Include="UpdateStateExtensions.cs" />
@@ -100,13 +82,6 @@
10082
<Compile Include="TargetDependencies.cs" />
10183
<Compile Include="NestedResourceConfig.cs" />
10284
<Compile Include="NestedResourceStrategy.cs" />
103-
<Compile Include="Network\NetworkInterfaceStrategy.cs" />
104-
<Compile Include="Network\NetworkSecurityGroupPolicy.cs" />
105-
<Compile Include="Network\NetworkStrategy.cs" />
106-
<Compile Include="Network\PublicIPAddressStrategy.cs" />
107-
<Compile Include="Network\SubnetStrategy.cs" />
108-
<Compile Include="Network\VirtualNetworkStrategy.cs" />
109-
<Compile Include="ResourceManager\ResourceGroupStrategy.cs" />
11085
<Compile Include="TargetState.cs" />
11186
<Compile Include="Properties\AssemblyInfo.cs" />
11287
<Compile Include="ResourceConfig.cs" />

src/ResourceManager/Common/Commands.Common.Strategies/LocationExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.ResourceManager.Models;
1615
using System.Linq;
1716

1817
namespace Microsoft.Azure.Commands.Common.Strategies
@@ -39,7 +38,7 @@ static DependencyLocation GetDependencyLocation<TModel>(
3938
return info != null
4039
? new DependencyLocation(
4140
config.Strategy.GetLocation(info),
42-
typeof(TModel) != typeof(ResourceGroup))
41+
config.Strategy.CompulsoryLocation)
4342
: config
4443
.GetResourceDependencies()
4544
.Select(state.GetDependencyLocationDispatch)

src/ResourceManager/Common/Commands.Common.Strategies/ResourceConfigExtensions.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.ResourceManager.Models;
1615
using Microsoft.Rest.Azure;
1716
using System;
1817
using System.Collections.Generic;
@@ -39,19 +38,6 @@ public static ResourceConfig<TModel> CreateConfig<TModel>(
3938
createModel ?? (_ => new TModel()),
4039
dependencies.EmptyIfNull());
4140

42-
public static ResourceConfig<TModel> CreateConfig<TModel>(
43-
this ResourceStrategy<TModel> strategy,
44-
ResourceConfig<ResourceGroup> resourceGroup,
45-
string name,
46-
Func<string, TModel> createModel = null,
47-
IEnumerable<IEntityConfig> dependencies = null)
48-
where TModel : class, new()
49-
=> strategy.CreateConfig(
50-
resourceGroup.Name,
51-
name,
52-
createModel,
53-
dependencies.EmptyIfNull().Where(d => d != null).Concat(new[] { resourceGroup }));
54-
5541
public static async Task<TModel> GetAsync<TModel>(
5642
this ResourceConfig<TModel> config,
5743
IClient client,

src/ResourceManager/Common/Commands.Common.Strategies/ResourceStrategy.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ public Func<IClient, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> CreateOrUp
3737

3838
public Func<TModel, int> CreateTime { get; }
3939

40+
public bool CompulsoryLocation { get; }
41+
4042
public ResourceStrategy(
4143
string type,
4244
Func<string, IEnumerable<string>> getId,
4345
Func<IClient, GetAsyncParams, Task<TModel>> getAsync,
4446
Func<IClient, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
4547
Func<TModel, string> getLocation,
4648
Action<TModel, string> setLocation,
47-
Func<TModel, int> createTime)
49+
Func<TModel, int> createTime,
50+
bool compulsoryLocation)
4851
{
4952
Type = type;
5053
GetId = getId;
@@ -53,6 +56,7 @@ public ResourceStrategy(
5356
GetLocation = getLocation;
5457
SetLocation = setLocation;
5558
CreateTime = createTime;
59+
CompulsoryLocation = compulsoryLocation;
5660
}
5761
}
5862

@@ -66,7 +70,8 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
6670
Func<TOperation, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
6771
Func<TModel, string> getLocation,
6872
Action<TModel, string> setLocation,
69-
Func<TModel, int> createTime)
73+
Func<TModel, int> createTime,
74+
bool compulsoryLocation)
7075
where TClient : ServiceClient<TClient>
7176
{
7277
Func<IClient, TOperation> toOperations = client => getOperations(client.GetClient<TClient>());
@@ -77,7 +82,8 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
7782
(client, p) => createOrUpdateAsync(toOperations(client), p),
7883
getLocation,
7984
setLocation,
80-
createTime);
85+
createTime,
86+
compulsoryLocation);
8187
}
8288

8389
public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
@@ -88,7 +94,8 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
8894
Func<TOperation, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
8995
Func<TModel, string> getLocation,
9096
Action<TModel, string> setLocation,
91-
Func<TModel, int> createTime)
97+
Func<TModel, int> createTime,
98+
bool compulsoryLocation)
9299
where TClient : ServiceClient<TClient>
93100
=> Create(
94101
type,
@@ -98,6 +105,7 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
98105
createOrUpdateAsync,
99106
getLocation,
100107
setLocation,
101-
createTime);
108+
createTime,
109+
compulsoryLocation);
102110
}
103111
}

src/ResourceManager/Common/Commands.Common.Strategies/UpdateStateExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
1715
using System.Linq;
1816
using System.Threading;
1917
using System.Threading.Tasks;

src/ResourceManager/Common/Commands.Common.Strategies/packages.config

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Azure.Management.Compute" version="16.3.0" targetFramework="net452" />
4-
<package id="Microsoft.Azure.Management.Network" version="15.1.0-preview" targetFramework="net452" />
5-
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
63
<package id="Microsoft.Rest.ClientRuntime" version="2.3.10" targetFramework="net452" />
74
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.10" targetFramework="net452" />
85
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net452" />

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,20 @@
292292
<Compile Include="StorageServices\StorageCredentialsFactory.cs" />
293293
<Compile Include="Strategies\AsyncCmdletExtensions.cs" />
294294
<Compile Include="Strategies\Client.cs" />
295+
<Compile Include="Strategies\Compute\ComputeStrategy.cs" />
296+
<Compile Include="Strategies\Compute\Image.cs" />
297+
<Compile Include="Strategies\Compute\Images.cs" />
298+
<Compile Include="Strategies\Compute\VirtualMachineStrategy.cs" />
295299
<Compile Include="Strategies\IAsyncCmdlet.cs" />
300+
<Compile Include="Strategies\Network\NetworkInterfaceStrategy.cs" />
301+
<Compile Include="Strategies\Network\NetworkSecurityGroupPolicy.cs" />
302+
<Compile Include="Strategies\Network\NetworkStrategy.cs" />
303+
<Compile Include="Strategies\Network\PublicIPAddressStrategy.cs" />
304+
<Compile Include="Strategies\Network\SubnetStrategy.cs" />
305+
<Compile Include="Strategies\Network\VirtualNetworkStrategy.cs" />
296306
<Compile Include="Strategies\ProgressReport.cs" />
307+
<Compile Include="Strategies\ResourceManager\ResourceConfigExtensions.cs" />
308+
<Compile Include="Strategies\ResourceManager\ResourceGroupStrategy.cs" />
297309
<Compile Include="Strategies\ShouldProcess.cs" />
298310
<Compile Include="Usage\GetAzureVMUsageCommand.cs" />
299311
<Compile Include="Usage\VirtualMachineUsageBaseCmdlet.cs" />
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Management.Compute;
16+
using Microsoft.Azure.Management.Compute.Models;
17+
using System;
18+
using System.Threading.Tasks;
19+
20+
namespace Microsoft.Azure.Commands.Common.Strategies.Compute
21+
{
22+
static class ComputePolicy
23+
{
24+
public static ResourceStrategy<TModel> Create<TModel, TOperations>(
25+
string type,
26+
string header,
27+
Func<ComputeManagementClient, TOperations> getOperations,
28+
Func<TOperations, GetAsyncParams, Task<TModel>> getAsync,
29+
Func<TOperations, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
30+
Func<TModel, int> createTime)
31+
where TModel : Resource
32+
=> ResourceStrategy.Create(
33+
type,
34+
new[] { "Microsoft.Compute", header },
35+
getOperations,
36+
getAsync,
37+
createOrUpdateAsync,
38+
config => config.Location,
39+
(config, location) => config.Location = location,
40+
createTime,
41+
true);
42+
}
43+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Common.Strategies.Compute
16+
{
17+
sealed class Image
18+
{
19+
public string publisher;
20+
21+
public string offer;
22+
23+
public string sku;
24+
25+
public string version;
26+
}
27+
}

0 commit comments

Comments
 (0)