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

Migrate rest of the cmdletd under StorageAccount to Track2 SDK #20

Closed
wants to merge 2 commits into from
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/Accounts/Accounts/Az.Accounts.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '2.7.6'
ModuleVersion = '2.8.0'

# Supported PSEditions
CompatiblePSEditions = 'Core', 'Desktop'
Expand Down
2 changes: 1 addition & 1 deletion src/Accounts/Accounts/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class CustomAssemblyResolver
private static IDictionary<string, Version> NetFxPreloadAssemblies =
new Dictionary<string, Version>(StringComparer.InvariantCultureIgnoreCase)
{
{"Azure.Core", new Version("1.24.0.0")},
{"Azure.Core", new Version("1.25.0.0")},
{"Microsoft.Bcl.AsyncInterfaces", new Version("1.1.1.0")},
{"Microsoft.Identity.Client", new Version("4.39.0.0") },
{"Microsoft.Identity.Client.Extensions.Msal", new Version("2.19.3.0") },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Management.Storage.Models;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Management.Storage.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using Track2 = Azure.ResourceManager.Storage;
using Track2Models = Azure.ResourceManager.Storage.Models;

namespace Microsoft.Azure.Commands.Management.Storage
{
Expand Down Expand Up @@ -126,12 +126,13 @@ public override void ExecuteCmdlet()
break;
}

var legalHold = this.StorageClient.BlobContainers.SetLegalHold(
this.ResourceGroupName,
this.StorageAccountName,
this.Name,
new List<string>(this.Tag),
this.allowProtectedAppendWriteAll);

Track2Models.LegalHold data = new Track2Models.LegalHold(new List<string>(this.Tag));
data.AllowProtectedAppendWritesAll = this.allowProtectedAppendWriteAll;

Track2Models.LegalHold legalHold = this.StorageClientTrack2.GetBlobContainerResource(this.ResourceGroupName, this.StorageAccountName, this.Name)
.SetLegalHold(data);

WriteObject(new PSLegalHold(legalHold));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public override void ExecuteCmdlet()
Track2.BlobServiceData data = new Track2.BlobServiceData();
data.DeleteRetentionPolicy = new Track2Models.DeleteRetentionPolicy
{
Enabled = false,
IsEnabled = false,
Days = null,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override void ExecuteCmdlet()
}
Track2.BlobServiceData data = new Track2.BlobServiceData();

data.RestorePolicy = new Track2Models.RestorePolicyProperties(false)
data.RestorePolicy = new Track2Models.RestorePolicy(false)
{
Days = null,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public override void ExecuteCmdlet()

data.ContainerDeleteRetentionPolicy = new Track2Models.DeleteRetentionPolicy
{
Enabled = false,
IsEnabled = false,
Days = null,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public override void ExecuteCmdlet()

data.DeleteRetentionPolicy = new Track2Models.DeleteRetentionPolicy
{
Enabled = true,
IsEnabled = true,
Days = RetentionDays,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public override void ExecuteCmdlet()

Track2.BlobServiceData data = new Track2.BlobServiceData();

data.RestorePolicy = new Track2Models.RestorePolicyProperties(true)
data.RestorePolicy = new Track2Models.RestorePolicy(true)
{
Days = this.RestoreDays,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public override void ExecuteCmdlet()
Track2.BlobServiceData data = new Track2.BlobServiceData();
data.ContainerDeleteRetentionPolicy = new Track2Models.DeleteRetentionPolicy
{
Enabled = true,
IsEnabled = true,
Days = this.RetentionDays,
};

Expand Down
52 changes: 39 additions & 13 deletions src/Storage/Storage.Management/Blob/GetAzureStorageContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Track2 = Azure.ResourceManager.Storage;
using Track2Models = Azure.ResourceManager.Storage.Models;

using Microsoft.Azure.Commands.Management.Storage.Models;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Management.Storage.Models;
using Microsoft.Rest.Azure;
using System;
using System.Collections.Generic;
using System.Management.Automation;
using Azure;

namespace Microsoft.Azure.Commands.Management.Storage
{
Expand Down Expand Up @@ -92,24 +96,46 @@ public override void ExecuteCmdlet()
{
WriteWarning("Can't get single deleted container, so -IncludeDeleted will be omit when get single container with -Name.");
}
var container = this.StorageClient.BlobContainers.Get(
this.ResourceGroupName,
this.StorageAccountName,
this.Name);
WriteObject(new PSContainer(container));

Track2.BlobContainerResource blobContainerResource = this.StorageClientTrack2
.GetBlobContainerResource(this.ResourceGroupName, this.StorageAccountName, this.Name).Get().Value;

//var container = this.StorageClient.BlobContainers.Get(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the commented part

// this.ResourceGroupName,
// this.StorageAccountName,
// this.Name);
//WriteObject(new PSContainer(container));
WriteObject(new PSContainer(blobContainerResource));
}
else
{
IPage<ListContainerItem> containerlistResult = this.StorageClient.BlobContainers.List(
this.ResourceGroupName,
this.StorageAccountName,
include: IncludeDeleted.IsPresent ? ListContainersInclude.Deleted : null);
WriteContainerList(containerlistResult);
while (containerlistResult.NextPageLink != null)

Pageable<Track2.BlobContainerResource> containerList = this.StorageClientTrack2.GetBlobServiceResource(this.ResourceGroupName, this.StorageAccountName)
.GetBlobContainers()
.GetAll(include: IncludeDeleted.IsPresent ? ListContainersInclude.Deleted : null);

if (containerList != null)
{
containerlistResult = this.StorageClient.BlobContainers.ListNext(containerlistResult.NextPageLink);
WriteContainerList(containerlistResult);
List<PSContainer> output = new List<PSContainer>();
foreach (Track2.BlobContainerResource container in containerList)
{
output.Add(new PSContainer(container));
}
WriteObject(output, true);
}



//IPage<ListContainerItem> containerlistResult = this.StorageClient.BlobContainers.List(
// this.ResourceGroupName,
// this.StorageAccountName,
// include: IncludeDeleted.IsPresent ? ListContainersInclude.Deleted : null);
//WriteContainerList(containerlistResult);
//while (containerlistResult.NextPageLink != null)
//{
// containerlistResult = this.StorageClient.BlobContainers.ListNext(containerlistResult.NextPageLink);
// WriteContainerList(containerlistResult);
//}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the commented part

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using Azure.ResourceManager.Storage;
using Azure.ResourceManager.Storage.Models;

namespace Microsoft.Azure.Commands.Management.Storage
{
Expand Down Expand Up @@ -111,12 +113,22 @@ public override void ExecuteCmdlet()
break;
}

ImmutabilityPolicy policy=
this.StorageClient.BlobContainers.GetImmutabilityPolicy(
this.ResourceGroupName,
this.StorageAccountName,
this.ContainerName,
Etag);
//ImmutabilityPolicy policy=
//this.StorageClient.BlobContainers.GetImmutabilityPolicy(
// this.ResourceGroupName,
// this.StorageAccountName,
// this.ContainerName,
// Etag);

//ImmutabilityPolicyResource policy = this.StorageClientTrack2.GetImmutabilityPolicy(
// this.ResourceGroupName,
// this.StorageAccountName,
// this.ContainerName,
// this.Etag);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the commented part


ImmutabilityPolicyResource policy = this.StorageClientTrack2.GetImmutabilityPolicyResource(
this.ResourceGroupName, this.StorageAccountName, this.ContainerName).Get(new global::Azure.ETag(this.Etag)).Value;


WriteObject(new PSImmutabilityPolicy(policy));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,20 @@ public override void ExecuteCmdlet()
default:
break;
}
this.StorageClient.BlobContainers.ObjectLevelWorm(
this.ResourceGroupName,
this.StorageAccountName,
this.Name);
var container = this.StorageClient.BlobContainers.Get(
this.ResourceGroupName,
this.StorageAccountName,
this.Name);
//this.StorageClient.BlobContainers.ObjectLevelWorm(
// this.ResourceGroupName,
// this.StorageAccountName,
// this.Name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the commented part
Same as below


this.StorageClientTrack2.GetBlobContainerResource(this.ResourceGroupName, this.StorageAccountName, this.Name)
.EnableObjectLevelWorm(global::Azure.WaitUntil.Completed);

var container = this.StorageClientTrack2.GetBlobContainerResource(this.ResourceGroupName, this.StorageAccountName, this.Name).Get();

//var container = this.StorageClient.BlobContainers.Get(
// this.ResourceGroupName,
// this.StorageAccountName,
// this.Name);
WriteObject(new PSContainer(container));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Azure;
using Azure.ResourceManager.Storage;
using Microsoft.Azure.Commands.Management.Storage.Models;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Management.Storage.Models;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -148,11 +148,18 @@ public override void ExecuteCmdlet()

if (Force || ShouldContinue(string.Format("Lock ImmutabilityPolicy in container '{0}' with Etag {1}", this.ContainerName, this.Etag), ""))
{
ImmutabilityPolicy policy = this.StorageClient.BlobContainers.LockImmutabilityPolicy(
this.ResourceGroupName,
this.StorageAccountName,
this.ContainerName,
this.Etag);
//ImmutabilityPolicy policy = this.StorageClient.BlobContainers.LockImmutabilityPolicy(
// this.ResourceGroupName,
// this.StorageAccountName,
// this.ContainerName,
// this.Etag);

//ImmutabilityPolicyResource policy = this.StorageClientTrack2.LockImmutabilityPolicy(
// this.ResourceGroupName, this.StorageAccountName, this.ContainerName, this.Etag);

ImmutabilityPolicyResource policy = this.StorageClientTrack2.GetImmutabilityPolicyResource(
this.ResourceGroupName, this.StorageAccountName, this.ContainerName).LockImmutabilityPolicy(new ETag(this.Etag)).Value;


WriteObject(new PSImmutabilityPolicy(policy));
}
Expand Down
Loading