appwrite 6.0.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +5 -2
  3. data/lib/appwrite/id.rb +11 -0
  4. data/lib/appwrite/models/account.rb +82 -0
  5. data/lib/appwrite/models/algo_argon2.rb +37 -0
  6. data/lib/appwrite/models/algo_bcrypt.rb +22 -0
  7. data/lib/appwrite/models/algo_md5.rb +22 -0
  8. data/lib/appwrite/models/algo_phpass.rb +22 -0
  9. data/lib/appwrite/models/algo_scrypt.rb +42 -0
  10. data/lib/appwrite/models/algo_scrypt_modified.rb +37 -0
  11. data/lib/appwrite/models/algo_sha.rb +22 -0
  12. data/lib/appwrite/models/attribute_datetime.rb +57 -0
  13. data/lib/appwrite/models/bucket.rb +15 -15
  14. data/lib/appwrite/models/collection.rb +10 -15
  15. data/lib/appwrite/models/database.rb +13 -3
  16. data/lib/appwrite/models/document.rb +5 -10
  17. data/lib/appwrite/models/execution.rb +10 -5
  18. data/lib/appwrite/models/file.rb +5 -10
  19. data/lib/appwrite/models/function.rb +2 -2
  20. data/lib/appwrite/models/index.rb +1 -1
  21. data/lib/appwrite/models/user.rb +15 -0
  22. data/lib/appwrite/models/variable.rb +52 -0
  23. data/lib/appwrite/models/variable_list.rb +32 -0
  24. data/lib/appwrite/permission.rb +21 -0
  25. data/lib/appwrite/query.rb +43 -14
  26. data/lib/appwrite/role.rb +31 -0
  27. data/lib/appwrite/services/account.rb +184 -143
  28. data/lib/appwrite/services/avatars.rb +72 -56
  29. data/lib/appwrite/services/databases.rb +638 -552
  30. data/lib/appwrite/services/functions.rb +380 -176
  31. data/lib/appwrite/services/health.rb +33 -10
  32. data/lib/appwrite/services/locale.rb +24 -7
  33. data/lib/appwrite/services/storage.rb +194 -193
  34. data/lib/appwrite/services/teams.rb +137 -128
  35. data/lib/appwrite/services/users.rb +572 -163
  36. data/lib/appwrite.rb +15 -0
  37. metadata +18 -4
@@ -3,30 +3,26 @@
3
3
  module Appwrite
4
4
  class Storage < Service
5
5
 
6
+ def initialize(client)
7
+ @client = client
8
+ end
6
9
 
7
10
  # Get a list of all the storage buckets. You can use the query params to
8
11
  # filter your results.
9
12
  #
10
- # @param [string] search Search term to filter your list results. Max length: 256 chars.
11
- # @param [number] limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.
12
- # @param [number] offset Results offset. The default value is 0. Use this param to manage pagination.
13
- # @param [string] cursor ID of the bucket used as the starting point for the query, excluding the bucket itself. Should be used for efficient pagination when working with large sets of data.
14
- # @param [string] cursor_direction Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
15
- # @param [string] order_type Order result by ASC or DESC order.
13
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus
14
+ # @param [String] search Search term to filter your list results. Max length: 256 chars.
16
15
  #
17
16
  # @return [BucketList]
18
- def list_buckets(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
17
+ def list_buckets(queries: nil, search: nil)
18
+
19
19
  path = '/storage/buckets'
20
20
 
21
21
  params = {
22
+ queries: queries,
22
23
  search: search,
23
- limit: limit,
24
- offset: offset,
25
- cursor: cursor,
26
- cursorDirection: cursor_direction,
27
- orderType: order_type,
28
24
  }
29
-
25
+
30
26
  headers = {
31
27
  "content-type": 'application/json',
32
28
  }
@@ -40,51 +36,49 @@ module Appwrite
40
36
  )
41
37
  end
42
38
 
39
+
43
40
  # Create a new storage bucket.
44
41
  #
