mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Add new V3 parameters
This commit is contained in:
@@ -10,7 +10,10 @@ class Func extends Event
|
||||
{
|
||||
protected string $jwt = '';
|
||||
protected string $type = '';
|
||||
protected string $data = '';
|
||||
protected string $body = '';
|
||||
protected string $path = '';
|
||||
protected string $method = '';
|
||||
protected array $headers = [];
|
||||
protected ?Document $function = null;
|
||||
protected ?Document $execution = null;
|
||||
|
||||
@@ -89,14 +92,53 @@ class Func extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets custom data for the function event.
|
||||
* Sets custom body for the function event.
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $body
|
||||
* @return self
|
||||
*/
|
||||
public function setData(string $data): self
|
||||
public function setBody(string $body): self
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->body = $body;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets custom method for the function event.
|
||||
*
|
||||
* @param string $method
|
||||
* @return self
|
||||
*/
|
||||
public function setMethod(string $method): self
|
||||
{
|
||||
$this->method = $method;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets custom path for the function event.
|
||||
*
|
||||
* @param string $path
|
||||
* @return self
|
||||
*/
|
||||
public function setPath(string $path): self
|
||||
{
|
||||
$this->path = $path;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets custom headers for the function event.
|
||||
*
|
||||
* @param string $headers
|
||||
* @return self
|
||||
*/
|
||||
public function setHeaders(array $headers): self
|
||||
{
|
||||
$this->headers = $headers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -155,7 +197,10 @@ class Func extends Event
|
||||
'jwt' => $this->jwt,
|
||||
'payload' => $this->payload,
|
||||
'events' => $events,
|
||||
'data' => $this->data,
|
||||
'body' => $this->body,
|
||||
'path' => $this->path,
|
||||
'headers' => $this->headers,
|
||||
'method' => $this->method,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ use Appwrite\Utopia\Response\Model\Platform;
|
||||
use Appwrite\Utopia\Response\Model\Project;
|
||||
use Appwrite\Utopia\Response\Model\Rule;
|
||||
use Appwrite\Utopia\Response\Model\Deployment;
|
||||
use Appwrite\Utopia\Response\Model\Headers;
|
||||
use Appwrite\Utopia\Response\Model\Token;
|
||||
use Appwrite\Utopia\Response\Model\Webhook;
|
||||
use Appwrite\Utopia\Response\Model\Preferences;
|
||||
@@ -187,6 +188,7 @@ class Response extends SwooleResponse
|
||||
public const MODEL_BUILD = 'build';
|
||||
public const MODEL_BUILD_LIST = 'buildList'; // Not used anywhere yet
|
||||
public const MODEL_FUNC_PERMISSIONS = 'funcPermissions';
|
||||
public const MODEL_HEADERS = 'headers';
|
||||
|
||||
// Project
|
||||
public const MODEL_PROJECT = 'project';
|
||||
@@ -341,6 +343,7 @@ class Response extends SwooleResponse
|
||||
->setModel(new UsageFunctions())
|
||||
->setModel(new UsageFunction())
|
||||
->setModel(new UsageProject())
|
||||
->setModel(new Headers())
|
||||
// Verification
|
||||
// Recovery
|
||||
// Tests (keep last)
|
||||
|
||||
@@ -60,19 +60,25 @@ class Execution extends Model
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('response', [
|
||||
->addRule('body', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'The script response output string. Logs the last 4,000 characters of the execution response output.',
|
||||
'default' => '',
|
||||
'example' => '',
|
||||
])
|
||||
->addRule('stdout', [
|
||||
->addRule('headers', [
|
||||
'type' => Response::MODEL_HEADERS,
|
||||
'description' => 'Response headers as a key-value object',
|
||||
'default' => new \stdClass(),
|
||||
'example' => ['x-internal-timezone' => 'UTC'],
|
||||
])
|
||||
->addRule('logs', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'The script stdout output string. Logs the last 4,000 characters of the execution stdout output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.',
|
||||
'default' => '',
|
||||
'example' => '',
|
||||
])
|
||||
->addRule('stderr', [
|
||||
->addRule('errors', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'The script stderr output string. Logs the last 4,000 characters of the execution stderr output. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.',
|
||||
'default' => '',
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
|
||||
class Headers extends Any
|
||||
{
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Headers';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return Response::MODEL_HEADERS;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class Executor
|
||||
) {
|
||||
$runtimeId = "$projectId-$deploymentId";
|
||||
$route = "/runtimes";
|
||||
$headers = [ 'x-opr-runtime-id' => $runtimeId ];
|
||||
$reqHeaders = [ 'x-opr-runtime-id' => $runtimeId ];
|
||||
$params = [
|
||||
'runtimeId' => $runtimeId,
|
||||
'source' => $source,
|
||||
@@ -92,7 +92,7 @@ class Executor
|
||||
|
||||
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
|
||||
|
||||
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, $timeout);
|
||||
$response = $this->call(self::METHOD_POST, $route, $reqHeaders, $params, true, $timeout);
|
||||
|
||||
$status = $response['headers']['status-code'];
|
||||
if ($status >= 400) {
|
||||
@@ -120,22 +120,28 @@ class Executor
|
||||
public function createExecution(
|
||||
string $projectId,
|
||||
string $deploymentId,
|
||||
string $payload,
|
||||
string $body,
|
||||
array $variables,
|
||||
int $timeout,
|
||||
string $image,
|
||||
string $source,
|
||||
string $entrypoint,
|
||||
string $version
|
||||
string $version,
|
||||
string $path,
|
||||
string $method,
|
||||
array $headers,
|
||||
) {
|
||||
$runtimeId = "$projectId-$deploymentId";
|
||||
$route = '/runtimes/' . $runtimeId . '/execution';
|
||||
$headers = [ 'x-opr-runtime-id' => $runtimeId ];
|
||||
$reqHeaders = [ 'x-opr-runtime-id' => $runtimeId ];
|
||||
$params = [
|
||||
'runtimeId' => $runtimeId,
|
||||
'variables' => $variables,
|
||||
'payload' => $payload,
|
||||
'body' => $body,
|
||||
'timeout' => $timeout,
|
||||
'path' => $path,
|
||||
'method' => $method,
|
||||
'headers' => $headers,
|
||||
|
||||
'image' => $image,
|
||||
'source' => $source,
|
||||
@@ -147,7 +153,7 @@ class Executor
|
||||
|
||||
$timeout = (int) App::getEnv('_APP_FUNCTIONS_BUILD_TIMEOUT', 900);
|
||||
|
||||
$response = $this->call(self::METHOD_POST, $route, $headers, $params, true, $timeout);
|
||||
$response = $this->call(self::METHOD_POST, $route, $reqHeaders, $params, true, $timeout);
|
||||
|
||||
$status = $response['headers']['status-code'];
|
||||
if ($status >= 400) {
|
||||
|
||||
Reference in New Issue
Block a user