console route change

This commit is contained in:
fogelito
2023-03-01 18:32:13 +02:00
parent 72b30d4f60
commit 3d3ffba93a
2 changed files with 11 additions and 9 deletions
+5 -3
View File
@@ -2929,10 +2929,11 @@ App::get('/v1/databases/:databaseId/slow-queries/:documentId')
->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_DOCUMENT)
->param('databaseId', '', new UID(), 'Database ID.')
->param('documentId', '', new UID(), 'Document ID.')
->inject('response')
->inject('dbForProject')
->action(function (string $documentId, Response $response, Database $dbForProject) {
->action(function (string $databaseId, string $documentId, Response $response, Database $dbForProject) {
$document = $dbForProject->getDocument('slowQueries', $documentId);
if ($document->isEmpty()) {
throw new Exception(Exception::DOCUMENT_NOT_FOUND);
@@ -2941,7 +2942,7 @@ App::get('/v1/databases/:databaseId/slow-queries/:documentId')
$response->dynamic($document, Response::MODEL_DOCUMENT);
});
App::get('/v1/databases/:databaseId/slow-queries/:documentId')
App::delete('/v1/databases/:databaseId/slow-queries/:documentId')
->desc('Delete Slow query Document')
->desc('List Documents')
->groups(['api', 'database'])
@@ -2955,10 +2956,11 @@ App::get('/v1/databases/:databaseId/slow-queries/:documentId')
->label('sdk.description', '/docs/references/databases/delete-slow-query-document.md')
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
->label('sdk.response.model', Response::MODEL_NONE)
->param('databaseId', '', new UID(), 'Database ID.')
->param('documentId', '', new UID(), 'Document ID.')
->inject('response')
->inject('dbForProject')
->action(function (string $documentId, Response $response, Database $dbForProject) {
->action(function (string $databaseId, string $documentId, Response $response, Database $dbForProject) {
$document = $dbForProject->getDocument('slowQueries', $documentId);
if ($document->isEmpty()) {
throw new Exception(Exception::DOCUMENT_NOT_FOUND);
@@ -306,23 +306,23 @@ class DatabasesConsoleClientTest extends Scope
$this->assertEquals(true, $documents['body']['documents'][0]['blocked']);
$this->assertEquals(2, $documents['body']['documents'][0]['count']);
$document = $this->client->call(Client::METHOD_GET, '/databases/slow-queries/' . $documents['body']['documents'][0]['$id'], array_merge([
$doc = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/slow-queries/' . $documents['body']['documents'][0]['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $documents['headers']['status-code']);
$this->assertEquals($document['body']['queries'][0], 'notEqual("longtext", "appwrite")');
$this->assertEquals(200, $doc['headers']['status-code']);
$this->assertEquals($doc['body']['queries'][0], 'notEqual("longtext", "appwrite")');
$response = $this->client->call(Client::METHOD_DELETE, '/databases/slow-queries/' . $documents['body']['documents'][0]['$id'], array_merge([
$response = $this->client->call(Client::METHOD_DELETE, '/databases/' . $data['databaseId'] . '/slow-queries/' . $documents['body']['documents'][0]['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(204, $response['headers']['status-code']);
$document = $this->client->call(Client::METHOD_GET, '/databases/slow-queries/' . $documents['body']['documents'][0]['$id'], array_merge([
$doc = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/slow-queries/' . $documents['body']['documents'][0]['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(404, $document['headers']['status-code']);
$this->assertEquals(404, $doc['headers']['status-code']);
}
}