appwrite 5.0.0 → 7.0.0.pre.RC2

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 +10 -0
  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 +250 -103
  35. data/lib/appwrite/services/avatars.rb +73 -56
  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 -10
  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 +610 -130
  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 -1047
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ceedf8f740ccc7f74d65b4ad4d12a7ff85095fcc72da4174faacf9da2279541
4
- data.tar.gz: 66a9db695a5704b9679f1652d0855385a2790160bbe3126fa4c6df476ebe095d
3
+ metadata.gz: db30162a2dac2692eeebf378f4cea8089b30d382cb5b156cbcdad545493cd73a
4
+ data.tar.gz: 5ebf76520c1ca461bdad5b634bd20c6c20d1c73ea823b06bae536379e33a9dd4
5
5
  SHA512:
6
- metadata.gz: 5872cf6c0b6ae680d62d9dcdea77277650cf7d98622616c8963b2bf5c1bb5420b36459d1453bc41a54fa71414255a52dc437492253d9a5dfeffbd6715a67bbd8
7
- data.tar.gz: 35888e3e67a0511778cf2248683a298cd208057990edb6f1b40086ef4cc3efd84f9fa37d20ffc52e68de2fa3a1ed7224946d98ef9297586561e07afe2b24ea05
6
+ metadata.gz: 6b9d5a7f32ae74e0522f123ab55396219dbbbef748ec4eb8f728f15ad8da9f0ead7c5c0f65be89842e2415ce37ab1edfa7c095fb349978f7abd5828e5e5dfabe
7
+ data.tar.gz: 93bd9893306bf165137705f65cd43ec04d4f314177b4e24f129cb077ec91e88068a9262602cc5d6a6d6d6e9851e1eb933a7dc0719980336eba1435df6ffd902b
@@ -12,8 +12,11 @@ module Appwrite
12
12
  @chunk_size = 5*1024*1024
13
13
  @headers = {
14
14
  'user-agent' => RUBY_PLATFORM + ':ruby-' + RUBY_VERSION,
15
- 'x-sdk-version' => 'appwrite:ruby:5.0.0',
16
- 'X-Appwrite-Response-Format' => '0.14.0'
15
+ 'x-sdk-name'=> 'Ruby',
16
+ 'x-sdk-platform'=> 'server',
17
+ 'x-sdk-language'=> 'ruby',
18
+ 'x-sdk-version'=> '7.0.0-RC2',
19
+ 'X-Appwrite-Response-Format' => '1.0.0-RC1'
17
20
  }
18
21
  @endpoint = 'https://HOSTNAME/v1'
19
22
  end
@@ -133,12 +136,20 @@ module Appwrite
133
136
  on_progress: nil,
134
137
  response_type: nil
135
138
  )
136
- file_path = params[param_name.to_sym]
137
- size = ::File.size(file_path)
139
+ input_file = params[param_name.to_sym]
140
+
141
+ case input_file.source_type
142
+ when 'path'
143
+ size = ::File.size(input_file.path)
144
+ when 'string'
145
+ size = input_file.data.bytesize
146
+ end
138
147
 
139
148
  if size < @chunk_size
