Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/StorageSync/StorageSync.Test/StorageSync.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.StorageSync" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Management.StorageSync" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="11.0.0" />
<PackageReference Include="System.Management" Version="4.5.0" />
</ItemGroup>
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ namespace Microsoft.Azure.Commands.StorageSync.Common.Converters
/// Implements the <see cref="Converters.ConverterBase{PSSyncSessionStatus, StorageSyncModels.SyncSessionStatus}" />
/// </summary>
/// <seealso cref="Converters.ConverterBase{PSSyncSessionStatus, StorageSyncModels.SyncSessionStatus}" />
public class SyncSessionStatusConvertor : ConverterBase<PSSyncSessionStatus, StorageSyncModels.SyncSessionStatus>
public class SyncSessionStatusConvertor : ConverterBase<PSSyncSessionStatus, StorageSyncModels.ServerEndpointSyncSessionStatus>
{
/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>StorageSyncModels.SyncSessionStatus.</returns>
protected override StorageSyncModels.SyncSessionStatus Transform(PSSyncSessionStatus source) => new StorageSyncModels.SyncSessionStatus(
protected override StorageSyncModels.ServerEndpointSyncSessionStatus Transform(PSSyncSessionStatus source) => new StorageSyncModels.ServerEndpointSyncSessionStatus(
source.LastSyncResult, source.LastSyncTimestamp, source.LastSyncSuccessTimestamp, source.LastSyncPerItemErrorCount);

/// <summary>
/// Transforms the specified source.
/// </summary>
/// <param name="source">The source.</param>
/// <returns>PSSyncSessionStatus.</returns>
protected override PSSyncSessionStatus Transform(StorageSyncModels.SyncSessionStatus source)
protected override PSSyncSessionStatus Transform(StorageSyncModels.ServerEndpointSyncSessionStatus source)
{
return new PSSyncSessionStatus()
{
Expand Down
4 changes: 4 additions & 0 deletions src/StorageSync/StorageSync/Common/HelpMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public class HelpMessages
/// </summary>
public const string StorageSyncServiceLocationParameter = "Storage Sync Service Location.";
/// <summary>
/// The storage sync service incoming traffic policy parameter
/// </summary>
public const string StorageSyncServiceIncomingTrafficPolicyParameter = "Storage Sync Service Incoming Traffic Policy.";
/// <summary>
/// The storage sync service tags parameter
/// </summary>
public const string StorageSyncServiceTagsParameter = "Storage Sync Service Tags.";
Expand Down
25 changes: 25 additions & 0 deletions src/StorageSync/StorageSync/Models/PSPrivateEndpoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ----------------------------------------------------------------------------------
//
// 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.StorageSync.Models
{
public class PSPrivateEndpoint
{
/// <summary>
/// Gets the resource identifier.
/// </summary>
/// <value></value>
public string ResourceId { get; internal set; }
}
}
Loading