12
12
// limitations under the License.
13
13
// ----------------------------------------------------------------------------------
14
14
15
+ using Track2 = Azure . ResourceManager . Storage ;
16
+ using Track2Models = Azure . ResourceManager . Storage . Models ;
15
17
using Microsoft . Azure . Management . Storage . Models ;
16
18
using Microsoft . WindowsAzure . Commands . Common . Attributes ;
17
19
using System ;
@@ -27,23 +29,21 @@ public class PSBlobInventoryPolicy
27
29
public PSBlobInventoryPolicy ( )
28
30
{ }
29
31
30
- public PSBlobInventoryPolicy ( BlobInventoryPolicy policy , string ResourceGroupName , string StorageAccountName )
32
+ public PSBlobInventoryPolicy ( Track2 . BlobInventoryPolicyResource policy , string resourceGroupName , string storageAccountName )
31
33
{
32
- this . ResourceGroupName = ResourceGroupName ;
33
- this . StorageAccountName = StorageAccountName ;
34
+ this . ResourceGroupName = resourceGroupName ;
35
+ this . StorageAccountName = storageAccountName ;
34
36
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 ;
39
42
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 )
44
44
{
45
45
List < PSBlobInventoryPolicyRule > psRules = new List < PSBlobInventoryPolicyRule > ( ) ;
46
- foreach ( BlobInventoryPolicyRule rule in policy . Policy . Rules )
46
+ foreach ( Track2Models . BlobInventoryPolicyRule rule in policy . Data . Policy . Rules )
47
47
{
48
48
psRules . Add ( new PSBlobInventoryPolicyRule ( rule ) ) ;
49
49
}
@@ -55,32 +55,29 @@ public PSBlobInventoryPolicy(BlobInventoryPolicy policy, string ResourceGroupNam
55
55
}
56
56
}
57
57
58
- public BlobInventoryPolicy ParseBlobInventoryPolicy ( )
58
+
59
+ public Track2 . BlobInventoryPolicyData ParseBlobInventoryPolicy ( )
59
60
{
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 ) ;
61
67
62
- BlobInventoryPolicySchema policySchema = new BlobInventoryPolicySchema ( )
68
+ Track2 . BlobInventoryPolicyData data = new Track2 . BlobInventoryPolicyData
63
69
{
64
- Enabled = this . Enabled ,
65
- //Destination = this.Destination,
66
- Rules = invRules
70
+ Policy = policySchema ,
67
71
} ;
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 ;
76
73
}
77
74
78
- public static List < BlobInventoryPolicyRule > ParseBlobInventoryPolicyRules ( PSBlobInventoryPolicyRule [ ] rules )
75
+ public static List < Track2Models . BlobInventoryPolicyRule > ParseBlobInventoryPolicyRules ( PSBlobInventoryPolicyRule [ ] rules )
79
76
{
80
- List < BlobInventoryPolicyRule > invRules = null ;
77
+ List < Track2Models . BlobInventoryPolicyRule > invRules = null ;
81
78
if ( rules != null )
82
79
{
83
- invRules = new List < BlobInventoryPolicyRule > ( ) ;
80
+ invRules = new List < Track2Models . BlobInventoryPolicyRule > ( ) ;
84
81
foreach ( PSBlobInventoryPolicyRule rule in rules )
85
82
{
86
83
invRules . Add ( rule . ParseBlobInventoryPolicyRule ( ) ) ;
@@ -99,7 +96,7 @@ public static List<BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlob
99
96
[ Ps1Xml ( Label = "Type" , Target = ViewControl . List , Position = 2 ) ]
100
97
public string Type { get ; set ; }
101
98
[ Ps1Xml ( Label = "LastModifiedTime" , Target = ViewControl . List , Position = 4 ) ]
102
- public DateTime ? LastModifiedTime { get ; set ; }
99
+ public DateTimeOffset ? LastModifiedTime { get ; set ; }
103
100
104
101
//public PSBlobInventoryPolicySchema Policy { get; set; }
105
102
@@ -108,7 +105,6 @@ public static List<BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlob
108
105
[ Ps1Xml ( Label = "Rules" , Target = ViewControl . List , Position = 7 ) ]
109
106
public PSBlobInventoryPolicyRule [ ] Rules { get ; set ; }
110
107
public PSSystemData SystemData { get ; set ; }
111
- public string Destination { get ; private set ; }
112
108
}
113
109
114
110
/// <summary>
@@ -117,23 +113,25 @@ public static List<BlobInventoryPolicyRule> ParseBlobInventoryPolicyRules(PSBlob
117
113
public class PSBlobInventoryPolicyRule
118
114
{
119
115
public PSBlobInventoryPolicyRule ( ) { }
120
- public PSBlobInventoryPolicyRule ( BlobInventoryPolicyRule rule )
116
+ public PSBlobInventoryPolicyRule ( Track2Models . BlobInventoryPolicyRule rule )
121
117
{
122
118
this . Enabled = rule . Enabled ;
123
119
this . Name = rule . Name ;
124
120
this . Destination = rule . Destination ;
125
121
this . Definition = rule . Definition is null ? null : new PSBlobInventoryPolicyDefinition ( rule . Definition ) ;
126
122
}
127
123
128
- public BlobInventoryPolicyRule ParseBlobInventoryPolicyRule ( )
124
+ public Track2Models . BlobInventoryPolicyRule ParseBlobInventoryPolicyRule ( )
129
125
{
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 ;
137
135
}
138
136
139
137
public bool Enabled { get ; set ; }
@@ -152,20 +150,29 @@ public class PSBlobInventoryPolicyDefinition
152
150
{
153
151
public PSBlobInventoryPolicyDefinition ( ) { }
154
152
155
- public PSBlobInventoryPolicyDefinition ( BlobInventoryPolicyDefinition Definition )
153
+ public PSBlobInventoryPolicyDefinition ( Track2Models . BlobInventoryPolicyDefinition Definition )
156
154
{
157
155
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 ( ) ;
161
159
this . SchemaFields = Definition . SchemaFields is null ? null : ( ( List < string > ) Definition . SchemaFields ) . ToArray ( ) ;
162
160
}
163
161
164
- public BlobInventoryPolicyDefinition parseBlobInventoryPolicyDefinition ( )
162
+ public Track2Models . BlobInventoryPolicyDefinition parseBlobInventoryPolicyDefinition ( )
165
163
{
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 ;
169
176
}
170
177
171
178
public PSBlobInventoryPolicyFilter Filters { get ; set ; }
@@ -213,23 +220,37 @@ public class PSBlobInventoryPolicyFilter
213
220
{
214
221
public PSBlobInventoryPolicyFilter ( ) { }
215
222
216
- public PSBlobInventoryPolicyFilter ( BlobInventoryPolicyFilter filters )
223
+ public PSBlobInventoryPolicyFilter ( Track2Models . BlobInventoryPolicyFilter filters )
217
224
{
218
225
this . PrefixMatch = PSManagementPolicyRuleFilter . StringListToArray ( filters . PrefixMatch ) ;
219
226
this . BlobTypes = PSManagementPolicyRuleFilter . StringListToArray ( filters . BlobTypes ) ;
220
227
this . IncludeBlobVersions = filters . IncludeBlobVersions ;
221
228
this . IncludeSnapshots = filters . IncludeSnapshots ;
222
229
}
223
230
224
- public BlobInventoryPolicyFilter ParseBlobInventoryPolicyFilter ( )
231
+ public Track2Models . BlobInventoryPolicyFilter ParseBlobInventoryPolicyFilter ( )
225
232
{
226
- return new BlobInventoryPolicyFilter ( )
233
+ Track2Models . BlobInventoryPolicyFilter policyFilter = new Track2Models . BlobInventoryPolicyFilter ( )
227
234
{
228
- PrefixMatch = PSManagementPolicyRuleFilter . StringArrayToList ( this . PrefixMatch ) ,
229
- BlobTypes = PSManagementPolicyRuleFilter . StringArrayToList ( this . BlobTypes ) ,
230
235
IncludeSnapshots = this . IncludeSnapshots ,
231
236
IncludeBlobVersions = this . IncludeBlobVersions
232
237
} ;
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 ;
233
254
}
234
255
235
256
public string [ ] PrefixMatch { get ; set ; }
@@ -245,26 +266,21 @@ public class PSSystemData
245
266
{
246
267
public PSSystemData ( ) { }
247
268
248
- public PSSystemData ( SystemData SystemData )
269
+ public PSSystemData ( global :: Azure . ResourceManager . Models . SystemData SystemData )
249
270
{
250
271
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 ;
253
274
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 ;
261
277
}
262
278
263
279
public string CreatedBy { get ; set ; }
264
280
public string CreatedByType { get ; set ; }
265
- public DateTime ? CreatedAt { get ; set ; }
281
+ public DateTimeOffset ? CreatedAt { get ; set ; }
266
282
public string LastModifiedBy { get ; set ; }
267
283
public string LastModifiedByType { get ; set ; }
268
- public DateTime ? LastModifiedAt { get ; set ; }
284
+ public DateTimeOffset ? LastModifiedAt { get ; set ; }
269
285
}
270
286
}
0 commit comments