Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Appwrite/Appwrite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<PackageId>Appwrite</PackageId>
<Version>1.0.0</Version>
<Version>2.0.0</Version>
<Authors>Appwrite Team</Authors>
<Company>Appwrite Team</Company>
<Description>
Expand Down
30 changes: 27 additions & 3 deletions Appwrite/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public Client(
_headers = new Dictionary<string, string>()
{
{ "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<string, string>();
Expand Down Expand Up @@ -156,6 +156,30 @@ public Client SetForwardedUserAgent(string value) {
return this;
}

/// <summary>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.</summary>
public Client SetImpersonateUserId(string value) {
_config.Add("impersonateUserId", value);
AddHeader("X-Appwrite-Impersonate-User-Id", value);

return this;
}

/// <summary>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.</summary>
public Client SetImpersonateUserEmail(string value) {
_config.Add("impersonateUserEmail", value);
AddHeader("X-Appwrite-Impersonate-User-Email", value);

return this;
}

/// <summary>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.</summary>
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);
Expand Down
3 changes: 3 additions & 0 deletions Appwrite/Enums/BackupServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 2 additions & 0 deletions Appwrite/Enums/DatabaseType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
19 changes: 19 additions & 0 deletions Appwrite/Enums/DatabasesIndexType.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}
19 changes: 0 additions & 19 deletions Appwrite/Enums/IndexType.cs

This file was deleted.

4 changes: 4 additions & 0 deletions Appwrite/Enums/Scopes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
19 changes: 19 additions & 0 deletions Appwrite/Enums/TablesDBIndexType.cs
Original file line number Diff line number Diff line change
@@ -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");
}
}
2 changes: 1 addition & 1 deletion Appwrite/Enums/TemplateReferenceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
6 changes: 3 additions & 3 deletions Appwrite/Models/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -36,7 +36,7 @@ public class Document

public Document(
string id,
long sequence,
string sequence,
string collectionId,
string databaseId,
string createdAt,
Expand All @@ -56,7 +56,7 @@ Dictionary<string, object> data

public static Document From(Dictionary<string, object> 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(),
Expand Down
26 changes: 20 additions & 6 deletions Appwrite/Models/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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,
Expand All @@ -105,6 +111,7 @@ public Function(
bool live,
bool logging,
string runtime,
long deploymentRetention,
string deploymentId,
string deploymentCreatedAt,
string latestDeploymentId,
Expand All @@ -123,7 +130,8 @@ public Function(
string providerBranch,
string providerRootDirectory,
bool providerSilentMode,
string specification
string buildSpecification,
string runtimeSpecification
) {
Id = id;
CreatedAt = createdAt;
Expand All @@ -134,6 +142,7 @@ string specification
Live = live;
Logging = logging;
Runtime = runtime;
DeploymentRetention = deploymentRetention;
DeploymentId = deploymentId;
DeploymentCreatedAt = deploymentCreatedAt;
LatestDeploymentId = latestDeploymentId;
Expand All @@ -152,7 +161,8 @@ string specification
ProviderBranch = providerBranch;
ProviderRootDirectory = providerRootDirectory;
ProviderSilentMode = providerSilentMode;
Specification = specification;
BuildSpecification = buildSpecification;
RuntimeSpecification = runtimeSpecification;
}

public static Function From(Dictionary<string, object> map) => new Function(
Expand All @@ -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(),
Expand All @@ -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<string, object?> ToMap() => new Dictionary<string, object?>()
Expand All @@ -197,6 +209,7 @@ string specification
{ "live", Live },
{ "logging", Logging },
{ "runtime", Runtime },
{ "deploymentRetention", DeploymentRetention },
{ "deploymentId", DeploymentId },
{ "deploymentCreatedAt", DeploymentCreatedAt },
{ "latestDeploymentId", LatestDeploymentId },
Expand All @@ -215,7 +228,8 @@ string specification
{ "providerBranch", ProviderBranch },
{ "providerRootDirectory", ProviderRootDirectory },
{ "providerSilentMode", ProviderSilentMode },
{ "specification", Specification }
{ "buildSpecification", BuildSpecification },
{ "runtimeSpecification", RuntimeSpecification }
};
}
}
6 changes: 3 additions & 3 deletions Appwrite/Models/Row.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -36,7 +36,7 @@ public class Row

public Row(
string id,
long sequence,
string sequence,
string tableId,
string databaseId,
string createdAt,
Expand All @@ -56,7 +56,7 @@ Dictionary<string, object> data

public static Row From(Dictionary<string, object> 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(),
Expand Down
Loading