1
0
Fork 0
mirror of synced 2024-07-04 06:00:53 +12:00

Updated error when _APP_USAGE_STATS is disabled

for usage
This commit is contained in:
Bhaskar Singh 2023-03-18 22:03:15 +05:30
parent e8c74d7204
commit ac2085ffa8
8 changed files with 34 additions and 1 deletions

View file

@ -88,6 +88,11 @@ return [
'description' => 'The request cannot be fulfilled with the current protocol. Please check the value of the _APP_OPTIONS_FORCE_HTTPS environment variable.',
'code' => 500,
],
Exception::GENERAL_USAGE_DISABLED => [
'name' => Exception::GENERAL_USAGE_DISABLED,
'description' => 'Usage stats is not configured. Please check the value of the _APP_USAGE_STATS environment variable of your Appwrite server.',
'code' => 501,
],
/** User Errors */
Exception::USER_COUNT_EXCEEDED => [

@ -1 +1 @@
Subproject commit 5e2a40c1e397bd341a432698c9d76a3f96315841
Subproject commit d30a4070d0bdf8fe89be23a141e261a8a8688246

View file

@ -2471,6 +2471,9 @@ App::get('/v1/databases/usage')
->action(function (string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
@ -2590,6 +2593,9 @@ App::get('/v1/databases/:databaseId/usage')
->action(function (string $databaseId, string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
@ -2710,6 +2716,9 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [

View file

@ -234,6 +234,9 @@ App::get('/v1/functions/:functionId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [
@ -337,6 +340,9 @@ App::get('/v1/functions/usage')
->action(function (string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [

View file

@ -268,6 +268,9 @@ App::get('/v1/projects/:projectId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [

View file

@ -1461,6 +1461,9 @@ App::get('/v1/storage/usage')
->action(function (string $range, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') {
$periods = [
'24h' => [
@ -1578,6 +1581,9 @@ App::get('/v1/storage/:bucketId/usage')
}
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') === 'enabled') {
$periods = [
'24h' => [

View file

@ -1114,6 +1114,9 @@ App::get('/v1/users/usage')
->action(function (string $range, string $provider, Response $response, Database $dbForProject) {
$usage = [];
if (App::getEnv('_APP_USAGE_STATS', 'enabled') != 'enabled') {
throw new Exception(Exception::GENERAL_USAGE_DISABLED);
}
if (App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled') {
$periods = [
'24h' => [

View file

@ -51,6 +51,7 @@ class Exception extends \Exception
public const GENERAL_CURSOR_NOT_FOUND = 'general_cursor_not_found';
public const GENERAL_SERVER_ERROR = 'general_server_error';
public const GENERAL_PROTOCOL_UNSUPPORTED = 'general_protocol_unsupported';
public const GENERAL_USAGE_DISABLED = 'general_usage_disabled';
/** Users */
public const USER_COUNT_EXCEEDED = 'user_count_exceeded';