mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
Add usage routes
This commit is contained in:
parent
ca03be5e41
commit
c86b35fbb3
3 changed files with 108 additions and 0 deletions
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Platform\Modules\Databases\Http\TablesDB\Databases\Usage;
|
||||
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Usage\Get as DatabaseUsageGet;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use Utopia\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
class Get extends DatabaseUsageGet
|
||||
{
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'getTablesDatabaseUsage';
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/tablesdb/:databaseId/usage')
|
||||
->desc('Get database usage stats')
|
||||
->groups(['api', 'database', 'usage'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', [
|
||||
new Method(
|
||||
namespace: 'tablesdb',
|
||||
group: null,
|
||||
name: 'getDatabaseUsage',
|
||||
description: '/docs/references/tablesdb/get-database-usage.md',
|
||||
auth: [AuthType::ADMIN],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: SwooleResponse::STATUS_CODE_OK,
|
||||
model: UtopiaResponse::MODEL_USAGE_DATABASE,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON,
|
||||
),
|
||||
])
|
||||
->param('databaseId', '', new UID(), 'Database ID.')
|
||||
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true)
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Platform\Modules\Databases\Http\TablesDB\Databases\Usage;
|
||||
|
||||
use Appwrite\Platform\Modules\Databases\Http\Databases\Usage\XList as DatabaseUsageXList;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\ContentType;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Utopia\Swoole\Response as SwooleResponse;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
class XList extends DatabaseUsageXList
|
||||
{
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'listTablesDatabaseUsage';
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->setHttpMethod(self::HTTP_REQUEST_METHOD_GET)
|
||||
->setHttpPath('/v1/tablesdb/usage')
|
||||
->desc('Get databases usage stats')
|
||||
->groups(['api', 'database', 'usage'])
|
||||
->label('scope', 'collections.read')
|
||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||
->label('sdk', [
|
||||
new Method(
|
||||
namespace: 'tablesdb',
|
||||
group: null,
|
||||
name: 'listDatabaseUsage',
|
||||
description: '/docs/references/tablesdb/list-database-usage.md',
|
||||
auth: [AuthType::ADMIN],
|
||||
responses: [
|
||||
new SDKResponse(
|
||||
code: SwooleResponse::STATUS_CODE_OK,
|
||||
model: UtopiaResponse::MODEL_USAGE_DATABASES,
|
||||
)
|
||||
],
|
||||
contentType: ContentType::JSON
|
||||
),
|
||||
])
|
||||
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true)
|
||||
->inject('response')
|
||||
->inject('dbForProject')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +53,8 @@ use Appwrite\Platform\Modules\Databases\Http\TablesDB\Tables\Rows\XList as ListR
|
|||
use Appwrite\Platform\Modules\Databases\Http\TablesDB\Tables\Update as UpdateTable;
|
||||
use Appwrite\Platform\Modules\Databases\Http\TablesDB\Tables\Usage\Get as GetTableUsage;
|
||||
use Appwrite\Platform\Modules\Databases\Http\TablesDB\Tables\XList as ListTables;
|
||||
use Appwrite\Platform\Modules\Databases\Http\TablesDB\Databases\Usage\Get as GetTablesDatabaseUsage;
|
||||
use Appwrite\Platform\Modules\Databases\Http\TablesDB\Databases\Usage\XList as ListTablesDatabaseUsage;
|
||||
use Utopia\Platform\Service;
|
||||
|
||||
/**
|
||||
|
|
@ -82,6 +84,8 @@ class Tables extends Base
|
|||
$service->addAction(UpdateTablesDatabase::getName(), new UpdateTablesDatabase());
|
||||
$service->addAction(DeleteTablesDatabase::getName(), new DeleteTablesDatabase());
|
||||
$service->addAction(ListTablesDatabase::getName(), new ListTablesDatabase());
|
||||
$service->addAction(GetTablesDatabaseUsage::getName(), new GetTablesDatabaseUsage());
|
||||
$service->addAction(ListTablesDatabaseUsage::getName(), new ListTablesDatabaseUsage());
|
||||
}
|
||||
|
||||
private function registerTableActions(Service $service): void
|
||||
|
|
|
|||
Loading…
Reference in a new issue