-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBulkOperationModels.cs
More file actions
618 lines (543 loc) · 19.6 KB
/
BulkOperationModels.cs
File metadata and controls
618 lines (543 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Contentstack.Management.Core.Models
{
/// <summary>
/// Represents details for bulk publish/unpublish operations.
/// </summary>
public class BulkPublishDetails
{
/// <summary>
/// Gets or sets the list of entries to publish/unpublish.
/// </summary>
[JsonProperty(propertyName: "entries")]
public List<BulkPublishEntry> Entries { get; set; }
/// <summary>
/// Gets or sets the list of assets to publish/unpublish.
/// </summary>
[JsonProperty(propertyName: "assets")]
public List<BulkPublishAsset> Assets { get; set; }
/// <summary>
/// Gets or sets the list of locales.
/// </summary>
[JsonProperty(propertyName: "locales")]
public List<string> Locales { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the list of environments.
/// </summary>
[JsonProperty(propertyName: "environments")]
public List<string> Environments { get; set; } = new List<string>();
/// <summary>
/// Gets or sets the rules for the bulk operation.
/// </summary>
[JsonProperty(propertyName: "rules")]
public BulkPublishRules Rules { get; set; }
/// <summary>
/// Gets or sets the scheduled time for the operation.
/// </summary>
[JsonProperty(propertyName: "scheduled_at")]
public string ScheduledAt { get; set; }
/// <summary>
/// Gets or sets whether to publish with reference.
/// </summary>
[JsonProperty(propertyName: "publish_with_reference")]
public bool PublishWithReference { get; set; }
/// <summary>
/// Determines whether to serialize the Entries property.
/// </summary>
/// <returns>True if Entries should be serialized, false otherwise.</returns>
public bool ShouldSerializeEntries()
{
return Entries != null && Entries.Count > 0;
}
/// <summary>
/// Determines whether to serialize the Assets property.
/// </summary>
/// <returns>True if Assets should be serialized, false otherwise.</returns>
public bool ShouldSerializeAssets()
{
return Assets != null && Assets.Count > 0;
}
}
/// <summary>
/// Represents an entry for bulk publish/unpublish operations.
/// </summary>
public class BulkPublishEntry
{
/// <summary>
/// Gets or sets the entry UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the content type.
/// </summary>
[JsonProperty(propertyName: "content_type")]
public string ContentType { get; set; }
/// <summary>
/// Gets or sets the version number.
/// </summary>
[JsonProperty(propertyName: "version")]
public int Version { get; set; }
/// <summary>
/// Gets or sets the locale.
/// </summary>
[JsonProperty(propertyName: "locale")]
public string Locale { get; set; }
}
/// <summary>
/// Represents rules for bulk publish operations.
/// </summary>
public class BulkPublishRules
{
/// <summary>
/// Gets or sets the approvals setting.
/// </summary>
[JsonProperty(propertyName: "approvals")]
public string Approvals { get; set; }
}
/// <summary>
/// Represents an asset for bulk publish/unpublish operations.
/// </summary>
public class BulkPublishAsset
{
/// <summary>
/// Gets or sets the asset UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
}
/// <summary>
/// Represents details for bulk delete operations.
/// </summary>
public class BulkDeleteDetails
{
/// <summary>
/// Gets or sets the list of entries to delete.
/// </summary>
[JsonProperty(propertyName: "entries")]
public List<BulkDeleteEntry> Entries { get; set; }
/// <summary>
/// Gets or sets the list of assets to delete.
/// </summary>
[JsonProperty(propertyName: "assets")]
public List<BulkDeleteAsset> Assets { get; set; }
/// <summary>
/// Determines whether to serialize the Entries property.
/// </summary>
/// <returns>True if Entries should be serialized, false otherwise.</returns>
public bool ShouldSerializeEntries()
{
return Entries != null && Entries.Count > 0;
}
/// <summary>
/// Determines whether to serialize the Assets property.
/// </summary>
/// <returns>True if Assets should be serialized, false otherwise.</returns>
public bool ShouldSerializeAssets()
{
return Assets != null && Assets.Count > 0;
}
}
/// <summary>
/// Represents an entry for bulk delete operations.
/// </summary>
public class BulkDeleteEntry
{
/// <summary>
/// Gets or sets the entry UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the content type.
/// </summary>
[JsonProperty(propertyName: "content_type")]
public string ContentType { get; set; }
/// <summary>
/// Gets or sets the locale.
/// </summary>
[JsonProperty(propertyName: "locale")]
public string Locale { get; set; }
}
/// <summary>
/// Represents an asset for bulk delete operations.
/// </summary>
public class BulkDeleteAsset
{
/// <summary>
/// Gets or sets the asset UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
}
/// <summary>
/// Represents the body for bulk workflow update operations.
/// </summary>
public class BulkWorkflowUpdateBody
{
/// <summary>
/// Gets or sets the list of entries to update.
/// </summary>
[JsonProperty(propertyName: "entries")]
public List<BulkWorkflowEntry> Entries { get; set; }
/// <summary>
/// Gets or sets the workflow stage information.
/// </summary>
[JsonProperty(propertyName: "workflow")]
public BulkWorkflowStage Workflow { get; set; }
/// <summary>
/// Determines whether to serialize the Entries property.
/// </summary>
/// <returns>True if Entries should be serialized, false otherwise.</returns>
public bool ShouldSerializeEntries()
{
return Entries != null && Entries.Count > 0;
}
}
/// <summary>
/// Represents an entry for bulk workflow update operations.
/// </summary>
public class BulkWorkflowEntry
{
/// <summary>
/// Gets or sets the entry UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the content type.
/// </summary>
[JsonProperty(propertyName: "content_type")]
public string ContentType { get; set; }
/// <summary>
/// Gets or sets the locale.
/// </summary>
[JsonProperty(propertyName: "locale")]
public string Locale { get; set; }
}
/// <summary>
/// Represents workflow stage information for bulk operations.
/// </summary>
public class BulkWorkflowStage
{
/// <summary>
/// Gets or sets the workflow stage UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the comment.
/// </summary>
[JsonProperty(propertyName: "comment")]
public string Comment { get; set; }
/// <summary>
/// Gets or sets the due date.
/// </summary>
[JsonProperty(propertyName: "due_date")]
public string DueDate { get; set; }
/// <summary>
/// Gets or sets whether to notify.
/// </summary>
[JsonProperty(propertyName: "notify")]
public bool Notify { get; set; }
/// <summary>
/// Gets or sets the list of assigned users.
/// </summary>
[JsonProperty(propertyName: "assigned_to")]
public List<BulkWorkflowUser> AssignedTo { get; set; }
/// <summary>
/// Gets or sets the list of assigned roles.
/// </summary>
[JsonProperty(propertyName: "assigned_by_roles")]
public List<BulkWorkflowRole> AssignedByRoles { get; set; }
/// <summary>
/// Determines whether to serialize the AssignedTo property.
/// </summary>
/// <returns>True if AssignedTo should be serialized, false otherwise.</returns>
public bool ShouldSerializeAssignedTo()
{
return AssignedTo != null && AssignedTo.Count > 0;
}
/// <summary>
/// Determines whether to serialize the AssignedByRoles property.
/// </summary>
/// <returns>True if AssignedByRoles should be serialized, false otherwise.</returns>
public bool ShouldSerializeAssignedByRoles()
{
return AssignedByRoles != null && AssignedByRoles.Count > 0;
}
}
/// <summary>
/// Represents a user assigned to a workflow stage.
/// </summary>
public class BulkWorkflowUser
{
/// <summary>
/// Gets or sets the user UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the user name.
/// </summary>
[JsonProperty(propertyName: "name")]
public string Name { get; set; }
/// <summary>
/// Gets or sets the user email.
/// </summary>
[JsonProperty(propertyName: "email")]
public string Email { get; set; }
}
/// <summary>
/// Represents a role assigned to a workflow stage.
/// </summary>
public class BulkWorkflowRole
{
/// <summary>
/// Gets or sets the role UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the role name.
/// </summary>
[JsonProperty(propertyName: "name")]
public string Name { get; set; }
}
/// <summary>
/// Represents data for bulk add/update items operations.
/// Enhanced to support both simple adding to release and complex release deployment operations.
/// </summary>
public class BulkAddItemsData
{
/// <summary>
/// Gets or sets the list of items to add/update.
/// </summary>
[JsonProperty(propertyName: "items")]
public List<BulkAddItem> Items { get; set; }
/// <summary>
/// Gets or sets the release UID for deployment operations.
/// When specified, this enables release deployment mode (like JavaScript SDK).
/// </summary>
[JsonProperty(propertyName: "release")]
public string Release { get; set; }
/// <summary>
/// Gets or sets the action to perform during deployment (publish, unpublish, etc.).
/// Only used when Release is specified.
/// </summary>
[JsonProperty(propertyName: "action")]
public string Action { get; set; }
/// <summary>
/// Gets or sets the list of locales for deployment.
/// Only used when Release is specified.
/// </summary>
[JsonProperty(propertyName: "locale")]
public List<string> Locale { get; set; }
/// <summary>
/// Gets or sets the reference flag for deployment.
/// Only used when Release is specified.
/// </summary>
[JsonProperty(propertyName: "reference")]
public bool? Reference { get; set; }
/// <summary>
/// Determines whether to serialize the Items property.
/// </summary>
/// <returns>True if Items should be serialized, false otherwise.</returns>
public bool ShouldSerializeItems()
{
return Items != null && Items.Count > 0;
}
/// <summary>
/// Determines whether to serialize the Release property.
/// </summary>
/// <returns>True if Release should be serialized, false otherwise.</returns>
public bool ShouldSerializeRelease()
{
return !string.IsNullOrEmpty(Release);
}
/// <summary>
/// Determines whether to serialize the Action property.
/// </summary>
/// <returns>True if Action should be serialized, false otherwise.</returns>
public bool ShouldSerializeAction()
{
return !string.IsNullOrEmpty(Action);
}
/// <summary>
/// Determines whether to serialize the Locale property.
/// </summary>
/// <returns>True if Locale should be serialized, false otherwise.</returns>
public bool ShouldSerializeLocale()
{
return Locale != null && Locale.Count > 0;
}
/// <summary>
/// Determines whether to serialize the Reference property.
/// </summary>
/// <returns>True if Reference should be serialized, false otherwise.</returns>
public bool ShouldSerializeReference()
{
return Reference.HasValue;
}
/// <summary>
/// Gets a value indicating whether this instance is configured for release deployment mode.
/// </summary>
/// <returns>True if this is a release deployment operation, false if simple add operation.</returns>
public bool IsReleaseDeploymentMode()
{
return !string.IsNullOrEmpty(Release) && !string.IsNullOrEmpty(Action);
}
}
/// <summary>
/// Represents an item for bulk add/update operations.
/// Enhanced to support both simple and complex release deployment properties.
/// </summary>
public class BulkAddItem
{
/// <summary>
/// Gets or sets the item UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the content type.
/// </summary>
[JsonProperty(propertyName: "content_type")]
public string ContentType { get; set; }
/// <summary>
/// Gets or sets the content type UID for release deployment mode.
/// This is an alias for ContentType with a different JSON property name.
/// </summary>
[JsonProperty(propertyName: "content_type_uid")]
public string ContentTypeUid { get; set; }
/// <summary>
/// Gets or sets the version number for release deployment mode.
/// Only used in enhanced release deployment operations.
/// </summary>
[JsonProperty(propertyName: "version")]
public int? Version { get; set; }
/// <summary>
/// Gets or sets the locale for release deployment mode.
/// Only used in enhanced release deployment operations.
/// </summary>
[JsonProperty(propertyName: "locale")]
public string Locale { get; set; }
/// <summary>
/// Gets or sets the title for release deployment mode.
/// Only used in enhanced release deployment operations.
/// </summary>
[JsonProperty(propertyName: "title")]
public string Title { get; set; }
/// <summary>
/// Determines whether to serialize the ContentTypeUid property.
/// </summary>
/// <returns>True if ContentTypeUid should be serialized, false otherwise.</returns>
public bool ShouldSerializeContentTypeUid()
{
return !string.IsNullOrEmpty(ContentTypeUid);
}
/// <summary>
/// Determines whether to serialize the Version property.
/// </summary>
/// <returns>True if Version should be serialized, false otherwise.</returns>
public bool ShouldSerializeVersion()
{
return Version.HasValue;
}
/// <summary>
/// Determines whether to serialize the Locale property.
/// </summary>
/// <returns>True if Locale should be serialized, false otherwise.</returns>
public bool ShouldSerializeLocale()
{
return !string.IsNullOrEmpty(Locale);
}
/// <summary>
/// Determines whether to serialize the Title property.
/// </summary>
/// <returns>True if Title should be serialized, false otherwise.</returns>
public bool ShouldSerializeTitle()
{
return !string.IsNullOrEmpty(Title);
}
}
/// <summary>
/// Represents data for bulk release items operations with complete request body structure.
/// </summary>
public class BulkReleaseItemsData
{
/// <summary>
/// Gets or sets the release UID.
/// </summary>
[JsonProperty(propertyName: "release")]
public string Release { get; set; }
/// <summary>
/// Gets or sets the action to perform (publish, unpublish, etc.).
/// </summary>
[JsonProperty(propertyName: "action")]
public string Action { get; set; }
/// <summary>
/// Gets or sets the list of locales.
/// </summary>
[JsonProperty(propertyName: "locale")]
public List<string> Locale { get; set; }
/// <summary>
/// Gets or sets the reference flag.
/// </summary>
[JsonProperty(propertyName: "reference")]
public bool Reference { get; set; }
/// <summary>
/// Gets or sets the list of items to process.
/// </summary>
[JsonProperty(propertyName: "items")]
public List<BulkReleaseItem> Items { get; set; }
/// <summary>
/// Determines whether to serialize the Locale property.
/// </summary>
/// <returns>True if Locale should be serialized, false otherwise.</returns>
public bool ShouldSerializeLocale()
{
return Locale != null && Locale.Count > 0;
}
/// <summary>
/// Determines whether to serialize the Items property.
/// </summary>
/// <returns>True if Items should be serialized, false otherwise.</returns>
public bool ShouldSerializeItems()
{
return Items != null && Items.Count > 0;
}
}
/// <summary>
/// Represents an item for bulk release operations with enhanced properties.
/// </summary>
public class BulkReleaseItem
{
/// <summary>
/// Gets or sets the content type UID.
/// </summary>
[JsonProperty(propertyName: "content_type_uid")]
public string ContentTypeUid { get; set; }
/// <summary>
/// Gets or sets the item UID.
/// </summary>
[JsonProperty(propertyName: "uid")]
public string Uid { get; set; }
/// <summary>
/// Gets or sets the version number.
/// </summary>
[JsonProperty(propertyName: "version")]
public int Version { get; set; }
/// <summary>
/// Gets or sets the locale.
/// </summary>
[JsonProperty(propertyName: "locale")]
public string Locale { get; set; }
/// <summary>
/// Gets or sets the title.
/// </summary>
[JsonProperty(propertyName: "title")]
public string Title { get; set; }
}
}