From 8fc7026cfbdb06951996dcd9545a9e90eb2177b2 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 31 Jan 2021 21:11:03 +0200 Subject: [PATCH 1/2] Changed file param to code (again) --- app/controllers/api/functions.php | 4 +-- .../examples/functions/create-execution.md | 22 ++++++++++++ .../examples/functions/get-execution.md | 23 +++++++++++++ .../examples/functions/list-executions.md | 22 ++++++++++++ .../Functions/FunctionsCustomServerTest.php | 34 +++++++++---------- 5 files changed, 86 insertions(+), 19 deletions(-) create mode 100644 docs/examples/0.7.0/client-flutter/examples/functions/create-execution.md create mode 100644 docs/examples/0.7.0/client-flutter/examples/functions/get-execution.md create mode 100644 docs/examples/0.7.0/client-flutter/examples/functions/list-executions.md diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index e5c663ffd..fe2b1cef3 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -436,7 +436,7 @@ App::post('/v1/functions/:functionId/tags') ->label('sdk.response.model', Response::MODEL_TAG) ->param('functionId', '', new UID(), 'Function unique ID.') ->param('command', '', new Text('1028'), 'Code execution command.') - ->param('file', null, new File(), 'Gzip file with your code package.', false) + ->param('code', null, new File(), 'Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.', false) ->inject('request') ->inject('response') ->inject('projectDB') @@ -453,7 +453,7 @@ App::post('/v1/functions/:functionId/tags') throw new Exception('Function not found', 404); } - $file = $request->getFiles('file'); + $file = $request->getFiles('code'); $device = Storage::getDevice('functions'); $fileExt = new FileExt([FileExt::TYPE_GZIP]); $fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0)); diff --git a/docs/examples/0.7.0/client-flutter/examples/functions/create-execution.md b/docs/examples/0.7.0/client-flutter/examples/functions/create-execution.md new file mode 100644 index 000000000..af61896d7 --- /dev/null +++ b/docs/examples/0.7.0/client-flutter/examples/functions/create-execution.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Functions functions = Functions(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = functions.createExecution( + functionId: '[FUNCTION_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/0.7.0/client-flutter/examples/functions/get-execution.md b/docs/examples/0.7.0/client-flutter/examples/functions/get-execution.md new file mode 100644 index 000000000..22135bbed --- /dev/null +++ b/docs/examples/0.7.0/client-flutter/examples/functions/get-execution.md @@ -0,0 +1,23 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Functions functions = Functions(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = functions.getExecution( + functionId: '[FUNCTION_ID]', + executionId: '[EXECUTION_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/docs/examples/0.7.0/client-flutter/examples/functions/list-executions.md b/docs/examples/0.7.0/client-flutter/examples/functions/list-executions.md new file mode 100644 index 000000000..fe53f4a82 --- /dev/null +++ b/docs/examples/0.7.0/client-flutter/examples/functions/list-executions.md @@ -0,0 +1,22 @@ +import 'package:appwrite/appwrite.dart'; + +void main() { // Init SDK + Client client = Client(); + Functions functions = Functions(client); + + client + .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint + .setProject('5df5acd0d48c2') // Your project ID + ; + + Future result = functions.listExecutions( + functionId: '[FUNCTION_ID]', + ); + + result + .then((response) { + print(response); + }).catchError((error) { + print(error.response); + }); +} \ No newline at end of file diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 7cd5f80aa..c340d369f 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -184,7 +184,7 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'command' => 'php function.php', - 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/functions/php.tar.gz'), 'application/x-gzip', 'php-fx.tar.gz'), + 'code' => new CURLFile(realpath(__DIR__ . '/../../../resources/functions/php.tar.gz'), 'application/x-gzip', 'php-fx.tar.gz'), ]); $tagId = $tag['body']['$id'] ?? ''; @@ -467,7 +467,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'PHP', 'version' => '7.4', 'name' => 'php-7.4', - 'file' => $functions.'/php.tar.gz', + 'code' => $functions.'/php.tar.gz', 'command' => 'php index.php', 'timeout' => 15, ], @@ -475,7 +475,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'PHP', 'version' => '8.0', 'name' => 'php-8.0', - 'file' => $functions.'/php.tar.gz', + 'code' => $functions.'/php.tar.gz', 'command' => 'php index.php', 'timeout' => 15, ], @@ -483,7 +483,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Python', 'version' => '3.8', 'name' => 'python-3.8', - 'file' => $functions.'/python.tar.gz', + 'code' => $functions.'/python.tar.gz', 'command' => 'python main.py', 'timeout' => 15, ], @@ -491,7 +491,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Node.js', 'version' => '14.5', 'name' => 'node-14.5', - 'file' => $functions.'/node.tar.gz', + 'code' => $functions.'/node.tar.gz', 'command' => 'node index.js', 'timeout' => 15, ], @@ -499,7 +499,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Node.js', 'version' => '15.5', 'name' => 'node-15.5', - 'file' => $functions.'/node.tar.gz', + 'code' => $functions.'/node.tar.gz', 'command' => 'node index.js', 'timeout' => 15, ], @@ -507,7 +507,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Ruby', 'version' => '2.7', 'name' => 'ruby-2.7', - 'file' => $functions.'/ruby.tar.gz', + 'code' => $functions.'/ruby.tar.gz', 'command' => 'ruby app.rb', 'timeout' => 15, ], @@ -515,7 +515,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Ruby', 'version' => '3.0', 'name' => 'ruby-3.0', - 'file' => $functions.'/ruby.tar.gz', + 'code' => $functions.'/ruby.tar.gz', 'command' => 'ruby app.rb', 'timeout' => 15, ], @@ -523,7 +523,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Deno', 'version' => '1.5', 'name' => 'deno-1.5', - 'file' => $functions.'/deno.tar.gz', + 'code' => $functions.'/deno.tar.gz', 'command' => 'deno run --allow-env index.ts', 'timeout' => 15, ], @@ -531,7 +531,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Deno', 'version' => '1.6', 'name' => 'deno-1.6', - 'file' => $functions.'/deno.tar.gz', + 'code' => $functions.'/deno.tar.gz', 'command' => 'deno run --allow-env index.ts', 'timeout' => 15, ], @@ -539,7 +539,7 @@ class FunctionsCustomServerTest extends Scope 'language' => 'Dart', 'version' => '2.10', 'name' => 'dart-2.10', - 'file' => $functions.'/dart.tar.gz', + 'code' => $functions.'/dart.tar.gz', 'command' => 'dart main.dart', 'timeout' => 15, ], @@ -547,7 +547,7 @@ class FunctionsCustomServerTest extends Scope 'language' => '.NET', 'version' => '3.1', 'name' => 'dotnet-3.1', - 'file' => $functions.'/dotnet-3.1.tar.gz', + 'code' => $functions.'/dotnet-3.1.tar.gz', 'command' => 'dotnet dotnet.dll', 'timeout' => 15, ], @@ -555,7 +555,7 @@ class FunctionsCustomServerTest extends Scope 'language' => '.NET', 'version' => '5.0', 'name' => 'dotnet-5.0', - 'file' => $functions.'/dotnet-5.0.tar.gz', + 'code' => $functions.'/dotnet-5.0.tar.gz', 'command' => 'dotnet dotnet.dll', 'timeout' => 15, ], @@ -571,7 +571,7 @@ class FunctionsCustomServerTest extends Scope 'content-type' => 'multipart/form-data', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), + 'code' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), 'read' => ['*'], 'write' => ['*'], 'folderId' => 'xyz', @@ -586,7 +586,7 @@ class FunctionsCustomServerTest extends Scope $language = $env['language'] ?? ''; $version = $env['version'] ?? ''; $name = $env['name'] ?? ''; - $code = $env['file'] ?? ''; + $code = $env['code'] ?? ''; $command = $env['command'] ?? ''; $timeout = $env['timeout'] ?? 15; @@ -618,7 +618,7 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'command' => $command, - 'file' => new CURLFile($code, 'application/x-gzip', basename($code)), + 'code' => new CURLFile($code, 'application/x-gzip', basename($code)), ]); $tagId = $tag['body']['$id'] ?? ''; @@ -716,7 +716,7 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'command' => $command, - 'file' => new CURLFile($code, 'application/x-gzip', basename($code)), + 'code' => new CURLFile($code, 'application/x-gzip', basename($code)), ]); $tagId = $tag['body']['$id'] ?? ''; From a7583c5f85c9bdbb91420c58b582f635029ab20c Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 31 Jan 2021 23:33:48 +0200 Subject: [PATCH 2/2] Fixed tests --- tests/e2e/Services/Functions/FunctionsCustomClientTest.php | 2 +- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 04d7a626f..25d3a8237 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -76,7 +76,7 @@ class FunctionsCustomClientTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'], ], [ 'command' => 'php function.php', - 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/functions/php.tar.gz'), 'application/x-gzip', 'php-fx.tar.gz'), + 'code' => new CURLFile(realpath(__DIR__ . '/../../../resources/functions/php.tar.gz'), 'application/x-gzip', 'php-fx.tar.gz'), ]); $tagId = $tag['body']['$id'] ?? ''; diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index c340d369f..5b15b61ce 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -571,7 +571,7 @@ class FunctionsCustomServerTest extends Scope 'content-type' => 'multipart/form-data', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'code' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), + 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), 'read' => ['*'], 'write' => ['*'], 'folderId' => 'xyz',