45
- # @param [string] bucket_id Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
46
- # @param [string] name Bucket name
47
- # @param [string] permission Permissions type model to use for reading files in this bucket. You can use bucket-level permission set once on the bucket using the `read` and `write` params, or you can set file-level permission where each file read and write params will decide who has access to read and write to each file individually. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
48
- # @param [array] read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
49
- # @param [array] write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
50
- # @param [boolean] enabled Is bucket enabled?
51
- # @param [number] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)
52
- # @param [array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
53
- # @param [boolean] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it&#039;s enabled
54
- # @param [boolean] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it&#039;s enabled
42
+ # @param [String] bucket_id Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
43
+ # @param [String] name Bucket name
44
+ # @param [Array] permissions An array of permission strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions).
45
+ # @param [] file_security Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).
46
+ # @param [] enabled Is bucket enabled?
47
+ # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)
48
+ # @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
49
+ # @param [String] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it&#039;s enabled
50
+ # @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it&#039;s enabled
51
+ # @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it&#039;s enabled
55
52
  #
56
53
  # @return [Bucket]
57
- def create_bucket(bucket_id:, name:, permission:, read: nil, write: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, encryption: nil, antivirus: nil)
58
- if bucket_id.nil?
59
- raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
60
- end
61
-
62
- if name.nil?
63
- raise Appwrite::Exception.new('Missing required parameter: "name"')
64
- end
65
-
66
- if permission.nil?
67
- raise Appwrite::Exception.new('Missing required parameter: "permission"')
68
- end
54
+ def create_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, compression: nil, encryption: nil, antivirus: nil)
69
55
 
70
56
  path = '/storage/buckets'
71
57
 
72
58
  params = {
73
59
  bucketId: bucket_id,
74
60
  name: name,
75
- permission: permission,
76
- read: read,
77
- write: write,
61
+ permissions: permissions,
62
+ fileSecurity: file_security,
78
63
  enabled: enabled,
79
64
  maximumFileSize: maximum_file_size,
80
65
  allowedFileExtensions: allowed_file_extensions,
66
+ compression: compression,
81
67
  encryption: encryption,
82
68
  antivirus: antivirus,
83
69
  }
84
-
70
+
85
71
  headers = {
86
72
  "content-type": 'application/json',
87
73
  }
74
+ if bucket_id.nil?
75
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
76
+ end
77
+
78
+ if name.nil?
79
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
80
+ end
81
+
88
82
 
89
83
  @client.call(
90
84
  method: 'POST',
@@ -95,26 +89,28 @@ module Appwrite
95
89
  )
96
90
  end
97
91
 
92
+
98
93
  # Get a storage bucket by its unique ID. This endpoint response returns a
99
94
  # JSON object with the storage bucket metadata.
100
95
  #
101
- # @param [string] bucket_id Bucket unique ID.
96
+ # @param [String] bucket_id Bucket unique ID.
102
97
  #
103
98
  # @return [Bucket]
104
99
  def get_bucket(bucket_id:)
105
- if bucket_id.nil?
106
- raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
107
- end
108
100
 
109
101
  path = '/storage/buckets/{bucketId}'
110
- .gsub('{bucketId}', bucket_id)
111
102
 
112
103
  params = {
113
104
  }
114
-
105
+
115
106
  headers = {
116
107
  "content-type": 'application/json',
117
108
  }
109
+ if bucket_id.nil?
110
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
111
+ end
112
+
113
+ .gsub('{bucketId}', bucket_id)
118
114
 
119
115
  @client.call(
120
116
  method: 'GET',
@@ -125,51 +121,49 @@ module Appwrite
125
121
  )
126
122
  end
127
123
 
124
+
128
125
  # Update a storage bucket by its unique ID.
129
126
  #
130
- # @param [string] bucket_id Bucket unique ID.
131
- # @param [string] name Bucket name
132
- # @param [string] permission Permissions type model to use for reading files in this bucket. You can use bucket-level permission set once on the bucket using the `read` and `write` params, or you can set file-level permission where each file read and write params will decide who has access to read and write to each file individually. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
133
- # @param [array] read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
134
- # @param [array] write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
135
- # @param [boolean] enabled Is bucket enabled?
136
- # @param [number] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)
137
- # @param [array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
138
- # @param [boolean] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it&#039;s enabled
139
- # @param [boolean] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it&#039;s enabled
127
+ # @param [String] bucket_id Bucket unique ID.
128
+ # @param [String] name Bucket name
129
+ # @param [Array] permissions An array of permission strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).
130
+ # @param [] file_security Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).
131
+ # @param [] enabled Is bucket enabled?
132
+ # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)
133
+ # @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
134
+ # @param [String] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it&#039;s enabled
135
+ # @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it&#039;s enabled
136
+ # @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it&#039;s enabled
140
137
  #
