Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PrivateLink] Update StorageSync SDK with 2020-03-01 #12249

Merged
merged 7 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ function Test-StorageSyncService
New-AzResourceGroup -Name $resourceGroupName -Location $resourceGroupLocation;

Write-Verbose "Resource: $storageSyncServiceName | Loc: $resourceLocation | Type : StorageSyncService"
New-AzStorageSyncService -ResourceGroupName $resourceGroupName -Location $resourceLocation -StorageSyncServiceName $storageSyncServiceName

New-AzStorageSyncService -ResourceGroupName $resourceGroupName -Location $resourceLocation -StorageSyncServiceName $storageSyncServiceName -IncomingTrafficPolicy "AllowVirtualNetworksOnly"

$storageSyncService = Get-AzStorageSyncService -ResourceGroupName $resourceGroupName -StorageSyncServiceName $storageSyncServiceName -Verbose
Write-Verbose "Validating StorageSyncService Properties"
Assert-AreEqual $storageSyncServiceName $storageSyncService.StorageSyncServiceName
Assert-AreEqual "AllowVirtualNetworksOnly" $storageSyncService.IncomingTrafficPolicy

Set-AzStorageSyncService -ResourceGroupName $resourceGroupName -StorageSyncServiceName $storageSyncServiceName -IncomingTrafficPolicy "AllowAllTraffic"

Write-Verbose "List StorageSyncServices by ResourceGroup"
$storageSyncServices = Get-AzStorageSyncService -ResourceGroupName $resourceGroupName

Expand All @@ -44,13 +51,20 @@ function Test-StorageSyncService

Write-Verbose "Validating StorageSyncService Properties"
Assert-AreEqual $storageSyncServiceName $storageSyncService.StorageSyncServiceName
Assert-AreEqual "AllowAllTraffic" $storageSyncService.IncomingTrafficPolicy
Assert-AreEqual (Normalize-Location($resourceLocation)) (Normalize-Location($storageSyncService.Location))

Write-Verbose "Removing StorageSyncService: $storageSyncServiceName"
Remove-AzStorageSyncService -Force -ResourceGroupName $resourceGroupName -Name $storageSyncServiceName -AsJob | Wait-Job

# TODO : Remove the new generation of sss, it should work
$storageSyncServiceName = Get-ResourceName("sss")

New-AzStorageSyncService -ResourceGroupName $resourceGroupName -Location $resourceLocation -StorageSyncServiceName $storageSyncServiceName | Get-AzStorageSyncService | Remove-AzStorageSyncService -Force -AsJob | Wait-Job

# TODO : Remove the new generation of sss, it should work
$storageSyncServiceName = Get-ResourceName("sss")

New-AzStorageSyncService -ResourceGroupName $resourceGroupName -Location $resourceLocation -StorageSyncServiceName $storageSyncServiceName | Remove-AzStorageSyncService -Force -AsJob | Wait-Job
}
finally
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/StorageSync/StorageSync.Test/StorageSync.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.StorageSync" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="11.0.0" />
<PackageReference Include="Microsoft.Azure.Management.StorageSync" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="17.0.0" />
<PackageReference Include="System.Management" Version="4.5.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/StorageSync/StorageSync/Az.StorageSync.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DotNetFrameworkVersion = '4.7.2'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '1.9.0'; })
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '1.8.1'; })
ankushbindlish2 marked this conversation as resolved.
Show resolved Hide resolved

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = 'Microsoft.Azure.Management.StorageSync.dll',
Expand All @@ -74,7 +74,7 @@ FunctionsToExport = @()

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = 'Invoke-AzStorageSyncCompatibilityCheck',
'New-AzStorageSyncService', 'Get-AzStorageSyncService',
'New-AzStorageSyncService', 'Get-AzStorageSyncService', 'Set-AzStorageSyncService',
'Remove-AzStorageSyncService', 'New-AzStorageSyncGroup',
'Get-AzStorageSyncGroup', 'Remove-AzStorageSyncGroup',
'New-AzStorageSyncCloudEndpoint', 'Get-AzStorageSyncCloudEndpoint',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// ----------------------------------------------------------------------------------
//
// 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.Commands.StorageSync.Models;
using StorageSyncModels = Microsoft.Azure.Management.StorageSync.Models;

