-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathBackupArchive.cs
More file actions
109 lines (93 loc) · 3.53 KB
/
BackupArchive.cs
File metadata and controls
109 lines (93 loc) · 3.53 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
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using Appwrite.Enums;
using Appwrite.Extensions;
namespace Appwrite.Models
{
public class BackupArchive
{
[JsonPropertyName("$id")]
public string Id { get; private set; }
[JsonPropertyName("$createdAt")]
public string CreatedAt { get; private set; }
[JsonPropertyName("$updatedAt")]
public string UpdatedAt { get; private set; }
[JsonPropertyName("policyId")]
public string PolicyId { get; private set; }
[JsonPropertyName("size")]
public long Size { get; private set; }
[JsonPropertyName("status")]
public string Status { get; private set; }
[JsonPropertyName("startedAt")]
public string StartedAt { get; private set; }
[JsonPropertyName("migrationId")]
public string MigrationId { get; private set; }
[JsonPropertyName("services")]
public List<string> Services { get; private set; }
[JsonPropertyName("resources")]
public List<string> Resources { get; private set; }
[JsonPropertyName("resourceId")]
public string? ResourceId { get; private set; }
[JsonPropertyName("resourceType")]
public string? ResourceType { get; private set; }
public BackupArchive(
string id,
string createdAt,
string updatedAt,
string policyId,
long size,
string status,
string startedAt,
string migrationId,
List<string> services,
List<string> resources,
string? resourceId,
string? resourceType
) {
Id = id;
CreatedAt = createdAt;
UpdatedAt = updatedAt;
PolicyId = policyId;
Size = size;
Status = status;
StartedAt = startedAt;
MigrationId = migrationId;
Services = services;
Resources = resources;
ResourceId = resourceId;
ResourceType = resourceType;
}
public static BackupArchive From(Dictionary<string, object> map) => new BackupArchive(
id: map["$id"].ToString(),
createdAt: map["$createdAt"].ToString(),
updatedAt: map["$updatedAt"].ToString(),
policyId: map["policyId"].ToString(),
size: Convert.ToInt64(map["size"]),
status: map["status"].ToString(),
startedAt: map["startedAt"].ToString(),
migrationId: map["migrationId"].ToString(),
services: map["services"].ConvertToList<string>(),
resources: map["resources"].ConvertToList<string>(),
resourceId: map.TryGetValue("resourceId", out var resourceId) ? resourceId?.ToString() : null,
resourceType: map.TryGetValue("resourceType", out var resourceType) ? resourceType?.ToString() : null
);
public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
{
{ "$id", Id },
{ "$createdAt", CreatedAt },
{ "$updatedAt", UpdatedAt },
{ "policyId", PolicyId },
{ "size", Size },
{ "status", Status },
{ "startedAt", StartedAt },
{ "migrationId", MigrationId },
{ "services", Services },
{ "resources", Resources },
{ "resourceId", ResourceId },
{ "resourceType", ResourceType }
};
}
}