Merge pull request #866 from appwrite/feat-updated-file-param-name-to-code
Feat updated file param name to code
This commit is contained in:
commit
affc5e5d4d
6 changed files with 86 additions and 19 deletions
|
@ -436,7 +436,7 @@ App::post('/v1/functions/:functionId/tags')
|
||||||
->label('sdk.response.model', Response::MODEL_TAG)
|
->label('sdk.response.model', Response::MODEL_TAG)
|
||||||
->param('functionId', '', new UID(), 'Function unique ID.')
|
->param('functionId', '', new UID(), 'Function unique ID.')
|
||||||
->param('command', '', new Text('1028'), 'Code execution command.')
|
->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('request')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('projectDB')
|
->inject('projectDB')
|
||||||
|
@ -453,7 +453,7 @@ App::post('/v1/functions/:functionId/tags')
|
||||||
throw new Exception('Function not found', 404);
|
throw new Exception('Function not found', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $request->getFiles('file');
|
$file = $request->getFiles('code');
|
||||||
$device = Storage::getDevice('functions');
|
$device = Storage::getDevice('functions');
|
||||||
$fileExt = new FileExt([FileExt::TYPE_GZIP]);
|
$fileExt = new FileExt([FileExt::TYPE_GZIP]);
|
||||||
$fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0));
|
$fileSize = new FileSize(App::getEnv('_APP_STORAGE_LIMIT', 0));
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
||||||
|
}
|
|
@ -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);
|
||||||
|
});
|
||||||
|
}
|
|
@ -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);
|
||||||
|
});
|
||||||
|
}
|
|
@ -76,7 +76,7 @@ class FunctionsCustomClientTest extends Scope
|
||||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||||
], [
|
], [
|
||||||
'command' => 'php function.php',
|
'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'] ?? '';
|
$tagId = $tag['body']['$id'] ?? '';
|
||||||
|
|
|
@ -184,7 +184,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
], $this->getHeaders()), [
|
], $this->getHeaders()), [
|
||||||
'command' => 'php function.php',
|
'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'] ?? '';
|
$tagId = $tag['body']['$id'] ?? '';
|
||||||
|
@ -467,7 +467,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'PHP',
|
'language' => 'PHP',
|
||||||
'version' => '7.4',
|
'version' => '7.4',
|
||||||
'name' => 'php-7.4',
|
'name' => 'php-7.4',
|
||||||
'file' => $functions.'/php.tar.gz',
|
'code' => $functions.'/php.tar.gz',
|
||||||
'command' => 'php index.php',
|
'command' => 'php index.php',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -475,7 +475,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'PHP',
|
'language' => 'PHP',
|
||||||
'version' => '8.0',
|
'version' => '8.0',
|
||||||
'name' => 'php-8.0',
|
'name' => 'php-8.0',
|
||||||
'file' => $functions.'/php.tar.gz',
|
'code' => $functions.'/php.tar.gz',
|
||||||
'command' => 'php index.php',
|
'command' => 'php index.php',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -483,7 +483,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Python',
|
'language' => 'Python',
|
||||||
'version' => '3.8',
|
'version' => '3.8',
|
||||||
'name' => 'python-3.8',
|
'name' => 'python-3.8',
|
||||||
'file' => $functions.'/python.tar.gz',
|
'code' => $functions.'/python.tar.gz',
|
||||||
'command' => 'python main.py',
|
'command' => 'python main.py',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -491,7 +491,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Node.js',
|
'language' => 'Node.js',
|
||||||
'version' => '14.5',
|
'version' => '14.5',
|
||||||
'name' => 'node-14.5',
|
'name' => 'node-14.5',
|
||||||
'file' => $functions.'/node.tar.gz',
|
'code' => $functions.'/node.tar.gz',
|
||||||
'command' => 'node index.js',
|
'command' => 'node index.js',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -499,7 +499,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Node.js',
|
'language' => 'Node.js',
|
||||||
'version' => '15.5',
|
'version' => '15.5',
|
||||||
'name' => 'node-15.5',
|
'name' => 'node-15.5',
|
||||||
'file' => $functions.'/node.tar.gz',
|
'code' => $functions.'/node.tar.gz',
|
||||||
'command' => 'node index.js',
|
'command' => 'node index.js',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -507,7 +507,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Ruby',
|
'language' => 'Ruby',
|
||||||
'version' => '2.7',
|
'version' => '2.7',
|
||||||
'name' => 'ruby-2.7',
|
'name' => 'ruby-2.7',
|
||||||
'file' => $functions.'/ruby.tar.gz',
|
'code' => $functions.'/ruby.tar.gz',
|
||||||
'command' => 'ruby app.rb',
|
'command' => 'ruby app.rb',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -515,7 +515,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Ruby',
|
'language' => 'Ruby',
|
||||||
'version' => '3.0',
|
'version' => '3.0',
|
||||||
'name' => 'ruby-3.0',
|
'name' => 'ruby-3.0',
|
||||||
'file' => $functions.'/ruby.tar.gz',
|
'code' => $functions.'/ruby.tar.gz',
|
||||||
'command' => 'ruby app.rb',
|
'command' => 'ruby app.rb',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -523,7 +523,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Deno',
|
'language' => 'Deno',
|
||||||
'version' => '1.5',
|
'version' => '1.5',
|
||||||
'name' => 'deno-1.5',
|
'name' => 'deno-1.5',
|
||||||
'file' => $functions.'/deno.tar.gz',
|
'code' => $functions.'/deno.tar.gz',
|
||||||
'command' => 'deno run --allow-env index.ts',
|
'command' => 'deno run --allow-env index.ts',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -531,7 +531,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Deno',
|
'language' => 'Deno',
|
||||||
'version' => '1.6',
|
'version' => '1.6',
|
||||||
'name' => 'deno-1.6',
|
'name' => 'deno-1.6',
|
||||||
'file' => $functions.'/deno.tar.gz',
|
'code' => $functions.'/deno.tar.gz',
|
||||||
'command' => 'deno run --allow-env index.ts',
|
'command' => 'deno run --allow-env index.ts',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -539,7 +539,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => 'Dart',
|
'language' => 'Dart',
|
||||||
'version' => '2.10',
|
'version' => '2.10',
|
||||||
'name' => 'dart-2.10',
|
'name' => 'dart-2.10',
|
||||||
'file' => $functions.'/dart.tar.gz',
|
'code' => $functions.'/dart.tar.gz',
|
||||||
'command' => 'dart main.dart',
|
'command' => 'dart main.dart',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -547,7 +547,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => '.NET',
|
'language' => '.NET',
|
||||||
'version' => '3.1',
|
'version' => '3.1',
|
||||||
'name' => 'dotnet-3.1',
|
'name' => 'dotnet-3.1',
|
||||||
'file' => $functions.'/dotnet-3.1.tar.gz',
|
'code' => $functions.'/dotnet-3.1.tar.gz',
|
||||||
'command' => 'dotnet dotnet.dll',
|
'command' => 'dotnet dotnet.dll',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -555,7 +555,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'language' => '.NET',
|
'language' => '.NET',
|
||||||
'version' => '5.0',
|
'version' => '5.0',
|
||||||
'name' => 'dotnet-5.0',
|
'name' => 'dotnet-5.0',
|
||||||
'file' => $functions.'/dotnet-5.0.tar.gz',
|
'code' => $functions.'/dotnet-5.0.tar.gz',
|
||||||
'command' => 'dotnet dotnet.dll',
|
'command' => 'dotnet dotnet.dll',
|
||||||
'timeout' => 15,
|
'timeout' => 15,
|
||||||
],
|
],
|
||||||
|
@ -586,7 +586,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
$language = $env['language'] ?? '';
|
$language = $env['language'] ?? '';
|
||||||
$version = $env['version'] ?? '';
|
$version = $env['version'] ?? '';
|
||||||
$name = $env['name'] ?? '';
|
$name = $env['name'] ?? '';
|
||||||
$code = $env['file'] ?? '';
|
$code = $env['code'] ?? '';
|
||||||
$command = $env['command'] ?? '';
|
$command = $env['command'] ?? '';
|
||||||
$timeout = $env['timeout'] ?? 15;
|
$timeout = $env['timeout'] ?? 15;
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
], $this->getHeaders()), [
|
], $this->getHeaders()), [
|
||||||
'command' => $command,
|
'command' => $command,
|
||||||
'file' => new CURLFile($code, 'application/x-gzip', basename($code)),
|
'code' => new CURLFile($code, 'application/x-gzip', basename($code)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tagId = $tag['body']['$id'] ?? '';
|
$tagId = $tag['body']['$id'] ?? '';
|
||||||
|
@ -716,7 +716,7 @@ class FunctionsCustomServerTest extends Scope
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
], $this->getHeaders()), [
|
], $this->getHeaders()), [
|
||||||
'command' => $command,
|
'command' => $command,
|
||||||
'file' => new CURLFile($code, 'application/x-gzip', basename($code)),
|
'code' => new CURLFile($code, 'application/x-gzip', basename($code)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tagId = $tag['body']['$id'] ?? '';
|
$tagId = $tag['body']['$id'] ?? '';
|
||||||
|
|
Loading…
Reference in a new issue