From e065a1a5a5480db129746a8962c908e170c5812d Mon Sep 17 00:00:00 2001 From: eldadfux Date: Wed, 28 Aug 2019 15:37:13 +0300 Subject: [PATCH] Updated SDKs --- .../docs/examples/projects/create-webhook.md | 2 +- .../js/docs/examples/projects/update-task.md | 2 +- .../docs/examples/projects/update-webhook.md | 2 +- .../js/docs/examples/storage/update-file.md | 14 +++++++++ app/sdks/js/package.json | 2 +- app/sdks/js/src/sdk.js | 30 ++++++++++++++++++- app/sdks/js/src/sdk.min.js | 5 ++-- .../docs/examples/projects/create-webhook.md | 2 +- .../docs/examples/projects/update-task.md | 2 +- .../docs/examples/projects/update-webhook.md | 2 +- .../node/docs/examples/storage/update-file.md | 14 +++++++++ app/sdks/node/lib/client.js | 2 +- app/sdks/node/lib/services/storage.js | 24 +++++++++++++++ app/sdks/node/package.json | 2 +- .../docs/examples/projects/create-webhook.md | 2 +- .../php/docs/examples/projects/update-task.md | 2 +- .../docs/examples/projects/update-webhook.md | 2 +- .../php/docs/examples/storage/update-file.md | 15 ++++++++++ app/sdks/php/docs/storage.md | 17 +++++++++++ app/sdks/php/src/Appwrite/Client.php | 2 +- .../php/src/Appwrite/Services/Storage.php | 26 ++++++++++++++++ app/sdks/python/appwrite/services/storage.py | 15 ++++++++++ .../ruby/lib/appwrite/services/storage.rb | 14 +++++++++ app/tasks/sdks.php | 6 ++-- 24 files changed, 187 insertions(+), 19 deletions(-) create mode 100644 app/sdks/js/docs/examples/storage/update-file.md create mode 100644 app/sdks/node/docs/examples/storage/update-file.md create mode 100644 app/sdks/php/docs/examples/storage/update-file.md diff --git a/app/sdks/js/docs/examples/projects/create-webhook.md b/app/sdks/js/docs/examples/projects/create-webhook.md index f3ed6e65b7..9210093702 100644 --- a/app/sdks/js/docs/examples/projects/create-webhook.md +++ b/app/sdks/js/docs/examples/projects/create-webhook.md @@ -5,7 +5,7 @@ sdk setKey('') ; -let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0); +let promise = sdk.projects.createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 1); promise.then(function (response) { console.log(response); diff --git a/app/sdks/js/docs/examples/projects/update-task.md b/app/sdks/js/docs/examples/projects/update-task.md index 693c61ee6b..c5bb04d59b 100644 --- a/app/sdks/js/docs/examples/projects/update-task.md +++ b/app/sdks/js/docs/examples/projects/update-task.md @@ -5,7 +5,7 @@ sdk setKey('') ; -let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); +let promise = sdk.projects.updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com'); promise.then(function (response) { console.log(response); diff --git a/app/sdks/js/docs/examples/projects/update-webhook.md b/app/sdks/js/docs/examples/projects/update-webhook.md index e8a5bd6c6d..514424a682 100644 --- a/app/sdks/js/docs/examples/projects/update-webhook.md +++ b/app/sdks/js/docs/examples/projects/update-webhook.md @@ -5,7 +5,7 @@ sdk setKey('') ; -let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 1); +let promise = sdk.projects.updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0); promise.then(function (response) { console.log(response); diff --git a/app/sdks/js/docs/examples/storage/update-file.md b/app/sdks/js/docs/examples/storage/update-file.md new file mode 100644 index 0000000000..74caaf3acd --- /dev/null +++ b/app/sdks/js/docs/examples/storage/update-file.md @@ -0,0 +1,14 @@ +let sdk = new Appwrite(); + +sdk + setProject('') + setKey('') +; + +let promise = sdk.storage.updateFile('[FILE_ID]'); + +promise.then(function (response) { + console.log(response); +}, function (error) { + console.log(error); +}); \ No newline at end of file diff --git a/app/sdks/js/package.json b/app/sdks/js/package.json index 6678382414..c6274d7e5a 100644 --- a/app/sdks/js/package.json +++ b/app/sdks/js/package.json @@ -2,7 +2,7 @@ "name": "appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)", - "version": "v1.0.18", + "version": "v1.0.19", "license": "BSD-3-Clause", "main": "src/sdk.js", "repository": { diff --git a/app/sdks/js/src/sdk.js b/app/sdks/js/src/sdk.js index 51baab8b6b..0114ce9e7d 100644 --- a/app/sdks/js/src/sdk.js +++ b/app/sdks/js/src/sdk.js @@ -138,7 +138,7 @@ globalParams.push({key: key, value: value}); }; - addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.18'); + addGlobalHeader('x-sdk-version', 'appwrite:javascript:v1.0.19'); addGlobalHeader('content-type', ''); /** @@ -2328,6 +2328,34 @@ }); }, + /** + * Update File + * + * Update file by its unique ID. Only users with write permissions have access + * to update this resource. + * + * @param {string} fileId + * @param {array} read + * @param {array} write + * @param {string} folderId + * @throws {Error} + * @return {Promise} */ + updateFile: function(fileId, read = [], write = [], folderId = '') { + if(fileId === undefined) { + throw new Error('Missing required parameter: "fileId"'); + } + + let path = '/storage/files/{fileId}'.replace(new RegExp('{fileId}', 'g'), fileId); + + return http + .put(path, {'content-type': 'application/json'}, + { + 'read': read, + 'write': write, + 'folderId': folderId + }); + }, + /** * Delete File * diff --git a/app/sdks/js/src/sdk.min.js b/app/sdks/js/src/sdk.min.js index 2c59b6ac0d..50751e5ef6 100644 --- a/app/sdks/js/src/sdk.min.js +++ b/app/sdks/js/src/sdk.min.js @@ -1,5 +1,5 @@ (function(window){window.Appwrite=function(){let config={endpoint:'https://appwrite.test/v1',project:'',key:'',locale:'',mode:'',};let setEndpoint=function(endpoint){config.endpoint=endpoint;return this};let setProject=function(value){http.addGlobalHeader('X-Appwrite-Project',value);config.project=value;return this};let setKey=function(value){http.addGlobalHeader('X-Appwrite-Key',value);config.key=value;return this};let setLocale=function(value){http.addGlobalHeader('X-Appwrite-Locale',value);config.locale=value;return this};let setMode=function(value){http.addGlobalHeader('X-Appwrite-Mode',value);config.mode=value;return this};let http=function(document){let globalParams=[],globalHeaders=[];let addParam=function(url,param,value){let a=document.createElement('a'),regex=/(?:\?|&|&)+([^=]+)(?:=([^&]*))*/g;let match,str=[];a.href=url;param=encodeURIComponent(param);while(match=regex.exec(a.search))if(param!==match[1])str.push(match[1]+(match[2]?"="+match[2]:""));str.push(param+(value?"="+encodeURIComponent(value):""));a.search=str.join("&");return a.href};let buildQuery=function(params){let str=[];for(let p in params){if(Array.isArray(params[p])){for(let index=0;indexcreateWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 0); \ No newline at end of file +$result = $projects->createWebhook('[PROJECT_ID]', '[NAME]', [], '[URL]', 1); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-task.md b/app/sdks/php/docs/examples/projects/update-task.md index 01a229b7b4..409f004868 100644 --- a/app/sdks/php/docs/examples/projects/update-task.md +++ b/app/sdks/php/docs/examples/projects/update-task.md @@ -12,4 +12,4 @@ $client $projects = new Projects($client); -$result = $projects->updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 0, 'GET', 'https://example.com'); \ No newline at end of file +$result = $projects->updateTask('[PROJECT_ID]', '[TASK_ID]', '[NAME]', 'play', '', 1, 'GET', 'https://example.com'); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/projects/update-webhook.md b/app/sdks/php/docs/examples/projects/update-webhook.md index c4fa7864a1..bf0679261b 100644 --- a/app/sdks/php/docs/examples/projects/update-webhook.md +++ b/app/sdks/php/docs/examples/projects/update-webhook.md @@ -12,4 +12,4 @@ $client $projects = new Projects($client); -$result = $projects->updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 1); \ No newline at end of file +$result = $projects->updateWebhook('[PROJECT_ID]', '[WEBHOOK_ID]', '[NAME]', [], '[URL]', 0); \ No newline at end of file diff --git a/app/sdks/php/docs/examples/storage/update-file.md b/app/sdks/php/docs/examples/storage/update-file.md new file mode 100644 index 0000000000..29c834d230 --- /dev/null +++ b/app/sdks/php/docs/examples/storage/update-file.md @@ -0,0 +1,15 @@ +updateFile('[FILE_ID]'); \ No newline at end of file diff --git a/app/sdks/php/docs/storage.md b/app/sdks/php/docs/storage.md index 54ef9c0468..d57a9a6ef2 100644 --- a/app/sdks/php/docs/storage.md +++ b/app/sdks/php/docs/storage.md @@ -48,6 +48,23 @@ GET https://appwrite.test/v1/storage/files/{fileId} | --- | --- | --- | --- | | fileId | string | **Required** File unique ID. | | +## Update File + +```http request +PUT https://appwrite.test/v1/storage/files/{fileId} +``` + +** Update file by its unique ID. Only users with write permissions have access to update this resource. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| fileId | string | **Required** File unique ID. | | +| read | array | An array of read permissions. [Learn more about permissions and roles](/docs/permissions). | [] | +| write | array | An array of write permissions. [Learn more about permissions and roles](/docs/permissions). | [] | +| folderId | string | Folder to associate files with. | | + ## Delete File ```http request diff --git a/app/sdks/php/src/Appwrite/Client.php b/app/sdks/php/src/Appwrite/Client.php index d34a7f8c44..4a5cbc007d 100644 --- a/app/sdks/php/src/Appwrite/Client.php +++ b/app/sdks/php/src/Appwrite/Client.php @@ -37,7 +37,7 @@ class Client */ protected $headers = [ 'content-type' => '', - 'x-sdk-version' => 'appwrite:php:v1.0.5', + 'x-sdk-version' => 'appwrite:php:v1.0.6', ]; /** diff --git a/app/sdks/php/src/Appwrite/Services/Storage.php b/app/sdks/php/src/Appwrite/Services/Storage.php index 907c85c342..2f74e97c28 100644 --- a/app/sdks/php/src/Appwrite/Services/Storage.php +++ b/app/sdks/php/src/Appwrite/Services/Storage.php @@ -85,6 +85,32 @@ class Storage extends Service ], $params); } + /** + * Update File + * + * Update file by its unique ID. Only users with write permissions have access + * to update this resource. + * + * @param string $fileId + * @param array $read + * @param array $write + * @param string $folderId + * @throws Exception + * @return array + */ + public function updateFile($fileId, $read = [], $write = [], $folderId = '') + { + $path = str_replace(['{fileId}'], [$fileId], '/storage/files/{fileId}'); + $params = []; + + $params['read'] = $read; + $params['write'] = $write; + $params['folderId'] = $folderId; + + return $this->client->call(Client::METHOD_PUT, $path, [ + ], $params); + } + /** * Delete File * diff --git a/app/sdks/python/appwrite/services/storage.py b/app/sdks/python/appwrite/services/storage.py index b878f956f6..0df4a4643b 100644 --- a/app/sdks/python/appwrite/services/storage.py +++ b/app/sdks/python/appwrite/services/storage.py @@ -42,6 +42,21 @@ class Storage(Service): return self.client.call('get', path, { }, params) + def update_file(self, file_id, readstring(4) ""[]"" +=[], writestring(4) ""[]"" +=[], folder_id=''): + """Update File""" + + params = {} + path = '/storage/files/{fileId}' + path.replace('{fileId}', file_id) + params['read'] = read + params['write'] = write + params['folderId'] = folder_id + + return self.client.call('put', path, { + }, params) + def delete_file(self, file_id): """Delete File""" diff --git a/app/sdks/ruby/lib/appwrite/services/storage.rb b/app/sdks/ruby/lib/appwrite/services/storage.rb index 0b2f867773..9a3e765422 100644 --- a/app/sdks/ruby/lib/appwrite/services/storage.rb +++ b/app/sdks/ruby/lib/appwrite/services/storage.rb @@ -40,6 +40,20 @@ module Appwrite }, params); end + def update_file(file_id:, read: [], write: [], folder_id: '') + path = '/storage/files/{fileId}' + .gsub('{file_id}', file_id) + + params = { + 'read': read, + 'write': write, + 'folderId': folder_id + } + + return @client.call('put', path, { + }, params); + end + def delete_file(file_id:) path = '/storage/files/{fileId}' .gsub('{file_id}', file_id) diff --git a/app/tasks/sdks.php b/app/tasks/sdks.php index d6547cf3f7..bc6c9cbb8f 100644 --- a/app/tasks/sdks.php +++ b/app/tasks/sdks.php @@ -38,7 +38,7 @@ $cli $clients = [ 'php' => [ - 'version' => 'v1.0.5', + 'version' => 'v1.0.6', 'result' => __DIR__ . '/../sdks/php/', 'gitURL' => 'https://github.com/appwrite/sdk-for-php.git', 'gitRepo' => 'git@github.com:appwrite/sdk-for-php.git', @@ -46,7 +46,7 @@ $cli 'gitUserName' => 'appwrite', ], 'js' => [ - 'version' => 'v1.0.18', + 'version' => 'v1.0.19', 'result' => __DIR__ . '/../sdks/js/', 'gitURL' => 'https://github.com/appwrite/sdk-for-js.git', 'gitRepo' => 'git@github.com:appwrite/sdk-for-js.git', @@ -54,7 +54,7 @@ $cli 'gitUserName' => 'appwrite', ], 'node' => [ - 'version' => 'v1.0.22', + 'version' => 'v1.0.23', 'result' => __DIR__ . '/../sdks/node/', 'gitURL' => 'https://github.com/appwrite/sdk-for-node.git', 'gitRepo' => 'git@github.com:appwrite/sdk-for-node.git',