From 4ac543d006ed304a2423f799098fb7b0f4988872 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Sep 2026 08:28:26 +0545 Subject: [PATCH 1/3] refactor: drop the stats collection and its retention sweeper StatsUsage and StatsResources became ClickHouse-only in #13286, so nothing writes the project-DB or logs-DB `stats` collection any more. Remove the definition from both collection sets and everything that existed only to prune it. Removing the definition makes the sweeper a hazard rather than dead weight: new projects get no `stats` metadata row, so deleteByGroup('stats', ...) would throw. deleteUsageStats() and both its dispatch sites go, taking DELETE_TYPE_USAGE, the hourlyUsageRetentionDatetime message field, the maintenance scheduling and _APP_MAINTENANCE_RETENTION_USAGE_HOURLY with them. The logs collection set is now empty but the file and the getLogsDB plumbing stay: the database itself is still created and other editions merge their own collections into that set. No API surface changes. The Usage* response models that are still returned somewhere keep their classes, constants and registrations; only the ones with no referee left in any edition go: UsageFunction(s), UsageSite, UsageDocumentsDB(s) and UsageVectorsDB(s), along with the two V19 filter arms that reshaped responses nothing emits. The spec test that pinned "a list of a sub-model emits array + $ref items, not allOf" used UsageProject as its fixture; re-point it at UsageMetric/UsageDataPoint so the generator guarantee typed SDKs depend on keeps its regression net. Migrations are untouched. Utopia resolves a collection from the database metadata table, not from this config, so V20's createDocument('stats', ...) still works on the <=1.5.x installs those migrations run against. --- .env | 1 - app/config/collections/common.php | 86 -------- app/config/collections/logs.php | 95 +-------- app/config/variables.php | 9 - app/init/constants.php | 1 - app/init/models.php | 16 -- docker-compose.yml | 2 - src/Appwrite/Event/Message/Delete.php | 3 - src/Appwrite/Platform/Tasks/Maintenance.php | 7 +- src/Appwrite/Platform/Workers/Deletes.php | 46 ---- src/Appwrite/Utopia/Response.php | 7 - src/Appwrite/Utopia/Response/Filters/V19.php | 21 -- .../Response/Model/UsageDocumentsDB.php | 96 --------- .../Response/Model/UsageDocumentsDBs.php | 109 ---------- .../Utopia/Response/Model/UsageFunction.php | 190 ----------------- .../Utopia/Response/Model/UsageFunctions.php | 197 ------------------ .../Utopia/Response/Model/UsageSite.php | 74 ------- .../Utopia/Response/Model/UsageVectorsDB.php | 96 --------- .../Utopia/Response/Model/UsageVectorsDBs.php | 109 ---------- tests/unit/SDK/Specification/FormatTest.php | 41 ++-- .../unit/Utopia/Response/Filters/V19Test.php | 69 ------ 21 files changed, 26 insertions(+), 1249 deletions(-) delete mode 100644 src/Appwrite/Utopia/Response/Model/UsageDocumentsDB.php delete mode 100644 src/Appwrite/Utopia/Response/Model/UsageDocumentsDBs.php delete mode 100644 src/Appwrite/Utopia/Response/Model/UsageFunction.php delete mode 100644 src/Appwrite/Utopia/Response/Model/UsageFunctions.php delete mode 100644 src/Appwrite/Utopia/Response/Model/UsageSite.php delete mode 100644 src/Appwrite/Utopia/Response/Model/UsageVectorsDB.php delete mode 100644 src/Appwrite/Utopia/Response/Model/UsageVectorsDBs.php diff --git a/.env b/.env index d8ae18e7d8..9f4ccf7b3e 100644 --- a/.env +++ b/.env @@ -150,7 +150,6 @@ _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE=15778800 _APP_MAINTENANCE_RETENTION_CACHE=2592000 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 _APP_MAINTENANCE_RETENTION_SCHEDULES=86400 -_APP_MAINTENANCE_RETENTION_USAGE_HOURLY=8640000 _APP_USAGE_STATS=enabled _APP_USAGE_PASS=appwrite _APP_CONNECTIONS_DB_USAGE=http://appwrite:appwrite@clickhouse:8123/appwrite diff --git a/app/config/collections/common.php b/app/config/collections/common.php index 469d2a78eb..cd491d1e79 100644 --- a/app/config/collections/common.php +++ b/app/config/collections/common.php @@ -1851,92 +1851,6 @@ return [ ] ], - 'stats' => [ - '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('stats'), - 'name' => 'Stats', - 'attributes' => [ - [ - '$id' => ID::custom('metric'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('region'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('value'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('time'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('period'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => ID::custom('_key_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - [ - '$id' => ID::custom('_key_period_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_metric_period_time'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['metric', 'period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - ], - ], - 'providers' => [ '$collection' => ID::custom(DATABASE::METADATA), '$id' => ID::custom('providers'), diff --git a/app/config/collections/logs.php b/app/config/collections/logs.php index 069dcf5a4b..6d8a1828f2 100644 --- a/app/config/collections/logs.php +++ b/app/config/collections/logs.php @@ -1,94 +1,5 @@ ID::custom(Database::METADATA), - '$id' => ID::custom('stats'), - 'name' => 'stats', - 'attributes' => [ - [ - '$id' => ID::custom('metric'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('region'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 255, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('value'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 8, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('time'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], - [ - '$id' => ID::custom('period'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 4, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - ], - 'indexes' => [ - [ - '$id' => ID::custom('_key_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - [ - '$id' => ID::custom('_key_period_time'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_metric_period_time'), - 'type' => Database::INDEX_UNIQUE, - 'attributes' => ['metric', 'period', 'time'], - 'lengths' => [], - 'orders' => [Database::ORDER_DESC], - ], - ], -]; - -return $logsCollection; +// Empty by design: the logs database is still created, and other editions merge +// their own collections into this set. +return []; diff --git a/app/config/variables.php b/app/config/variables.php index a376989d3e..2541898ecb 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -1768,15 +1768,6 @@ return [ 'question' => '', 'filter' => '' ], - [ - 'name' => '_APP_MAINTENANCE_RETENTION_USAGE_HOURLY', - 'description' => 'The maximum duration (in seconds) upto which to retain hourly usage metrics. The default value is 8640000 seconds (100 days).', - 'introduction' => '', - 'default' => '8640000', - 'required' => false, - 'question' => '', - 'filter' => '' - ], [ 'name' => '_APP_MAINTENANCE_RETENTION_SCHEDULES', 'description' => 'Schedules deletion interval ( in seconds ) ', diff --git a/app/init/constants.php b/app/init/constants.php index b311e2e3d1..bbb8f549db 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -278,7 +278,6 @@ const DELETE_TYPE_EXECUTIONS = 'executions'; const DELETE_TYPE_EXECUTIONS_LIMIT = 'executionsLimit'; const DELETE_TYPE_AUDIT = 'audit'; const DELETE_TYPE_ABUSE = 'abuse'; -const DELETE_TYPE_USAGE = 'usage'; const DELETE_TYPE_REALTIME = 'realtime'; const DELETE_TYPE_BUCKETS = 'buckets'; const DELETE_TYPE_INSTALLATIONS = 'installations'; diff --git a/app/init/models.php b/app/init/models.php index e2afa223a4..1cfa30468f 100644 --- a/app/init/models.php +++ b/app/init/models.php @@ -219,19 +219,12 @@ use Appwrite\Utopia\Response\Model\Token; use Appwrite\Utopia\Response\Model\Topic; use Appwrite\Utopia\Response\Model\Transaction; use Appwrite\Utopia\Response\Model\UsageDataPoint; -use Appwrite\Utopia\Response\Model\UsageDocumentsDB; -use Appwrite\Utopia\Response\Model\UsageDocumentsDBs; use Appwrite\Utopia\Response\Model\UsageEventList; -use Appwrite\Utopia\Response\Model\UsageFunction; -use Appwrite\Utopia\Response\Model\UsageFunctions; use Appwrite\Utopia\Response\Model\UsageGaugeList; use Appwrite\Utopia\Response\Model\UsageMetric; use Appwrite\Utopia\Response\Model\UsagePresence; use Appwrite\Utopia\Response\Model\UsageProject; -use Appwrite\Utopia\Response\Model\UsageSite; use Appwrite\Utopia\Response\Model\UsageUsers; -use Appwrite\Utopia\Response\Model\UsageVectorsDB; -use Appwrite\Utopia\Response\Model\UsageVectorsDBs; use Appwrite\Utopia\Response\Model\User; use Appwrite\Utopia\Response\Model\Variable; use Appwrite\Utopia\Response\Model\VcsContent; @@ -340,16 +333,10 @@ Response::setModel(new AttributeText()); Response::setModel(new AttributeMediumtext()); Response::setModel(new AttributeLongtext()); -// DocumentsDB API Models -Response::setModel(new UsageDocumentsDBs()); -Response::setModel(new UsageDocumentsDB()); - // VectorsDB API Models Response::setModel(new VectorsDBCollection()); Response::setModel(new AttributeObject()); Response::setModel(new AttributeVector()); -Response::setModel(new UsageVectorsDBs()); -Response::setModel(new UsageVectorsDB()); // Table API Models Response::setModel(new Table()); @@ -512,9 +499,6 @@ Response::setModel(new Metric()); Response::setModel(new MetricBreakdown()); Response::setModel(new UsageUsers()); Response::setModel(new UsagePresence()); -Response::setModel(new UsageFunctions()); -Response::setModel(new UsageFunction()); -Response::setModel(new UsageSite()); Response::setModel(new UsageProject()); Response::setModel(new UsageDataPoint()); Response::setModel(new UsageMetric()); diff --git a/docker-compose.yml b/docker-compose.yml index 935554bae2..9bfb00c823 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -215,7 +215,6 @@ services: - _APP_MAINTENANCE_RETENTION_ABUSE - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE - - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY - _APP_MAINTENANCE_RETENTION_SCHEDULES - _APP_SMS_PROVIDER - _APP_SMS_FROM @@ -1411,7 +1410,6 @@ services: - _APP_MAINTENANCE_RETENTION_ABUSE - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_AUDIT_CONSOLE - - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY - _APP_MAINTENANCE_RETENTION_SCHEDULES - _APP_MAINTENANCE_START_TIME - _APP_DATABASE_SHARED_TABLES diff --git a/src/Appwrite/Event/Message/Delete.php b/src/Appwrite/Event/Message/Delete.php index 6866cf3f02..7984103492 100644 --- a/src/Appwrite/Event/Message/Delete.php +++ b/src/Appwrite/Event/Message/Delete.php @@ -13,7 +13,6 @@ final class Delete extends Base public readonly ?string $resource = null, public readonly ?string $resourceType = null, public readonly ?string $datetime = null, - public readonly ?string $hourlyUsageRetentionDatetime = null, ) { } @@ -26,7 +25,6 @@ final class Delete extends Base 'resource' => $this->resource, 'resourceType' => $this->resourceType, 'datetime' => $this->datetime, - 'hourlyUsageRetentionDatetime' => $this->hourlyUsageRetentionDatetime, ]; } @@ -39,7 +37,6 @@ final class Delete extends Base resource: $data['resource'] ?? null, resourceType: $data['resourceType'] ?? null, datetime: $data['datetime'] ?? null, - hourlyUsageRetentionDatetime: $data['hourlyUsageRetentionDatetime'] ?? null, ); } } diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index d30e8fc567..927792905c 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -43,7 +43,6 @@ class Maintenance extends Action Console::success(APP_NAME . ' maintenance process v1 has started'); $interval = (int) System::getEnv('_APP_MAINTENANCE_INTERVAL', '86400'); // 1 day - $usageStatsRetentionHourly = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_HOURLY', '8640000'); //100 days $cacheRetention = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days $schedulesDeletionRetention = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_SCHEDULES', '86400'); // 1 Day $jobInitTime = System::getEnv('_APP_MAINTENANCE_START_TIME', '00:00'); // (hour:minutes) @@ -62,7 +61,7 @@ class Maintenance extends Action $delay = $next->getTimestamp() - $now->getTimestamp(); } - $action = function () use ($interval, $cacheRetention, $schedulesDeletionRetention, $usageStatsRetentionHourly, $dbForPlatform, $console, $publisherForDeletes, $publisherForCertificates, $certificateIssuer) { + $action = function () use ($interval, $cacheRetention, $schedulesDeletionRetention, $dbForPlatform, $console, $publisherForDeletes, $publisherForCertificates, $certificateIssuer) { $time = DatabaseDateTime::now(); Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds"); @@ -74,11 +73,10 @@ class Maintenance extends Action $dbForPlatform->skipFilters( fn () => $dbForPlatform->foreach( 'projects', - function (Document $project) use ($publisherForDeletes, $usageStatsRetentionHourly) { + function (Document $project) use ($publisherForDeletes) { $publisherForDeletes->enqueue(new DeleteMessage( project: $project, type: DELETE_TYPE_MAINTENANCE, - hourlyUsageRetentionDatetime: DatabaseDateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly), )); }, [ @@ -94,7 +92,6 @@ class Maintenance extends Action $publisherForDeletes->enqueue(new DeleteMessage( project: $console, type: DELETE_TYPE_MAINTENANCE, - hourlyUsageRetentionDatetime: DatabaseDateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly), )); $this->notifyDeleteConnections($publisherForDeletes); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index d1282af846..a68beff1ee 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -246,7 +246,6 @@ class Deletes extends Action $deleteMessage = DeleteMessage::fromArray($payload); $type = $deleteMessage->type; $datetime = $deleteMessage->datetime; - $hourlyUsageRetentionDatetime = $deleteMessage->hourlyUsageRetentionDatetime; $resource = $deleteMessage->resource; $resourceType = $deleteMessage->resourceType; $document = $deleteMessage->document ?? new Document(); @@ -318,9 +317,6 @@ class Deletes extends Action case DELETE_TYPE_SESSIONS: $this->deleteExpiredSessions($project, $getProjectDB); break; - case DELETE_TYPE_USAGE: - $this->deleteUsageStats($project, $getProjectDB, $getLogsDB, $hourlyUsageRetentionDatetime); - break; case DELETE_TYPE_CACHE_BY_RESOURCE: $this->deleteCacheByResource($project, $getProjectDB, $resource, $resourceType); break; @@ -348,7 +344,6 @@ class Deletes extends Action case DELETE_TYPE_MAINTENANCE: $this->deleteExpiredTargets($project, $getProjectDB); $this->deleteExecutionLogs($project, $getProjectDB, $executionRetention, $executionsRetentionCount, $executionStore); - $this->deleteUsageStats($project, $getProjectDB, $getLogsDB, $hourlyUsageRetentionDatetime); $this->deleteExpiredSessions($project, $getProjectDB); $this->deleteExpiredTokens($project, $getProjectDB); $this->deleteExpiredChallenges($project, $getProjectDB); @@ -708,47 +703,6 @@ class Deletes extends Action ); } - /** - * @param callable $getProjectDB - * @param string $hourlyUsageRetentionDatetime - * @return void - * @throws Exception - */ - private function deleteUsageStats(Document $project, callable $getProjectDB, callable $getLogsDB, string $hourlyUsageRetentionDatetime): void - { - if ($project->getId() === 'console') { - return; - } - - Console::info('Delete usage stats'); - - /** @var Database $dbForProject */ - $dbForProject = $getProjectDB($project); - - $selects = [...$this->selects, 'time']; - - // Delete Usage stats from projectDB - $this->deleteByGroup('stats', [ - Query::select($selects), - Query::equal('period', ['1h']), - Query::lessThan('time', $hourlyUsageRetentionDatetime), - Query::orderDesc('time'), - Query::orderDesc(), - ], $dbForProject); - - /** @var Database $dbForLogs */ - $dbForLogs = call_user_func($getLogsDB, $project); - - // Delete Usage stats from logsDB - $this->deleteByGroup('stats', [ - Query::select($selects), - Query::equal('period', ['1h']), - Query::lessThan('time', $hourlyUsageRetentionDatetime), - Query::orderDesc('time'), - Query::orderDesc(), - ], $dbForLogs); - } - /** * @param callable $getProjectDB * @param Document $document teams document diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index e725e4f25b..d45232bfe2 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -29,15 +29,8 @@ class Response extends SwooleResponse public const MODEL_METRIC_LIST = 'metricList'; public const MODEL_METRIC_BREAKDOWN = 'metricBreakdown'; public const MODEL_ERROR_DEV = 'errorDev'; - public const MODEL_USAGE_DOCUMENTSDBS = 'usageDocumentsDBs'; - public const MODEL_USAGE_DOCUMENTSDB = 'usageDocumentsDB'; - public const MODEL_USAGE_VECTORSDBS = 'usageVectorsDBs'; - public const MODEL_USAGE_VECTORSDB = 'usageVectorsDB'; public const MODEL_USAGE_USERS = 'usageUsers'; public const MODEL_USAGE_PRESENCE = 'usagePresence'; - public const MODEL_USAGE_FUNCTIONS = 'usageFunctions'; - public const MODEL_USAGE_FUNCTION = 'usageFunction'; - public const MODEL_USAGE_SITE = 'usageSite'; public const MODEL_USAGE_PROJECT = 'usageProject'; public const MODEL_USAGE_DATA_POINT = 'usageDataPoint'; public const MODEL_USAGE_METRIC = 'usageMetric'; diff --git a/src/Appwrite/Utopia/Response/Filters/V19.php b/src/Appwrite/Utopia/Response/Filters/V19.php index 88f8323da9..cd7aa144f6 100644 --- a/src/Appwrite/Utopia/Response/Filters/V19.php +++ b/src/Appwrite/Utopia/Response/Filters/V19.php @@ -25,8 +25,6 @@ class V19 extends Filter Response::MODEL_PROJECT_LIST => $this->handleList($content, 'projects', fn ($item) => $this->parseProject($item)), Response::MODEL_PROVIDER_REPOSITORY => $this->parseProviderRepository($content), Response::MODEL_TEMPLATE_VARIABLE => $this->parseTemplateVariable($content), - Response::MODEL_USAGE_FUNCTION => $this->parseUsageFunction($content), - Response::MODEL_USAGE_FUNCTIONS => $this->parseUsageFunctions($content), Response::MODEL_VARIABLE => $this->parseVariable($content), Response::MODEL_VARIABLE_LIST => $this->handleList($content, 'variables', fn ($item) => $this->parseVariable($item)), default => $parsedResponse, @@ -97,25 +95,6 @@ class V19 extends Filter return $content; } - protected function parseUsageFunction(array $content) - { - unset($content['buildsSuccessTotal']); - unset($content['buildsFailedTotal']); - unset($content['buildsTimeAverage']); - unset($content['buildsSuccess']); - unset($content['buildsFailed']); - return $content; - } - - protected function parseUsageFunctions(array $content) - { - unset($content['buildsSuccessTotal']); - unset($content['buildsFailedTotal']); - unset($content['buildsSuccess']); - unset($content['buildsFailed']); - return $content; - } - protected function parseVariable(array $content) { unset($content['secret']); diff --git a/src/Appwrite/Utopia/Response/Model/UsageDocumentsDB.php b/src/Appwrite/Utopia/Response/Model/UsageDocumentsDB.php deleted file mode 100644 index 099a9887b8..0000000000 --- a/src/Appwrite/Utopia/Response/Model/UsageDocumentsDB.php +++ /dev/null @@ -1,96 +0,0 @@ -addRule('range', [ - 'type' => self::TYPE_STRING, - 'description' => 'Time range of the usage stats.', - 'default' => '', - 'example' => '30d', - ]) - ->addRule('collectionsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of collections.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('documentsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of documents.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('storageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated storage used in bytes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databaseReadsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of database reads.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databaseWritesTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of database writes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('collections', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of collections per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('documents', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of documents per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('storage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated storage used in bytes per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databaseReads', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database reads.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databaseWrites', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database writes.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ; - } - - public function getName(): string - { - return 'UsageDocumentsDB'; - } - - public function getType(): string - { - return Response::MODEL_USAGE_DOCUMENTSDB; - } -} diff --git a/src/Appwrite/Utopia/Response/Model/UsageDocumentsDBs.php b/src/Appwrite/Utopia/Response/Model/UsageDocumentsDBs.php deleted file mode 100644 index 5ce229ce4a..0000000000 --- a/src/Appwrite/Utopia/Response/Model/UsageDocumentsDBs.php +++ /dev/null @@ -1,109 +0,0 @@ -addRule('range', [ - 'type' => self::TYPE_STRING, - 'description' => 'Time range of the usage stats.', - 'default' => '', - 'example' => '30d', - ]) - ->addRule('databasesTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of DocumentsDB databases.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('collectionsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of collections.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('documentsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of documents.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('storageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of total databases storage in bytes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databasesReadsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of databases reads.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databasesWritesTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of databases writes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databases', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of databases per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('collections', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of collections per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('documents', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of documents per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('storage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of the aggregated number of databases storage in bytes per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databasesReads', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database reads.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databasesWrites', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database writes.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ; - } - - public function getName(): string - { - return 'UsageDocumentsDBs'; - } - - public function getType(): string - { - return Response::MODEL_USAGE_DOCUMENTSDBS; - } -} diff --git a/src/Appwrite/Utopia/Response/Model/UsageFunction.php b/src/Appwrite/Utopia/Response/Model/UsageFunction.php deleted file mode 100644 index 32a23250d4..0000000000 --- a/src/Appwrite/Utopia/Response/Model/UsageFunction.php +++ /dev/null @@ -1,190 +0,0 @@ -addRule('range', [ - 'type' => self::TYPE_STRING, - 'description' => 'The time range of the usage stats.', - 'default' => '', - 'example' => '30d', - ]) - ->addRule('deploymentsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of function deployments.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('deploymentsStorageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of function deployments storage.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of function builds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsSuccessTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of successful function builds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsFailedTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of failed function builds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsStorageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'total aggregated sum of function builds storage.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsTimeTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of function builds compute time.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsTimeAverage', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Average builds compute time.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsMbSecondsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of function builds mbSeconds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('executionsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of function executions.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('executionsTimeTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of function executions compute time.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('executionsMbSecondsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of function executions mbSeconds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('deployments', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function deployments per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('deploymentsStorage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function deployments storage per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('builds', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function builds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsStorage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated sum of function builds storage per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsTime', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated sum of function builds compute time per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsMbSeconds', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function builds mbSeconds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('executions', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function executions per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('executionsTime', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function executions compute time per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('executionsMbSeconds', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of function mbSeconds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsSuccess', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of successful builds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsFailed', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of failed builds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName(): string - { - return 'UsageFunction'; - } - - /** - * Get Type - * - * @return string - */ - public function getType(): string - { - return Response::MODEL_USAGE_FUNCTION; - } -} diff --git a/src/Appwrite/Utopia/Response/Model/UsageFunctions.php b/src/Appwrite/Utopia/Response/Model/UsageFunctions.php deleted file mode 100644 index 6dc03c6293..0000000000 --- a/src/Appwrite/Utopia/Response/Model/UsageFunctions.php +++ /dev/null @@ -1,197 +0,0 @@ -addRule('range', [ - 'type' => self::TYPE_STRING, - 'description' => 'Time range of the usage stats.', - 'default' => '', - 'example' => '30d', - ]) - ->addRule('functionsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of functions.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('deploymentsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of functions deployments.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('deploymentsStorageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of functions deployment storage.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of functions build.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsStorageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'total aggregated sum of functions build storage.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsTimeTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of functions build compute time.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsMbSecondsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of functions build mbSeconds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('executionsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of functions execution.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('executionsTimeTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of functions execution compute time.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('executionsMbSecondsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated sum of functions execution mbSeconds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('functions', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of functions per period.', - 'default' => 0, - 'example' => 0, - 'array' => true - ]) - ->addRule('deployments', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of functions deployment per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('deploymentsStorage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of functions deployment storage per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsSuccessTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of successful function builds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('buildsFailedTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of failed function builds.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('builds', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of functions build per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsStorage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated sum of functions build storage per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsTime', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated sum of functions build compute time per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsMbSeconds', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated sum of functions build mbSeconds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('executions', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of functions execution per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('executionsTime', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of functions execution compute time per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('executionsMbSeconds', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of functions mbSeconds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsSuccess', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of successful function builds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('buildsFailed', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of failed function builds per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName(): string - { - return 'UsageFunctions'; - } - - /** - * Get Type - * - * @return string - */ - public function getType(): string - { - return Response::MODEL_USAGE_FUNCTIONS; - } -} diff --git a/src/Appwrite/Utopia/Response/Model/UsageSite.php b/src/Appwrite/Utopia/Response/Model/UsageSite.php deleted file mode 100644 index c45dc831cd..0000000000 --- a/src/Appwrite/Utopia/Response/Model/UsageSite.php +++ /dev/null @@ -1,74 +0,0 @@ -addRule('requestsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of requests.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('requests', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of requests per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('inboundTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated inbound bandwidth.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('inbound', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of inbound bandwidth per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('outboundTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated outbound bandwidth.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('outbound', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of outbound bandwidth per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName(): string - { - return 'UsageSite'; - } - - /** - * Get Type - * - * @return string - */ - public function getType(): string - { - return Response::MODEL_USAGE_SITE; - } -} diff --git a/src/Appwrite/Utopia/Response/Model/UsageVectorsDB.php b/src/Appwrite/Utopia/Response/Model/UsageVectorsDB.php deleted file mode 100644 index c652a3d62e..0000000000 --- a/src/Appwrite/Utopia/Response/Model/UsageVectorsDB.php +++ /dev/null @@ -1,96 +0,0 @@ -addRule('range', [ - 'type' => self::TYPE_STRING, - 'description' => 'Time range of the usage stats.', - 'default' => '', - 'example' => '30d', - ]) - ->addRule('collectionsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of collections.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('documentsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of documents.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('storageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated storage used in bytes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databaseReadsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of database reads.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databaseWritesTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of database writes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('collections', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of collections per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('documents', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of documents per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('storage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated storage used in bytes per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databaseReads', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database reads.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databaseWrites', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database writes.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ; - } - - public function getName(): string - { - return 'UsageVectorsDB'; - } - - public function getType(): string - { - return Response::MODEL_USAGE_VECTORSDB; - } -} diff --git a/src/Appwrite/Utopia/Response/Model/UsageVectorsDBs.php b/src/Appwrite/Utopia/Response/Model/UsageVectorsDBs.php deleted file mode 100644 index 1f5fe7853d..0000000000 --- a/src/Appwrite/Utopia/Response/Model/UsageVectorsDBs.php +++ /dev/null @@ -1,109 +0,0 @@ -addRule('range', [ - 'type' => self::TYPE_STRING, - 'description' => 'Time range of the usage stats.', - 'default' => '', - 'example' => '30d', - ]) - ->addRule('databasesTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of VectorsDB databases.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('collectionsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of collections.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('documentsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated number of documents.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('storageTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total aggregated storage in bytes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databasesReadsTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of database reads.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databasesWritesTotal', [ - 'type' => self::TYPE_INTEGER, - 'description' => 'Total number of database writes.', - 'default' => 0, - 'example' => 0, - ]) - ->addRule('databases', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of databases per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('collections', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of collections per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('documents', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated number of documents per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('storage', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated storage in bytes per period.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databasesReads', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database reads.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ->addRule('databasesWrites', [ - 'type' => Response::MODEL_METRIC, - 'description' => 'An array of aggregated number of database writes.', - 'default' => [], - 'example' => [], - 'array' => true - ]) - ; - } - - public function getName(): string - { - return 'UsageVectorsDBs'; - } - - public function getType(): string - { - return Response::MODEL_USAGE_VECTORSDBS; - } -} diff --git a/tests/unit/SDK/Specification/FormatTest.php b/tests/unit/SDK/Specification/FormatTest.php index 47e6ed01f3..5dbf8e681a 100644 --- a/tests/unit/SDK/Specification/FormatTest.php +++ b/tests/unit/SDK/Specification/FormatTest.php @@ -29,7 +29,6 @@ use Appwrite\Utopia\Response\Model\Error as ErrorModel; use Appwrite\Utopia\Response\Model\ErrorDev; use Appwrite\Utopia\Response\Model\FrameworkAdapter; use Appwrite\Utopia\Response\Model\HealthStatus; -use Appwrite\Utopia\Response\Model\Metric; use Appwrite\Utopia\Response\Model\Migration; use Appwrite\Utopia\Response\Model\None as NoneModel; use Appwrite\Utopia\Response\Model\PlatformAndroid; @@ -45,7 +44,7 @@ use Appwrite\Utopia\Response\Model\TemplateFramework; use Appwrite\Utopia\Response\Model\TemplateSite; use Appwrite\Utopia\Response\Model\TemplateVariable; use Appwrite\Utopia\Response\Model\UsageDataPoint; -use Appwrite\Utopia\Response\Model\UsageProject; +use Appwrite\Utopia\Response\Model\UsageMetric; use Appwrite\Utopia\Response\Model\User; use Appwrite\Utopia\Response\Model\Webhook; use PHPUnit\Framework\Attributes\DataProvider; @@ -831,12 +830,10 @@ final class FormatTest extends TestCase } /** - * The project usage handler writes the text embedding metrics as four - * per-period lists plus four scalar totals. A typed SDK generated from a - * schema that calls all eight a single metric object rejects every valid - * response, so pin the emitted schema rather than the rule table. + * A single model reference is deliberately wrapped in `allOf`, but a list of + * one must not be: typed SDKs reject every valid response if it is. */ - public function testUsageProjectEmbeddingsTextSchema(): void + public function testUsageMetricPointsSchema(): void { Method::$processed = []; Method::$errors = []; @@ -852,31 +849,35 @@ final class FormatTest extends TestCase responses: [ new SDKResponse( code: 200, - model: Response::MODEL_USAGE_PROJECT, + model: Response::MODEL_USAGE_METRIC, ), ], )); $models = [ - new UsageProject(), - new Metric(), + new UsageMetric(), + new UsageDataPoint(), new ErrorModel(), ]; $openApi = (new OpenAPI3(new Container(), [], [$route], $models, [], ['console' => 0], 'console'))->parse(); - $properties = $openApi['components']['schemas']['usageProject']['properties']; + $points = $openApi['components']['schemas']['usageMetric']['properties']['points']; - foreach (['embeddingsText', 'embeddingsTextTokens', 'embeddingsTextDuration', 'embeddingsTextErrors'] as $key) { - $this->assertSame('array', $properties[$key]['type'], $key); - $this->assertSame(['$ref' => '#/components/schemas/metric'], $properties[$key]['items'], $key); - $this->assertArrayNotHasKey('allOf', $properties[$key], $key); - } + $this->assertSame('array', $points['type']); + $this->assertSame(['$ref' => '#/components/schemas/usageDataPoint'], $points['items']); + $this->assertArrayNotHasKey('allOf', $points); - foreach (['embeddingsTextTotal', 'embeddingsTextTokensTotal', 'embeddingsTextDurationTotal', 'embeddingsTextErrorsTotal'] as $key) { - $this->assertSame('integer', $properties[$key]['type'], $key); - $this->assertArrayNotHasKey('allOf', $properties[$key], $key); - $this->assertArrayNotHasKey('items', $properties[$key], $key); + foreach ([ + ['usageMetric', 'metric', 'string'], + ['usageDataPoint', 'time', 'string'], + ['usageDataPoint', 'value', 'number'], + ] as [$schema, $key, $type]) { + $property = $openApi['components']['schemas'][$schema]['properties'][$key]; + + $this->assertSame($type, $property['type'], $key); + $this->assertArrayNotHasKey('allOf', $property, $key); + $this->assertArrayNotHasKey('items', $property, $key); } } diff --git a/tests/unit/Utopia/Response/Filters/V19Test.php b/tests/unit/Utopia/Response/Filters/V19Test.php index b9d4b28371..b04d2d72eb 100644 --- a/tests/unit/Utopia/Response/Filters/V19Test.php +++ b/tests/unit/Utopia/Response/Filters/V19Test.php @@ -271,75 +271,6 @@ final class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function usageFunctionProvider(): \Iterator - { - yield 'remove build-related fields' => [ - [ - 'buildsSuccessTotal' => 10, - 'buildsFailedTotal' => 2, - 'buildsTimeAverage' => 30, - 'buildsSuccess' => 5, - 'buildsFailed' => 1, - 'executions' => 100, - ], - [ - 'executions' => 100, - ] - ]; - yield 'handle content without build fields' => [ - [ - 'executions' => 100, - ], - [ - 'executions' => 100, - ] - ]; - } - - #[DataProvider('usageFunctionProvider')] - public function testUsageFunction(array $content, array $expected): void - { - $model = Response::MODEL_USAGE_FUNCTION; - - $result = $this->filter->parse($content, $model); - - $this->assertEquals($expected, $result); - } - - public static function usageFunctionsProvider(): \Iterator - { - yield 'remove build-related fields' => [ - [ - 'buildsSuccessTotal' => 20, - 'buildsFailedTotal' => 4, - 'buildsSuccess' => 10, - 'buildsFailed' => 2, - 'executions' => 200, - ], - [ - 'executions' => 200, - ] - ]; - yield 'handle content without build fields' => [ - [ - 'executions' => 200, - ], - [ - 'executions' => 200, - ] - ]; - } - - #[DataProvider('usageFunctionsProvider')] - public function testUsageFunctions(array $content, array $expected): void - { - $model = Response::MODEL_USAGE_FUNCTIONS; - - $result = $this->filter->parse($content, $model); - - $this->assertEquals($expected, $result); - } - public static function variableProvider(): \Iterator { yield 'remove secret field' => [ From c86c9da9e462ac2783711f44b7f702e321ff88d9 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 12 Sep 2026 11:47:06 +0545 Subject: [PATCH 2/3] test: leave FormatTest untouched The test was re-pointed at UsageMetric while UsageProject was on its way out. UsageProject stays, so its fixture is still valid and the churn bought nothing. --- tests/unit/SDK/Specification/FormatTest.php | 41 ++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/tests/unit/SDK/Specification/FormatTest.php b/tests/unit/SDK/Specification/FormatTest.php index 5dbf8e681a..47e6ed01f3 100644 --- a/tests/unit/SDK/Specification/FormatTest.php +++ b/tests/unit/SDK/Specification/FormatTest.php @@ -29,6 +29,7 @@ use Appwrite\Utopia\Response\Model\Error as ErrorModel; use Appwrite\Utopia\Response\Model\ErrorDev; use Appwrite\Utopia\Response\Model\FrameworkAdapter; use Appwrite\Utopia\Response\Model\HealthStatus; +use Appwrite\Utopia\Response\Model\Metric; use Appwrite\Utopia\Response\Model\Migration; use Appwrite\Utopia\Response\Model\None as NoneModel; use Appwrite\Utopia\Response\Model\PlatformAndroid; @@ -44,7 +45,7 @@ use Appwrite\Utopia\Response\Model\TemplateFramework; use Appwrite\Utopia\Response\Model\TemplateSite; use Appwrite\Utopia\Response\Model\TemplateVariable; use Appwrite\Utopia\Response\Model\UsageDataPoint; -use Appwrite\Utopia\Response\Model\UsageMetric; +use Appwrite\Utopia\Response\Model\UsageProject; use Appwrite\Utopia\Response\Model\User; use Appwrite\Utopia\Response\Model\Webhook; use PHPUnit\Framework\Attributes\DataProvider; @@ -830,10 +831,12 @@ final class FormatTest extends TestCase } /** - * A single model reference is deliberately wrapped in `allOf`, but a list of - * one must not be: typed SDKs reject every valid response if it is. + * The project usage handler writes the text embedding metrics as four + * per-period lists plus four scalar totals. A typed SDK generated from a + * schema that calls all eight a single metric object rejects every valid + * response, so pin the emitted schema rather than the rule table. */ - public function testUsageMetricPointsSchema(): void + public function testUsageProjectEmbeddingsTextSchema(): void { Method::$processed = []; Method::$errors = []; @@ -849,35 +852,31 @@ final class FormatTest extends TestCase responses: [ new SDKResponse( code: 200, - model: Response::MODEL_USAGE_METRIC, + model: Response::MODEL_USAGE_PROJECT, ), ], )); $models = [ - new UsageMetric(), - new UsageDataPoint(), + new UsageProject(), + new Metric(), new ErrorModel(), ]; $openApi = (new OpenAPI3(new Container(), [], [$route], $models, [], ['console' => 0], 'console'))->parse(); - $points = $openApi['components']['schemas']['usageMetric']['properties']['points']; + $properties = $openApi['components']['schemas']['usageProject']['properties']; - $this->assertSame('array', $points['type']); - $this->assertSame(['$ref' => '#/components/schemas/usageDataPoint'], $points['items']); - $this->assertArrayNotHasKey('allOf', $points); + foreach (['embeddingsText', 'embeddingsTextTokens', 'embeddingsTextDuration', 'embeddingsTextErrors'] as $key) { + $this->assertSame('array', $properties[$key]['type'], $key); + $this->assertSame(['$ref' => '#/components/schemas/metric'], $properties[$key]['items'], $key); + $this->assertArrayNotHasKey('allOf', $properties[$key], $key); + } - foreach ([ - ['usageMetric', 'metric', 'string'], - ['usageDataPoint', 'time', 'string'], - ['usageDataPoint', 'value', 'number'], - ] as [$schema, $key, $type]) { - $property = $openApi['components']['schemas'][$schema]['properties'][$key]; - - $this->assertSame($type, $property['type'], $key); - $this->assertArrayNotHasKey('allOf', $property, $key); - $this->assertArrayNotHasKey('items', $property, $key); + foreach (['embeddingsTextTotal', 'embeddingsTextTokensTotal', 'embeddingsTextDurationTotal', 'embeddingsTextErrorsTotal'] as $key) { + $this->assertSame('integer', $properties[$key]['type'], $key); + $this->assertArrayNotHasKey('allOf', $properties[$key], $key); + $this->assertArrayNotHasKey('items', $properties[$key], $key); } } From a045983e3ebed0aadd9e1e8c9cbcabbfbb9a7278 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 13 Sep 2026 08:37:12 +0545 Subject: [PATCH 3/3] docs: remove the reference for the deleted project usage endpoint docs/references/project/get-usage.md was reached only through the SDK method description on Cloud's GET /v1/project/usage, which appwrite-labs/cloud#5785 removes. No route names the file any more. --- docs/references/project/get-usage.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docs/references/project/get-usage.md diff --git a/docs/references/project/get-usage.md b/docs/references/project/get-usage.md deleted file mode 100644 index d6802c5588..0000000000 --- a/docs/references/project/get-usage.md +++ /dev/null @@ -1 +0,0 @@ -Get comprehensive usage statistics for your project. View metrics including network requests, bandwidth, storage, function executions, database usage, and user activity. Specify a time range with startDate and endDate, and optionally set the data granularity with period (1h or 1d). The response includes both total counts and detailed breakdowns by resource, along with historical data over the specified period. \ No newline at end of file