140
- slice = ::File.read(file_path)
141
- params[param_name] = File.new(file_path, slice)
149
+ if input_file.source_type == 'path'
150
+ input_file.data = IO.read(input_file.path)
151
+ end
152
+ params[param_name.to_sym] = input_file
142
153
  return call(
143
154
  method: 'POST',
144
155
  path: path,
@@ -163,9 +174,19 @@ module Appwrite
163
174
  end
164
175
 
165
176
  while offset < size
166
- slice = IO.read(file_path, @chunk_size, offset)
177
+ case input_file.source_type
178
+ when 'path'
179
+ string = IO.read(input_file.path, @chunk_size, offset)
180
+ when 'string'
181
+ string = input_file.data.byteslice(offset, [@chunk_size, size - offset].min)
182
+ end
183
+
184
+ params[param_name.to_sym] = InputFile::from_string(
185
+ string,
186
+ filename: input_file.filename,
187
+ mime_type: input_file.mime_type
188
+ )
167
189
 
168
- params[param_name] = File.new(file_path, slice)
169
190
  headers['content-range'] = "bytes #{offset}-#{[offset + @chunk_size - 1, size].min}/#{size}"
170
191
 
171
192
  result = call(
@@ -279,10 +300,10 @@ module Appwrite
279
300
  ''
280
301
  else
281
302
  post_body = []
282
- if value.instance_of? File
283
- post_body << "Content-Disposition: form-data; name=\"#{key}\"; filename=\"#{value.name}\"\r\n"
303
+ if value.instance_of? InputFile
304
+ post_body << "Content-Disposition: form-data; name=\"#{key}\"; filename=\"#{value.filename}\"\r\n"
284
305
  post_body << "Content-Type: #{value.mime_type}\r\n\r\n"
285
- post_body << value.content
306
+ post_body << value.data
286
307
  post_body << "\r\n--#{@boundary}--\r\n"
287
308
  else
288
309
  post_body << "Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n"
@@ -0,0 +1,11 @@
1
+ module Appwrite
2
+ class ID
3
+ def self.custom(id)
4
+ id
5
+ end
6
+
7
+ def self.unique
8
+ 'unique()'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ require 'mime/types'
2
+
3
+ module Appwrite
4
+ class InputFile
5
+ attr_accessor :path
6
+ attr_accessor :filename
7
+ attr_accessor :mime_type
8
+ attr_accessor :source_type
9
+ attr_accessor :data
10
+
11
+ def self.from_path(path)
12
+ instance = InputFile.new
13
+ instance.path = path
14
+ instance.filename = ::File.basename(path)
15
+ instance.mime_type = MIME::Types.type_for(path).first.content_type
16
+ instance.source_type = 'path'
17
+ instance
18
+ end
19
+
20
+ def self.from_string(string, filename: nil, mime_type: nil)
21
+ instance = InputFile.new
22
+ instance.data = string
23
+ instance.filename = filename
24
+ instance.mime_type = mime_type
25
+ instance.source_type = 'string'
26
+ instance
27
+ end
28
+
29
+ def self.from_bytes(bytes, filename: nil, mime_type: nil)
30
+ self.from_string(bytes.pack('C*'), filename: filename, mime_type: mime_type)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,82 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class Account
6
+ attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :name
10
+ attr_reader :registration
11
+ attr_reader :status
12
+ attr_reader :password_update
13
+ attr_reader :email
14
+ attr_reader :phone
15
+ attr_reader :email_verification
16
+ attr_reader :phone_verification
17
+ attr_reader :prefs
18
+
19
+ def initialize(
20
+ id:,
21
+ created_at:,
22
+ updated_at:,
23
+ name:,
24
+ registration:,
25
+ status:,
26
+ password_update:,
27
+ email:,
28
+ phone:,
29
+ email_verification:,
30
+ phone_verification:,
31
+ prefs:
32
+ )
33
+ @id = id
34
+ @created_at = created_at
35
+ @updated_at = updated_at
36
+ @name = name
37
+ @registration = registration
38
+ @status = status
39
+ @password_update = password_update
40
+ @email = email
41
+ @phone = phone
42
+ @email_verification = email_verification
43
+ @phone_verification = phone_verification
44
+ @prefs = prefs
45
+ end
46
+
47
+ def self.from(map:)
48
+ Account.new(
49
+ id: map["$id"],
50
+ created_at: map["$createdAt"],
51
+ updated_at: map["$updatedAt"],
52
+ name: map["name"],
53
+ registration: map["registration"],
54
+ status: map["status"],
55
+ password_update: map["passwordUpdate"],
56
+ email: map["email"],
57
+ phone: map["phone"],
58
+ email_verification: map["emailVerification"],
59
+ phone_verification: map["phoneVerification"],
60
+ prefs: Preferences.from(map: map["prefs"])
61
+ )
62
+ end
63
+
64
+ def to_map
65
+ {
66
+ "$id": @id,
67
+ "$createdAt": @created_at,
68
+ "$updatedAt": @updated_at,
69
+ "name": @name,
70
+ "registration": @registration,
71
+ "status": @status,
72
+ "passwordUpdate": @password_update,
73
+ "email": @email,
74
+ "phone": @phone,
75
+ "emailVerification": @email_verification,
76
+ "phoneVerification": @phone_verification,
77
+ "prefs": @prefs.to_map
78
+ }
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,37 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AlgoArgon2
6
+ attr_reader :memory_cost
7
+ attr_reader :time_cost
8
+ attr_reader :threads
9
+
10
+ def initialize(
11
+ memory_cost:,
12
+ time_cost:,
13
+ threads:
14
+ )
15
+ @memory_cost = memory_cost
16
+ @time_cost = time_cost
17
+ @threads = threads
18
+ end
19
+
20
+ def self.from(map:)
21
+ AlgoArgon2.new(
22
+ memory_cost: map["memoryCost"],
23
+ time_cost: map["timeCost"],
24
+ threads: map["threads"]
25
+ )
26
+ end
27
+
28
+ def to_map
29
+ {
30
+ "memoryCost": @memory_cost,
31
+ "timeCost": @time_cost,
32
+ "threads": @threads
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,22 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AlgoBcrypt
6
+
7
+ def initialize(
8
+ )
9
+ end
10
+
11
+ def self.from(map:)
12
+ AlgoBcrypt.new(
13
+ )
14
+ end
15
+
16
+ def to_map
17
+ {
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AlgoMd5
6
+
7
+ def initialize(
8
+ )
9
+ end
10
+
11
+ def self.from(map:)
12
+ AlgoMd5.new(
13
+ )
14
+ end
15
+
16
+ def to_map
17
+ {
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AlgoPhpass
6
+
7
+ def initialize(
8
+ )
9
+ end
10
+
11
+ def self.from(map:)
12
+ AlgoPhpass.new(
13
+ )
14
+ end
15
+
16
+ def to_map
17
+ {
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,42 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AlgoScrypt
6
+ attr_reader :cost_cpu
7
+ attr_reader :cost_memory
8
+ attr_reader :cost_parallel
9
+ attr_reader :length
10
+
11
+ def initialize(
12
+ cost_cpu:,
13
+ cost_memory:,
14
+ cost_parallel:,
15
+ length:
16
+ )
17
+ @cost_cpu = cost_cpu
18
+ @cost_memory = cost_memory
19
+ @cost_parallel = cost_parallel
20
+ @length = length
21
+ end
22
+
23
+ def self.from(map:)
24
+ AlgoScrypt.new(
25
+ cost_cpu: map["costCpu"],
26
+ cost_memory: map["costMemory"],
27
+ cost_parallel: map["costParallel"],
28
+ length: map["length"]
29
+ )
30
+ end
31
+
32
+ def to_map
33
+ {
34
+ "costCpu": @cost_cpu,
35
+ "costMemory": @cost_memory,
36
+ "costParallel": @cost_parallel,
37
+ "length": @length
38
+ }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,37 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AlgoScryptModified
6
+ attr_reader :salt
7
+ attr_reader :salt_separator
8
+ attr_reader :signer_key
9
+
10
+ def initialize(
11
+ salt:,
12
+ salt_separator:,
13
+ signer_key:
14
+ )
15
+ @salt = salt
16
+ @salt_separator = salt_separator
17
+ @signer_key = signer_key
18
+ end
19
+
20
+ def self.from(map:)
21
+ AlgoScryptModified.new(
22
+ salt: map["salt"],
23
+ salt_separator: map["saltSeparator"],
24
+ signer_key: map["signerKey"]
25
+ )
26
+ end
27
+
28
+ def to_map
29
+ {
30
+ "salt": @salt,
31
+ "saltSeparator": @salt_separator,
32
+ "signerKey": @signer_key
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,22 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AlgoSha
6
+
7
+ def initialize(
8
+ )
9
+ end
10
+
11
+ def self.from(map:)
12
+ AlgoSha.new(
13
+ )
14
+ end
15
+
16
+ def to_map
17
+ {
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,57 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class AttributeDatetime
6
+ attr_reader :key
7
+ attr_reader :type
8
+ attr_reader :status
9
+ attr_reader :required
10
+ attr_reader :array
11
+ attr_reader :format
12
+ attr_reader :default
13
+
14
+ def initialize(
15
+ key:,
16
+ type:,
17
+ status:,
18
+ required:,
19
+ array: ,
20
+ format:,
21
+ default:
22
+ )
23
+ @key = key
24
+ @type = type
25
+ @status = status
26
+ @required = required
27
+ @array = array
28
+ @format = format
29
+ @default = default
30
+ end
31
+
32
+ def self.from(map:)
33
+ AttributeDatetime.new(
34
+ key: map["key"],
35
+ type: map["type"],
36
+ status: map["status"],
37
+ required: map["required"],
38
+ array: map["array"],
39
+ format: map["format"],
40
+ default: map["default"]
41
+ )
42
+ end
43
+
44
+ def to_map
45
+ {
46
+ "key": @key,
47
+ "type": @type,
48
+ "status": @status,
49
+ "required": @required,
50
+ "array": @array,
51
+ "format": @format,
52
+ "default": @default
53
+ }
54
+ end
55
+ end
56
+ end
57
+ end
@@ -4,42 +4,42 @@ module Appwrite
4
4
  module Models
5
5
  class Bucket
6
6
  attr_reader :id
7
- attr_reader :read
8
- attr_reader :write
9
- attr_reader :permission
10
- attr_reader :date_created
11
- attr_reader :date_updated
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :permissions
10
+ attr_reader :file_security
12
11
  attr_reader :name
13
12
  attr_reader :enabled
14
13
  attr_reader :maximum_file_size
15
14
  attr_reader :allowed_file_extensions
15
+ attr_reader :compression
16
16
  attr_reader :encryption
17
17
  attr_reader :antivirus
18
18
 
19
19
  def initialize(
20
20
  id:,
21
- read:,
22
- write:,
23
- permission:,
24
- date_created:,
25
- date_updated:,
21
+ created_at:,
22
+ updated_at:,
23
+ permissions:,
24
+ file_security:,
26
25
  name:,
27
26
  enabled:,
28
27
  maximum_file_size:,
29
28
  allowed_file_extensions:,
29
+ compression:,
30
30
  encryption:,
31
31
  antivirus:
32
32
  )
33
33
  @id = id
34
- @read = read
35
- @write = write
36
- @permission = permission
37
- @date_created = date_created
38
- @date_updated = date_updated
34
+ @created_at = created_at
35
+ @updated_at = updated_at
36
+ @permissions = permissions
37
+ @file_security = file_security
39
38
  @name = name
40
39
  @enabled = enabled
41
40
  @maximum_file_size = maximum_file_size
42
41
  @allowed_file_extensions = allowed_file_extensions
42
+ @compression = compression
43
43
  @encryption = encryption
44
44
  @antivirus = antivirus
45
45
  end
@@ -47,15 +47,15 @@ module Appwrite
47
47
  def self.from(map:)
48
48
  Bucket.new(
49
49
  id: map["$id"],
50
- read: map["$read"],
51
- write: map["$write"],
52
- permission: map["permission"],
53
- date_created: map["dateCreated"],
54
- date_updated: map["dateUpdated"],
50
+ created_at: map["$createdAt"],
51
+ updated_at: map["$updatedAt"],
52
+ permissions: map["$permissions"],
53
+ file_security: map["fileSecurity"],
55
54
  name: map["name"],
56
55
  enabled: map["enabled"],
57
56
  maximum_file_size: map["maximumFileSize"],
58
57
  allowed_file_extensions: map["allowedFileExtensions"],
58
+ compression: map["compression"],
59
59
  encryption: map["encryption"],
60
60
  antivirus: map["antivirus"]
61
61
  )
@@ -64,15 +64,15 @@ module Appwrite
64
64
  def to_map
65
65
  {
66
66
  "$id": @id,
67
- "$read": @read,
68
- "$write": @write,
69
- "permission": @permission,
70
- "dateCreated": @date_created,
71
- "dateUpdated": @date_updated,
67
+ "$createdAt": @created_at,
68
+ "$updatedAt": @updated_at,
69
+ "$permissions": @permissions,
70
+ "fileSecurity": @file_security,
72
71
  "name": @name,
73
72
  "enabled": @enabled,
74
73
  "maximumFileSize": @maximum_file_size,
75
74
  "allowedFileExtensions": @allowed_file_extensions,
75
+ "compression": @compression,
76
76
  "encryption": @encryption,
77
77
  "antivirus": @antivirus
78
78
  }
@@ -4,30 +4,36 @@ module Appwrite
4
4
  module Models
5
5
  class Collection
6
6
  attr_reader :id
7
- attr_reader :read
8
- attr_reader :write
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :permissions
10
+ attr_reader :database_id
9
11
  attr_reader :name
10
12
  attr_reader :enabled
11
- attr_reader :permission
13
+ attr_reader :document_security
12
14
  attr_reader :attributes
13
15
  attr_reader :indexes
14
16
 
15
17
  def initialize(
16
18
  id:,
17
- read:,
18
- write:,
19
+ created_at:,
20
+ updated_at:,
21
+ permissions:,
22
+ database_id:,
19
23
  name:,
20
24
  enabled:,
21
- permission:,
25
+ document_security:,
22
26
  attributes:,
23
27
  indexes:
24
28
  )
25
29
  @id = id
26
- @read = read
27
- @write = write
30
+ @created_at = created_at
31
+ @updated_at = updated_at
32
+ @permissions = permissions
33
+ @database_id = database_id
28
34
  @name = name
29
35
  @enabled = enabled
30
- @permission = permission
36
+ @document_security = document_security
31
37
  @attributes = attributes
32
38
  @indexes = indexes
33
39
  end
@@ -35,11 +41,13 @@ module Appwrite
35
41
  def self.from(map:)
36
42
  Collection.new(
37
43
  id: map["$id"],
38
- read: map["$read"],
39
- write: map["$write"],
44
+ created_at: map["$createdAt"],
45
+ updated_at: map["$updatedAt"],
46
+ permissions: map["$permissions"],
47
+ database_id: map["databaseId"],
40
48
  name: map["name"],
41
49
  enabled: map["enabled"],
42
- permission: map["permission"],
50
+ document_security: map["documentSecurity"],
43
51
  attributes: map["attributes"],
44
52
  indexes: map["indexes"].map { |it| Index.from(map: it) }
45
53
  )
@@ -48,11 +56,13 @@ module Appwrite
48
56
  def to_map
49
57
  {
50
58
  "$id": @id,
51
- "$read": @read,
52
- "$write": @write,
59
+ "$createdAt": @created_at,
60
+ "$updatedAt": @updated_at,
61
+ "$permissions": @permissions,
62
+ "databaseId": @database_id,
53
63
  "name": @name,
54
64
  "enabled": @enabled,
55
- "permission": @permission,
65
+ "documentSecurity": @document_security,
56
66
  "attributes": @attributes,
57
67
  "indexes": @indexes.map { |it| it.to_map }
58
68
  }