updateVariable 'key' param marked as required
This commit is contained in:
parent
1e95346205
commit
3fc2e70007
6 changed files with 52 additions and 23 deletions
|
@ -544,11 +544,6 @@ return [
|
||||||
'description' => 'Variable with the same ID already exists in your project.',
|
'description' => 'Variable with the same ID already exists in your project.',
|
||||||
'code' => 409,
|
'code' => 409,
|
||||||
],
|
],
|
||||||
Exception::VARIABLE_MISSING_PAYLOAD => [
|
|
||||||
'name' => Exception::VARIABLE_MISSING_PAYLOAD,
|
|
||||||
'description' => 'The variable key or value is missing.',
|
|
||||||
'code' => 400,
|
|
||||||
],
|
|
||||||
Exception::DOMAIN_VERIFICATION_FAILED => [
|
Exception::DOMAIN_VERIFICATION_FAILED => [
|
||||||
'name' => Exception::DOMAIN_VERIFICATION_FAILED,
|
'name' => Exception::DOMAIN_VERIFICATION_FAILED,
|
||||||
'description' => 'Domain verification for the requested domain has failed.',
|
'description' => 'Domain verification for the requested domain has failed.',
|
||||||
|
|
|
@ -1444,14 +1444,11 @@ App::put('/v1/functions/:functionId/variables/:variableId')
|
||||||
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
||||||
->param('functionId', null, new UID(), 'Function unique ID.', false)
|
->param('functionId', null, new UID(), 'Function unique ID.', false)
|
||||||
->param('variableId', null, new UID(), 'Variable unique ID.', false)
|
->param('variableId', null, new UID(), 'Variable unique ID.', false)
|
||||||
->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', true)
|
->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', false)
|
||||||
->param('value', null, new Text(8192), 'Variable value. Max length: 8192 chars.', true)
|
->param('value', null, new Text(8192), 'Variable value. Max length: 8192 chars.', true)
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->action(function (string $functionId, string $variableId, ?string $key, ?string $value, Response $response, Database $dbForProject) {
|
->action(function (string $functionId, string $variableId, string $key, ?string $value, Response $response, Database $dbForProject) {
|
||||||
if (empty($key) && empty($value)) {
|
|
||||||
throw new Exception(Exception::VARIABLE_MISSING_PAYLOAD, 'Missing key or value. Define at least one.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$function = $dbForProject->getDocument('functions', $functionId);
|
$function = $dbForProject->getDocument('functions', $functionId);
|
||||||
|
|
||||||
|
@ -1469,7 +1466,7 @@ App::put('/v1/functions/:functionId/variables/:variableId')
|
||||||
}
|
}
|
||||||
|
|
||||||
$variable
|
$variable
|
||||||
->setAttribute('key', $key ?? $variable->getAttribute('key'))
|
->setAttribute('key', $key)
|
||||||
->setAttribute('value', $value ?? $variable->getAttribute('value'))
|
->setAttribute('value', $value ?? $variable->getAttribute('value'))
|
||||||
->setAttribute('search', implode(' ', [$variableId, $function->getId(), $key]))
|
->setAttribute('search', implode(' ', [$variableId, $function->getId(), $key]))
|
||||||
;
|
;
|
||||||
|
|
20
composer.lock
generated
20
composer.lock
generated
|
@ -2841,12 +2841,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/appwrite/sdk-generator.git",
|
"url": "https://github.com/appwrite/sdk-generator.git",
|
||||||
"reference": "6e630a62f522ac68a7056bebf81cd032c7a053ba"
|
"reference": "6597948263e88f73dbdd5c70259dd54aff2dfcf8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6e630a62f522ac68a7056bebf81cd032c7a053ba",
|
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6597948263e88f73dbdd5c70259dd54aff2dfcf8",
|
||||||
"reference": "6e630a62f522ac68a7056bebf81cd032c7a053ba",
|
"reference": "6597948263e88f73dbdd5c70259dd54aff2dfcf8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2884,7 +2884,7 @@
|
||||||
"issues": "https://github.com/appwrite/sdk-generator/issues",
|
"issues": "https://github.com/appwrite/sdk-generator/issues",
|
||||||
"source": "https://github.com/appwrite/sdk-generator/tree/master"
|
"source": "https://github.com/appwrite/sdk-generator/tree/master"
|
||||||
},
|
},
|
||||||
"time": "2022-08-29T10:43:33+00:00"
|
"time": "2022-08-30T18:29:13+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "doctrine/instantiator",
|
"name": "doctrine/instantiator",
|
||||||
|
@ -3534,16 +3534,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "9.2.16",
|
"version": "9.2.17",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "2593003befdcc10db5e213f9f28814f5aa8ac073"
|
"reference": "aa94dc41e8661fe90c7316849907cba3007b10d8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2593003befdcc10db5e213f9f28814f5aa8ac073",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8",
|
||||||
"reference": "2593003befdcc10db5e213f9f28814f5aa8ac073",
|
"reference": "aa94dc41e8661fe90c7316849907cba3007b10d8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -3599,7 +3599,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.16"
|
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -3607,7 +3607,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2022-08-20T05:26:47+00:00"
|
"time": "2022-08-30T12:24:04+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
convertNoticesToExceptions="true"
|
convertNoticesToExceptions="true"
|
||||||
convertWarningsToExceptions="true"
|
convertWarningsToExceptions="true"
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnFailure="false"
|
stopOnFailure="true"
|
||||||
>
|
>
|
||||||
<extensions>
|
<extensions>
|
||||||
<extension class="Appwrite\Tests\TestHook" />
|
<extension class="Appwrite\Tests\TestHook" />
|
||||||
|
|
|
@ -168,7 +168,6 @@ class Exception extends \Exception
|
||||||
/** Variables */
|
/** Variables */
|
||||||
public const VARIABLE_NOT_FOUND = 'variable_not_found';
|
public const VARIABLE_NOT_FOUND = 'variable_not_found';
|
||||||
public const VARIABLE_ALREADY_EXISTS = 'variable_already_exists';
|
public const VARIABLE_ALREADY_EXISTS = 'variable_already_exists';
|
||||||
public const VARIABLE_MISSING_PAYLOAD = 'variable_missing_payload';
|
|
||||||
|
|
||||||
/** Platform */
|
/** Platform */
|
||||||
public const PLATFORM_NOT_FOUND = 'platform_not_found';
|
public const PLATFORM_NOT_FOUND = 'platform_not_found';
|
||||||
|
|
|
@ -303,6 +303,8 @@ class FunctionsConsoleClientTest extends Scope
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals(200, $response['headers']['status-code']);
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
|
$this->assertEquals("APP_TEST_UPDATE", $response['body']['key']);
|
||||||
|
$this->assertEquals("TESTINGVALUEUPDATED", $response['body']['value']);
|
||||||
|
|
||||||
$variable = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
$variable = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
@ -313,10 +315,46 @@ class FunctionsConsoleClientTest extends Scope
|
||||||
$this->assertEquals("APP_TEST_UPDATE", $variable['body']['key']);
|
$this->assertEquals("APP_TEST_UPDATE", $variable['body']['key']);
|
||||||
$this->assertEquals("TESTINGVALUEUPDATED", $variable['body']['value']);
|
$this->assertEquals("TESTINGVALUEUPDATED", $variable['body']['value']);
|
||||||
|
|
||||||
|
$response = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()), [
|
||||||
|
'key' => 'APP_TEST_UPDATE_2',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(200, $response['headers']['status-code']);
|
||||||
|
$this->assertEquals("APP_TEST_UPDATE_2", $response['body']['key']);
|
||||||
|
$this->assertEquals("TESTINGVALUEUPDATED", $response['body']['value']);
|
||||||
|
|
||||||
|
$variable = $this->client->call(Client::METHOD_GET, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$this->assertEquals(200, $variable['headers']['status-code']);
|
||||||
|
$this->assertEquals("APP_TEST_UPDATE_2", $variable['body']['key']);
|
||||||
|
$this->assertEquals("TESTINGVALUEUPDATED", $variable['body']['value']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for FAILURE
|
* Test for FAILURE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$response = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()));
|
||||||
|
|
||||||
|
$this->assertEquals(400, $response['headers']['status-code']);
|
||||||
|
|
||||||
|
$response = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
], $this->getHeaders()), [
|
||||||
|
'value' => 'TESTINGVALUEUPDATED_2'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(400, $response['headers']['status-code']);
|
||||||
|
|
||||||
$longKey = str_repeat("A", 256);
|
$longKey = str_repeat("A", 256);
|
||||||
$response = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
$response = $this->client->call(Client::METHOD_PUT, '/functions/' . $data['functionId'] . '/variables/' . $data['variableId'], array_merge([
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
|
|
Loading…
Reference in a new issue