Skip to content

Commit 625b99d

Browse files
committed
temp
1 parent bc9e400 commit 625b99d

7 files changed

+114
-111
lines changed

src/Storage/Storage.Management/Models/PSBlobInventoryPolicy.cs

Lines changed: 81 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Track2 = Azure.ResourceManager.Storage;
16+
using Track2Models = Azure.ResourceManager.Storage.Models;
1517
using Microsoft.Azure.Management.Storage.Models;
1618
using Microsoft.WindowsAzure.Commands.Common.Attributes;
1719
using System;
@@ -27,23 +29,21 @@ public class PSBlobInventoryPolicy
2729
public PSBlobInventoryPolicy()
2830
{ }
2931

30-
public PSBlobInventoryPolicy(BlobInventoryPolicy policy, string ResourceGroupName, string StorageAccountName)
32+
public PSBlobInventoryPolicy(Track2.BlobInventoryPolicyResource policy, string resourceGroupName, string storageAccountName)
3133
{
32-
this.ResourceGroupName = ResourceGroupName;
33-
this.StorageAccountName = StorageAccountName;
34+
this.ResourceGroupName = resourceGroupName;
35+
this.StorageAccountName = storageAccountName;
3436
this.Id = policy.Id;
35-
this.Name = policy.Name;
36-
this.Type = policy.Type;
37-
this.LastModifiedTime = policy.LastModifiedTime;
38-
this.SystemData = policy.SystemData is null ? null : new PSSystemData(policy.SystemData);
37+
this.Name = policy.Data.Name;
38+
this.Type = policy.Data.ResourceType;
39+
this.LastModifiedTime = policy.Data.LastModifiedOn;
40+
this.SystemData = policy.Data.SystemData is null ? null : new PSSystemData(policy.Data.SystemData);
41+
this.Enabled = policy.Data.Policy.Enabled;
3942

40-
this.Enabled = policy.Policy.Enabled;
41-
this.Destination = policy.Policy.Destination;
42-
43-
if (policy.Policy.Rules != null)
43+
if (policy.Data.Policy.Rules != null)
4444
{
4545
List<PSBlobInventoryPolicyRule> psRules = new List<PSBlobInventoryPolicyRule>();
46-
foreach (BlobInventoryPolicyRule rule in policy.Policy.Rules)
46+
foreach (Track2Models.BlobInventoryPolicyRule rule in policy.Data.Policy.Rules)
4747
{
4848
psRules.Add(new PSBlobInventoryPolicyRule(rule));
4949
}
@@ -55,32 +55,29 @@ public PSBlobInventoryPolicy(BlobInventoryPolicy policy, string ResourceGroupNam
5555
}
5656
}
5757

58-
public BlobInventoryPolicy ParseBlobInventoryPolicy()
58+
59+
public Track2.BlobInventoryPolicyData ParseBlobInventoryPolicy()
5960
{
60-
List<BlobInventoryPolicyRule> invRules = ParseBlobInventoryPolicyRules(this.Rules);
61+
List<Track2Models.BlobInventoryPolicyRule> invRules = ParseBlobInventoryPolicyRules(this.Rules);
62+
63+
Track2Models.BlobInventoryPolicySchema policySchema = new Track2Models.BlobInventoryPolicySchema(
64+
this.Enabled,
65+
Track2Models.InventoryRuleType.Inventory,
66+
invRules);
6167

62-
BlobInventoryPolicySchema policySchema = new BlobInventoryPolicySchema()
68+
Track2.BlobInventoryPolicyData data = new Track2.BlobInventoryPolicyData
6369
{
64-
Enabled = this.Enabled,
65-
//Destination = this.Destination,
66-
Rules = invRules
70+
Policy = policySchema,
6771
};
68-
return new BlobInventoryPolicy(
69-
policySchema,
70-
this.Id,
71-
this.Name,
72-
this.Type,
73-
this.LastModifiedTime,
74-
this.SystemData is null ? null : this.SystemData.ParseSystemData()
75-
);
72+
return data;
7673
}
7774

78-
public static List<BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlobInventoryPolicyRule[] rules)
75+
public static List<Track2Models.BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlobInventoryPolicyRule[] rules)
7976
{
80-
List<BlobInventoryPolicyRule> invRules = null;
77+
List<Track2Models.BlobInventoryPolicyRule> invRules = null;
8178
if (rules != null)
8279
{
83-
invRules = new List<BlobInventoryPolicyRule>();
80+
invRules = new List<Track2Models.BlobInventoryPolicyRule>();
8481
foreach (PSBlobInventoryPolicyRule rule in rules)
8582
{
8683
invRules.Add(rule.ParseBlobInventoryPolicyRule());
@@ -99,7 +96,7 @@ public static List<BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlob
9996
[Ps1Xml(Label = "Type", Target = ViewControl.List, Position = 2)]
10097
public string Type { get; set; }
10198
[Ps1Xml(Label = "LastModifiedTime", Target = ViewControl.List, Position = 4)]
102-
public DateTime? LastModifiedTime { get; set; }
99+
public DateTimeOffset? LastModifiedTime { get; set; }
103100

104101
//public PSBlobInventoryPolicySchema Policy { get; set; }
105102

@@ -108,7 +105,6 @@ public static List<BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlob
108105
[Ps1Xml(Label = "Rules", Target = ViewControl.List, Position = 7)]
109106
public PSBlobInventoryPolicyRule[] Rules { get; set; }
110107
public PSSystemData SystemData { get; set; }
111-
public string Destination { get; private set; }
112108
}
113109

114110
/// <summary>
@@ -117,23 +113,25 @@ public static List<BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlob
117113
public class PSBlobInventoryPolicyRule
118114
{
119115
public PSBlobInventoryPolicyRule() { }
120-
public PSBlobInventoryPolicyRule(BlobInventoryPolicyRule rule)
116+
public PSBlobInventoryPolicyRule(Track2Models.BlobInventoryPolicyRule rule)
121117
{
122118
this.Enabled = rule.Enabled;
123119
this.Name = rule.Name;
124120
this.Destination = rule.Destination;
125121
this.Definition = rule.Definition is null ? null : new PSBlobInventoryPolicyDefinition(rule.Definition);
126122
}
127123

128-
public BlobInventoryPolicyRule ParseBlobInventoryPolicyRule()
124+
public Track2Models.BlobInventoryPolicyRule ParseBlobInventoryPolicyRule()
129125
{
130-
return new BlobInventoryPolicyRule()
131-
{
132-
Enabled = this.Enabled,
133-
Name = this.Name,
134-
Destination = this.Destination,
135-
Definition = this.Definition is null ? null : this.Definition.parseBlobInventoryPolicyDefinition()
136-
};
126+
Track2Models.BlobInventoryPolicyDefinition policyDefinition = this.Definition?.parseBlobInventoryPolicyDefinition();
127+
128+
Track2Models.BlobInventoryPolicyRule policyRule = new Track2Models.BlobInventoryPolicyRule(
129+
this.Enabled,
130+
this.Name,
131+
this.Destination,
132+
policyDefinition);
133+
134+
return policyRule;
137135
}
138136

139137
public bool Enabled { get; set; }
@@ -152,20 +150,29 @@ public class PSBlobInventoryPolicyDefinition
152150
{
153151
public PSBlobInventoryPolicyDefinition() { }
154152

155-
public PSBlobInventoryPolicyDefinition(BlobInventoryPolicyDefinition Definition)
153+
public PSBlobInventoryPolicyDefinition(Track2Models.BlobInventoryPolicyDefinition Definition)
156154
{
157155
this.Filters = Definition.Filters is null ? null : new PSBlobInventoryPolicyFilter(Definition.Filters);
158-
this.Format = Definition.Format;
159-
this.Schedule = Definition.Schedule;
160-
this.ObjectType = Definition.ObjectType;
156+
this.Format = Definition.Format.ToString();
157+
this.Schedule = Definition.Schedule.ToString();
158+
this.ObjectType = Definition.ObjectType.ToString();
161159
this.SchemaFields = Definition.SchemaFields is null ? null : ((List<string>)Definition.SchemaFields).ToArray();
162160
}
163161

164-
public BlobInventoryPolicyDefinition parseBlobInventoryPolicyDefinition()
162+
public Track2Models.BlobInventoryPolicyDefinition parseBlobInventoryPolicyDefinition()
165163
{
166-
return new BlobInventoryPolicyDefinition(this.Format, this.Schedule, this.ObjectType,
167-
this.SchemaFields is null? null: new List<string>(this.SchemaFields),
168-
this.Filters is null? null : this.Filters.ParseBlobInventoryPolicyFilter());
164+
Track2Models.BlobInventoryPolicyDefinition policyDefinition = new Track2Models.BlobInventoryPolicyDefinition(
165+
new Track2Models.Format(this.Format),
166+
new Track2Models.Schedule(this.Schedule),
167+
new Track2Models.ObjectType(this.ObjectType),
168+
this.SchemaFields is null ? null : new List<string>(this.SchemaFields)
169+
);
170+
171+
if (this.Filters != null)
172+
{
173+
policyDefinition.Filters = this.Filters.ParseBlobInventoryPolicyFilter();
174+
}
175+
return policyDefinition;
169176
}
170177

171178
public PSBlobInventoryPolicyFilter Filters { get; set; }
@@ -213,23 +220,37 @@ public class PSBlobInventoryPolicyFilter
213220
{
214221
public PSBlobInventoryPolicyFilter() { }
215222

216-
public PSBlobInventoryPolicyFilter(BlobInventoryPolicyFilter filters)
223+
public PSBlobInventoryPolicyFilter(Track2Models.BlobInventoryPolicyFilter filters)
217224
{
218225
this.PrefixMatch = PSManagementPolicyRuleFilter.StringListToArray(filters.PrefixMatch);
219226
this.BlobTypes = PSManagementPolicyRuleFilter.StringListToArray(filters.BlobTypes);
220227
this.IncludeBlobVersions = filters.IncludeBlobVersions;
221228
this.IncludeSnapshots = filters.IncludeSnapshots;
222229
}
223230

224-
public BlobInventoryPolicyFilter ParseBlobInventoryPolicyFilter()
231+
public Track2Models.BlobInventoryPolicyFilter ParseBlobInventoryPolicyFilter()
225232
{
226-
return new BlobInventoryPolicyFilter()
233+
Track2Models.BlobInventoryPolicyFilter policyFilter = new Track2Models.BlobInventoryPolicyFilter()
227234
{
228-
PrefixMatch = PSManagementPolicyRuleFilter.StringArrayToList(this.PrefixMatch),
229-
BlobTypes = PSManagementPolicyRuleFilter.StringArrayToList(this.BlobTypes),
230235
IncludeSnapshots = this.IncludeSnapshots,
231236
IncludeBlobVersions = this.IncludeBlobVersions
232237
};
238+
239+
if (this.PrefixMatch != null)
240+
{
241+
foreach (string prefixMatch in this.PrefixMatch)
242+
{
243+
policyFilter.PrefixMatch.Add(prefixMatch);
244+
}
245+
}
246+
if (this.BlobTypes != null)
247+
{
248+
foreach (string blobType in this.BlobTypes)
249+
{
250+
policyFilter.BlobTypes.Add(blobType);
251+
}
252+
}
253+
return policyFilter;
233254
}
234255

235256
public string[] PrefixMatch { get; set; }
@@ -245,26 +266,21 @@ public class PSSystemData
245266
{
246267
public PSSystemData() { }
247268

248-
public PSSystemData(SystemData SystemData)
269+
public PSSystemData(global::Azure.ResourceManager.Models.SystemData SystemData)
249270
{
250271
this.CreatedBy = SystemData.CreatedBy;
251-
this.CreatedByType = SystemData.CreatedByType;
252-
this.CreatedAt = SystemData.CreatedAt;
272+
this.CreatedByType = SystemData.CreatedByType.ToString();
273+
this.CreatedAt = SystemData.CreatedOn;
253274
this.LastModifiedBy = SystemData.LastModifiedBy;
254-
this.LastModifiedByType = SystemData.LastModifiedByType;
255-
this.LastModifiedAt = SystemData.LastModifiedAt;
256-
}
257-
258-
public SystemData ParseSystemData()
259-
{
260-
return new SystemData(this.CreatedBy, this.CreatedByType, this.CreatedAt, this.LastModifiedBy, this.LastModifiedByType, this.LastModifiedAt);
275+
this.LastModifiedByType = SystemData.LastModifiedByType.ToString();
276+
this.LastModifiedAt = SystemData.LastModifiedOn;
261277
}
262278

263279
public string CreatedBy { get; set; }
264280
public string CreatedByType { get; set; }
265-
public DateTime? CreatedAt { get; set; }
281+
public DateTimeOffset? CreatedAt { get; set; }
266282
public string LastModifiedBy { get; set; }
267283
public string LastModifiedByType { get; set; }
268-
public DateTime? LastModifiedAt { get; set; }
284+
public DateTimeOffset? LastModifiedAt { get; set; }
269285
}
270286
}

src/Storage/Storage.Management/Storage.Management.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<Compile Remove="File\UpdateAzAzStorageFileServiceProperty.cs" />
2020
<Compile Remove="Models\PSFileServiceProperties.cs" />
2121
<Compile Remove="StorageAccount\InvokeAzureStorageAccountHierarchicalNamespaceUpgrade.cs" />
22-
<Compile Remove="StorageAccount\InvokeAzureStorageAccountFailover.cs" />
2322
</ItemGroup>
2423
<ItemGroup>
2524
<!-- <PackageReference Include="Azure.Core" Version="1.24.0" /> -->

src/Storage/Storage.Management/StorageAccount/GetAzureStorageBlobInventoryPolicy.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
using Microsoft.Azure.Commands.Management.Storage.Models;
1616
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1717
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
18-
using Microsoft.Azure.Management.Storage;
19-
using Microsoft.Azure.Management.Storage.Models;
2018
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2119
using System.Management.Automation;
20+
using Track2 = Azure.ResourceManager.Storage;
2221

2322
namespace Microsoft.Azure.Commands.Management.Storage
2423
{
@@ -95,9 +94,8 @@ public override void ExecuteCmdlet()
9594
break;
9695
}
9796

98-
BlobInventoryPolicy policy = this.StorageClient.BlobInventoryPolicies.Get(
99-
this.ResourceGroupName,
100-
this.StorageAccountName);
97+
Track2.BlobInventoryPolicyResource policy =
98+
this.StorageClientTrack2.GetBlobInventoryPolicyResource(this.ResourceGroupName, this.StorageAccountName, "default").Get();
10199

102100
WriteObject(new PSBlobInventoryPolicy(policy, this.ResourceGroupName, this.StorageAccountName), true);
103101
}

src/Storage/Storage.Management/StorageAccount/InvokeAzureStorageAccountFailover.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections;
16-
using System.Collections.Generic;
17-
using System.Management.Automation;
18-
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
19-
using Microsoft.Azure.Management.Storage;
20-
using Microsoft.Azure.Management.Storage.Models;
21-
using StorageModels = Microsoft.Azure.Management.Storage.Models;
2215
using Microsoft.Azure.Commands.Management.Storage.Models;
2316
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
17+
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
2418
using System;
19+
using System.Collections;
20+
using System.Collections.Generic;
21+
using System.Management.Automation;
2522
using System.Text;
2623

2724
namespace Microsoft.Azure.Commands.Management.Storage
@@ -89,7 +86,6 @@ public override void ExecuteCmdlet()
8986
shouldContinuePrompt.AppendLine(" 2. After the failover, your storage account type will be converted to locally redundant storage (LRS). You can convert your account to use geo-redundant storage (GRS).");
9087
shouldContinuePrompt.AppendLine(" 3. Once you re-enable GRS for your storage account, Microsoft will replicate data to your new secondary region. Replication time is dependent on the amount of data to replicate. Please note that there are bandwidth charges for the bootstrap. Please refer to doc: https://azure.microsoft.com/en-us/pricing/details/bandwidth/");
9188

92-
9389
if (this.force || ShouldContinue(shouldContinuePrompt.ToString(), ""))
9490
{
9591
if (ParameterSetName == AccountObjectParameterSet)
@@ -98,11 +94,8 @@ public override void ExecuteCmdlet()
9894
this.Name = InputObject.StorageAccountName;
9995
}
10096

101-
this.StorageClient.StorageAccounts.Failover(
102-
this.ResourceGroupName,
103-
this.Name);
104-
105-
var storageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
97+
this.StorageClientTrack2.GetStorageAccount(this.ResourceGroupName, this.Name).Failover(global::Azure.WaitUntil.Completed);
98+
var storageAccount = this.StorageClientTrack2.GetStorageAccount(this.ResourceGroupName, this.Name).Get();
10699

107100
WriteStorageAccount(storageAccount);
108101
}

src/Storage/Storage.Management/StorageAccount/NewAzureStorageBlobInventoryPolicyRule.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414

1515
using Microsoft.Azure.Commands.Management.Storage.Models;
1616
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
17-
using Microsoft.Azure.Management.Storage;
18-
using Microsoft.Azure.Management.Storage.Models;
1917
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2018
using System.Collections.Generic;
2119
using System.Management.Automation;
2220
using System.Reflection;
23-
using StorageModels = Microsoft.Azure.Management.Storage.Models;
21+
2422

2523
namespace Microsoft.Azure.Commands.Management.Storage
2624
{

src/Storage/Storage.Management/StorageAccount/RemoveAzureStorageBlobInventoryPolicy.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
using Microsoft.Azure.Commands.Management.Storage.Models;
1616
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
1717
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
18-
using Microsoft.Azure.Management.Storage;
19-
using Microsoft.Azure.Management.Storage.Models;
2018
using System.Management.Automation;
19+
using Azure;
2120

2221
namespace Microsoft.Azure.Commands.Management.Storage
2322
{
@@ -115,10 +114,7 @@ public override void ExecuteCmdlet()
115114
// For AccountNameParameterSet, the ResourceGroupName and StorageAccountName can get from input directly
116115
break;
117116
}
118-
119-
this.StorageClient.BlobInventoryPolicies.Delete(
120-
this.ResourceGroupName,
121-
this.StorageAccountName);
117+
this.StorageClientTrack2.GetBlobInventoryPolicyResource(this.ResourceGroupName, this.StorageAccountName, "default").Delete(WaitUntil.Completed);
122118

123119
if (PassThru.IsPresent)
124120
{

0 commit comments

Comments
 (0)