From 08f2a59766651ec744e1b5937a6777e1b42acd4e Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 23 Jan 2025 18:54:02 +0530 Subject: [PATCH 1/6] add: database read, write metrics. --- app/controllers/api/databases.php | 16 +++++++++++-- app/controllers/api/project.php | 14 +++++++---- .../Utopia/Response/Model/UsageDatabase.php | 24 +++++++++++++++++++ .../Utopia/Response/Model/UsageDatabases.php | 24 +++++++++++++++++++ .../Utopia/Response/Model/UsageProject.php | 24 +++++++++++++++++++ 5 files changed, 96 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 6798d71502..44eab5a08a 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -3904,7 +3904,9 @@ App::get('/v1/databases/usage') METRIC_DATABASES, METRIC_COLLECTIONS, METRIC_DOCUMENTS, - METRIC_DATABASES_STORAGE + METRIC_DATABASES_STORAGE, + METRIC_DATABASES_OPERATIONS_READS, + METRIC_DATABASES_OPERATIONS_WRITES, ]; Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { @@ -3956,10 +3958,14 @@ App::get('/v1/databases/usage') 'collectionsTotal' => $usage[$metrics[1]]['total'], 'documentsTotal' => $usage[$metrics[2]]['total'], 'storageTotal' => $usage[$metrics[3]]['total'], + 'databasesReadsTotal' => $usage[$metrics[4]]['total'], + 'databasesWritesTotal' => $usage[$metrics[5]]['total'], 'databases' => $usage[$metrics[0]]['data'], 'collections' => $usage[$metrics[1]]['data'], 'documents' => $usage[$metrics[2]]['data'], 'storage' => $usage[$metrics[3]]['data'], + 'databasesReads' => $usage[$metrics[4]]['data'], + 'databasesWrites' => $usage[$metrics[5]]['data'], ]), Response::MODEL_USAGE_DATABASES); }); @@ -3992,7 +3998,9 @@ App::get('/v1/databases/:databaseId/usage') $metrics = [ str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS), str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS), - str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE) + str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE), + str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_READS), + str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_WRITES) ]; Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { @@ -4044,9 +4052,13 @@ App::get('/v1/databases/:databaseId/usage') 'collectionsTotal' => $usage[$metrics[0]]['total'], 'documentsTotal' => $usage[$metrics[1]]['total'], 'storageTotal' => $usage[$metrics[2]]['total'], + 'databaseReadsTotal' => $usage[$metrics[3]]['total'], + 'databaseWritesTotal' => $usage[$metrics[4]]['total'], 'collections' => $usage[$metrics[0]]['data'], 'documents' => $usage[$metrics[1]]['data'], 'storage' => $usage[$metrics[2]]['data'], + 'databaseReads' => $usage[$metrics[3]]['data'], + 'databaseWrites' => $usage[$metrics[4]]['data'], ]), Response::MODEL_USAGE_DATABASE); }); diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 5a1bf063f2..44c5d797ba 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -50,7 +50,9 @@ App::get('/v1/project/usage') METRIC_FILES_STORAGE, METRIC_DATABASES_STORAGE, METRIC_DEPLOYMENTS_STORAGE, - METRIC_BUILDS_STORAGE + METRIC_BUILDS_STORAGE, + METRIC_DATABASES_OPERATIONS_READS, + METRIC_DATABASES_OPERATIONS_WRITES, ], 'period' => [ METRIC_NETWORK_REQUESTS, @@ -60,7 +62,9 @@ App::get('/v1/project/usage') METRIC_EXECUTIONS, METRIC_DATABASES_STORAGE, METRIC_EXECUTIONS_MB_SECONDS, - METRIC_BUILDS_MB_SECONDS + METRIC_BUILDS_MB_SECONDS, + METRIC_DATABASES_OPERATIONS_READS, + METRIC_DATABASES_OPERATIONS_WRITES, ] ]; @@ -336,10 +340,12 @@ App::get('/v1/project/usage') 'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE], 'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE], 'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE], + 'databasesReadsTotal' => $total[METRIC_DATABASES_OPERATIONS_READS], + 'databasesWritesTotal' => $total[METRIC_DATABASES_OPERATIONS_WRITES], 'executionsBreakdown' => $executionsBreakdown, - 'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown, - 'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown, 'bucketsBreakdown' => $bucketsBreakdown, + 'databasesReads' => $usage[METRIC_DATABASES_OPERATIONS_READS], + 'databasesWrites' => $usage[METRIC_DATABASES_OPERATIONS_WRITES], 'databasesStorageBreakdown' => $databasesStorageBreakdown, 'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown, 'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown, diff --git a/src/Appwrite/Utopia/Response/Model/UsageDatabase.php b/src/Appwrite/Utopia/Response/Model/UsageDatabase.php index eb985baabb..d6afa02f65 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageDatabase.php +++ b/src/Appwrite/Utopia/Response/Model/UsageDatabase.php @@ -34,6 +34,18 @@ class UsageDatabase extends Model 'default' => 0, 'example' => 0, ]) + ->addRule('databaseReadsTotal', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Total number of databases reads.', + 'default' => 0, + 'example' => 0, + ]) + ->addRule('databaseWritesTotal', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Total number of databases writes.', + 'default' => 0, + 'example' => 0, + ]) ->addRule('collections', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated number of collections per period.', @@ -55,6 +67,18 @@ class UsageDatabase extends Model 'example' => [], 'array' => true ]) + ->addRule('databaseReads', [ + 'type' => Response::MODEL_METRIC, + 'description' => 'An array of aggregated number of database reads.', + 'default' => 0, + 'example' => 0, + ]) + ->addRule('databaseWrites', [ + 'type' => Response::MODEL_METRIC, + 'description' => 'An array of aggregated number of database writes.', + 'default' => 0, + 'example' => 0, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/UsageDatabases.php b/src/Appwrite/Utopia/Response/Model/UsageDatabases.php index e0abba8ab8..a9c8e5fada 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageDatabases.php +++ b/src/Appwrite/Utopia/Response/Model/UsageDatabases.php @@ -40,6 +40,18 @@ class UsageDatabases extends Model '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.', @@ -68,6 +80,18 @@ class UsageDatabases extends Model 'example' => [], 'array' => true ]) + ->addRule('databasesReads', [ + 'type' => Response::MODEL_METRIC, + 'description' => 'An array of aggregated number of database reads.', + 'default' => 0, + 'example' => 0, + ]) + ->addRule('databasesWrites', [ + 'type' => Response::MODEL_METRIC, + 'description' => 'An array of aggregated number of database writes.', + 'default' => 0, + 'example' => 0, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/UsageProject.php b/src/Appwrite/Utopia/Response/Model/UsageProject.php index 39c245a542..ff4106eaed 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageProject.php +++ b/src/Appwrite/Utopia/Response/Model/UsageProject.php @@ -82,6 +82,18 @@ class UsageProject extends Model '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('requests', [ 'type' => Response::MODEL_METRIC, 'description' => 'Aggregated number of requests per period.', @@ -171,6 +183,18 @@ class UsageProject extends Model 'example' => [], 'array' => true ]) + ->addRule('databasesReads', [ + 'type' => Response::MODEL_METRIC, + 'description' => 'An array of aggregated number of database reads.', + 'default' => 0, + 'example' => 0, + ]) + ->addRule('databasesWrites', [ + 'type' => Response::MODEL_METRIC, + 'description' => 'An array of aggregated number of database writes.', + 'default' => 0, + 'example' => 0, + ]) ; } From 00a24133661ec15105a2d819dfe635ecc831d0b2 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 23 Jan 2025 19:17:20 +0530 Subject: [PATCH 2/6] fix: tests due to additional response vars. --- tests/e2e/General/UsageTest.php | 2 +- tests/e2e/Services/Databases/DatabasesConsoleClientTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index ffc63708c8..d408ee7645 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -143,7 +143,7 @@ class UsageTest extends Scope ); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(25, count($response['body'])); + $this->assertEquals(29, count($response['body'])); $this->validateDates($response['body']['network']); $this->validateDates($response['body']['requests']); $this->validateDates($response['body']['users']); diff --git a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php index 96bb0b5609..2266c91afe 100644 --- a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php @@ -224,7 +224,7 @@ class DatabasesConsoleClientTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(7, count($response['body'])); + $this->assertEquals(11, count($response['body'])); $this->assertEquals('24h', $response['body']['range']); $this->assertIsNumeric($response['body']['documentsTotal']); $this->assertIsNumeric($response['body']['collectionsTotal']); From 3cfd59235168f3e92a1d6edee7288565be9dc8d0 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 23 Jan 2025 19:35:36 +0530 Subject: [PATCH 3/6] fix: tests further. --- tests/e2e/General/UsageTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index d408ee7645..17e432103d 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -324,7 +324,7 @@ class UsageTest extends Scope ] ); - $this->assertEquals(25, count($response['body'])); + $this->assertEquals(29, count($response['body'])); $this->assertEquals(1, count($response['body']['requests'])); $this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']); $this->validateDates($response['body']['requests']); @@ -545,7 +545,7 @@ class UsageTest extends Scope ] ); - $this->assertEquals(25, count($response['body'])); + $this->assertEquals(29, count($response['body'])); $this->assertEquals(1, count($response['body']['requests'])); $this->assertEquals(1, count($response['body']['network'])); $this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']); From e9136444d79d5f5914a35a9209631a1ff1c9cc74 Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 27 Jan 2025 17:33:49 +0530 Subject: [PATCH 4/6] update: latest sdk specs. --- app/config/specs/open-api3-latest-client.json | 1 + .../specs/open-api3-latest-console.json | 103 ++++++++++++++++- app/config/specs/open-api3-latest-server.json | 1 + app/config/specs/swagger2-latest-client.json | 1 + app/config/specs/swagger2-latest-console.json | 109 +++++++++++++++++- app/config/specs/swagger2-latest-server.json | 1 + 6 files changed, 210 insertions(+), 6 deletions(-) diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index 232861f0ff..820b1f55e0 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -6361,6 +6361,7 @@ "gif", "png", "webp", + "heic", "avif" ], "x-enum-name": "ImageFormat", diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 42ed7b9d28..a709c12b9c 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -25157,6 +25157,7 @@ "gif", "png", "webp", + "heic", "avif" ], "x-enum-name": "ImageFormat", @@ -35706,6 +35707,18 @@ "x-example": 0, "format": "int32" }, + "databasesReadsTotal": { + "type": "integer", + "description": "Total number of databases reads.", + "x-example": 0, + "format": "int32" + }, + "databasesWritesTotal": { + "type": "integer", + "description": "Total number of databases writes.", + "x-example": 0, + "format": "int32" + }, "databases": { "type": "array", "description": "Aggregated number of databases per period.", @@ -35737,6 +35750,22 @@ "$ref": "#\/components\/schemas\/metric" }, "x-example": [] + }, + "databasesReads": { + "type": "object", + "description": "An array of aggregated number of database reads.", + "x-example": 0, + "items": { + "$ref": "#\/components\/schemas\/metric" + } + }, + "databasesWrites": { + "type": "object", + "description": "An array of aggregated number of database writes.", + "x-example": 0, + "items": { + "$ref": "#\/components\/schemas\/metric" + } } }, "required": [ @@ -35745,10 +35774,14 @@ "collectionsTotal", "documentsTotal", "storageTotal", + "databasesReadsTotal", + "databasesWritesTotal", "databases", "collections", "documents", - "storage" + "storage", + "databasesReads", + "databasesWrites" ] }, "usageDatabase": { @@ -35778,6 +35811,18 @@ "x-example": 0, "format": "int32" }, + "databaseReadsTotal": { + "type": "integer", + "description": "Total number of databases reads.", + "x-example": 0, + "format": "int32" + }, + "databaseWritesTotal": { + "type": "integer", + "description": "Total number of databases writes.", + "x-example": 0, + "format": "int32" + }, "collections": { "type": "array", "description": "Aggregated number of collections per period.", @@ -35801,6 +35846,22 @@ "$ref": "#\/components\/schemas\/metric" }, "x-example": [] + }, + "databaseReads": { + "type": "object", + "description": "An array of aggregated number of database reads.", + "x-example": 0, + "items": { + "$ref": "#\/components\/schemas\/metric" + } + }, + "databaseWrites": { + "type": "object", + "description": "An array of aggregated number of database writes.", + "x-example": 0, + "items": { + "$ref": "#\/components\/schemas\/metric" + } } }, "required": [ @@ -35808,9 +35869,13 @@ "collectionsTotal", "documentsTotal", "storageTotal", + "databaseReadsTotal", + "databaseWritesTotal", "collections", "documents", - "storage" + "storage", + "databaseReads", + "databaseWrites" ] }, "usageCollection": { @@ -36405,6 +36470,18 @@ "x-example": 0, "format": "int32" }, + "databasesReadsTotal": { + "type": "integer", + "description": "Total number of databases reads.", + "x-example": 0, + "format": "int32" + }, + "databasesWritesTotal": { + "type": "integer", + "description": "Total number of databases writes.", + "x-example": 0, + "format": "int32" + }, "requests": { "type": "array", "description": "Aggregated number of requests per period.", @@ -36504,6 +36581,22 @@ "$ref": "#\/components\/schemas\/metricBreakdown" }, "x-example": [] + }, + "databasesReads": { + "type": "object", + "description": "An array of aggregated number of database reads.", + "x-example": 0, + "items": { + "$ref": "#\/components\/schemas\/metric" + } + }, + "databasesWrites": { + "type": "object", + "description": "An array of aggregated number of database writes.", + "x-example": 0, + "items": { + "$ref": "#\/components\/schemas\/metric" + } } }, "required": [ @@ -36519,6 +36612,8 @@ "bucketsTotal", "executionsMbSecondsTotal", "buildsMbSecondsTotal", + "databasesReadsTotal", + "databasesWritesTotal", "requests", "network", "users", @@ -36531,7 +36626,9 @@ "functionsStorageBreakdown", "authPhoneTotal", "authPhoneEstimate", - "authPhoneCountryBreakdown" + "authPhoneCountryBreakdown", + "databasesReads", + "databasesWrites" ] }, "headers": { diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index aee66626cf..aec14113b6 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -17577,6 +17577,7 @@ "gif", "png", "webp", + "heic", "avif" ], "x-enum-name": "ImageFormat", diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index 5369cd4c92..c0980c44ce 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -6560,6 +6560,7 @@ "gif", "png", "webp", + "heic", "avif" ], "x-enum-name": "ImageFormat", diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index f9a423d954..3a59d6e9da 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -25633,6 +25633,7 @@ "gif", "png", "webp", + "heic", "avif" ], "x-enum-name": "ImageFormat", @@ -36243,6 +36244,18 @@ "x-example": 0, "format": "int32" }, + "databasesReadsTotal": { + "type": "integer", + "description": "Total number of databases reads.", + "x-example": 0, + "format": "int32" + }, + "databasesWritesTotal": { + "type": "integer", + "description": "Total number of databases writes.", + "x-example": 0, + "format": "int32" + }, "databases": { "type": "array", "description": "Aggregated number of databases per period.", @@ -36278,6 +36291,24 @@ "$ref": "#\/definitions\/metric" }, "x-example": [] + }, + "databasesReads": { + "type": "object", + "description": "An array of aggregated number of database reads.", + "x-example": 0, + "items": { + "type": "object", + "$ref": "#\/definitions\/metric" + } + }, + "databasesWrites": { + "type": "object", + "description": "An array of aggregated number of database writes.", + "x-example": 0, + "items": { + "type": "object", + "$ref": "#\/definitions\/metric" + } } }, "required": [ @@ -36286,10 +36317,14 @@ "collectionsTotal", "documentsTotal", "storageTotal", + "databasesReadsTotal", + "databasesWritesTotal", "databases", "collections", "documents", - "storage" + "storage", + "databasesReads", + "databasesWrites" ] }, "usageDatabase": { @@ -36319,6 +36354,18 @@ "x-example": 0, "format": "int32" }, + "databaseReadsTotal": { + "type": "integer", + "description": "Total number of databases reads.", + "x-example": 0, + "format": "int32" + }, + "databaseWritesTotal": { + "type": "integer", + "description": "Total number of databases writes.", + "x-example": 0, + "format": "int32" + }, "collections": { "type": "array", "description": "Aggregated number of collections per period.", @@ -36345,6 +36392,24 @@ "$ref": "#\/definitions\/metric" }, "x-example": [] + }, + "databaseReads": { + "type": "object", + "description": "An array of aggregated number of database reads.", + "x-example": 0, + "items": { + "type": "object", + "$ref": "#\/definitions\/metric" + } + }, + "databaseWrites": { + "type": "object", + "description": "An array of aggregated number of database writes.", + "x-example": 0, + "items": { + "type": "object", + "$ref": "#\/definitions\/metric" + } } }, "required": [ @@ -36352,9 +36417,13 @@ "collectionsTotal", "documentsTotal", "storageTotal", + "databaseReadsTotal", + "databaseWritesTotal", "collections", "documents", - "storage" + "storage", + "databaseReads", + "databaseWrites" ] }, "usageCollection": { @@ -36976,6 +37045,18 @@ "x-example": 0, "format": "int32" }, + "databasesReadsTotal": { + "type": "integer", + "description": "Total number of databases reads.", + "x-example": 0, + "format": "int32" + }, + "databasesWritesTotal": { + "type": "integer", + "description": "Total number of databases writes.", + "x-example": 0, + "format": "int32" + }, "requests": { "type": "array", "description": "Aggregated number of requests per period.", @@ -37086,6 +37167,24 @@ "$ref": "#\/definitions\/metricBreakdown" }, "x-example": [] + }, + "databasesReads": { + "type": "object", + "description": "An array of aggregated number of database reads.", + "x-example": 0, + "items": { + "type": "object", + "$ref": "#\/definitions\/metric" + } + }, + "databasesWrites": { + "type": "object", + "description": "An array of aggregated number of database writes.", + "x-example": 0, + "items": { + "type": "object", + "$ref": "#\/definitions\/metric" + } } }, "required": [ @@ -37101,6 +37200,8 @@ "bucketsTotal", "executionsMbSecondsTotal", "buildsMbSecondsTotal", + "databasesReadsTotal", + "databasesWritesTotal", "requests", "network", "users", @@ -37113,7 +37214,9 @@ "functionsStorageBreakdown", "authPhoneTotal", "authPhoneEstimate", - "authPhoneCountryBreakdown" + "authPhoneCountryBreakdown", + "databasesReads", + "databasesWrites" ] }, "headers": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index a3c6a0d70c..98ebfa6116 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -18034,6 +18034,7 @@ "gif", "png", "webp", + "heic", "avif" ], "x-enum-name": "ImageFormat", From 5ac95bc103b9eea7e56c5d1aaab3a4784a492e4a Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 27 Jan 2025 18:03:31 +0530 Subject: [PATCH 5/6] fix: wrong types on sdk models. --- src/Appwrite/Utopia/Response/Model/UsageDatabase.php | 10 ++++++---- src/Appwrite/Utopia/Response/Model/UsageDatabases.php | 10 ++++++---- src/Appwrite/Utopia/Response/Model/UsageProject.php | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/UsageDatabase.php b/src/Appwrite/Utopia/Response/Model/UsageDatabase.php index d6afa02f65..a0fe421f5f 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageDatabase.php +++ b/src/Appwrite/Utopia/Response/Model/UsageDatabase.php @@ -70,14 +70,16 @@ class UsageDatabase extends Model ->addRule('databaseReads', [ 'type' => Response::MODEL_METRIC, 'description' => 'An array of aggregated number of database reads.', - 'default' => 0, - 'example' => 0, + 'default' => [], + 'example' => [], + 'array' => true ]) ->addRule('databaseWrites', [ 'type' => Response::MODEL_METRIC, 'description' => 'An array of aggregated number of database writes.', - 'default' => 0, - 'example' => 0, + 'default' => [], + 'example' => [], + 'array' => true ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/UsageDatabases.php b/src/Appwrite/Utopia/Response/Model/UsageDatabases.php index a9c8e5fada..4e053e5223 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageDatabases.php +++ b/src/Appwrite/Utopia/Response/Model/UsageDatabases.php @@ -83,14 +83,16 @@ class UsageDatabases extends Model ->addRule('databasesReads', [ 'type' => Response::MODEL_METRIC, 'description' => 'An array of aggregated number of database reads.', - 'default' => 0, - 'example' => 0, + 'default' => [], + 'example' => [], + 'array' => true ]) ->addRule('databasesWrites', [ 'type' => Response::MODEL_METRIC, 'description' => 'An array of aggregated number of database writes.', - 'default' => 0, - 'example' => 0, + 'default' => [], + 'example' => [], + 'array' => true ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/UsageProject.php b/src/Appwrite/Utopia/Response/Model/UsageProject.php index ff4106eaed..1006276b56 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageProject.php +++ b/src/Appwrite/Utopia/Response/Model/UsageProject.php @@ -186,14 +186,16 @@ class UsageProject extends Model ->addRule('databasesReads', [ 'type' => Response::MODEL_METRIC, 'description' => 'An array of aggregated number of database reads.', - 'default' => 0, - 'example' => 0, + 'default' => [], + 'example' => [], + 'array' => true ]) ->addRule('databasesWrites', [ 'type' => Response::MODEL_METRIC, 'description' => 'An array of aggregated number of database writes.', - 'default' => 0, - 'example' => 0, + 'default' => [], + 'example' => [], + 'array' => true ]) ; } From c0dc43fb2941ebdc0c6e89b68dd60bc36418fd21 Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 27 Jan 2025 18:19:07 +0530 Subject: [PATCH 6/6] update: specs. --- .../specs/open-api3-latest-console.json | 36 +++++++++---------- app/config/specs/swagger2-latest-console.json | 36 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index a709c12b9c..1390319703 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -35752,20 +35752,20 @@ "x-example": [] }, "databasesReads": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database reads.", - "x-example": 0, "items": { "$ref": "#\/components\/schemas\/metric" - } + }, + "x-example": [] }, "databasesWrites": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database writes.", - "x-example": 0, "items": { "$ref": "#\/components\/schemas\/metric" - } + }, + "x-example": [] } }, "required": [ @@ -35848,20 +35848,20 @@ "x-example": [] }, "databaseReads": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database reads.", - "x-example": 0, "items": { "$ref": "#\/components\/schemas\/metric" - } + }, + "x-example": [] }, "databaseWrites": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database writes.", - "x-example": 0, "items": { "$ref": "#\/components\/schemas\/metric" - } + }, + "x-example": [] } }, "required": [ @@ -36583,20 +36583,20 @@ "x-example": [] }, "databasesReads": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database reads.", - "x-example": 0, "items": { "$ref": "#\/components\/schemas\/metric" - } + }, + "x-example": [] }, "databasesWrites": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database writes.", - "x-example": 0, "items": { "$ref": "#\/components\/schemas\/metric" - } + }, + "x-example": [] } }, "required": [ diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 3a59d6e9da..d57385c56e 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -36293,22 +36293,22 @@ "x-example": [] }, "databasesReads": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database reads.", - "x-example": 0, "items": { "type": "object", "$ref": "#\/definitions\/metric" - } + }, + "x-example": [] }, "databasesWrites": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database writes.", - "x-example": 0, "items": { "type": "object", "$ref": "#\/definitions\/metric" - } + }, + "x-example": [] } }, "required": [ @@ -36394,22 +36394,22 @@ "x-example": [] }, "databaseReads": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database reads.", - "x-example": 0, "items": { "type": "object", "$ref": "#\/definitions\/metric" - } + }, + "x-example": [] }, "databaseWrites": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database writes.", - "x-example": 0, "items": { "type": "object", "$ref": "#\/definitions\/metric" - } + }, + "x-example": [] } }, "required": [ @@ -37169,22 +37169,22 @@ "x-example": [] }, "databasesReads": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database reads.", - "x-example": 0, "items": { "type": "object", "$ref": "#\/definitions\/metric" - } + }, + "x-example": [] }, "databasesWrites": { - "type": "object", + "type": "array", "description": "An array of aggregated number of database writes.", - "x-example": 0, "items": { "type": "object", "$ref": "#\/definitions\/metric" - } + }, + "x-example": [] } }, "required": [