141
138
  # @return [Bucket]
142
- def update_bucket(bucket_id:, name:, permission:, read: nil, write: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, encryption: nil, antivirus: nil)
143
- if bucket_id.nil?
144
- raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
145
- end
146
-
147
- if name.nil?
148
- raise Appwrite::Exception.new('Missing required parameter: "name"')
149
- end
150
-
151
- if permission.nil?
152
- raise Appwrite::Exception.new('Missing required parameter: "permission"')
153
- end
139
+ def update_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, compression: nil, encryption: nil, antivirus: nil)
154
140
 
155
141
  path = '/storage/buckets/{bucketId}'
156
- .gsub('{bucketId}', bucket_id)
157
142
 
158
143
  params = {
159
144
  name: name,
160
- permission: permission,
161
- read: read,
162
- write: write,
145
+ permissions: permissions,
146
+ fileSecurity: file_security,
163
147
  enabled: enabled,
164
148
  maximumFileSize: maximum_file_size,
165
149
  allowedFileExtensions: allowed_file_extensions,
150
+ compression: compression,
166
151
  encryption: encryption,
167
152
  antivirus: antivirus,
168
153
  }
169
-
154
+
170
155
  headers = {
171
156
  "content-type": 'application/json',
172
157
  }
158
+ if bucket_id.nil?
159
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
160
+ end
161
+
162
+ if name.nil?
163
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
164
+ end
165
+
166
+ .gsub('{bucketId}', bucket_id)
173
167
 
174
168
  @client.call(
175
169
  method: 'PUT',
@@ -180,25 +174,27 @@ module Appwrite
180
174
  )
181
175
  end
182
176
 
177
+
183
178
  # Delete a storage bucket by its unique ID.
184
179
  #
185
- # @param [string] bucket_id Bucket unique ID.
180
+ # @param [String] bucket_id Bucket unique ID.
186
181
  #
187
182
  # @return []
188
183
  def delete_bucket(bucket_id:)
189
- if bucket_id.nil?
190
- raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
191
- end
192
184
 
193
185
  path = '/storage/buckets/{bucketId}'
194
- .gsub('{bucketId}', bucket_id)
195
186
 
196
187
  params = {
197
188
  }
198
-
189
+
199
190
  headers = {
200
191
  "content-type": 'application/json',
201
192
  }
193
+ if bucket_id.nil?
194
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
195
+ end
196
+
197
+ .gsub('{bucketId}', bucket_id)
202
198
 
203
199
  @client.call(
204
200
  method: 'DELETE',
@@ -208,39 +204,33 @@ module Appwrite
208
204
  )
209
205
  end
210
206
 
207
+
211
208
  # Get a list of all the user files. You can use the query params to filter
212
209
  # your results. On admin mode, this endpoint will return a list of all of the
213
210
  # project's files. [Learn more about different API modes](/docs/admin).
214
211
  #
215
- # @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
216
- # @param [string] search Search term to filter your list results. Max length: 256 chars.
217
- # @param [number] limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
218
- # @param [number] offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
219
- # @param [string] cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
220
- # @param [string] cursor_direction Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
221
- # @param [string] order_type Order result by ASC or DESC order.
212
+ # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
213
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
214
+ # @param [String] search Search term to filter your list results. Max length: 256 chars.
222
215
  #
223
216
  # @return [FileList]