namespace Microsoft.Azure.Commands.StorageSync.Common.Converters
{

/// <summary>
/// Class PrivateEndpointConnectionsConverter.
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Common.Converters.ConverterBase{Microsoft.Azure.Commands.StorageSync.Models.PSPrivateEndpointConnection, Microsoft.Azure.Management.StorageSync.Models.PrivateEndpointConnection}" />
/// </summary>
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Common.Converters.ConverterBase{Microsoft.Azure.Commands.StorageSync.Models.PSPrivateEndpointConnection, Microsoft.Azure.Management.StorageSync.Models.PrivateEndpointConnection}" />
public class PrivateEndpointConnectionConverter : ConverterBase<PSPrivateEndpointConnection, StorageSyncModels.PrivateEndpointConnection>
{

/// <summary>
/// Initializes a new instance of the <see cref="PrivateEndpointConnectionConverter" /> class.
/// </summary>
public PrivateEndpointConnectionConverter()
{
}

/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>StorageSyncModels.PrivateEndpointConnection.</returns>
protected override StorageSyncModels.PrivateEndpointConnection Transform(PSPrivateEndpointConnection source) => new StorageSyncModels.PrivateEndpointConnection(
new PrivateLinkServiceConnectionStateConverter().Convert(source.PrivateLinkServiceConnectionState),
source.ResourceId,
source.PrivateEndpointConnectionName,
source.Type,
new PrivateEndpointConverter().Convert(source.PrivateEndpoint),
source.ProvisioningState);

/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>PSPrivateEndpointConnection.</returns>
protected override PSPrivateEndpointConnection Transform(StorageSyncModels.PrivateEndpointConnection source)
{
return new PSPrivateEndpointConnection()
{
ResourceId = source.Id,
PrivateEndpointConnectionName = source.Name,
PrivateEndpoint = new PrivateEndpointConverter().Convert(source.PrivateEndpoint),
PrivateLinkServiceConnectionState = new PrivateLinkServiceConnectionStateConverter().Convert(source.PrivateLinkServiceConnectionState),
ProvisioningState = source.ProvisioningState,
Type = source.Type,
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ----------------------------------------------------------------------------------
//
// 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.Commands.StorageSync.Models;
using StorageSyncModels = Microsoft.Azure.Management.StorageSync.Models;

namespace Microsoft.Azure.Commands.StorageSync.Common.Converters
{
/// <summary>
/// Class PrivateEndpointConverter.
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Common.Converters.ConverterBase{Microsoft.Azure.Commands.StorageSync.Models.PSPrivateEndpoint, Microsoft.Azure.Management.StorageSync.Models.PrivateEndpoint}" />
/// </summary>
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Common.Converters.ConverterBase{Microsoft.Azure.Commands.StorageSync.Models.PSPrivateEndpoint, Microsoft.Azure.Management.StorageSync.Models.PrivateEndpoint}" />
public class PrivateEndpointConverter : ConverterBase<PSPrivateEndpoint, StorageSyncModels.PrivateEndpoint>
{

/// <summary>
/// Initializes a new instance of the <see cref="PrivateEndpointConverter" /> class.
/// </summary>
public PrivateEndpointConverter()
{
}

/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>StorageSyncModels.PrivateEndpoint.</returns>
protected override StorageSyncModels.PrivateEndpoint Transform(PSPrivateEndpoint source) => new StorageSyncModels.PrivateEndpoint(source.ResourceId);

/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>PSPrivateEndpoint.</returns>
protected override PSPrivateEndpoint Transform(StorageSyncModels.PrivateEndpoint source)
{
return new PSPrivateEndpoint()
{
ResourceId = source.Id
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// ----------------------------------------------------------------------------------
//
// 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.Commands.StorageSync.Models;
using StorageSyncModels = Microsoft.Azure.Management.StorageSync.Models;

namespace Microsoft.Azure.Commands.StorageSync.Common.Converters
{
/// <summary>
/// Class PrivateLinkServiceConnectionStateConverter.
/// Implements the <see cref="Microsoft.Azure.Commands.StorageSync.Common.Converters.ConverterBase{Microsoft.Azure.Commands.StorageSync.Models.PSPrivateLinkServiceConnectionState, Microsoft.Azure.Management.StorageSync.Models.PrivateLinkServiceConnectionState}" />
/// </summary>
/// <seealso cref="Microsoft.Azure.Commands.StorageSync.Common.Converters.ConverterBase{Microsoft.Azure.Commands.StorageSync.Models.PSPrivateLinkServiceConnectionState, Microsoft.Azure.Management.StorageSync.Models.PrivateLinkServiceConnectionState}" />
public class PrivateLinkServiceConnectionStateConverter : ConverterBase<PSPrivateLinkServiceConnectionState, StorageSyncModels.PrivateLinkServiceConnectionState>
{

/// <summary>
/// Initializes a new instance of the <see cref="PrivateLinkServiceConnectionStateConverter" /> class.
/// </summary>
public PrivateLinkServiceConnectionStateConverter()
{
}

/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>StorageSyncModels.PrivateLinkServiceConnectionState.</returns>
protected override StorageSyncModels.PrivateLinkServiceConnectionState Transform(PSPrivateLinkServiceConnectionState source) => new StorageSyncModels.PrivateLinkServiceConnectionState(
source.Status,
source.Description,
source.ActionRequired);

/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>PSPrivateLinkServiceConnectionState.</returns>
protected override PSPrivateLinkServiceConnectionState Transform(StorageSyncModels.PrivateLinkServiceConnectionState source)
{
return new PSPrivateLinkServiceConnectionState()
{
Status = source.Status,
Description = source.Description,
ActionRequired = source.ActionRequired,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ protected override StorageSyncModels.RegisteredServer Transform(PSRegisteredServ
source.ServiceLocation,
source.FriendlyName,
source.ManagementEndpointUri,
source.MonitoringEndpointUri,
source.MonitoringConfiguration);
}

Expand Down Expand Up @@ -91,6 +92,7 @@ protected override PSRegisteredServer Transform(StorageSyncModels.RegisteredServ
LastOperationName = source.LastOperationName,
LastWorkflowId = source.LastWorkflowId?.Trim('"'),
ManagementEndpointUri = source.ManagementEndpointUri?.Trim('"'),
MonitoringEndpointUri = source.MonitoringEndpointUri,
ResourceLocation = source.ResourceLocation,
ServerCertificate = source.ServerCertificate?.Trim('"'),
ServerId = source.ServerId?.Trim('"'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

using Microsoft.Azure.Commands.StorageSync.Models;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.Azure.Management.StorageSync.Models;
using System.Collections.Generic;
using StorageSyncModels = Microsoft.Azure.Management.StorageSync.Models;

namespace Microsoft.Azure.Commands.StorageSync.Common.Converters
Expand All @@ -39,7 +41,13 @@ public StorageSyncServiceConverter()
/// </summary>
/// <param name="source">The source.</param>
/// <returns>StorageSyncModels.StorageSyncService.</returns>
protected override StorageSyncModels.StorageSyncService Transform(PSStorageSyncService source) => new StorageSyncModels.StorageSyncService(source.Location, source.ResourceId, source.StorageSyncServiceName, StorageSyncConstants.StorageSyncServiceType, source.Tags);
protected override StorageSyncModels.StorageSyncService Transform(PSStorageSyncService source) => new StorageSyncModels.StorageSyncService(
source.Location,
source.ResourceId,
source.StorageSyncServiceName,
StorageSyncConstants.StorageSyncServiceType,
source.Tags,
source.IncomingTrafficPolicy);

/// <summary>
/// Transforms the specified source.
Expand All @@ -49,14 +57,27 @@ public StorageSyncServiceConverter()
protected override PSStorageSyncService Transform(StorageSyncModels.StorageSyncService source)
{
var resourceIdentifier = new ResourceIdentifier(source.Id);

var psPrivateEndpointConnections = new List<PSPrivateEndpointConnection>();
// Convert individual PrivateEndpointConnection objects
if (source.PrivateEndpointConnections != null)
{
foreach(PrivateEndpointConnection privateEndpointConnection in source.PrivateEndpointConnections)
{
psPrivateEndpointConnections.Add(new PrivateEndpointConnectionConverter().Convert(privateEndpointConnection));
}
}

return new PSStorageSyncService()
{
ResourceId = source.Id,
StorageSyncServiceName = source.Name,
ResourceGroupName = resourceIdentifier.ResourceGroupName,
Location = source.Location,
IncomingTrafficPolicy = source.IncomingTrafficPolicy,
Tags = source.Tags,
Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.StorageSyncServiceType
Type = resourceIdentifier.ResourceType ?? StorageSyncConstants.StorageSyncServiceType,
PrivateEndpointConnections = psPrivateEndpointConnections.Count > 0 ? psPrivateEndpointConnections : null
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ namespace Microsoft.Azure.Commands.StorageSync.Common.Converters
/// Implements the <see cref="Converters.ConverterBase{PSSyncActivityStatus, StorageSyncModels.SyncProgressStatus}" />
/// </summary>
/// <seealso cref="Converters.ConverterBase{PSSyncActivityStatus, StorageSyncModels.SyncProgressStatus}" />
public class SyncActivityStatusConverter : ConverterBase<PSSyncActivityStatus, StorageSyncModels.SyncActivityStatus>
public class SyncActivityStatusConverter : ConverterBase<PSSyncActivityStatus, StorageSyncModels.ServerEndpointSyncActivityStatus>
{
/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>StorageSyncModels.SyncProgressStatus.</returns>
protected override StorageSyncModels.SyncActivityStatus Transform(PSSyncActivityStatus source) => new StorageSyncModels.SyncActivityStatus(
protected override StorageSyncModels.ServerEndpointSyncActivityStatus Transform(PSSyncActivityStatus source) => new StorageSyncModels.ServerEndpointSyncActivityStatus(
source.Timestamp,
source.PerItemErrorCount,
source.AppliedItemCount,
Expand All @@ -41,7 +41,7 @@ public class SyncActivityStatusConverter : ConverterBase<PSSyncActivityStatus, S
/// </summary>
/// <param name="source">The source.</param>
/// <returns>PSSyncProgressStatus.</returns>
protected override PSSyncActivityStatus Transform(StorageSyncModels.SyncActivityStatus source)
protected override PSSyncActivityStatus Transform(StorageSyncModels.ServerEndpointSyncActivityStatus source)
{
return new PSSyncActivityStatus()
{
Expand Down
Loading