Skip to content

Commit

Permalink
track2 initial setup and StorageAccount related cmdlets (Azure#13)
Browse files Browse the repository at this point in the history
* track2 initial setup and StorageAccount related cmdlets

* fix bugs and formatting per comments

* Fix AccountIdentityType
  • Loading branch information
yifanz0 authored May 23, 2022
1 parent c11047e commit 85aba87
Show file tree
Hide file tree
Showing 13 changed files with 857 additions and 471 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.Storage.Models;
using Track2Models = Azure.ResourceManager.Storage.Models;

namespace Microsoft.Azure.Commands.Management.Storage.Models
{
public class PSAzureFilesIdentityBasedAuthentication
{
public PSAzureFilesIdentityBasedAuthentication(AzureFilesIdentityBasedAuthentication auth)
public PSAzureFilesIdentityBasedAuthentication(Track2Models.AzureFilesIdentityBasedAuthentication auth)
{
if (auth != null)
{
this.DirectoryServiceOptions = auth.DirectoryServiceOptions;
this.DirectoryServiceOptions = auth.DirectoryServiceOptions.ToString();
this.ActiveDirectoryProperties = auth.ActiveDirectoryProperties != null ? new PSActiveDirectoryProperties(auth.ActiveDirectoryProperties) : null;
this.DefaultSharePermission = auth.DefaultSharePermission;
this.DefaultSharePermission = auth.DefaultSharePermission.ToString();
}
}
// Gets or sets indicates the directory service used. Possible values include: 'None','AADDS', 'AD'
Expand All @@ -35,7 +35,7 @@ public PSAzureFilesIdentityBasedAuthentication(AzureFilesIdentityBasedAuthentica

public class PSActiveDirectoryProperties
{
public PSActiveDirectoryProperties(ActiveDirectoryProperties properties)
public PSActiveDirectoryProperties(Track2Models.ActiveDirectoryProperties properties)
{
if (properties != null)
{
Expand All @@ -46,7 +46,7 @@ public PSActiveDirectoryProperties(ActiveDirectoryProperties properties)
this.DomainSid = properties.DomainSid;
this.AzureStorageSid = properties.AzureStorageSid;
this.SamAccountName = properties.SamAccountName;
this.AccountType = properties.AccountType;
this.AccountType = properties.AccountType != null ? properties.AccountType.ToString() : null;
}
}
public string DomainName { get; set; }
Expand Down
31 changes: 12 additions & 19 deletions src/Storage/Storage.Management/Models/PSBlobRestore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Microsoft.WindowsAzure.Commands.Common.Attributes;
using System;
using System.Collections.Generic;
using Track2Models = Azure.ResourceManager.Storage.Models;

namespace Microsoft.Azure.Commands.Management.Storage.Models
{
Expand All @@ -37,48 +38,40 @@ public PSBlobRestoreRange(string startRange, string endRange)
this.EndRange = endRange;
}

public PSBlobRestoreRange(BlobRestoreRange range)
public PSBlobRestoreRange(Track2Models.BlobRestoreRange range)
{
this.StartRange = range.StartRange;
this.EndRange = range.EndRange;
}

public static IList<BlobRestoreRange> ParseBlobRestoreRanges(PSBlobRestoreRange[] ranges)
public static IList<Track2Models.BlobRestoreRange> ParseBlobRestoreRanges(PSBlobRestoreRange[] ranges)
{
IList<BlobRestoreRange> re = new List<BlobRestoreRange>();
IList<Track2Models.BlobRestoreRange> re = new List<Track2Models.BlobRestoreRange>();
if (ranges == null)
{
re.Add(
new BlobRestoreRange
{
StartRange = "",
EndRange = ""
});
new Track2Models.BlobRestoreRange("", ""));
}
else
{
foreach (PSBlobRestoreRange range in ranges)
{
re.Add(
new BlobRestoreRange
{
StartRange = range.StartRange,
EndRange = range.EndRange
});
new Track2Models.BlobRestoreRange(range.EndRange, range.StartRange));
}
}
return re;
}

public static PSBlobRestoreRange[] ParsePSBlobRestoreRanges(IList<BlobRestoreRange> ranges)
public static PSBlobRestoreRange[] ParsePSBlobRestoreRanges(IList<Track2Models.BlobRestoreRange> ranges)
{
if (ranges == null)
{
return null;
}

List<PSBlobRestoreRange> re = new List<PSBlobRestoreRange>();
foreach (BlobRestoreRange range in ranges)
foreach (Track2Models.BlobRestoreRange range in ranges)
{
re.Add(
new PSBlobRestoreRange
Expand Down Expand Up @@ -109,11 +102,11 @@ public class PSBlobRestoreStatus
public PSBlobRestoreStatus()
{ }

public PSBlobRestoreStatus(BlobRestoreStatus status)
public PSBlobRestoreStatus(Track2Models.BlobRestoreStatus status)
{
if (status != null)
{
this.Status = status.Status;
this.Status = status.Status != null ? status.Status.ToString() : null;
this.FailureReason = status.FailureReason;
this.RestoreId = status.RestoreId;
this.Parameters = status.Parameters is null ? null : new PSBlobRestoreParameters(status.Parameters);
Expand All @@ -126,13 +119,13 @@ public PSBlobRestoreStatus(BlobRestoreStatus status)
/// </summary>
public class PSBlobRestoreParameters
{
public DateTime TimeToRestore { get; set; }
public DateTimeOffset TimeToRestore { get; set; }
public PSBlobRestoreRange[] BlobRanges { get; set; }

public PSBlobRestoreParameters()
{ }

public PSBlobRestoreParameters(BlobRestoreParameters parameters)
public PSBlobRestoreParameters(Track2Models.BlobRestoreContent parameters)
{
this.TimeToRestore = parameters.TimeToRestore;
this.BlobRanges = PSBlobRestoreRange.ParsePSBlobRestoreRanges(parameters.BlobRanges);
Expand Down
20 changes: 10 additions & 10 deletions src/Storage/Storage.Management/Models/PSGeoReplicationStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.Storage.Models;
using Track2Models = Azure.ResourceManager.Storage.Models;
using System;

namespace Microsoft.Azure.Commands.Management.Storage.Models
{
public class PSGeoReplicationStats
{
//Parse GeoReplicationStats in SDK to wrapped property PSGeoReplicationStats
public static PSGeoReplicationStats ParsePSGeoReplicationStats(GeoReplicationStats geoReplicationStats)
//Parse GeoReplicationStats in SDK to wrapped property PSGeoReplicationStats
public static PSGeoReplicationStats ParsePSGeoReplicationStats(Track2Models.GeoReplicationStats geoReplicationStats)
{
if (geoReplicationStats == null)
{
return null;
}

PSGeoReplicationStats pSGeoReplicationStats = new PSGeoReplicationStats();

pSGeoReplicationStats.Status = geoReplicationStats.Status;
pSGeoReplicationStats.LastSyncTime = geoReplicationStats.LastSyncTime;
pSGeoReplicationStats.CanFailover = geoReplicationStats.CanFailover;

PSGeoReplicationStats pSGeoReplicationStats = new PSGeoReplicationStats
{
Status = geoReplicationStats.Status != null ? geoReplicationStats.Status.ToString() : null,
LastSyncTime = geoReplicationStats.LastSyncOn,
CanFailover = geoReplicationStats.CanFailover != null ? geoReplicationStats.CanFailover : null
};
return pSGeoReplicationStats;
}

public string Status { get; set; }
public DateTime? LastSyncTime { get; set; }
public DateTimeOffset? LastSyncTime { get; set; }
public bool? CanFailover { get; set; }
}
}
Loading

0 comments on commit 85aba87

Please sign in to comment.