Skip to content

Commit

Permalink
merge from no-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Dec 5, 2017
2 parents 572b642 + 1f2e6b7 commit 8c5d5f8
Show file tree
Hide file tree
Showing 22 changed files with 746 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.Management.Compute, Version=16.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.16.3.0\lib\net452\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=15.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.15.1.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.1.6.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
Expand All @@ -67,20 +55,14 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Compute\Image.cs" />
<Compile Include="Compute\Images.cs" />
<Compile Include="Compute\VirtualMachineScaleSetStrategy.cs" />
<Compile Include="IReportProgress.cs" />
<Compile Include="IResourceConfig.cs" />
<Compile Include="IResourceConfigVisitor.cs" />
<Compile Include="IResourceStrategy.cs" />
<Compile Include="IShouldProcess.cs" />
<Compile Include="Network\LoadBalancerStrategy.cs" />
<Compile Include="ProgressMap.cs" />
<Compile Include="TimeSlot.cs" />
<Compile Include="StateOperationContext.cs" />
<Compile Include="Compute\ComputeStrategy.cs" />
<Compile Include="Compute\VirtualMachineStrategy.cs" />
<Compile Include="SyncTaskScheduler.cs" />
<Compile Include="TimeSlotExtensions.cs" />
<Compile Include="UpdateStateExtensions.cs" />
Expand All @@ -100,13 +82,6 @@
<Compile Include="TargetDependencies.cs" />
<Compile Include="NestedResourceConfig.cs" />
<Compile Include="NestedResourceStrategy.cs" />
<Compile Include="Network\NetworkInterfaceStrategy.cs" />
<Compile Include="Network\NetworkSecurityGroupPolicy.cs" />
<Compile Include="Network\NetworkStrategy.cs" />
<Compile Include="Network\PublicIPAddressStrategy.cs" />
<Compile Include="Network\SubnetStrategy.cs" />
<Compile Include="Network\VirtualNetworkStrategy.cs" />
<Compile Include="ResourceManager\ResourceGroupStrategy.cs" />
<Compile Include="TargetState.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceConfig.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.ResourceManager.Models;
using System.Linq;

namespace Microsoft.Azure.Commands.Common.Strategies
Expand All @@ -39,7 +38,7 @@ static DependencyLocation GetDependencyLocation<TModel>(
return info != null
? new DependencyLocation(
config.Strategy.GetLocation(info),
typeof(TModel) != typeof(ResourceGroup))
config.Strategy.CompulsoryLocation)
: config
.GetResourceDependencies()
.Select(state.GetDependencyLocationDispatch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

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

public static ResourceConfig<TModel> CreateConfig<TModel>(
this ResourceStrategy<TModel> strategy,
ResourceConfig<ResourceGroup> resourceGroup,
string name,
Func<string, TModel> createModel = null,
IEnumerable<IEntityConfig> dependencies = null)
where TModel : class, new()
=> strategy.CreateConfig(
resourceGroup.Name,
name,
createModel,
dependencies.EmptyIfNull().Where(d => d != null).Concat(new[] { resourceGroup }));

public static async Task<TModel> GetAsync<TModel>(
this ResourceConfig<TModel> config,
IClient client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ public Func<IClient, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> CreateOrUp

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

public bool CompulsoryLocation { get; }

public ResourceStrategy(
string type,
Func<string, IEnumerable<string>> getId,
Func<IClient, GetAsyncParams, Task<TModel>> getAsync,
Func<IClient, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
Func<TModel, string> getLocation,
Action<TModel, string> setLocation,
Func<TModel, int> createTime)
Func<TModel, int> createTime,
bool compulsoryLocation)
{
Type = type;
GetId = getId;
Expand All @@ -53,6 +56,7 @@ public ResourceStrategy(
GetLocation = getLocation;
SetLocation = setLocation;
CreateTime = createTime;
CompulsoryLocation = compulsoryLocation;
}
}

Expand All @@ -66,7 +70,8 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
Func<TOperation, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
Func<TModel, string> getLocation,
Action<TModel, string> setLocation,
Func<TModel, int> createTime)
Func<TModel, int> createTime,
bool compulsoryLocation)
where TClient : ServiceClient<TClient>
{
Func<IClient, TOperation> toOperations = client => getOperations(client.GetClient<TClient>());
Expand All @@ -77,7 +82,8 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
(client, p) => createOrUpdateAsync(toOperations(client), p),
getLocation,
setLocation,
createTime);
createTime,
compulsoryLocation);
}

public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
Expand All @@ -88,7 +94,8 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
Func<TOperation, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
Func<TModel, string> getLocation,
Action<TModel, string> setLocation,
Func<TModel, int> createTime)
Func<TModel, int> createTime,
bool compulsoryLocation)
where TClient : ServiceClient<TClient>
=> Create(
type,
Expand All @@ -98,6 +105,7 @@ public static ResourceStrategy<TModel> Create<TModel, TClient, TOperation>(
createOrUpdateAsync,
getLocation,
setLocation,
createTime);
createTime,
compulsoryLocation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.Management.Compute" version="16.3.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Network" version="15.1.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.10" targetFramework="net452" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.10" targetFramework="net452" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,20 @@
<Compile Include="StorageServices\StorageCredentialsFactory.cs" />
<Compile Include="Strategies\AsyncCmdletExtensions.cs" />
<Compile Include="Strategies\Client.cs" />
<Compile Include="Strategies\Compute\ComputeStrategy.cs" />
<Compile Include="Strategies\Compute\Image.cs" />
<Compile Include="Strategies\Compute\Images.cs" />
<Compile Include="Strategies\Compute\VirtualMachineStrategy.cs" />
<Compile Include="Strategies\IAsyncCmdlet.cs" />
<Compile Include="Strategies\Network\NetworkInterfaceStrategy.cs" />
<Compile Include="Strategies\Network\NetworkSecurityGroupPolicy.cs" />
<Compile Include="Strategies\Network\NetworkStrategy.cs" />
<Compile Include="Strategies\Network\PublicIPAddressStrategy.cs" />
<Compile Include="Strategies\Network\SubnetStrategy.cs" />
<Compile Include="Strategies\Network\VirtualNetworkStrategy.cs" />
<Compile Include="Strategies\ProgressReport.cs" />
<Compile Include="Strategies\ResourceManager\ResourceConfigExtensions.cs" />
<Compile Include="Strategies\ResourceManager\ResourceGroupStrategy.cs" />
<Compile Include="Strategies\ShouldProcess.cs" />
<Compile Include="Usage\GetAzureVMUsageCommand.cs" />
<Compile Include="Usage\VirtualMachineUsageBaseCmdlet.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using System;
using System.Threading.Tasks;

namespace Microsoft.Azure.Commands.Common.Strategies.Compute
{
static class ComputePolicy
{
public static ResourceStrategy<TModel> Create<TModel, TOperations>(
string type,
string header,
Func<ComputeManagementClient, TOperations> getOperations,
Func<TOperations, GetAsyncParams, Task<TModel>> getAsync,
Func<TOperations, CreateOrUpdateAsyncParams<TModel>, Task<TModel>> createOrUpdateAsync,
Func<TModel, int> createTime)
where TModel : Resource
=> ResourceStrategy.Create(
type,
new[] { "Microsoft.Compute", header },
getOperations,
getAsync,
createOrUpdateAsync,
config => config.Location,
(config, location) => config.Location = location,
createTime,
true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Common.Strategies.Compute
{
sealed class Image
{
public string publisher;

public string offer;

public string sku;

public string version;
}
}
Loading

0 comments on commit 8c5d5f8

Please sign in to comment.