224
- def list_files(bucket_id:, search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
225
- if bucket_id.nil?
226
- raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
227
- end
217
+ def list_files(bucket_id:, queries: nil, search: nil)
228
218
 
229
219
  path = '/storage/buckets/{bucketId}/files'
230
- .gsub('{bucketId}', bucket_id)
231
220
 
232
221
  params = {
222
+ queries: queries,
233
223
  search: search,
234
- limit: limit,
235
- offset: offset,
236
- cursor: cursor,
237
- cursorDirection: cursor_direction,
238
- orderType: order_type,
239
224
  }
240
-
225
+
241
226
  headers = {
242
227
  "content-type": 'application/json',
243
228
  }
229
+ if bucket_id.nil?
230
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
231
+ end
232
+
233
+ .gsub('{bucketId}', bucket_id)
244
234
 
245
235
  @client.call(
246
236
  method: 'GET',
@@ -251,10 +241,11 @@ module Appwrite
251
241
  )
252
242
  end
253
243
 
244
+
254
245
  # Create a new file. Before using this route, you should create a new bucket
255
246
  # resource using either a [server
256
- # integration](/docs/server/database#storageCreateBucket) API or directly
257
- # from your Appwrite console.
247
+ # integration](/docs/server/storage#storageCreateBucket) API or directly from
248
+ # your Appwrite console.
258
249
  #
259
250
  # Larger files should be uploaded using multiple requests with the
260
251
  # [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
@@ -270,14 +261,25 @@ module Appwrite
270
261
  # chunking logic will be managed by the SDK internally.
271
262
  #
272
263
  #
273
- # @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
274
- # @param [string] file_id File ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
264
+ # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
265
+ # @param [String] file_id File ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
275
266
  # @param [file] file Binary file.
276
- # @param [array] read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
277
- # @param [array] write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
267
+ # @param [Array] permissions An array of permission strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions).
278
268
  #
279
269
  # @return [File]
280
- def create_file(bucket_id:, file_id:, file:, read: nil, write: nil, on_progress: nil)
270
+ def create_file(bucket_id:, file_id:, file:, permissions: nil, on_progress: nil)
271
+
272
+ path = '/storage/buckets/{bucketId}/files'
273
+
274
+ params = {
275
+ fileId: file_id,
276
+ file: file,
277
+ permissions: permissions,
278
+ }
279
+
280
+ headers = {
281
+ "content-type": 'multipart/form-data',
282
+ }
281
283
  if bucket_id.nil?
282
284
  raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
283
285
  end
@@ -290,20 +292,8 @@ module Appwrite
290
292
  raise Appwrite::Exception.new('Missing required parameter: "file"')
291
293
  end
292
294
 
293
- path = '/storage/buckets/{bucketId}/files'
294
295
  .gsub('{bucketId}', bucket_id)
295
296
 
296
- params = {
297
- fileId: file_id,
298
- file: file,
299
- read: read,
300
- write: write,
301
- }
302
-
303
- headers = {
304
- "content-type": 'multipart/form-data',
305
- }
306
-
307
297
  id_param_name = "fileId"
308
298
  param_name = 'file'
309
299
 
@@ -318,14 +308,24 @@ module Appwrite
318
308
  )
319
309
  end
320
310
 
311
+
321
312
  # Get a file by its unique ID. This endpoint response returns a JSON object
322
313
  # with the file metadata.
323
314
  #
324
- # @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
325
- # @param [string] file_id File ID.
315
+ # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
316
+ # @param [String] file_id File ID.
326
317
  #
327
318
  # @return [File]
328
319
  def get_file(bucket_id:, file_id:)
320
+
321
+ path = '/storage/buckets/{bucketId}/files/{fileId}'
322
+
323
+ params = {
324
+ }
325
+
326
+ headers = {
327
+ "content-type": 'application/json',
328
+ }
329
329
  if bucket_id.nil?
330
330
  raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
331
331
  end
@@ -334,17 +334,9 @@ module Appwrite
334
334
  raise Appwrite::Exception.new('Missing required parameter: "fileId"')
335
335
  end
336
336
 
337
- path = '/storage/buckets/{bucketId}/files/{fileId}'
338
337
  .gsub('{bucketId}', bucket_id)
339
338
  .gsub('{fileId}', file_id)
340
339
 
341
- params = {
342
- }
343
-
344
- headers = {
345
- "content-type": 'application/json',
346
- }
347
-
348
340
  @client.call(
349
341
  method: 'GET',
350
342
  path: path,
@@ -354,16 +346,26 @@ module Appwrite
354
346
  )
355
347
  end
356
348
 
349
+
357
350
  # Update a file by its unique ID. Only users with write permissions have
358
351
  # access to update this resource.
359
352
  #
360
- # @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
361
- # @param [string] file_id File unique ID.
362
- # @param [array] read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
363
- # @param [array] write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
353
+ # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
354
+ # @param [String] file_id File unique ID.
355
+ # @param [Array] permissions An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).
364
356
  #
365
357
  # @return [File]
