diff --git a/Appwrite/Appwrite.csproj b/Appwrite/Appwrite.csproj index 0f4eba21..581c122a 100644 --- a/Appwrite/Appwrite.csproj +++ b/Appwrite/Appwrite.csproj @@ -2,7 +2,7 @@ netstandard2.0;net462 Appwrite - 1.0.0 + 2.0.0 Appwrite Team Appwrite Team diff --git a/Appwrite/Client.cs b/Appwrite/Client.cs index 5fa902be..90cf4908 100644 --- a/Appwrite/Client.cs +++ b/Appwrite/Client.cs @@ -69,12 +69,12 @@ public Client( _headers = new Dictionary() { { "content-type", "application/json" }, - { "user-agent" , $"AppwriteDotNetSDK/1.0.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"}, + { "user-agent" , $"AppwriteDotNetSDK/2.0.0 ({Environment.OSVersion.Platform}; {Environment.OSVersion.VersionString})"}, { "x-sdk-name", ".NET" }, { "x-sdk-platform", "server" }, { "x-sdk-language", "dotnet" }, - { "x-sdk-version", "1.0.0"}, - { "X-Appwrite-Response-Format", "1.8.0" } + { "x-sdk-version", "2.0.0"}, + { "X-Appwrite-Response-Format", "1.9.0" } }; _config = new Dictionary(); @@ -156,6 +156,30 @@ public Client SetForwardedUserAgent(string value) { return this; } + /// Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + public Client SetImpersonateUserId(string value) { + _config.Add("impersonateUserId", value); + AddHeader("X-Appwrite-Impersonate-User-Id", value); + + return this; + } + + /// Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + public Client SetImpersonateUserEmail(string value) { + _config.Add("impersonateUserEmail", value); + AddHeader("X-Appwrite-Impersonate-User-Email", value); + + return this; + } + + /// Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. + public Client SetImpersonateUserPhone(string value) { + _config.Add("impersonateUserPhone", value); + AddHeader("X-Appwrite-Impersonate-User-Phone", value); + + return this; + } + public Client AddHeader(string key, string value) { _headers.Add(key, value); diff --git a/Appwrite/Enums/BackupServices.cs b/Appwrite/Enums/BackupServices.cs index ef9d1a17..b211334b 100644 --- a/Appwrite/Enums/BackupServices.cs +++ b/Appwrite/Enums/BackupServices.cs @@ -12,6 +12,9 @@ public BackupServices(string value) } public static BackupServices Databases => new BackupServices("databases"); + public static BackupServices Tablesdb => new BackupServices("tablesdb"); + public static BackupServices Documentsdb => new BackupServices("documentsdb"); + public static BackupServices Vectorsdb => new BackupServices("vectorsdb"); public static BackupServices Functions => new BackupServices("functions"); public static BackupServices Storage => new BackupServices("storage"); } diff --git a/Appwrite/Enums/DatabaseType.cs b/Appwrite/Enums/DatabaseType.cs index bcbe1d91..11b4916b 100644 --- a/Appwrite/Enums/DatabaseType.cs +++ b/Appwrite/Enums/DatabaseType.cs @@ -13,5 +13,7 @@ public DatabaseType(string value) public static DatabaseType Legacy => new DatabaseType("legacy"); public static DatabaseType Tablesdb => new DatabaseType("tablesdb"); + public static DatabaseType Documentsdb => new DatabaseType("documentsdb"); + public static DatabaseType Vectorsdb => new DatabaseType("vectorsdb"); } } diff --git a/Appwrite/Enums/DatabasesIndexType.cs b/Appwrite/Enums/DatabasesIndexType.cs new file mode 100644 index 00000000..71494c99 --- /dev/null +++ b/Appwrite/Enums/DatabasesIndexType.cs @@ -0,0 +1,19 @@ +using System; + +namespace Appwrite.Enums +{ + public class DatabasesIndexType : IEnum + { + public string Value { get; private set; } + + public DatabasesIndexType(string value) + { + Value = value; + } + + public static DatabasesIndexType Key => new DatabasesIndexType("key"); + public static DatabasesIndexType Fulltext => new DatabasesIndexType("fulltext"); + public static DatabasesIndexType Unique => new DatabasesIndexType("unique"); + public static DatabasesIndexType Spatial => new DatabasesIndexType("spatial"); + } +} diff --git a/Appwrite/Enums/IndexType.cs b/Appwrite/Enums/IndexType.cs deleted file mode 100644 index eee4618f..00000000 --- a/Appwrite/Enums/IndexType.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace Appwrite.Enums -{ - public class IndexType : IEnum - { - public string Value { get; private set; } - - public IndexType(string value) - { - Value = value; - } - - public static IndexType Key => new IndexType("key"); - public static IndexType Fulltext => new IndexType("fulltext"); - public static IndexType Unique => new IndexType("unique"); - public static IndexType Spatial => new IndexType("spatial"); - } -} diff --git a/Appwrite/Enums/Scopes.cs b/Appwrite/Enums/Scopes.cs index 813361dd..3f4e8bb3 100644 --- a/Appwrite/Enums/Scopes.cs +++ b/Appwrite/Enums/Scopes.cs @@ -68,6 +68,10 @@ public Scopes(string value) public static Scopes AssistantRead => new Scopes("assistant.read"); public static Scopes TokensRead => new Scopes("tokens.read"); public static Scopes TokensWrite => new Scopes("tokens.write"); + public static Scopes WebhooksRead => new Scopes("webhooks.read"); + public static Scopes WebhooksWrite => new Scopes("webhooks.write"); + public static Scopes ProjectRead => new Scopes("project.read"); + public static Scopes ProjectWrite => new Scopes("project.write"); public static Scopes PoliciesWrite => new Scopes("policies.write"); public static Scopes PoliciesRead => new Scopes("policies.read"); public static Scopes ArchivesRead => new Scopes("archives.read"); diff --git a/Appwrite/Enums/TablesDBIndexType.cs b/Appwrite/Enums/TablesDBIndexType.cs new file mode 100644 index 00000000..859d5fdd --- /dev/null +++ b/Appwrite/Enums/TablesDBIndexType.cs @@ -0,0 +1,19 @@ +using System; + +namespace Appwrite.Enums +{ + public class TablesDBIndexType : IEnum + { + public string Value { get; private set; } + + public TablesDBIndexType(string value) + { + Value = value; + } + + public static TablesDBIndexType Key => new TablesDBIndexType("key"); + public static TablesDBIndexType Fulltext => new TablesDBIndexType("fulltext"); + public static TablesDBIndexType Unique => new TablesDBIndexType("unique"); + public static TablesDBIndexType Spatial => new TablesDBIndexType("spatial"); + } +} diff --git a/Appwrite/Enums/TemplateReferenceType.cs b/Appwrite/Enums/TemplateReferenceType.cs index 36b1f7d7..4c09d4f8 100644 --- a/Appwrite/Enums/TemplateReferenceType.cs +++ b/Appwrite/Enums/TemplateReferenceType.cs @@ -11,8 +11,8 @@ public TemplateReferenceType(string value) Value = value; } - public static TemplateReferenceType Branch => new TemplateReferenceType("branch"); public static TemplateReferenceType Commit => new TemplateReferenceType("commit"); + public static TemplateReferenceType Branch => new TemplateReferenceType("branch"); public static TemplateReferenceType Tag => new TemplateReferenceType("tag"); } } diff --git a/Appwrite/Models/Document.cs b/Appwrite/Models/Document.cs index d23dd352..1bc72c8b 100644 --- a/Appwrite/Models/Document.cs +++ b/Appwrite/Models/Document.cs @@ -15,7 +15,7 @@ public class Document public string Id { get; private set; } [JsonPropertyName("$sequence")] - public long Sequence { get; private set; } + public string Sequence { get; private set; } [JsonPropertyName("$collectionId")] public string CollectionId { get; private set; } @@ -36,7 +36,7 @@ public class Document public Document( string id, - long sequence, + string sequence, string collectionId, string databaseId, string createdAt, @@ -56,7 +56,7 @@ Dictionary data public static Document From(Dictionary map) => new Document( id: map["$id"].ToString(), - sequence: Convert.ToInt64(map["$sequence"]), + sequence: map["$sequence"].ToString(), collectionId: map["$collectionId"].ToString(), databaseId: map["$databaseId"].ToString(), createdAt: map["$createdAt"].ToString(), diff --git a/Appwrite/Models/Function.cs b/Appwrite/Models/Function.cs index 7673f0ee..b9ee4c3b 100644 --- a/Appwrite/Models/Function.cs +++ b/Appwrite/Models/Function.cs @@ -38,6 +38,9 @@ public class Function [JsonPropertyName("runtime")] public string Runtime { get; private set; } + [JsonPropertyName("deploymentRetention")] + public long DeploymentRetention { get; private set; } + [JsonPropertyName("deploymentId")] public string DeploymentId { get; private set; } @@ -92,8 +95,11 @@ public class Function [JsonPropertyName("providerSilentMode")] public bool ProviderSilentMode { get; private set; } - [JsonPropertyName("specification")] - public string Specification { get; private set; } + [JsonPropertyName("buildSpecification")] + public string BuildSpecification { get; private set; } + + [JsonPropertyName("runtimeSpecification")] + public string RuntimeSpecification { get; private set; } public Function( string id, @@ -105,6 +111,7 @@ public Function( bool live, bool logging, string runtime, + long deploymentRetention, string deploymentId, string deploymentCreatedAt, string latestDeploymentId, @@ -123,7 +130,8 @@ public Function( string providerBranch, string providerRootDirectory, bool providerSilentMode, - string specification + string buildSpecification, + string runtimeSpecification ) { Id = id; CreatedAt = createdAt; @@ -134,6 +142,7 @@ string specification Live = live; Logging = logging; Runtime = runtime; + DeploymentRetention = deploymentRetention; DeploymentId = deploymentId; DeploymentCreatedAt = deploymentCreatedAt; LatestDeploymentId = latestDeploymentId; @@ -152,7 +161,8 @@ string specification ProviderBranch = providerBranch; ProviderRootDirectory = providerRootDirectory; ProviderSilentMode = providerSilentMode; - Specification = specification; + BuildSpecification = buildSpecification; + RuntimeSpecification = runtimeSpecification; } public static Function From(Dictionary map) => new Function( @@ -165,6 +175,7 @@ string specification live: (bool)map["live"], logging: (bool)map["logging"], runtime: map["runtime"].ToString(), + deploymentRetention: Convert.ToInt64(map["deploymentRetention"]), deploymentId: map["deploymentId"].ToString(), deploymentCreatedAt: map["deploymentCreatedAt"].ToString(), latestDeploymentId: map["latestDeploymentId"].ToString(), @@ -183,7 +194,8 @@ string specification providerBranch: map["providerBranch"].ToString(), providerRootDirectory: map["providerRootDirectory"].ToString(), providerSilentMode: (bool)map["providerSilentMode"], - specification: map["specification"].ToString() + buildSpecification: map["buildSpecification"].ToString(), + runtimeSpecification: map["runtimeSpecification"].ToString() ); public Dictionary ToMap() => new Dictionary() @@ -197,6 +209,7 @@ string specification { "live", Live }, { "logging", Logging }, { "runtime", Runtime }, + { "deploymentRetention", DeploymentRetention }, { "deploymentId", DeploymentId }, { "deploymentCreatedAt", DeploymentCreatedAt }, { "latestDeploymentId", LatestDeploymentId }, @@ -215,7 +228,8 @@ string specification { "providerBranch", ProviderBranch }, { "providerRootDirectory", ProviderRootDirectory }, { "providerSilentMode", ProviderSilentMode }, - { "specification", Specification } + { "buildSpecification", BuildSpecification }, + { "runtimeSpecification", RuntimeSpecification } }; } } diff --git a/Appwrite/Models/Row.cs b/Appwrite/Models/Row.cs index 075e0a6e..d2e4b05c 100644 --- a/Appwrite/Models/Row.cs +++ b/Appwrite/Models/Row.cs @@ -15,7 +15,7 @@ public class Row public string Id { get; private set; } [JsonPropertyName("$sequence")] - public long Sequence { get; private set; } + public string Sequence { get; private set; } [JsonPropertyName("$tableId")] public string TableId { get; private set; } @@ -36,7 +36,7 @@ public class Row public Row( string id, - long sequence, + string sequence, string tableId, string databaseId, string createdAt, @@ -56,7 +56,7 @@ Dictionary data public static Row From(Dictionary map) => new Row( id: map["$id"].ToString(), - sequence: Convert.ToInt64(map["$sequence"]), + sequence: map["$sequence"].ToString(), tableId: map["$tableId"].ToString(), databaseId: map["$databaseId"].ToString(), createdAt: map["$createdAt"].ToString(), diff --git a/Appwrite/Models/Site.cs b/Appwrite/Models/Site.cs index 0b9ca5b8..79958dff 100644 --- a/Appwrite/Models/Site.cs +++ b/Appwrite/Models/Site.cs @@ -35,6 +35,9 @@ public class Site [JsonPropertyName("framework")] public string Framework { get; private set; } + [JsonPropertyName("deploymentRetention")] + public long DeploymentRetention { get; private set; } + [JsonPropertyName("deploymentId")] public string DeploymentId { get; private set; } @@ -68,6 +71,9 @@ public class Site [JsonPropertyName("buildCommand")] public string BuildCommand { get; private set; } + [JsonPropertyName("startCommand")] + public string StartCommand { get; private set; } + [JsonPropertyName("outputDirectory")] public string OutputDirectory { get; private set; } @@ -86,8 +92,11 @@ public class Site [JsonPropertyName("providerSilentMode")] public bool ProviderSilentMode { get; private set; } - [JsonPropertyName("specification")] - public string Specification { get; private set; } + [JsonPropertyName("buildSpecification")] + public string BuildSpecification { get; private set; } + + [JsonPropertyName("runtimeSpecification")] + public string RuntimeSpecification { get; private set; } [JsonPropertyName("buildRuntime")] public string BuildRuntime { get; private set; } @@ -107,6 +116,7 @@ public Site( bool live, bool logging, string framework, + long deploymentRetention, string deploymentId, string deploymentCreatedAt, string deploymentScreenshotLight, @@ -118,13 +128,15 @@ public Site( long timeout, string installCommand, string buildCommand, + string startCommand, string outputDirectory, string installationId, string providerRepositoryId, string providerBranch, string providerRootDirectory, bool providerSilentMode, - string specification, + string buildSpecification, + string runtimeSpecification, string buildRuntime, string adapter, string fallbackFile @@ -137,6 +149,7 @@ string fallbackFile Live = live; Logging = logging; Framework = framework; + DeploymentRetention = deploymentRetention; DeploymentId = deploymentId; DeploymentCreatedAt = deploymentCreatedAt; DeploymentScreenshotLight = deploymentScreenshotLight; @@ -148,13 +161,15 @@ string fallbackFile Timeout = timeout; InstallCommand = installCommand; BuildCommand = buildCommand; + StartCommand = startCommand; OutputDirectory = outputDirectory; InstallationId = installationId; ProviderRepositoryId = providerRepositoryId; ProviderBranch = providerBranch; ProviderRootDirectory = providerRootDirectory; ProviderSilentMode = providerSilentMode; - Specification = specification; + BuildSpecification = buildSpecification; + RuntimeSpecification = runtimeSpecification; BuildRuntime = buildRuntime; Adapter = adapter; FallbackFile = fallbackFile; @@ -169,6 +184,7 @@ string fallbackFile live: (bool)map["live"], logging: (bool)map["logging"], framework: map["framework"].ToString(), + deploymentRetention: Convert.ToInt64(map["deploymentRetention"]), deploymentId: map["deploymentId"].ToString(), deploymentCreatedAt: map["deploymentCreatedAt"].ToString(), deploymentScreenshotLight: map["deploymentScreenshotLight"].ToString(), @@ -180,13 +196,15 @@ string fallbackFile timeout: Convert.ToInt64(map["timeout"]), installCommand: map["installCommand"].ToString(), buildCommand: map["buildCommand"].ToString(), + startCommand: map["startCommand"].ToString(), outputDirectory: map["outputDirectory"].ToString(), installationId: map["installationId"].ToString(), providerRepositoryId: map["providerRepositoryId"].ToString(), providerBranch: map["providerBranch"].ToString(), providerRootDirectory: map["providerRootDirectory"].ToString(), providerSilentMode: (bool)map["providerSilentMode"], - specification: map["specification"].ToString(), + buildSpecification: map["buildSpecification"].ToString(), + runtimeSpecification: map["runtimeSpecification"].ToString(), buildRuntime: map["buildRuntime"].ToString(), adapter: map["adapter"].ToString(), fallbackFile: map["fallbackFile"].ToString() @@ -202,6 +220,7 @@ string fallbackFile { "live", Live }, { "logging", Logging }, { "framework", Framework }, + { "deploymentRetention", DeploymentRetention }, { "deploymentId", DeploymentId }, { "deploymentCreatedAt", DeploymentCreatedAt }, { "deploymentScreenshotLight", DeploymentScreenshotLight }, @@ -213,13 +232,15 @@ string fallbackFile { "timeout", Timeout }, { "installCommand", InstallCommand }, { "buildCommand", BuildCommand }, + { "startCommand", StartCommand }, { "outputDirectory", OutputDirectory }, { "installationId", InstallationId }, { "providerRepositoryId", ProviderRepositoryId }, { "providerBranch", ProviderBranch }, { "providerRootDirectory", ProviderRootDirectory }, { "providerSilentMode", ProviderSilentMode }, - { "specification", Specification }, + { "buildSpecification", BuildSpecification }, + { "runtimeSpecification", RuntimeSpecification }, { "buildRuntime", BuildRuntime }, { "adapter", Adapter }, { "fallbackFile", FallbackFile } diff --git a/Appwrite/Models/User.cs b/Appwrite/Models/User.cs index 480ede9b..4a2bd7a7 100644 --- a/Appwrite/Models/User.cs +++ b/Appwrite/Models/User.cs @@ -68,6 +68,12 @@ public class User [JsonPropertyName("accessedAt")] public string AccessedAt { get; private set; } + [JsonPropertyName("impersonator")] + public bool? Impersonator { get; private set; } + + [JsonPropertyName("impersonatorUserId")] + public string? ImpersonatorUserId { get; private set; } + public User( string id, string createdAt, @@ -87,7 +93,9 @@ public User( bool mfa, Preferences prefs, List targets, - string accessedAt + string accessedAt, + bool? impersonator, + string? impersonatorUserId ) { Id = id; CreatedAt = createdAt; @@ -108,6 +116,8 @@ string accessedAt Prefs = prefs; Targets = targets; AccessedAt = accessedAt; + Impersonator = impersonator; + ImpersonatorUserId = impersonatorUserId; } public static User From(Dictionary map) => new User( @@ -129,7 +139,9 @@ string accessedAt mfa: (bool)map["mfa"], prefs: Preferences.From(map: map["prefs"] is JsonElement jsonObj17 ? jsonObj17.Deserialize>()! : (Dictionary)map["prefs"]), targets: map["targets"].ConvertToList>().Select(it => Target.From(map: it)).ToList(), - accessedAt: map["accessedAt"].ToString() + accessedAt: map["accessedAt"].ToString(), + impersonator: (bool?)map["impersonator"], + impersonatorUserId: map.TryGetValue("impersonatorUserId", out var impersonatorUserId) ? impersonatorUserId?.ToString() : null ); public Dictionary ToMap() => new Dictionary() @@ -152,7 +164,9 @@ string accessedAt { "mfa", Mfa }, { "prefs", Prefs.ToMap() }, { "targets", Targets.Select(it => it.ToMap()) }, - { "accessedAt", AccessedAt } + { "accessedAt", AccessedAt }, + { "impersonator", Impersonator }, + { "impersonatorUserId", ImpersonatorUserId } }; } } diff --git a/Appwrite/Models/Webhook.cs b/Appwrite/Models/Webhook.cs new file mode 100644 index 00000000..c1c319b9 --- /dev/null +++ b/Appwrite/Models/Webhook.cs @@ -0,0 +1,116 @@ + +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 Webhook + { + [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("name")] + public string Name { get; private set; } + + [JsonPropertyName("url")] + public string Url { get; private set; } + + [JsonPropertyName("events")] + public List Events { get; private set; } + + [JsonPropertyName("security")] + public bool Security { get; private set; } + + [JsonPropertyName("httpUser")] + public string HttpUser { get; private set; } + + [JsonPropertyName("httpPass")] + public string HttpPass { get; private set; } + + [JsonPropertyName("signatureKey")] + public string SignatureKey { get; private set; } + + [JsonPropertyName("enabled")] + public bool Enabled { get; private set; } + + [JsonPropertyName("logs")] + public string Logs { get; private set; } + + [JsonPropertyName("attempts")] + public long Attempts { get; private set; } + + public Webhook( + string id, + string createdAt, + string updatedAt, + string name, + string url, + List events, + bool security, + string httpUser, + string httpPass, + string signatureKey, + bool enabled, + string logs, + long attempts + ) { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Name = name; + Url = url; + Events = events; + Security = security; + HttpUser = httpUser; + HttpPass = httpPass; + SignatureKey = signatureKey; + Enabled = enabled; + Logs = logs; + Attempts = attempts; + } + + public static Webhook From(Dictionary map) => new Webhook( + id: map["$id"].ToString(), + createdAt: map["$createdAt"].ToString(), + updatedAt: map["$updatedAt"].ToString(), + name: map["name"].ToString(), + url: map["url"].ToString(), + events: map["events"].ConvertToList(), + security: (bool)map["security"], + httpUser: map["httpUser"].ToString(), + httpPass: map["httpPass"].ToString(), + signatureKey: map["signatureKey"].ToString(), + enabled: (bool)map["enabled"], + logs: map["logs"].ToString(), + attempts: Convert.ToInt64(map["attempts"]) + ); + + public Dictionary ToMap() => new Dictionary() + { + { "$id", Id }, + { "$createdAt", CreatedAt }, + { "$updatedAt", UpdatedAt }, + { "name", Name }, + { "url", Url }, + { "events", Events }, + { "security", Security }, + { "httpUser", HttpUser }, + { "httpPass", HttpPass }, + { "signatureKey", SignatureKey }, + { "enabled", Enabled }, + { "logs", Logs }, + { "attempts", Attempts } + }; + } +} diff --git a/Appwrite/Models/WebhookList.cs b/Appwrite/Models/WebhookList.cs new file mode 100644 index 00000000..fe46416a --- /dev/null +++ b/Appwrite/Models/WebhookList.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 WebhookList + { + [JsonPropertyName("total")] + public long Total { get; private set; } + + [JsonPropertyName("webhooks")] + public List Webhooks { get; private set; } + + public WebhookList( + long total, + List webhooks + ) { + Total = total; + Webhooks = webhooks; + } + + public static WebhookList From(Dictionary map) => new WebhookList( + total: Convert.ToInt64(map["total"]), + webhooks: map["webhooks"].ConvertToList>().Select(it => Webhook.From(map: it)).ToList() + ); + + public Dictionary ToMap() => new Dictionary() + { + { "total", Total }, + { "webhooks", Webhooks.Select(it => it.ToMap()) } + }; + } +} diff --git a/Appwrite/Services/Databases.cs b/Appwrite/Services/Databases.cs index 24faf620..05c9e4b1 100644 --- a/Appwrite/Services/Databases.cs +++ b/Appwrite/Services/Databases.cs @@ -2443,7 +2443,7 @@ static Models.IndexList Convert(Dictionary it) => /// /// [Obsolete("This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead.")] - public Task CreateIndex(string databaseId, string collectionId, string key, Appwrite.Enums.IndexType type, List attributes, List? orders = null, List? lengths = null) + public Task CreateIndex(string databaseId, string collectionId, string key, Appwrite.Enums.DatabasesIndexType type, List attributes, List? orders = null, List? lengths = null) { var apiPath = "/databases/{databaseId}/collections/{collectionId}/indexes" .Replace("{databaseId}", databaseId) diff --git a/Appwrite/Services/Functions.cs b/Appwrite/Services/Functions.cs index 12e6b4e6..8e168c65 100644 --- a/Appwrite/Services/Functions.cs +++ b/Appwrite/Services/Functions.cs @@ -54,7 +54,7 @@ static Models.FunctionList Convert(Dictionary it) => /// API. /// /// - public Task Create(string functionId, string name, Appwrite.Enums.Runtime runtime, List? execute = null, List? events = null, string? schedule = null, long? timeout = null, bool? enabled = null, bool? logging = null, string? entrypoint = null, string? commands = null, List? scopes = null, string? installationId = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? specification = null) + public Task Create(string functionId, string name, Appwrite.Enums.Runtime runtime, List? execute = null, List? events = null, string? schedule = null, long? timeout = null, bool? enabled = null, bool? logging = null, string? entrypoint = null, string? commands = null, List? scopes = null, string? installationId = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? buildSpecification = null, string? runtimeSpecification = null, long? deploymentRetention = null) { var apiPath = "/functions"; @@ -77,7 +77,9 @@ static Models.FunctionList Convert(Dictionary it) => { "providerBranch", providerBranch }, { "providerSilentMode", providerSilentMode }, { "providerRootDirectory", providerRootDirectory }, - { "specification", specification } + { "buildSpecification", buildSpecification }, + { "runtimeSpecification", runtimeSpecification }, + { "deploymentRetention", deploymentRetention } }; var apiHeaders = new Dictionary() @@ -190,7 +192,7 @@ static Models.Function Convert(Dictionary it) => /// Update function by its unique ID. /// /// - public Task Update(string functionId, string name, Appwrite.Enums.Runtime? runtime = null, List? execute = null, List? events = null, string? schedule = null, long? timeout = null, bool? enabled = null, bool? logging = null, string? entrypoint = null, string? commands = null, List? scopes = null, string? installationId = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? specification = null) + public Task Update(string functionId, string name, Appwrite.Enums.Runtime? runtime = null, List? execute = null, List? events = null, string? schedule = null, long? timeout = null, bool? enabled = null, bool? logging = null, string? entrypoint = null, string? commands = null, List? scopes = null, string? installationId = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? buildSpecification = null, string? runtimeSpecification = null, long? deploymentRetention = null) { var apiPath = "/functions/{functionId}" .Replace("{functionId}", functionId); @@ -213,7 +215,9 @@ static Models.Function Convert(Dictionary it) => { "providerBranch", providerBranch }, { "providerSilentMode", providerSilentMode }, { "providerRootDirectory", providerRootDirectory }, - { "specification", specification } + { "buildSpecification", buildSpecification }, + { "runtimeSpecification", runtimeSpecification }, + { "deploymentRetention", deploymentRetention } }; var apiHeaders = new Dictionary() diff --git a/Appwrite/Services/Health.cs b/Appwrite/Services/Health.cs index 20b5901a..529b9b54 100644 --- a/Appwrite/Services/Health.cs +++ b/Appwrite/Services/Health.cs @@ -254,66 +254,6 @@ static Models.HealthQueue Convert(Dictionary it) => } - /// - /// Get billing project aggregation queue. - /// - /// - public Task GetQueueBillingProjectAggregation(long? threshold = null) - { - var apiPath = "/health/queue/billing-project-aggregation"; - - var apiParameters = new Dictionary() - { - { "threshold", threshold } - }; - - var apiHeaders = new Dictionary() - { - }; - - - static Models.HealthQueue Convert(Dictionary it) => - Models.HealthQueue.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 billing team aggregation queue. - /// - /// - public Task GetQueueBillingTeamAggregation(long? threshold = null) - { - var apiPath = "/health/queue/billing-team-aggregation"; - - var apiParameters = new Dictionary() - { - { "threshold", threshold } - }; - - var apiHeaders = new Dictionary() - { - }; - - - static Models.HealthQueue Convert(Dictionary it) => - Models.HealthQueue.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 number of builds that are waiting to be processed in the Appwrite /// internal queue server. @@ -345,36 +285,6 @@ static Models.HealthQueue Convert(Dictionary it) => } - /// - /// Get the priority builds queue size. - /// - /// - public Task GetQueuePriorityBuilds(long? threshold = null) - { - var apiPath = "/health/queue/builds-priority"; - - var apiParameters = new Dictionary() - { - { "threshold", threshold } - }; - - var apiHeaders = new Dictionary() - { - }; - - - static Models.HealthQueue Convert(Dictionary it) => - Models.HealthQueue.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 number of certificates that are waiting to be issued against /// [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue @@ -657,36 +567,6 @@ static Models.HealthQueue Convert(Dictionary it) => } - /// - /// Get region manager queue. - /// - /// - public Task GetQueueRegionManager(long? threshold = null) - { - var apiPath = "/health/queue/region-manager"; - - var apiParameters = new Dictionary() - { - { "threshold", threshold } - }; - - var apiHeaders = new Dictionary() - { - }; - - - static Models.HealthQueue Convert(Dictionary it) => - Models.HealthQueue.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 number of metrics that are waiting to be processed in the Appwrite /// stats resources queue. @@ -749,36 +629,6 @@ static Models.HealthQueue Convert(Dictionary it) => } - /// - /// Get threats queue. - /// - /// - public Task GetQueueThreats(long? threshold = null) - { - var apiPath = "/health/queue/threats"; - - var apiParameters = new Dictionary() - { - { "threshold", threshold } - }; - - var apiHeaders = new Dictionary() - { - }; - - - static Models.HealthQueue Convert(Dictionary it) => - Models.HealthQueue.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 number of webhooks that are waiting to be processed in the Appwrite /// internal queue server. diff --git a/Appwrite/Services/Project.cs b/Appwrite/Services/Project.cs new file mode 100644 index 00000000..fd9fea72 --- /dev/null +++ b/Appwrite/Services/Project.cs @@ -0,0 +1,176 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; +using Appwrite.Enums; + +namespace Appwrite.Services +{ + public class Project : Service + { + public Project(Client client) : base(client) + { + } + + /// + /// Get a list of all project environment variables. + /// + /// + public Task ListVariables(List? queries = null, bool? total = null) + { + var apiPath = "/project/variables"; + + var apiParameters = new Dictionary() + { + { "queries", queries }, + { "total", total } + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.VariableList Convert(Dictionary it) => + Models.VariableList.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 project environment variable. These variables can be accessed + /// by all functions and sites in the project. + /// + /// + public Task CreateVariable(string variableId, string key, string xvalue, bool? secret = null) + { + var apiPath = "/project/variables"; + + var apiParameters = new Dictionary() + { + { "variableId", variableId }, + { "key", key }, + { "value", xvalue }, + { "secret", secret } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.Variable Convert(Dictionary it) => + Models.Variable.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 variable by its unique ID. + /// + /// + public Task GetVariable(string variableId) + { + var apiPath = "/project/variables/{variableId}" + .Replace("{variableId}", variableId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.Variable Convert(Dictionary it) => + Models.Variable.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 variable by its unique ID. + /// + /// + public Task UpdateVariable(string variableId, string? key = null, string? xvalue = null, bool? secret = null) + { + var apiPath = "/project/variables/{variableId}" + .Replace("{variableId}", variableId); + + var apiParameters = new Dictionary() + { + { "key", key }, + { "value", xvalue }, + { "secret", secret } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.Variable Convert(Dictionary it) => + Models.Variable.From(map: it); + + return _client.Call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete a variable by its unique ID. + /// + /// + public Task DeleteVariable(string variableId) + { + var apiPath = "/project/variables/{variableId}" + .Replace("{variableId}", variableId); + + 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)!); + + } + + } +} diff --git a/Appwrite/Services/Sites.cs b/Appwrite/Services/Sites.cs index 5f12bd3f..2dc8d8bf 100644 --- a/Appwrite/Services/Sites.cs +++ b/Appwrite/Services/Sites.cs @@ -51,7 +51,7 @@ static Models.SiteList Convert(Dictionary it) => /// Create a new site. /// /// - public Task Create(string siteId, string name, Appwrite.Enums.Framework framework, Appwrite.Enums.BuildRuntime buildRuntime, bool? enabled = null, bool? logging = null, long? timeout = null, string? installCommand = null, string? buildCommand = null, string? outputDirectory = null, Appwrite.Enums.Adapter? adapter = null, string? installationId = null, string? fallbackFile = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? specification = null) + public Task Create(string siteId, string name, Appwrite.Enums.Framework framework, Appwrite.Enums.BuildRuntime buildRuntime, bool? enabled = null, bool? logging = null, long? timeout = null, string? installCommand = null, string? buildCommand = null, string? startCommand = null, string? outputDirectory = null, Appwrite.Enums.Adapter? adapter = null, string? installationId = null, string? fallbackFile = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? buildSpecification = null, string? runtimeSpecification = null, long? deploymentRetention = null) { var apiPath = "/sites"; @@ -65,6 +65,7 @@ static Models.SiteList Convert(Dictionary it) => { "timeout", timeout }, { "installCommand", installCommand }, { "buildCommand", buildCommand }, + { "startCommand", startCommand }, { "outputDirectory", outputDirectory }, { "buildRuntime", buildRuntime?.Value }, { "adapter", adapter?.Value }, @@ -74,7 +75,9 @@ static Models.SiteList Convert(Dictionary it) => { "providerBranch", providerBranch }, { "providerSilentMode", providerSilentMode }, { "providerRootDirectory", providerRootDirectory }, - { "specification", specification } + { "buildSpecification", buildSpecification }, + { "runtimeSpecification", runtimeSpecification }, + { "deploymentRetention", deploymentRetention } }; var apiHeaders = new Dictionary() @@ -188,7 +191,7 @@ static Models.Site Convert(Dictionary it) => /// Update site by its unique ID. /// /// - public Task Update(string siteId, string name, Appwrite.Enums.Framework framework, bool? enabled = null, bool? logging = null, long? timeout = null, string? installCommand = null, string? buildCommand = null, string? outputDirectory = null, Appwrite.Enums.BuildRuntime? buildRuntime = null, Appwrite.Enums.Adapter? adapter = null, string? fallbackFile = null, string? installationId = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? specification = null) + public Task Update(string siteId, string name, Appwrite.Enums.Framework framework, bool? enabled = null, bool? logging = null, long? timeout = null, string? installCommand = null, string? buildCommand = null, string? startCommand = null, string? outputDirectory = null, Appwrite.Enums.BuildRuntime? buildRuntime = null, Appwrite.Enums.Adapter? adapter = null, string? fallbackFile = null, string? installationId = null, string? providerRepositoryId = null, string? providerBranch = null, bool? providerSilentMode = null, string? providerRootDirectory = null, string? buildSpecification = null, string? runtimeSpecification = null, long? deploymentRetention = null) { var apiPath = "/sites/{siteId}" .Replace("{siteId}", siteId); @@ -202,6 +205,7 @@ static Models.Site Convert(Dictionary it) => { "timeout", timeout }, { "installCommand", installCommand }, { "buildCommand", buildCommand }, + { "startCommand", startCommand }, { "outputDirectory", outputDirectory }, { "buildRuntime", buildRuntime?.Value }, { "adapter", adapter?.Value }, @@ -211,7 +215,9 @@ static Models.Site Convert(Dictionary it) => { "providerBranch", providerBranch }, { "providerSilentMode", providerSilentMode }, { "providerRootDirectory", providerRootDirectory }, - { "specification", specification } + { "buildSpecification", buildSpecification }, + { "runtimeSpecification", runtimeSpecification }, + { "deploymentRetention", deploymentRetention } }; var apiHeaders = new Dictionary() diff --git a/Appwrite/Services/TablesDB.cs b/Appwrite/Services/TablesDB.cs index 2e49c22b..acd49529 100644 --- a/Appwrite/Services/TablesDB.cs +++ b/Appwrite/Services/TablesDB.cs @@ -1953,7 +1953,7 @@ static Models.ColumnIndexList Convert(Dictionary it) => /// Type can be `key`, `fulltext`, or `unique`. /// /// - public Task CreateIndex(string databaseId, string tableId, string key, Appwrite.Enums.IndexType type, List columns, List? orders = null, List? lengths = null) + public Task CreateIndex(string databaseId, string tableId, string key, Appwrite.Enums.TablesDBIndexType type, List columns, List? orders = null, List? lengths = null) { var apiPath = "/tablesdb/{databaseId}/tables/{tableId}/indexes" .Replace("{databaseId}", databaseId) diff --git a/Appwrite/Services/Users.cs b/Appwrite/Services/Users.cs index 36ebadfb..4e8c6c58 100644 --- a/Appwrite/Services/Users.cs +++ b/Appwrite/Services/Users.cs @@ -506,6 +506,43 @@ static Models.User Convert(Dictionary it) => } + /// + /// Enable or disable whether a user can impersonate other users. When + /// impersonation headers are used, the request runs as the target user for API + /// behavior, while internal audit logs still attribute the action to the + /// original impersonator and store the impersonated target details only in + /// internal audit payload data. + /// + /// + /// + public Task UpdateImpersonator(string userId, bool impersonator) + { + var apiPath = "/users/{userId}/impersonator" + .Replace("{userId}", userId); + + var apiParameters = new Dictionary() + { + { "impersonator", impersonator } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.User Convert(Dictionary it) => + Models.User.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); + + } + /// /// Use this endpoint to create a JSON Web Token for user by its unique ID. You /// can use the resulting JWT to authenticate on behalf of the user. The JWT diff --git a/Appwrite/Services/Webhooks.cs b/Appwrite/Services/Webhooks.cs new file mode 100644 index 00000000..5a6d5292 --- /dev/null +++ b/Appwrite/Services/Webhooks.cs @@ -0,0 +1,221 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Appwrite.Models; +using Appwrite.Enums; + +namespace Appwrite.Services +{ + public class Webhooks : Service + { + public Webhooks(Client client) : base(client) + { + } + + /// + /// Get a list of all webhooks belonging to the project. You can use the query + /// params to filter your results. + /// + /// + public Task List(List? queries = null, bool? total = null) + { + var apiPath = "/webhooks"; + + var apiParameters = new Dictionary() + { + { "queries", queries }, + { "total", total } + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.WebhookList Convert(Dictionary it) => + Models.WebhookList.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 webhook. Use this endpoint to configure a URL that will + /// receive events from Appwrite when specific events occur. + /// + /// + public Task Create(string webhookId, string url, string name, List events, bool? enabled = null, bool? security = null, string? httpUser = null, string? httpPass = null) + { + var apiPath = "/webhooks"; + + var apiParameters = new Dictionary() + { + { "webhookId", webhookId }, + { "url", url }, + { "name", name }, + { "events", events }, + { "enabled", enabled }, + { "security", security }, + { "httpUser", httpUser }, + { "httpPass", httpPass } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.Webhook Convert(Dictionary it) => + Models.Webhook.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 webhook by its unique ID. This endpoint returns details about a + /// specific webhook configured for a project. + /// + /// + public Task Get(string webhookId) + { + var apiPath = "/webhooks/{webhookId}" + .Replace("{webhookId}", webhookId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + }; + + + static Models.Webhook Convert(Dictionary it) => + Models.Webhook.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 a webhook by its unique ID. Use this endpoint to update the URL, + /// events, or status of an existing webhook. + /// + /// + public Task Update(string webhookId, string name, string url, List events, bool? enabled = null, bool? security = null, string? httpUser = null, string? httpPass = null) + { + var apiPath = "/webhooks/{webhookId}" + .Replace("{webhookId}", webhookId); + + var apiParameters = new Dictionary() + { + { "name", name }, + { "url", url }, + { "events", events }, + { "enabled", enabled }, + { "security", security }, + { "httpUser", httpUser }, + { "httpPass", httpPass } + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.Webhook Convert(Dictionary it) => + Models.Webhook.From(map: it); + + return _client.Call( + method: "PUT", + path: apiPath, + headers: apiHeaders, + parameters: apiParameters.Where(it => it.Value != null).ToDictionary(it => it.Key, it => it.Value)!, + convert: Convert); + + } + + /// + /// Delete a webhook by its unique ID. Once deleted, the webhook will no longer + /// receive project events. + /// + /// + public Task Delete(string webhookId) + { + var apiPath = "/webhooks/{webhookId}" + .Replace("{webhookId}", webhookId); + + 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)!); + + } + + /// + /// Update the webhook signature key. This endpoint can be used to regenerate + /// the signature key used to sign and validate payload deliveries for a + /// specific webhook. + /// + /// + public Task UpdateSignature(string webhookId) + { + var apiPath = "/webhooks/{webhookId}/signature" + .Replace("{webhookId}", webhookId); + + var apiParameters = new Dictionary() + { + }; + + var apiHeaders = new Dictionary() + { + { "content-type", "application/json" } + }; + + + static Models.Webhook Convert(Dictionary it) => + Models.Webhook.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/CHANGELOG.md b/CHANGELOG.md index 6637c1ef..85687a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Change Log +## 2.0.0 + +* [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents +* Breaking: Removed `IndexType`; replaced with `DatabasesIndexType`, `TablesDBIndexType` +* Added `Model` class with `Embeddinggemma` value +* Expanded runtime RCs in `BuildRuntime`/`Runtime` for multiple languages +* Added impersonation support via `SetImpersonateUserId`, `SetImpersonateUserEmail`, `SetImpersonateUserPhone` +* Added scopes `WebhooksRead`, `WebhooksWrite`, `ProjectRead`, `ProjectWrite` +* Updated `Client` headers: `User-Agent` and `x-sdk-version` to 0.28.0 +* Updated `X-Appwrite-Response-Format` to `1.9.0` + ## 1.0.0 * Breaking: Sites.CreateDeployment signature changed; 'activate' moved after outputDirectory. diff --git a/README.md b/README.md index 30f17fca..b813e0f4 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # 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.1-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.0-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 1.9.x. 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 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) @@ -17,17 +17,17 @@ Appwrite is an open-source backend as a service server that abstracts and simpli 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 1.0.0 +Install-Package Appwrite -Version 2.0.0 # or .NET CLI -dotnet add package Appwrite --version 1.0.0 +dotnet add package Appwrite --version 2.0.0 ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 7f0e22af..3d653021 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -15,7 +15,7 @@ Index result = await databases.CreateIndex( databaseId: "", collectionId: "", key: "", - type: IndexType.Key, + type: DatabasesIndexType.Key, attributes: new List(), orders: new List<OrderBy> { OrderBy.Asc }, // optional lengths: new List() // optional diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 5032fc38..3a68fda7 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -29,5 +29,7 @@ Function result = await functions.Create( providerBranch: "", // optional providerSilentMode: false, // optional providerRootDirectory: "", // optional - specification: "" // optional + buildSpecification: "", // optional + runtimeSpecification: "", // optional + deploymentRetention: 0 // optional );``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 4f9df255..953417f8 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -29,5 +29,7 @@ Function result = await functions.Update( providerBranch: "", // optional providerSilentMode: false, // optional providerRootDirectory: "", // optional - specification: "" // optional + buildSpecification: "", // optional + runtimeSpecification: "", // optional + deploymentRetention: 0 // optional );``` diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md new file mode 100644 index 00000000..a49aa454 --- /dev/null +++ b/docs/examples/project/create-variable.md @@ -0,0 +1,18 @@ +```csharp +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 + +Project project = new Project(client); + +Variable result = await project.CreateVariable( + variableId: "", + key: "", + value: "", + secret: false // optional +);``` diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md new file mode 100644 index 00000000..83762d9b --- /dev/null +++ b/docs/examples/project/delete-variable.md @@ -0,0 +1,15 @@ +```csharp +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 + +Project project = new Project(client); + +await project.DeleteVariable( + variableId: "" +);``` diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md new file mode 100644 index 00000000..d1283ed3 --- /dev/null +++ b/docs/examples/project/get-variable.md @@ -0,0 +1,15 @@ +```csharp +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 + +Project project = new Project(client); + +Variable result = await project.GetVariable( + variableId: "" +);``` diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md new file mode 100644 index 00000000..5f6f00cc --- /dev/null +++ b/docs/examples/project/list-variables.md @@ -0,0 +1,16 @@ +```csharp +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 + +Project project = new Project(client); + +VariableList result = await project.ListVariables( + queries: new List(), // optional + total: false // optional +);``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md new file mode 100644 index 00000000..cfdf56bd --- /dev/null +++ b/docs/examples/project/update-variable.md @@ -0,0 +1,18 @@ +```csharp +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 + +Project project = new Project(client); + +Variable result = await project.UpdateVariable( + variableId: "", + key: "", // optional + value: "", // optional + secret: false // optional +);``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md index ac31e244..391a56c3 100644 --- a/docs/examples/sites/create.md +++ b/docs/examples/sites/create.md @@ -21,6 +21,7 @@ Site result = await sites.Create( timeout: 1, // optional installCommand: "", // optional buildCommand: "", // optional + startCommand: "", // optional outputDirectory: "", // optional adapter: Adapter.Static, // optional installationId: "", // optional @@ -29,5 +30,7 @@ Site result = await sites.Create( providerBranch: "", // optional providerSilentMode: false, // optional providerRootDirectory: "", // optional - specification: "" // optional + buildSpecification: "", // optional + runtimeSpecification: "", // optional + deploymentRetention: 0 // optional );``` diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md index bd65e36d..69662fe0 100644 --- a/docs/examples/sites/update.md +++ b/docs/examples/sites/update.md @@ -20,6 +20,7 @@ Site result = await sites.Update( timeout: 1, // optional installCommand: "", // optional buildCommand: "", // optional + startCommand: "", // optional outputDirectory: "", // optional buildRuntime: BuildRuntime.Node145, // optional adapter: Adapter.Static, // optional @@ -29,5 +30,7 @@ Site result = await sites.Update( providerBranch: "", // optional providerSilentMode: false, // optional providerRootDirectory: "", // optional - specification: "" // optional + buildSpecification: "", // optional + runtimeSpecification: "", // optional + deploymentRetention: 0 // optional );``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index ec486577..46bfcd27 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -15,7 +15,7 @@ ColumnIndex result = await tablesDB.CreateIndex( databaseId: "", tableId: "", key: "", - type: IndexType.Key, + type: TablesDBIndexType.Key, columns: new List(), orders: new List<OrderBy> { OrderBy.Asc }, // optional lengths: new List() // optional diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md new file mode 100644 index 00000000..908bad5f --- /dev/null +++ b/docs/examples/users/update-impersonator.md @@ -0,0 +1,16 @@ +```csharp +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 + +Users users = new Users(client); + +User result = await users.UpdateImpersonator( + userId: "", + impersonator: false +);``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md new file mode 100644 index 00000000..53ccc0a3 --- /dev/null +++ b/docs/examples/webhooks/create.md @@ -0,0 +1,22 @@ +```csharp +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 + +Webhooks webhooks = new Webhooks(client); + +Webhook result = await webhooks.Create( + webhookId: "", + url: "", + name: "", + events: new List(), + enabled: false, // optional + security: false, // optional + httpUser: "", // optional + httpPass: "" // optional +);``` diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md new file mode 100644 index 00000000..a9aac880 --- /dev/null +++ b/docs/examples/webhooks/delete.md @@ -0,0 +1,15 @@ +```csharp +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 + +Webhooks webhooks = new Webhooks(client); + +await webhooks.Delete( + webhookId: "" +);``` diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md new file mode 100644 index 00000000..f9c6835a --- /dev/null +++ b/docs/examples/webhooks/get.md @@ -0,0 +1,15 @@ +```csharp +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 + +Webhooks webhooks = new Webhooks(client); + +Webhook result = await webhooks.Get( + webhookId: "" +);``` diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md new file mode 100644 index 00000000..94db7d62 --- /dev/null +++ b/docs/examples/webhooks/list.md @@ -0,0 +1,16 @@ +```csharp +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 + +Webhooks webhooks = new Webhooks(client); + +WebhookList result = await webhooks.List( + queries: new List(), // optional + total: false // optional +);``` diff --git a/docs/examples/webhooks/update-signature.md b/docs/examples/webhooks/update-signature.md new file mode 100644 index 00000000..3e5d1531 --- /dev/null +++ b/docs/examples/webhooks/update-signature.md @@ -0,0 +1,15 @@ +```csharp +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 + +Webhooks webhooks = new Webhooks(client); + +Webhook result = await webhooks.UpdateSignature( + webhookId: "" +);``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md new file mode 100644 index 00000000..cce5da7c --- /dev/null +++ b/docs/examples/webhooks/update.md @@ -0,0 +1,22 @@ +```csharp +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 + +Webhooks webhooks = new Webhooks(client); + +Webhook result = await webhooks.Update( + webhookId: "", + name: "", + url: "", + events: new List(), + enabled: false, // optional + security: false, // optional + httpUser: "", // optional + httpPass: "" // optional +);```