appwrite 4.1.0 → 7.0.0.pre.RC1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +32 -11
  3. data/lib/appwrite/id.rb +11 -0
  4. data/lib/appwrite/input_file.rb +33 -0
  5. data/lib/appwrite/models/account.rb +82 -0
  6. data/lib/appwrite/models/algo_argon2.rb +37 -0
  7. data/lib/appwrite/models/algo_bcrypt.rb +22 -0
  8. data/lib/appwrite/models/algo_md5.rb +22 -0
  9. data/lib/appwrite/models/algo_phpass.rb +22 -0
  10. data/lib/appwrite/models/algo_scrypt.rb +42 -0
  11. data/lib/appwrite/models/algo_scrypt_modified.rb +37 -0
  12. data/lib/appwrite/models/algo_sha.rb +22 -0
  13. data/lib/appwrite/models/attribute_datetime.rb +57 -0
  14. data/lib/appwrite/models/bucket.rb +25 -25
  15. data/lib/appwrite/models/collection.rb +25 -15
  16. data/lib/appwrite/models/database.rb +42 -0
  17. data/lib/appwrite/models/database_list.rb +32 -0
  18. data/lib/appwrite/models/deployment.rb +10 -5
  19. data/lib/appwrite/models/document.rb +15 -10
  20. data/lib/appwrite/models/execution.rb +20 -10
  21. data/lib/appwrite/models/file.rb +15 -15
  22. data/lib/appwrite/models/function.rb +12 -12
  23. data/lib/appwrite/models/index.rb +1 -1
  24. data/lib/appwrite/models/membership.rb +25 -10
  25. data/lib/appwrite/models/session.rb +5 -0
  26. data/lib/appwrite/models/team.rb +10 -5
  27. data/lib/appwrite/models/token.rb +5 -0
  28. data/lib/appwrite/models/user.rb +35 -0
  29. data/lib/appwrite/models/variable.rb +52 -0
  30. data/lib/appwrite/models/variable_list.rb +32 -0
  31. data/lib/appwrite/permission.rb +21 -0
  32. data/lib/appwrite/query.rb +43 -14
  33. data/lib/appwrite/role.rb +31 -0
  34. data/lib/appwrite/services/account.rb +274 -126
  35. data/lib/appwrite/services/avatars.rb +106 -59
  36. data/lib/appwrite/services/databases.rb +1425 -0
  37. data/lib/appwrite/services/functions.rb +381 -176
  38. data/lib/appwrite/services/health.rb +34 -34
  39. data/lib/appwrite/services/locale.rb +25 -7
  40. data/lib/appwrite/services/storage.rb +195 -193
  41. data/lib/appwrite/services/teams.rb +138 -128
  42. data/lib/appwrite/services/users.rb +637 -123
  43. data/lib/appwrite.rb +19 -2
  44. metadata +22 -6
  45. data/lib/appwrite/file.rb +0 -17
  46. data/lib/appwrite/services/database.rb +0 -1049