366
- def update_file(bucket_id:, file_id:, read: nil, write: nil)
358
+ def update_file(bucket_id:, file_id:, permissions: nil)
359
+
360
+ path = '/storage/buckets/{bucketId}/files/{fileId}'
361
+
362
+ params = {
363
+ permissions: permissions,
364
+ }
365
+
366
+ headers = {
367
+ "content-type": 'application/json',
368
+ }
367
369
  if bucket_id.nil?
368
370
  raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
369
371
  end
@@ -372,19 +374,9 @@ module Appwrite
372
374
  raise Appwrite::Exception.new('Missing required parameter: "fileId"')
373
375
  end
374
376
 
375
- path = '/storage/buckets/{bucketId}/files/{fileId}'
376
377
  .gsub('{bucketId}', bucket_id)
377
378
  .gsub('{fileId}', file_id)
378
379
 
379
- params = {
380
- read: read,
381
- write: write,
382
- }
383
-
384
- headers = {
385
- "content-type": 'application/json',
386
- }
387
-
388
380
  @client.call(
389
381
  method: 'PUT',
390
382
  path: path,
@@ -394,14 +386,24 @@ module Appwrite
394
386
  )
395
387
  end
396
388
 
389
+
397
390
  # Delete a file by its unique ID. Only users with write permissions have
398
391
  # access to delete this resource.
399
392
  #
400
- # @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
401
- # @param [string] file_id File ID.
393
+ # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
394
+ # @param [String] file_id File ID.
402
395
  #
403
396
  # @return []
404
397
  def delete_file(bucket_id:, file_id:)
398
+
399
+ path = '/storage/buckets/{bucketId}/files/{fileId}'
400
+
401
+ params = {
402
+ }
403
+
404
+ headers = {
405
+ "content-type": 'application/json',
406
+ }
405
407
  if bucket_id.nil?
406
408
  raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
407
409
  end
@@ -410,17 +412,9 @@ module Appwrite
410
412
  raise Appwrite::Exception.new('Missing required parameter: "fileId"')
411
413
  end
412
414
 
413
- path = '/storage/buckets/{bucketId}/files/{fileId}'
414
415
  .gsub('{bucketId}', bucket_id)
415
416
  .gsub('{fileId}', file_id)
416
417
 
417
- params = {
418
- }
419
-
420
- headers = {
421
- "content-type": 'application/json',
422
- }
423
-
424
418
  @client.call(
425
419
  method: 'DELETE',
426
420
  path: path,
@@ -429,15 +423,25 @@ module Appwrite
429
423
  )
430
424
  end
431
425
 
426
+
432
427
  # Get a file content by its unique ID. The endpoint response return with a
433
428
  # 'Content-Disposition: attachment' header that tells the browser to start
434
429
  # downloading the file to user downloads directory.
435
430
  #
436
- # @param [string] bucket_id Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
437
- # @param [string] file_id File ID.
431
+ # @param [String] bucket_id Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
432
+ # @param [String] file_id File ID.
438
433
  #
439
434
  # @return []
440
435
  def get_file_download(bucket_id:, file_id:)
436
+
437
+ path = '/storage/buckets/{bucketId}/files/{fileId}/download'
438
+
439
+ params = {
440
+ }
441
+
442
+ headers = {
443
+ "content-type": 'application/json',
444
+ }
441
445
  if bucket_id.nil?
442
446
  raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
443
447
  end
@@ -446,17 +450,9 @@ module Appwrite
446
450
  raise Appwrite::Exception.new('Missing required parameter: "fileId"')
447
451
  end
448
452
 
449
- path = '/storage/buckets/{bucketId}/files/{fileId}/download'
450
453
  .gsub('{bucketId}', bucket_id)
451
454
  .gsub('{fileId}', file_id)
452
455
 
453
- params = {
454
- }
455
-
456
- headers = {
457
- "content-type": 'application/json',
458
- }
459
-
460
456
  @client.call(
461
457
  method: 'GET',
462
458
  path: path,
@@ -465,39 +461,31 @@ module Appwrite
465
461
  )
466
462
  end
467
463
 
464
+
468
465
  # Get a file preview image. Currently, this method supports preview for image
469
466
  # files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
470
467
  # and spreadsheets, will return the file icon image. You can also pass query
471
468
  # string arguments for cutting and resizing your preview image. Preview is
