diff --git a/Appwrite/Appwrite.csproj b/Appwrite/Appwrite.csproj index 1cfdf35..c1f5130 100644 --- a/Appwrite/Appwrite.csproj +++ b/Appwrite/Appwrite.csproj @@ -2,11 +2,11 @@ netstandard2.0;net462 Appwrite - 0.24.0 + 0.24.1 Appwrite Team Appwrite Team - Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API + Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API icon.png README.md diff --git a/Appwrite/Client.cs b/Appwrite/Client.cs index 57f98e7..2f789b9 100644 --- a/Appwrite/Client.cs +++ b/Appwrite/Client.cs @@ -69,11 +69,11 @@ public Client( _headers = new Dictionary() { { "content-type", "application/json" }, - { "user-agent" , $"AppwriteDotNetSDK/0.24.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"}, + { "user-agent" , $"AppwriteDotNetSDK/0.24.1 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"}, { "x-sdk-name", ".NET" }, { "x-sdk-platform", "server" }, { "x-sdk-language", "dotnet" }, - { "x-sdk-version", "0.24.0"}, + { "x-sdk-version", "0.24.1"}, { "X-Appwrite-Response-Format", "1.8.0" } }; diff --git a/Appwrite/Enums/BuildRuntime.cs b/Appwrite/Enums/BuildRuntime.cs index c71e7d4..8d9a75c 100644 --- a/Appwrite/Enums/BuildRuntime.cs +++ b/Appwrite/Enums/BuildRuntime.cs @@ -33,9 +33,6 @@ public BuildRuntime(string value) public static BuildRuntime Python312 => new BuildRuntime("python-3.12"); public static BuildRuntime PythonMl311 => new BuildRuntime("python-ml-3.11"); public static BuildRuntime PythonMl312 => new BuildRuntime("python-ml-3.12"); - public static BuildRuntime Deno121 => new BuildRuntime("deno-1.21"); - public static BuildRuntime Deno124 => new BuildRuntime("deno-1.24"); - public static BuildRuntime Deno135 => new BuildRuntime("deno-1.35"); public static BuildRuntime Deno140 => new BuildRuntime("deno-1.40"); public static BuildRuntime Deno146 => new BuildRuntime("deno-1.46"); public static BuildRuntime Deno20 => new BuildRuntime("deno-2.0"); diff --git a/Appwrite/Enums/Name.cs b/Appwrite/Enums/Name.cs index 61a3352..e3f6df2 100644 --- a/Appwrite/Enums/Name.cs +++ b/Appwrite/Enums/Name.cs @@ -21,6 +21,7 @@ public Name(string value) public static Name V1Webhooks => new Name("v1-webhooks"); public static Name V1Certificates => new Name("v1-certificates"); public static Name V1Builds => new Name("v1-builds"); + public static Name V1Screenshots => new Name("v1-screenshots"); public static Name V1Messaging => new Name("v1-messaging"); public static Name V1Migrations => new Name("v1-migrations"); } diff --git a/Appwrite/Enums/OAuthProvider.cs b/Appwrite/Enums/OAuthProvider.cs index 6ca58b1..bac7ce7 100644 --- a/Appwrite/Enums/OAuthProvider.cs +++ b/Appwrite/Enums/OAuthProvider.cs @@ -50,6 +50,5 @@ public OAuthProvider(string value) public static OAuthProvider Yandex => new OAuthProvider("yandex"); public static OAuthProvider Zoho => new OAuthProvider("zoho"); public static OAuthProvider Zoom => new OAuthProvider("zoom"); - public static OAuthProvider Mock => new OAuthProvider("mock"); } } diff --git a/Appwrite/Enums/Output.cs b/Appwrite/Enums/Output.cs deleted file mode 100644 index 73cb1ef..0000000 --- a/Appwrite/Enums/Output.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace Appwrite.Enums -{ - public class Output : IEnum - { - public string Value { get; private set; } - - public Output(string value) - { - Value = value; - } - - public static Output Jpg => new Output("jpg"); - public static Output Jpeg => new Output("jpeg"); - public static Output Png => new Output("png"); - public static Output Webp => new Output("webp"); - public static Output Heic => new Output("heic"); - public static Output Avif => new Output("avif"); - public static Output Gif => new Output("gif"); - } -} diff --git a/Appwrite/Enums/Runtime.cs b/Appwrite/Enums/Runtime.cs index 3dc7451..4153d82 100644 --- a/Appwrite/Enums/Runtime.cs +++ b/Appwrite/Enums/Runtime.cs @@ -33,9 +33,6 @@ public Runtime(string value) public static Runtime Python312 => new Runtime("python-3.12"); public static Runtime PythonMl311 => new Runtime("python-ml-3.11"); public static Runtime PythonMl312 => new Runtime("python-ml-3.12"); - public static Runtime Deno121 => new Runtime("deno-1.21"); - public static Runtime Deno124 => new Runtime("deno-1.24"); - public static Runtime Deno135 => new Runtime("deno-1.35"); public static Runtime Deno140 => new Runtime("deno-1.40"); public static Runtime Deno146 => new Runtime("deno-1.46"); public static Runtime Deno20 => new Runtime("deno-2.0"); diff --git a/Appwrite/Models/BackupArchive.cs b/Appwrite/Models/BackupArchive.cs new file mode 100644 index 0000000..37d4e87 --- /dev/null +++ b/Appwrite/Models/BackupArchive.cs @@ -0,0 +1,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 Services { get; private set; } + + [JsonPropertyName("resources")] + public List 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 services, + List 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 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(), + resources: map["resources"].ConvertToList(), + resourceId: map.TryGetValue("resourceId", out var resourceId) ? resourceId?.ToString() : null, + resourceType: map.TryGetValue("resourceType", out var resourceType) ? resourceType?.ToString() : null + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "policyId", PolicyId }, + { "size", Size }, + { "status", Status }, + { "startedAt", StartedAt }, + { "migrationId", MigrationId }, + { "services", Services }, + { "resources", Resources }, + { "resourceId", ResourceId }, + { "resourceType", ResourceType } + }; + } +} diff --git a/Appwrite/Models/BackupArchiveList.cs b/Appwrite/Models/BackupArchiveList.cs new file mode 100644 index 0000000..6c1e0df --- /dev/null +++ b/Appwrite/Models/BackupArchiveList.cs @@ -0,0 +1,39 @@ + +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 BackupArchiveList + { + [JsonPropertyName("total")] + public long Total { get; private set; } + + [JsonPropertyName("archives")] + public List Archives { get; private set; } + + public BackupArchiveList( + long total, + List archives + ) { + Total = total; + Archives = archives; + } + + public static BackupArchiveList From(Dictionary map) => new BackupArchiveList( + total: Convert.ToInt64(map["total"]), + archives: map["archives"].ConvertToList>().Select(it => BackupArchive.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "archives", Archives.Select(it => it.ToMap()) } + }; + } +} diff --git a/Appwrite/Models/BackupPolicy.cs b/Appwrite/Models/BackupPolicy.cs new file mode 100644 index 0000000..7f1a5b2 --- /dev/null +++ b/Appwrite/Models/BackupPolicy.cs @@ -0,0 +1,102 @@ + +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 BackupPolicy + { + [JsonPropertyName("$id")] + public string Id { get; private set; } + + [JsonPropertyName("name")] + public string Name { get; private set; } + + [JsonPropertyName("$createdAt")] + public string CreatedAt { get; private set; } + + [JsonPropertyName("$updatedAt")] + public string UpdatedAt { get; private set; } + + [JsonPropertyName("services")] + public List Services { get; private set; } + + [JsonPropertyName("resources")] + public List Resources { get; private set; } + + [JsonPropertyName("resourceId")] + public string? ResourceId { get; private set; } + + [JsonPropertyName("resourceType")] + public string? ResourceType { get; private set; } + + [JsonPropertyName("retention")] + public long Retention { get; private set; } + + [JsonPropertyName("schedule")] + public string Schedule { get; private set; } + + [JsonPropertyName("enabled")] + public bool Enabled { get; private set; } + + public BackupPolicy( + string id, + string name, + string createdAt, + string updatedAt, + List services, + List resources, + string? resourceId, + string? resourceType, + long retention, + string schedule, + bool enabled + ) { + Id = id; + Name = name; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Services = services; + Resources = resources; + ResourceId = resourceId; + ResourceType = resourceType; + Retention = retention; + Schedule = schedule; + Enabled = enabled; + } + + public static BackupPolicy From(Dictionary map) => new BackupPolicy( + id: map["$id"].ToString(), + name: map["name"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + services: map["services"].ConvertToList(), + resources: map["resources"].ConvertToList(), + resourceId: map.TryGetValue("resourceId", out var resourceId) ? resourceId?.ToString() : null, + resourceType: map.TryGetValue("resourceType", out var resourceType) ? resourceType?.ToString() : null, + retention: Convert.ToInt64(map["retention"]), + schedule: map["schedule"].ToString(), + enabled: (bool)map["enabled"] + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "name", Name }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "services", Services }, + { "resources", Resources }, + { "resourceId", ResourceId }, + { "resourceType", ResourceType }, + { "retention", Retention }, + { "schedule", Schedule }, + { "enabled", Enabled } + }; + } +} diff --git a/Appwrite/Models/BackupPolicyList.cs b/Appwrite/Models/BackupPolicyList.cs new file mode 100644 index 0000000..414319b --- /dev/null +++ b/Appwrite/Models/BackupPolicyList.cs @@ -0,0 +1,39 @@ + +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 BackupPolicyList + { + [JsonPropertyName("total")] + public long Total { get; private set; } + + [JsonPropertyName("policies")] + public List Policies { get; private set; } + + public BackupPolicyList( + long total, + List policies + ) { + Total = total; + Policies = policies; + } + + public static BackupPolicyList From(Dictionary map) => new BackupPolicyList( + total: Convert.ToInt64(map["total"]), + policies: map["policies"].ConvertToList>().Select(it => BackupPolicy.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "policies", Policies.Select(it => it.ToMap()) } + }; + } +} diff --git a/Appwrite/Models/BackupRestoration.cs b/Appwrite/Models/BackupRestoration.cs new file mode 100644 index 0000000..ecf5d7a --- /dev/null +++ b/Appwrite/Models/BackupRestoration.cs @@ -0,0 +1,102 @@ + +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 BackupRestoration + { + [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("archiveId")] + public string ArchiveId { get; private set; } + + [JsonPropertyName("policyId")] + public string PolicyId { 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 Services { get; private set; } + + [JsonPropertyName("resources")] + public List Resources { get; private set; } + + [JsonPropertyName("options")] + public string Options { get; private set; } + + public BackupRestoration( + string id, + string createdAt, + string updatedAt, + string archiveId, + string policyId, + string status, + string startedAt, + string migrationId, + List services, + List resources, + string options + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + ArchiveId = archiveId; + PolicyId = policyId; + Status = status; + StartedAt = startedAt; + MigrationId = migrationId; + Services = services; + Resources = resources; + Options = options; + } + + public static BackupRestoration From(Dictionary map) => new BackupRestoration( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + archiveId: map["archiveId"].ToString(), + policyId: map["policyId"].ToString(), + status: map["status"].ToString(), + startedAt: map["startedAt"].ToString(), + migrationId: map["migrationId"].ToString(), + services: map["services"].ConvertToList(), + resources: map["resources"].ConvertToList(), + options: map["options"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "archiveId", ArchiveId }, + { "policyId", PolicyId }, + { "status", Status }, + { "startedAt", StartedAt }, + { "migrationId", MigrationId }, + { "services", Services }, + { "resources", Resources }, + { "options", Options } + }; + } +} diff --git a/Appwrite/Models/BackupRestorationList.cs b/Appwrite/Models/BackupRestorationList.cs new file mode 100644 index 0000000..51a304c --- /dev/null +++ b/Appwrite/Models/BackupRestorationList.cs @@ -0,0 +1,39 @@ + +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 BackupRestorationList + { + [JsonPropertyName("total")] + public long Total { get; private set; } + + [JsonPropertyName("restorations")] + public List Restorations { get; private set; } + + public BackupRestorationList( + long total, + List restorations + ) { + Total = total; + Restorations = restorations; + } + + public static BackupRestorationList From(Dictionary map) => new BackupRestorationList( + total: Convert.ToInt64(map["total"]), + restorations: map["restorations"].ConvertToList>().Select(it => BackupRestoration.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "restorations", Restorations.Select(it => it.ToMap()) } + }; + } +} diff --git a/Appwrite/Models/Bucket.cs b/Appwrite/Models/Bucket.cs index 79de11d..b5a3aa9 100644 --- a/Appwrite/Models/Bucket.cs +++ b/Appwrite/Models/Bucket.cs @@ -50,6 +50,9 @@ public class Bucket [JsonPropertyName("transformations")] public bool Transformations { get; private set; } + [JsonPropertyName("totalSize")] + public long TotalSize { get; private set; } + public Bucket( string id, string createdAt, @@ -63,7 +66,8 @@ public Bucket( string compression, bool encryption, bool antivirus, - bool transformations + bool transformations, + long totalSize ) { Id = id; CreatedAt = createdAt; @@ -78,6 +82,7 @@ bool transformations Encryption = encryption; Antivirus = antivirus; Transformations = transformations; + TotalSize = totalSize; } public static Bucket From(Dictionary map) => new Bucket( @@ -93,7 +98,8 @@ bool transformations compression: map["compression"].ToString(), encryption: (bool)map["encryption"], antivirus: (bool)map["antivirus"], - transformations: (bool)map["transformations"] + transformations: (bool)map["transformations"], + totalSize: Convert.ToInt64(map["totalSize"]) ); public Dictionary ToMap() => new Dictionary() @@ -110,7 +116,8 @@ bool transformations { "compression", Compression }, { "encryption", Encryption }, { "antivirus", Antivirus }, - { "transformations", Transformations } + { "transformations", Transformations }, + { "totalSize", TotalSize } }; } } diff --git a/Appwrite/Models/Database.cs b/Appwrite/Models/Database.cs index 5a980bf..7143316 100644 --- a/Appwrite/Models/Database.cs +++ b/Appwrite/Models/Database.cs @@ -29,13 +29,21 @@ public class Database [JsonPropertyName("type")] public DatabaseType Type { get; private set; } + [JsonPropertyName("policies")] + public List Policies { get; private set; } + + [JsonPropertyName("archives")] + public List Archives { get; private set; } + public Database( string id, string name, string createdAt, string updatedAt, bool enabled, - DatabaseType type + DatabaseType type, + List policies, + List archives ) { Id = id; Name = name; @@ -43,6 +51,8 @@ DatabaseType type UpdatedAt = updatedAt; Enabled = enabled; Type = type; + Policies = policies; + Archives = archives; } public static Database From(Dictionary map) => new Database( @@ -51,7 +61,9 @@ DatabaseType type createdAt: map["$createdAt"].ToString(), updatedAt: map["$updatedAt"].ToString(), enabled: (bool)map["enabled"], - type: new DatabaseType(map["type"].ToString()!) + type: new DatabaseType(map["type"].ToString()!), + policies: map["policies"].ConvertToList>().Select(it => Index.From(map: it)).ToList(), + archives: map["archives"].ConvertToList>().Select(it => Collection.From(map: it)).ToList() ); public Dictionary ToMap() => new Dictionary() @@ -61,7 +73,9 @@ DatabaseType type { "$createdAt", CreatedAt }, { "$updatedAt", UpdatedAt }, { "enabled", Enabled }, - { "type", Type.Value } + { "type", Type.Value }, + { "policies", Policies.Select(it => it.ToMap()) }, + { "archives", Archives.Select(it => it.ToMap()) } }; } } diff --git a/Appwrite/Models/EstimationDeleteOrganization.cs b/Appwrite/Models/EstimationDeleteOrganization.cs new file mode 100644 index 0000000..a2d1c29 --- /dev/null +++ b/Appwrite/Models/EstimationDeleteOrganization.cs @@ -0,0 +1,32 @@ + +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 EstimationDeleteOrganization + { + [JsonPropertyName("unpaidInvoices")] + public List UnpaidInvoices { get; private set; } + + public EstimationDeleteOrganization( + List unpaidInvoices + ) { + UnpaidInvoices = unpaidInvoices; + } + + public static EstimationDeleteOrganization From(Dictionary map) => new EstimationDeleteOrganization( + unpaidInvoices: map["unpaidInvoices"].ConvertToList>().Select(it => Invoice.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "unpaidInvoices", UnpaidInvoices.Select(it => it.ToMap()) } + }; + } +} diff --git a/Appwrite/Models/File.cs b/Appwrite/Models/File.cs index b0649f0..d992ed5 100644 --- a/Appwrite/Models/File.cs +++ b/Appwrite/Models/File.cs @@ -44,6 +44,12 @@ public class File [JsonPropertyName("chunksUploaded")] public long ChunksUploaded { get; private set; } + [JsonPropertyName("encryption")] + public bool Encryption { get; private set; } + + [JsonPropertyName("compression")] + public string Compression { get; private set; } + public File( string id, string bucketId, @@ -55,7 +61,9 @@ public File( string mimeType, long sizeOriginal, long chunksTotal, - long chunksUploaded + long chunksUploaded, + bool encryption, + string compression ) { Id = id; BucketId = bucketId; @@ -68,6 +76,8 @@ long chunksUploaded SizeOriginal = sizeOriginal; ChunksTotal = chunksTotal; ChunksUploaded = chunksUploaded; + Encryption = encryption; + Compression = compression; } public static File From(Dictionary map) => new File( @@ -81,7 +91,9 @@ long chunksUploaded mimeType: map["mimeType"].ToString(), sizeOriginal: Convert.ToInt64(map["sizeOriginal"]), chunksTotal: Convert.ToInt64(map["chunksTotal"]), - chunksUploaded: Convert.ToInt64(map["chunksUploaded"]) + chunksUploaded: Convert.ToInt64(map["chunksUploaded"]), + encryption: (bool)map["encryption"], + compression: map["compression"].ToString() ); public Dictionary ToMap() => new Dictionary() @@ -96,7 +108,9 @@ long chunksUploaded { "mimeType", MimeType }, { "sizeOriginal", SizeOriginal }, { "chunksTotal", ChunksTotal }, - { "chunksUploaded", ChunksUploaded } + { "chunksUploaded", ChunksUploaded }, + { "encryption", Encryption }, + { "compression", Compression } }; } } diff --git a/Appwrite/Models/Invoice.cs b/Appwrite/Models/Invoice.cs new file mode 100644 index 0000000..dc7ceae --- /dev/null +++ b/Appwrite/Models/Invoice.cs @@ -0,0 +1,179 @@ + +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 Invoice + { + [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("$permissions")] + public List Permissions { get; private set; } + + [JsonPropertyName("teamId")] + public string TeamId { get; private set; } + + [JsonPropertyName("aggregationId")] + public string AggregationId { get; private set; } + + [JsonPropertyName("plan")] + public string Plan { get; private set; } + + [JsonPropertyName("usage")] + public List Usage { get; private set; } + + [JsonPropertyName("amount")] + public double Amount { get; private set; } + + [JsonPropertyName("tax")] + public double Tax { get; private set; } + + [JsonPropertyName("taxAmount")] + public double TaxAmount { get; private set; } + + [JsonPropertyName("vat")] + public double Vat { get; private set; } + + [JsonPropertyName("vatAmount")] + public double VatAmount { get; private set; } + + [JsonPropertyName("grossAmount")] + public double GrossAmount { get; private set; } + + [JsonPropertyName("creditsUsed")] + public double CreditsUsed { get; private set; } + + [JsonPropertyName("currency")] + public string Currency { get; private set; } + + [JsonPropertyName("clientSecret")] + public string ClientSecret { get; private set; } + + [JsonPropertyName("status")] + public string Status { get; private set; } + + [JsonPropertyName("lastError")] + public string LastError { get; private set; } + + [JsonPropertyName("dueAt")] + public string DueAt { get; private set; } + + [JsonPropertyName("from")] + public string From { get; private set; } + + [JsonPropertyName("to")] + public string To { get; private set; } + + public Invoice( + string id, + string createdAt, + string updatedAt, + List permissions, + string teamId, + string aggregationId, + string plan, + List usage, + double amount, + double tax, + double taxAmount, + double vat, + double vatAmount, + double grossAmount, + double creditsUsed, + string currency, + string clientSecret, + string status, + string lastError, + string dueAt, + string xfrom, + string to + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Permissions = permissions; + TeamId = teamId; + AggregationId = aggregationId; + Plan = plan; + Usage = usage; + Amount = amount; + Tax = tax; + TaxAmount = taxAmount; + Vat = vat; + VatAmount = vatAmount; + GrossAmount = grossAmount; + CreditsUsed = creditsUsed; + Currency = currency; + ClientSecret = clientSecret; + Status = status; + LastError = lastError; + DueAt = dueAt; + From = xfrom; + To = to; + } + + public static Invoice From(Dictionary map) => new Invoice( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + permissions: map["$permissions"].ConvertToList(), + teamId: map["teamId"].ToString(), + aggregationId: map["aggregationId"].ToString(), + plan: map["plan"].ToString(), + usage: map["usage"].ConvertToList>().Select(it => UsageResources.From(map: it)).ToList(), + amount: Convert.ToDouble(map["amount"]), + tax: Convert.ToDouble(map["tax"]), + taxAmount: Convert.ToDouble(map["taxAmount"]), + vat: Convert.ToDouble(map["vat"]), + vatAmount: Convert.ToDouble(map["vatAmount"]), + grossAmount: Convert.ToDouble(map["grossAmount"]), + creditsUsed: Convert.ToDouble(map["creditsUsed"]), + currency: map["currency"].ToString(), + clientSecret: map["clientSecret"].ToString(), + status: map["status"].ToString(), + lastError: map["lastError"].ToString(), + dueAt: map["dueAt"].ToString(), + xfrom: map["from"].ToString(), + to: map["to"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "$permissions", Permissions }, + { "teamId", TeamId }, + { "aggregationId", AggregationId }, + { "plan", Plan }, + { "usage", Usage.Select(it => it.ToMap()) }, + { "amount", Amount }, + { "tax", Tax }, + { "taxAmount", TaxAmount }, + { "vat", Vat }, + { "vatAmount", VatAmount }, + { "grossAmount", GrossAmount }, + { "creditsUsed", CreditsUsed }, + { "currency", Currency }, + { "clientSecret", ClientSecret }, + { "status", Status }, + { "lastError", LastError }, + { "dueAt", DueAt }, + { "from", From }, + { "to", To } + }; + } +} diff --git a/Appwrite/Models/UsageResources.cs b/Appwrite/Models/UsageResources.cs new file mode 100644 index 0000000..61c36d0 --- /dev/null +++ b/Appwrite/Models/UsageResources.cs @@ -0,0 +1,67 @@ + +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 UsageResources + { + [JsonPropertyName("name")] + public string Name { get; private set; } + + [JsonPropertyName("value")] + public long Value { get; private set; } + + [JsonPropertyName("amount")] + public double Amount { get; private set; } + + [JsonPropertyName("rate")] + public double Rate { get; private set; } + + [JsonPropertyName("desc")] + public string Desc { get; private set; } + + [JsonPropertyName("resourceId")] + public string ResourceId { get; private set; } + + public UsageResources( + string name, + long xvalue, + double amount, + double rate, + string desc, + string resourceId + ) { + Name = name; + Value = xvalue; + Amount = amount; + Rate = rate; + Desc = desc; + ResourceId = resourceId; + } + + public static UsageResources From(Dictionary map) => new UsageResources( + name: map["name"].ToString(), + xvalue: Convert.ToInt64(map["value"]), + amount: Convert.ToDouble(map["amount"]), + rate: Convert.ToDouble(map["rate"]), + desc: map["desc"].ToString(), + resourceId: map["resourceId"].ToString() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "name", Name }, + { "value", Value }, + { "amount", Amount }, + { "rate", Rate }, + { "desc", Desc }, + { "resourceId", ResourceId } + }; + } +} diff --git a/Appwrite/Query.cs b/Appwrite/Query.cs index a4bb12c..8369336 100644 --- a/Appwrite/Query.cs +++ b/Appwrite/Query.cs @@ -4,7 +4,6 @@ using System.Text.Json; using System.Text.Json.Serialization; - namespace Appwrite { public class Query diff --git a/Appwrite/Services/Account.cs b/Appwrite/Services/Account.cs index 6954033..94a69e8 100644 --- a/Appwrite/Services/Account.cs +++ b/Appwrite/Services/Account.cs @@ -189,12 +189,13 @@ public Task DeleteIdentity(string identityId) /// frame. /// /// - public Task CreateJWT() + public Task CreateJWT(long? duration = null) { var apiPath = "/account/jwts"; var apiParameters = new Dictionary() { + { "duration", duration } }; var apiHeaders = new Dictionary() diff --git a/Appwrite/Services/Avatars.cs b/Appwrite/Services/Avatars.cs index b04836a..df94d9b 100644 --- a/Appwrite/Services/Avatars.cs +++ b/Appwrite/Services/Avatars.cs @@ -289,7 +289,7 @@ public Task GetQR(string text, long? size = null, long? margin = null, b /// dimensions are not specified, the default viewport size is 1280x720px. /// /// - public Task GetScreenshot(string url, object? headers = null, long? viewportWidth = null, long? viewportHeight = null, double? scale = null, Appwrite.Enums.Theme? theme = null, string? userAgent = null, bool? fullpage = null, string? locale = null, Appwrite.Enums.Timezone? timezone = null, double? latitude = null, double? longitude = null, double? accuracy = null, bool? touch = null, List? permissions = null, long? sleep = null, long? width = null, long? height = null, long? quality = null, Appwrite.Enums.Output? output = null) + public Task GetScreenshot(string url, object? headers = null, long? viewportWidth = null, long? viewportHeight = null, double? scale = null, Appwrite.Enums.Theme? theme = null, string? userAgent = null, bool? fullpage = null, string? locale = null, Appwrite.Enums.Timezone? timezone = null, double? latitude = null, double? longitude = null, double? accuracy = null, bool? touch = null, List? permissions = null, long? sleep = null, long? width = null, long? height = null, long? quality = null, Appwrite.Enums.ImageFormat? output = null) { var apiPath = "/avatars/screenshots"; diff --git a/Appwrite/Services/Backups.cs b/Appwrite/Services/Backups.cs new file mode 100644 index 0000000..69e9885 --- /dev/null +++ b/Appwrite/Services/Backups.cs @@ -0,0 +1,392 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; +using Appwrite.Enums; + +namespace Appwrite.Services +{ + public class Backups : Service + { + public Backups(Client client) : base(client) + { + } + + /// + /// List all archives for a project. + /// + /// + public Task ListArchives(List? queries = null) + { + var apiPath = "/backups/archives"; + + var apiParameters = new Dictionary() + { + { "queries", queries } + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.BackupArchiveList Convert(Dictionary it) => + Models.BackupArchiveList.From(map: it); + + return _client.Call( + method: "GET", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create a new archive asynchronously for a project. + /// + /// + public Task CreateArchive(List services, string? resourceId = null) + { + var apiPath = "/backups/archives"; + + var apiParameters = new Dictionary() + { + { "services", services }, + { "resourceId", resourceId } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.BackupArchive Convert(Dictionary it) => + Models.BackupArchive.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get a backup archive using it's ID. + /// + /// + public Task GetArchive(string archiveId) + { + var apiPath = "/backups/archives/{archiveId}" + .Replace("{archiveId}", archiveId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.BackupArchive Convert(Dictionary it) => + Models.BackupArchive.From(map: it); + + return _client.Call( + method: "GET", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete an existing archive for a project. + /// + /// + public Task DeleteArchive(string archiveId) + { + var apiPath = "/backups/archives/{archiveId}" + .Replace("{archiveId}", archiveId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + return _client.Call( + method: "DELETE", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// List all policies for a project. + /// + /// + public Task ListPolicies(List? queries = null) + { + var apiPath = "/backups/policies"; + + var apiParameters = new Dictionary() + { + { "queries", queries } + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.BackupPolicyList Convert(Dictionary it) => + Models.BackupPolicyList.From(map: it); + + return _client.Call( + method: "GET", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Create a new backup policy. + /// + /// + public Task CreatePolicy(string policyId, List services, long retention, string schedule, string? name = null, string? resourceId = null, bool? enabled = null) + { + var apiPath = "/backups/policies"; + + var apiParameters = new Dictionary() + { + { "policyId", policyId }, + { "name", name }, + { "services", services }, + { "resourceId", resourceId }, + { "enabled", enabled }, + { "retention", retention }, + { "schedule", schedule } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.BackupPolicy Convert(Dictionary it) => + Models.BackupPolicy.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get a backup policy using it's ID. + /// + /// + public Task GetPolicy(string policyId) + { + var apiPath = "/backups/policies/{policyId}" + .Replace("{policyId}", policyId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.BackupPolicy Convert(Dictionary it) => + Models.BackupPolicy.From(map: it); + + return _client.Call( + method: "GET", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Update an existing policy using it's ID. + /// + /// + public Task UpdatePolicy(string policyId, string? name = null, long? retention = null, string? schedule = null, bool? enabled = null) + { + var apiPath = "/backups/policies/{policyId}" + .Replace("{policyId}", policyId); + + var apiParameters = new Dictionary() + { + { "name", name }, + { "retention", retention }, + { "schedule", schedule }, + { "enabled", enabled } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.BackupPolicy Convert(Dictionary it) => + Models.BackupPolicy.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete a policy using it's ID. + /// + /// + public Task DeletePolicy(string policyId) + { + var apiPath = "/backups/policies/{policyId}" + .Replace("{policyId}", policyId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + return _client.Call( + method: "DELETE", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Create and trigger a new restoration for a backup on a project. + /// + /// + public Task CreateRestoration(string archiveId, List services, string? newResourceId = null, string? newResourceName = null) + { + var apiPath = "/backups/restoration"; + + var apiParameters = new Dictionary() + { + { "archiveId", archiveId }, + { "services", services }, + { "newResourceId", newResourceId }, + { "newResourceName", newResourceName } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.BackupRestoration Convert(Dictionary it) => + Models.BackupRestoration.From(map: it); + + return _client.Call( + method: "POST", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// List all backup restorations for a project. + /// + /// + public Task ListRestorations(List? queries = null) + { + var apiPath = "/backups/restorations"; + + var apiParameters = new Dictionary() + { + { "queries", queries } + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.BackupRestorationList Convert(Dictionary it) => + Models.BackupRestorationList.From(map: it); + + return _client.Call( + method: "GET", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Get the current status of a backup restoration. + /// + /// + public Task GetRestoration(string restorationId) + { + var apiPath = "/backups/restorations/{restorationId}" + .Replace("{restorationId}", restorationId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.BackupRestoration Convert(Dictionary it) => + Models.BackupRestoration.From(map: it); + + return _client.Call( + method: "GET", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +} diff --git a/Appwrite/Services/Databases.cs b/Appwrite/Services/Databases.cs index 4d8cab0..8f9ec94 100644 --- a/Appwrite/Services/Databases.cs +++ b/Appwrite/Services/Databases.cs @@ -1565,12 +1565,15 @@ public Task GetAttribute(string databaseId, string collectionId, string }; + static object Convert(Dictionary it) => + it; return _client.Call( method: "GET", path: apiPath, headers: apiHeaders, - parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); } @@ -1914,7 +1917,7 @@ static Models.Document Convert(Dictionary it) => /// /// [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.")] - public Task UpsertDocument(string databaseId, string collectionId, string documentId, object data, List? permissions = null, string? transactionId = null) + public Task UpsertDocument(string databaseId, string collectionId, string documentId, object? data = null, List? permissions = null, string? transactionId = null) { var apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .Replace("{databaseId}", databaseId) diff --git a/Appwrite/Services/Organizations.cs b/Appwrite/Services/Organizations.cs new file mode 100644 index 0000000..0e3f05b --- /dev/null +++ b/Appwrite/Services/Organizations.cs @@ -0,0 +1,77 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; +using Appwrite.Enums; + +namespace Appwrite.Services +{ + public class Organizations : Service + { + public Organizations(Client client) : base(client) + { + } + + /// + /// Delete an organization. + /// + /// + public Task Delete(string organizationId) + { + var apiPath = "/organizations/{organizationId}" + .Replace("{organizationId}", organizationId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + + return _client.Call( + method: "DELETE", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + + } + + /// + /// Get estimation for deleting an organization. + /// + /// + public Task EstimationDeleteOrganization(string organizationId) + { + var apiPath = "/organizations/{organizationId}/estimations/delete-organization" + .Replace("{organizationId}", organizationId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.EstimationDeleteOrganization Convert(Dictionary it) => + Models.EstimationDeleteOrganization.From(map: it); + + return _client.Call( + method: "PATCH", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + } +} diff --git a/Appwrite/Services/TablesDB.cs b/Appwrite/Services/TablesDB.cs index 85d78aa..c86d0a5 100644 --- a/Appwrite/Services/TablesDB.cs +++ b/Appwrite/Services/TablesDB.cs @@ -1527,12 +1527,15 @@ public Task GetColumn(string databaseId, string tableId, string key) }; + static object Convert(Dictionary it) => + it; return _client.Call( method: "GET", path: apiPath, headers: apiHeaders, - parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!); + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); } diff --git a/CHANGELOG.md b/CHANGELOG.md index 092bfc1..c2f992a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 0.24.1 + +* Update SDK as per latest server specs, these include - + * Updates to Runtime enums + * `Output` is now renamed to `ImageFormat` - Note that this is a breaking change + * Introduces Backups module for managing Database backups + * Introduces Organization module + ## 0.24.0 * Added ability to create columns and indexes synchronously while creating a table @@ -7,7 +15,8 @@ ## 0.23.0 * Rename `VCSDeploymentType` enum to `VCSReferenceType` -* Change `CreateTemplateDeployment` method signature: replace `Version` parameter with `Type` (TemplateReferenceType) and `Reference` parameters +* Change `CreateTemplateDeployment` method signature: replace `Version` parameter with `Type` (TemplateReferenceType) + and `Reference` parameters * Add `GetScreenshot` method to `Avatars` service * Add `Theme`, `Timezone` and `Output` enums @@ -91,10 +100,14 @@ * Added `scheduledAt` parameter to `createExecution()`: Enables creating a delayed execution #### Breaking changes -You can find the new syntax for breaking changes in the [Appwrite API references](https://appwrite.io/docs/references). Select version `1.6.x`. + +You can find the new syntax for breaking changes in the [Appwrite API references](https://appwrite.io/docs/references). +Select version `1.6.x`. + * Removed `otp` parameter from `deleteMFAAuthenticator`. * Added `scopes` parameter for create/update function. * Renamed `templateBranch` to `templateVersion` in `createFunction()`. * Renamed `downloadDeployment()` to `getDeploymentDownload()` -> **Please note: This version is compatible with Appwrite 1.6 and later only. If you do not update your Appwrite SDK, old SDKs will not break your app. Appwrite APIs are backwards compatible.** +> **Please note: This version is compatible with Appwrite 1.6 and later only. If you do not update your Appwrite SDK, +old SDKs will not break your app. Appwrite APIs are backwards compatible.** diff --git a/LICENSE b/LICENSE index c1602fc..6f8702b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2026 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index f2c59f4..0e55c8a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Appwrite .NET SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-dotnet.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dotnet/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-dotnet/releases).** -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the .NET SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the .NET SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ## Installation @@ -17,21 +17,20 @@ Appwrite is an open-source backend as a service server that abstract and simplif Add this reference to your project's `.csproj` file: ```xml - + ``` You can install packages from the command line: ```powershell # Package Manager -Install-Package Appwrite -Version 0.24.0 +Install-Package Appwrite -Version 0.24.1 # or .NET CLI -dotnet add package Appwrite --version 0.24.0 +dotnet add package Appwrite --version 0.24.1 ``` - ## Getting Started ### Initialize & Make API Request diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index 9572d69..d3e1348 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -9,4 +9,6 @@ Client client = new Client() Account account = new Account(client); -JWT result = await account.CreateJWT(); +JWT result = await account.CreateJWT( + duration: 0 // optional +); \ No newline at end of file diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 58e6e42..09cd43d 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -33,5 +33,5 @@ byte[] result = await avatars.GetScreenshot( width: 800, // optional height: 600, // optional quality: 85, // optional - output: Output.Jpg // optional + output: ImageFormat.Jpg // optional ); \ No newline at end of file diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 0000000..d5a4d7c --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,15 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupArchive result = await backups.CreateArchive( + services: new List(), + resourceId: "" // optional +); \ No newline at end of file diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 0000000..936df3b --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,20 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupPolicy result = await backups.CreatePolicy( + policyId: "", + services: new List(), + retention: 1, + schedule: "", + name: "", // optional + resourceId: "", // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 0000000..801d5e9 --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,17 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupRestoration result = await backups.CreateRestoration( + archiveId: "", + services: new List(), + newResourceId: "", // optional + newResourceName: "" // optional +); \ No newline at end of file diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 0000000..ef03290 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +await backups.DeleteArchive( + archiveId: "" +); \ No newline at end of file diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 0000000..fa0a76b --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +await backups.DeletePolicy( + policyId: "" +); \ No newline at end of file diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 0000000..602580e --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupArchive result = await backups.GetArchive( + archiveId: "" +); \ No newline at end of file diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 0000000..9ad43fc --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupPolicy result = await backups.GetPolicy( + policyId: "" +); \ No newline at end of file diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 0000000..0d680e5 --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupRestoration result = await backups.GetRestoration( + restorationId: "" +); \ No newline at end of file diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 0000000..16b6a17 --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupArchiveList result = await backups.ListArchives( + queries: new List() // optional +); \ No newline at end of file diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 0000000..1c66728 --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupPolicyList result = await backups.ListPolicies( + queries: new List() // optional +); \ No newline at end of file diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 0000000..1d6b296 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupRestorationList result = await backups.ListRestorations( + queries: new List() // optional +); \ No newline at end of file diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 0000000..84e40fe --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetKey(""); // Your secret API key + +Backups backups = new Backups(client); + +BackupPolicy result = await backups.UpdatePolicy( + policyId: "", + name: "", // optional + retention: 1, // optional + schedule: "", // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md index d9e02e3..024f14f 100644 --- a/docs/examples/databases/get-attribute.md +++ b/docs/examples/databases/get-attribute.md @@ -9,7 +9,7 @@ Client client = new Client() Databases databases = new Databases(client); - result = await databases.GetAttribute( +AttributeBoolean result = await databases.GetAttribute( databaseId: "", collectionId: "", key: "" diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 85f3ba5..8bebfdf 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -13,7 +13,13 @@ Document result = await databases.UpdateDocument( databaseId: "", collectionId: "", documentId: "", - data: [object], // optional + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 33, + isAdmin = false + }, // optional permissions: new List { Permission.Read(Role.Any()) }, // optional transactionId: "" // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 077ec04..d7788b4 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -12,7 +12,13 @@ Databases databases = new Databases(client); DocumentList result = await databases.UpdateDocuments( databaseId: "", collectionId: "", - data: [object], // optional + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 33, + isAdmin = false + }, // optional queries: new List(), // optional transactionId: "" // optional ); \ No newline at end of file diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 9ebcafe..c54bcfc 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -13,7 +13,13 @@ Document result = await databases.UpsertDocument( databaseId: "", collectionId: "", documentId: "", - data: [object], + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 30, + isAdmin = false + }, // optional permissions: new List { Permission.Read(Role.Any()) }, // optional transactionId: "" // optional ); \ No newline at end of file diff --git a/docs/examples/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 0000000..06dd6a5 --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetSession(""); // The user session to authenticate with + +Organizations organizations = new Organizations(client); + +await organizations.Delete( + organizationId: "" +); \ No newline at end of file diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 0000000..673d72d --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,14 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetSession(""); // The user session to authenticate with + +Organizations organizations = new Organizations(client); + +EstimationDeleteOrganization result = await organizations.EstimationDeleteOrganization( + organizationId: "" +); \ No newline at end of file diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md index 70089aa..e4c1780 100644 --- a/docs/examples/tablesdb/get-column.md +++ b/docs/examples/tablesdb/get-column.md @@ -9,7 +9,7 @@ Client client = new Client() TablesDB tablesDB = new TablesDB(client); - result = await tablesDB.GetColumn( +ColumnBoolean result = await tablesDB.GetColumn( databaseId: "", tableId: "", key: "" diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 3284699..31dfd9d 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -13,7 +13,13 @@ Row result = await tablesDB.UpdateRow( databaseId: "", tableId: "", rowId: "", - data: [object], // optional + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 33, + isAdmin = false + }, // optional permissions: new List { Permission.Read(Role.Any()) }, // optional transactionId: "" // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 368977a..ddd88e0 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -12,7 +12,13 @@ TablesDB tablesDB = new TablesDB(client); RowList result = await tablesDB.UpdateRows( databaseId: "", tableId: "", - data: [object], // optional + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 33, + isAdmin = false + }, // optional queries: new List(), // optional transactionId: "" // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 88ef714..f4860bc 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -13,7 +13,13 @@ Row result = await tablesDB.UpsertRow( databaseId: "", tableId: "", rowId: "", - data: [object], // optional + data: new { + username = "walter.obrien", + email = "walter.obrien@example.com", + fullName = "Walter O'Brien", + age = 33, + isAdmin = false + }, // optional permissions: new List { Permission.Read(Role.Any()) }, // optional transactionId: "" // optional ); \ No newline at end of file