@@ -0,0 +1,42 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class Database
6
+ attr_reader :id
7
+ attr_reader :name
8
+ attr_reader :created_at
9
+ attr_reader :updated_at
10
+
11
+ def initialize(
12
+ id:,
13
+ name:,
14
+ created_at:,
15
+ updated_at:
16
+ )
17
+ @id = id
18
+ @name = name
19
+ @created_at = created_at
20
+ @updated_at = updated_at
21
+ end
22
+
23
+ def self.from(map:)
24
+ Database.new(
25
+ id: map["$id"],
26
+ name: map["name"],
27
+ created_at: map["$createdAt"],
28
+ updated_at: map["$updatedAt"]
29
+ )
30
+ end
31
+
32
+ def to_map
33
+ {
34
+ "$id": @id,
35
+ "name": @name,
36
+ "$createdAt": @created_at,
37
+ "$updatedAt": @updated_at
38
+ }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class DatabaseList
6
+ attr_reader :total
7
+ attr_reader :databases
8
+
9
+ def initialize(
10
+ total:,
11
+ databases:
12
+ )
13
+ @total = total
14
+ @databases = databases
15
+ end
16
+
17
+ def self.from(map:)
18
+ DatabaseList.new(
19
+ total: map["total"],
20
+ databases: map["databases"].map { |it| Database.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "databases": @databases.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -4,9 +4,10 @@ module Appwrite
4
4
  module Models
5
5
  class Deployment
6
6
  attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
7
9
  attr_reader :resource_id
8
10
  attr_reader :resource_type
9
- attr_reader :date_created
10
11
  attr_reader :entrypoint
11
12
  attr_reader :size
12
13
  attr_reader :build_id
@@ -17,9 +18,10 @@ module Appwrite
17
18
 
18
19
  def initialize(
19
20
  id:,
21
+ created_at:,
22
+ updated_at:,
20
23
  resource_id:,
21
24
  resource_type:,
22
- date_created:,
23
25
  entrypoint:,
24
26
  size:,
25
27
  build_id:,
@@ -29,9 +31,10 @@ module Appwrite
29
31
  build_stderr:
30
32
  )
31
33
  @id = id
34
+ @created_at = created_at
35
+ @updated_at = updated_at
32
36
  @resource_id = resource_id
33
37
  @resource_type = resource_type
34
- @date_created = date_created
35
38
  @entrypoint = entrypoint
36
39
  @size = size
37
40
  @build_id = build_id
@@ -44,9 +47,10 @@ module Appwrite
44
47
  def self.from(map:)
45
48
  Deployment.new(
46
49
  id: map["$id"],
50
+ created_at: map["$createdAt"],
51
+ updated_at: map["$updatedAt"],
47
52
  resource_id: map["resourceId"],
48
53
  resource_type: map["resourceType"],
49
- date_created: map["dateCreated"],
50
54
  entrypoint: map["entrypoint"],
51
55
  size: map["size"],
52
56
  build_id: map["buildId"],
@@ -60,9 +64,10 @@ module Appwrite
60
64
  def to_map
61
65
  {
62
66
  "$id": @id,
67
+ "$createdAt": @created_at,
68
+ "$updatedAt": @updated_at,
63
69
  "resourceId": @resource_id,
64
70
  "resourceType": @resource_type,
65
- "dateCreated": @date_created,
66
71
  "entrypoint": @entrypoint,
67
72
  "size": @size,
68
73
  "buildId": @build_id,
@@ -5,20 +5,23 @@ module Appwrite
5
5
  class Document
6
6
  attr_reader :id
7
7
  attr_reader :collection
8
- attr_reader :read
9
- attr_reader :write
8
+ attr_reader :created_at
9
+ attr_reader :updated_at
10
+ attr_reader :permissions
10
11
 
11
12
  def initialize(
12
13
  id:,
13
14
  collection:,
14
- read:,
15
- write:,
15
+ created_at:,
16
+ updated_at:,
17
+ permissions:,
16
18
  data:
17
19
  )
18
20
  @id = id
19
21
  @collection = collection
20
- @read = read
21
- @write = write
22
+ @created_at = created_at
23
+ @updated_at = updated_at
24
+ @permissions = permissions
22
25
  @data = data
23
26
  end
24
27
 
@@ -26,8 +29,9 @@ module Appwrite
26
29
  Document.new(
27
30
  id: map["$id"],
28
31
  collection: map["$collection"],
29
- read: map["$read"],
30
- write: map["$write"],
32
+ created_at: map["$createdAt"],
33
+ updated_at: map["$updatedAt"],
34
+ permissions: map["$permissions"],
31
35
  data: map["data"]
32
36
  )
33
37
  end
@@ -36,8 +40,9 @@ module Appwrite
36
40
  {
37
41
  "$id": @id,
38
42
  "$collection": @collection,
39
- "$read": @read,
40
- "$write": @write,
43
+ "$createdAt": @created_at,
44
+ "$updatedAt": @updated_at,
45
+ "$permissions": @permissions,
41
46
  "data": @data
42
47
  }
43
48
  end
@@ -4,35 +4,41 @@ module Appwrite
4
4
  module Models
5
5
  class Execution
6
6
  attr_reader :id
7
- attr_reader :read
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :permissions
8
10
  attr_reader :function_id
9
- attr_reader :date_created
10
11
  attr_reader :trigger
11
12
  attr_reader :status
12
13
  attr_reader :status_code
14
+ attr_reader :response
13
15
  attr_reader :stdout
14
16
  attr_reader :stderr
15
17
  attr_reader :time
16
18
 
17
19
  def initialize(
18
20
  id:,
19
- read:,
21
+ created_at:,
22
+ updated_at:,
23
+ permissions:,
20
24
  function_id:,
21
- date_created:,
22
25
  trigger:,
23
26
  status:,
24
27
  status_code:,
28
+ response:,
25
29
  stdout:,
26
30
  stderr:,
27
31
  time:
28
32
  )
29
33
  @id = id
30
- @read = read
34
+ @created_at = created_at
35
+ @updated_at = updated_at
36
+ @permissions = permissions
31
37
  @function_id = function_id
32
- @date_created = date_created
33
38
  @trigger = trigger
34
39
  @status = status
35
40
  @status_code = status_code
41
+ @response = response
36
42
  @stdout = stdout
37
43
  @stderr = stderr
38
44
  @time = time
@@ -41,12 +47,14 @@ module Appwrite
41
47
  def self.from(map:)
42
48
  Execution.new(
43
49
  id: map["$id"],
44
- read: map["$read"],
50
+ created_at: map["$createdAt"],
51
+ updated_at: map["$updatedAt"],
52
+ permissions: map["$permissions"],
45
53
  function_id: map["functionId"],
46
- date_created: map["dateCreated"],
47
54
  trigger: map["trigger"],
48
55
  status: map["status"],
49
56
  status_code: map["statusCode"],
57
+ response: map["response"],
50
58
  stdout: map["stdout"],
51
59
  stderr: map["stderr"],
52
60
  time: map["time"]
@@ -56,12 +64,14 @@ module Appwrite
56
64
  def to_map
57
65
  {
58
66
  "$id": @id,
59
- "$read": @read,
67
+ "$createdAt": @created_at,
68
+ "$updatedAt": @updated_at,
69
+ "$permissions": @permissions,
60
70
  "functionId": @function_id,
61
- "dateCreated": @date_created,
62
71
  "trigger": @trigger,
63
72
  "status": @status,
64
73
  "statusCode": @status_code,
74
+ "response": @response,
65
75
  "stdout": @stdout,
66
76
  "stderr": @stderr,
67
77
  "time": @time
@@ -5,10 +5,10 @@ module Appwrite
5
5
  class File
6
6
  attr_reader :id
7
7
  attr_reader :bucket_id
8
- attr_reader :read
9
- attr_reader :write
8
+ attr_reader :created_at
9
+ attr_reader :updated_at
10
+ attr_reader :permissions
10
11
  attr_reader :name
11
- attr_reader :date_created
12
12
  attr_reader :signature
13
13
  attr_reader :mime_type
14
14
  attr_reader :size_original
@@ -18,10 +18,10 @@ module Appwrite
18
18
  def initialize(
19
19
  id:,
20
20
  bucket_id:,
21
- read:,
22
- write:,
21
+ created_at:,
22
+ updated_at:,
23
+ permissions:,
23
24
  name:,
24
- date_created:,
25
25
  signature:,
26
26
  mime_type:,
27
27
  size_original:,
@@ -30,10 +30,10 @@ module Appwrite
30
30
  )
31
31
  @id = id
32
32
  @bucket_id = bucket_id
33
- @read = read
34
- @write = write
33
+ @created_at = created_at
34
+ @updated_at = updated_at
35
+ @permissions = permissions
35
36
  @name = name
36
- @date_created = date_created
37
37
  @signature = signature
38
38
  @mime_type = mime_type
39
39
  @size_original = size_original
@@ -45,10 +45,10 @@ module Appwrite
45
45
  File.new(
46
46
  id: map["$id"],
47
47
  bucket_id: map["bucketId"],
48
- read: map["$read"],
49
- write: map["$write"],
48
+ created_at: map["$createdAt"],
49
+ updated_at: map["$updatedAt"],
50
+ permissions: map["$permissions"],
50
51
  name: map["name"],
51
- date_created: map["dateCreated"],
52
52
  signature: map["signature"],
53
53
  mime_type: map["mimeType"],
54
54
  size_original: map["sizeOriginal"],
@@ -61,10 +61,10 @@ module Appwrite
61
61
  {
62
62
  "$id": @id,
63
63
  "bucketId": @bucket_id,
64
- "$read": @read,
65
- "$write": @write,
64
+ "$createdAt": @created_at,
65
+ "$updatedAt": @updated_at,
66
+ "$permissions": @permissions,
66
67
  "name": @name,
67
- "dateCreated": @date_created,
68
68
  "signature": @signature,
69
69
  "mimeType": @mime_type,
70
70
  "sizeOriginal": @size_original,
@@ -4,10 +4,10 @@ module Appwrite
4
4
  module Models
5
5
  class Function
6
6
  attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
7
9
  attr_reader :execute
8
10
  attr_reader :name
9
- attr_reader :date_created
10
- attr_reader :date_updated
11
11
  attr_reader :status
12
12
  attr_reader :runtime
13
13
  attr_reader :deployment
@@ -20,10 +20,10 @@ module Appwrite
20
20
 
21
21
  def initialize(
22
22
  id:,
23
+ created_at:,
24
+ updated_at:,
23
25
  execute:,
24
26
  name:,
25
- date_created:,
26
- date_updated:,
27
27
  status:,
28
28
  runtime:,
29
29
  deployment:,
@@ -35,10 +35,10 @@ module Appwrite
35
35
  timeout:
36
36
  )
37
37
  @id = id
38
+ @created_at = created_at
39
+ @updated_at = updated_at
38
40
  @execute = execute
39
41
  @name = name
40
- @date_created = date_created
41
- @date_updated = date_updated
42
42
  @status = status
43
43
  @runtime = runtime
44
44
  @deployment = deployment
@@ -53,14 +53,14 @@ module Appwrite
53
53
  def self.from(map:)
54
54
  Function.new(
55
55
  id: map["$id"],
56
+ created_at: map["$createdAt"],
57
+ updated_at: map["$updatedAt"],
56
58
  execute: map["execute"],
57
59
  name: map["name"],
58
- date_created: map["dateCreated"],
59
- date_updated: map["dateUpdated"],
60
60
  status: map["status"],
61
61
  runtime: map["runtime"],
62
62
  deployment: map["deployment"],
63
- vars: map["vars"],
63
+ vars: map["vars"].map { |it| Variable.from(map: it) },
64
64
  events: map["events"],
65
65
  schedule: map["schedule"],
66
66
  schedule_next: map["scheduleNext"],
@@ -72,14 +72,14 @@ module Appwrite
72
72
  def to_map
73
73
  {
74
74
  "$id": @id,
75
+ "$createdAt": @created_at,
76
+ "$updatedAt": @updated_at,
75
77
  "execute": @execute,
76
78
  "name": @name,
77
- "dateCreated": @date_created,
78
- "dateUpdated": @date_updated,
79
79
  "status": @status,
80
80
  "runtime": @runtime,
81
81
  "deployment": @deployment,
82
- "vars": @vars,
82
+ "vars": @vars.map { |it| it.to_map },
83
83
  "events": @events,
84
84
  "schedule": @schedule,
85
85
  "scheduleNext": @schedule_next,
@@ -14,7 +14,7 @@ module Appwrite
14
14
  type:,
15
15
  status:,
16
16
  attributes:,
17
- orders:
17
+ orders:
18
18
  )
19
19
  @key = key
20
20
  @type = type
@@ -4,10 +4,13 @@ module Appwrite
4
4
  module Models
5
5
  class Membership
6
6
  attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
7
9
  attr_reader :user_id
10
+ attr_reader :user_name
11
+ attr_reader :user_email
8
12
  attr_reader :team_id
9
- attr_reader :name
10
- attr_reader :email
13
+ attr_reader :team_name
11
14
  attr_reader :invited
12
15
  attr_reader :joined
13
16
  attr_reader :confirm
@@ -15,20 +18,26 @@ module Appwrite
15
18
 
16
19
  def initialize(
17
20
  id:,
21
+ created_at:,
22
+ updated_at:,
18
23
  user_id:,
24
+ user_name:,
25
+ user_email:,
19
26
  team_id:,
20
- name:,
21
- email:,
27
+ team_name:,
22
28
  invited:,
23
29
  joined:,
24
30
  confirm:,
25
31
  roles:
26
32
  )
27
33
  @id = id
34
+ @created_at = created_at
35
+ @updated_at = updated_at
28
36
  @user_id = user_id
37
+ @user_name = user_name
38
+ @user_email = user_email
29
39
  @team_id = team_id
30
- @name = name
31
- @email = email
40
+ @team_name = team_name
32
41
  @invited = invited
33
42
  @joined = joined
34
43
  @confirm = confirm
@@ -38,10 +47,13 @@ module Appwrite
38
47
  def self.from(map:)
39
48
  Membership.new(
40
49
  id: map["$id"],
50
+ created_at: map["$createdAt"],
51
+ updated_at: map["$updatedAt"],
41
52
  user_id: map["userId"],
53
+ user_name: map["userName"],
54
+ user_email: map["userEmail"],
42
55
  team_id: map["teamId"],
43
- name: map["name"],
44
- email: map["email"],
56
+ team_name: map["teamName"],
45
57
  invited: map["invited"],
46
58
  joined: map["joined"],
47
59
  confirm: map["confirm"],
@@ -52,10 +64,13 @@ module Appwrite
52
64
  def to_map
53
65
  {
54
66
  "$id": @id,
67
+ "$createdAt": @created_at,
68
+ "$updatedAt": @updated_at,
55
69
  "userId": @user_id,
70
+ "userName": @user_name,
71
+ "userEmail": @user_email,
56
72
  "teamId": @team_id,
57
- "name": @name,
58
- "email": @email,
73
+ "teamName": @team_name,
59
74
  "invited": @invited,
60
75
  "joined": @joined,
61
76
  "confirm": @confirm,
@@ -4,6 +4,7 @@ module Appwrite
4
4
  module Models
5
5
  class Session
6
6
  attr_reader :id
7
+ attr_reader :created_at
7
8
  attr_reader :user_id
8
9
  attr_reader :expire
9
10
  attr_reader :provider
@@ -30,6 +31,7 @@ module Appwrite
30
31
 
31
32
  def initialize(
32
33
  id:,
34
+ created_at:,
33
35
  user_id:,
34
36
  expire:,
35
37
  provider:,
@@ -55,6 +57,7 @@ module Appwrite
55
57
  current:
56
58
  )
57
59
  @id = id
60
+ @created_at = created_at
58
61
  @user_id = user_id
59
62
  @expire = expire
60
63
  @provider = provider
@@ -83,6 +86,7 @@ module Appwrite
83
86
  def self.from(map:)
84
87
  Session.new(
85
88
  id: map["$id"],
89
+ created_at: map["$createdAt"],
86
90
  user_id: map["userId"],
87
91
  expire: map["expire"],
88
92
  provider: map["provider"],
@@ -112,6 +116,7 @@ module Appwrite
112
116
  def to_map
113
117
  {
114
118
  "$id": @id,
119
+ "$createdAt": @created_at,
115
120
  "userId": @user_id,
116
121
  "expire": @expire,
117
122
  "provider": @provider,
@@ -4,27 +4,31 @@ module Appwrite
4
4
  module Models
5
5
  class Team
6
6
  attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
7
9
  attr_reader :name
8
- attr_reader :date_created
9
10
  attr_reader :total
10
11
 
11
12
  def initialize(
12
13
  id:,
14
+ created_at:,
15
+ updated_at:,
13
16
  name:,
14
- date_created:,
15
17
  total:
16
18
  )
17
19
  @id = id
20
+ @created_at = created_at
21
+ @updated_at = updated_at
18
22
  @name = name
19
- @date_created = date_created
20
23
  @total = total
21
24
  end
22
25
 
23
26
  def self.from(map:)
24
27
  Team.new(
25
28
  id: map["$id"],
29
+ created_at: map["$createdAt"],
30
+ updated_at: map["$updatedAt"],
26
31
  name: map["name"],
27
- date_created: map["dateCreated"],
28
32
  total: map["total"]
29
33
  )
30
34
  end
@@ -32,8 +36,9 @@ module Appwrite
32
36
  def to_map
33
37
  {
34
38
  "$id": @id,
39
+ "$createdAt": @created_at,
40
+ "$updatedAt": @updated_at,
35
41
  "name": @name,
36
- "dateCreated": @date_created,
37
42
  "total": @total
38
43
  }
39
44
  end
@@ -4,17 +4,20 @@ module Appwrite
4
4
  module Models
5
5
  class Token
6
6
  attr_reader :id
7
+ attr_reader :created_at
7
8
  attr_reader :user_id
8
9
  attr_reader :secret
9
10
  attr_reader :expire
10
11
 
11
12
  def initialize(
12
13
  id:,
14
+ created_at:,
13
15
  user_id:,
14
16
  secret:,
15
17
  expire:
16
18
  )
17
19
  @id = id
20
+ @created_at = created_at
18
21
  @user_id = user_id
19
22
  @secret = secret
20
23
  @expire = expire
@@ -23,6 +26,7 @@ module Appwrite
23
26
  def self.from(map:)
24
27
  Token.new(
25
28
  id: map["$id"],
29
+ created_at: map["$createdAt"],
26
30
  user_id: map["userId"],
27
31
  secret: map["secret"],
28
32
  expire: map["expire"]
@@ -32,6 +36,7 @@ module Appwrite
32
36
  def to_map
33
37
  {
34
38
  "$id": @id,
39
+ "$createdAt": @created_at,
35
40
  "userId": @user_id,
36
41
  "secret": @secret,
37
42
  "expire": @expire