472
469
  # supported only for image files smaller than 10MB.
473
470
  #
474
- # @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
475
- # @param [string] file_id File ID
476
- # @param [number] width Resize preview image width, Pass an integer between 0 to 4000.
477
- # @param [number] height Resize preview image height, Pass an integer between 0 to 4000.
478
- # @param [string] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
479
- # @param [number] quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100.
480
- # @param [number] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
481
- # @param [string] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix.
482
- # @param [number] border_radius Preview image border radius in pixels. Pass an integer between 0 to 4000.
483
- # @param [number] opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
484
- # @param [number] rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
485
- # @param [string] background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
486
- # @param [string] output Output format type (jpeg, jpg, png, gif and webp).
471
+ # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
472
+ # @param [String] file_id File ID
473
+ # @param [Integer] width Resize preview image width, Pass an integer between 0 to 4000.
474
+ # @param [Integer] height Resize preview image height, Pass an integer between 0 to 4000.
475
+ # @param [String] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
476
+ # @param [Integer] quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100.
477
+ # @param [Integer] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
478
+ # @param [String] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix.
479
+ # @param [Integer] border_radius Preview image border radius in pixels. Pass an integer between 0 to 4000.
480
+ # @param [Float] opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
481
+ # @param [Integer] rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
482
+ # @param [String] background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
483
+ # @param [String] output Output format type (jpeg, jpg, png, gif and webp).
487
484
  #
488
485
  # @return []
489
486
  def get_file_preview(bucket_id:, file_id:, width: nil, height: nil, gravity: nil, quality: nil, border_width: nil, border_color: nil, border_radius: nil, opacity: nil, rotation: nil, background: nil, output: nil)
490
- if bucket_id.nil?
491
- raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
492
- end
493
-
494
- if file_id.nil?
495
- raise Appwrite::Exception.new('Missing required parameter: "fileId"')
496
- end
497
487
 
498
488
  path = '/storage/buckets/{bucketId}/files/{fileId}/preview'
499
- .gsub('{bucketId}', bucket_id)
500
- .gsub('{fileId}', file_id)
501
489
 
502
490
  params = {
503
491
  width: width,
@@ -512,10 +500,20 @@ module Appwrite
512
500
  background: background,
513
501
  output: output,
514
502
  }
515
-
503
+
516
504
  headers = {
517
505
  "content-type": 'application/json',
518
506
  }
507
+ if bucket_id.nil?
508
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
509
+ end
510
+
511
+ if file_id.nil?
512
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
513
+ end
514
+
515
+ .gsub('{bucketId}', bucket_id)
516
+ .gsub('{fileId}', file_id)
519
517
 
520
518
  @client.call(
521
519
  method: 'GET',
@@ -525,15 +523,25 @@ module Appwrite
525
523
  )
526
524
  end
527
525
 
526
+
528
527
  # Get a file content by its unique ID. This endpoint is similar to the
529
528
  # download method but returns with no 'Content-Disposition: attachment'
530
529
  # header.
531
530
  #
532
- # @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
533
- # @param [string] file_id File ID.
531
+ # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
532
+ # @param [String] file_id File ID.
534
533
  #
535
534
  # @return []
536
535
  def get_file_view(bucket_id:, file_id:)
536
+
537
+ path = '/storage/buckets/{bucketId}/files/{fileId}/view'
538
+
539
+ params = {
540
+ }
541
+
542
+ headers = {
543
+ "content-type": 'application/json',
544
+ }
537
545
  if bucket_id.nil?
538
546
  raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
539
547
  end
@@ -542,17 +550,9 @@ module Appwrite
542
550
  raise Appwrite::Exception.new('Missing required parameter: "fileId"')
543
551
  end
544
552
 
545
- path = '/storage/buckets/{bucketId}/files/{fileId}/view'
546
553
  .gsub('{bucketId}', bucket_id)
547
554
  .gsub('{fileId}', file_id)
548
555
 
549
- params = {
550
- }
551
-
552
- headers = {
553
- "content-type": 'application/json',
554
- }
555
-
556
556
  @client.call(
557
557
  method: 'GET',
558
558
  path: path,
@@ -561,5 +561,6 @@ module Appwrite
561
561
  )
562
562
  end
563
563
 
564
+
564
565
  end
565
566
  end