From 942034087155727fe271899792a6ed64cc0c4e56 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 4 Feb 2025 10:53:15 +0000 Subject: [PATCH] chore: changed directory structure for devkeys --- src/Appwrite/Platform/Appwrite.php | 4 +-- .../Modules/DevKeys/Services/Http.php | 23 --------------- .../Http/DevKeys/CreateDevKey.php} | 28 +++++++++++++------ .../Http/DevKeys/DeleteDevKey.php} | 27 ++++++++++++------ .../Http/DevKeys/GetDevKey.php} | 28 +++++++++++++------ .../Http/DevKeys/ListDevKeys.php} | 28 +++++++++++++------ .../Http/DevKeys/UpdateDevKey.php} | 28 +++++++++++++------ .../Modules/{DevKeys => Projects}/Module.php | 4 +-- .../Modules/Projects/Services/Http.php | 23 +++++++++++++++ 9 files changed, 122 insertions(+), 71 deletions(-) delete mode 100644 src/Appwrite/Platform/Modules/DevKeys/Services/Http.php rename src/Appwrite/Platform/Modules/{DevKeys/Http/DevKeys/CreateKey.php => Projects/Http/DevKeys/CreateDevKey.php} (78%) rename src/Appwrite/Platform/Modules/{DevKeys/Http/DevKeys/DeleteKey.php => Projects/Http/DevKeys/DeleteDevKey.php} (71%) rename src/Appwrite/Platform/Modules/{DevKeys/Http/DevKeys/GetKey.php => Projects/Http/DevKeys/GetDevKey.php} (70%) rename src/Appwrite/Platform/Modules/{DevKeys/Http/DevKeys/ListKeys.php => Projects/Http/DevKeys/ListDevKeys.php} (68%) rename src/Appwrite/Platform/Modules/{DevKeys/Http/DevKeys/UpdateKey.php => Projects/Http/DevKeys/UpdateDevKey.php} (76%) rename src/Appwrite/Platform/Modules/{DevKeys => Projects}/Module.php (62%) create mode 100644 src/Appwrite/Platform/Modules/Projects/Services/Http.php diff --git a/src/Appwrite/Platform/Appwrite.php b/src/Appwrite/Platform/Appwrite.php index ec19b3248c..b4510df777 100644 --- a/src/Appwrite/Platform/Appwrite.php +++ b/src/Appwrite/Platform/Appwrite.php @@ -3,7 +3,7 @@ namespace Appwrite\Platform; use Appwrite\Platform\Modules\Core; -use Appwrite\Platform\Modules\DevKeys; +use Appwrite\Platform\Modules\Projects; use Utopia\Platform\Platform; class Appwrite extends Platform @@ -11,6 +11,6 @@ class Appwrite extends Platform public function __construct() { parent::__construct(new Core()); - $this->addModule(new DevKeys\Module()); + $this->addModule(new Projects\Module()); } } diff --git a/src/Appwrite/Platform/Modules/DevKeys/Services/Http.php b/src/Appwrite/Platform/Modules/DevKeys/Services/Http.php deleted file mode 100644 index 0e9decc3a9..0000000000 --- a/src/Appwrite/Platform/Modules/DevKeys/Services/Http.php +++ /dev/null @@ -1,23 +0,0 @@ -type = Service::TYPE_HTTP; - $this->addAction(CreateKey::getName(), new CreateKey()); - $this->addAction(UpdateKey::getName(), new UpdateKey()); - $this->addAction(GetKey::getName(), new GetKey()); - $this->addAction(ListKeys::getName(), new ListKeys()); - $this->addAction(DeleteKey::getName(), new DeleteKey()); - } -} diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/CreateKey.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/CreateDevKey.php similarity index 78% rename from src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/CreateKey.php rename to src/Appwrite/Platform/Modules/Projects/Http/DevKeys/CreateDevKey.php index a1f4c2a296..3f28cd6f81 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/CreateKey.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/CreateDevKey.php @@ -1,8 +1,11 @@ desc('Create dev key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'createDevKey') - ->label('sdk.response.code', Response::STATUS_CODE_CREATED) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_DEV_KEY) + ->label('sdk', new Method( + namespace: 'projects', + name: 'createDevKey', + description: '', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_CREATED, + model: Response::MODEL_DEV_KEY + ) + ], + contentType: ContentType::JSON + )) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.', false) diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/DeleteKey.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/DeleteDevKey.php similarity index 71% rename from src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/DeleteKey.php rename to src/Appwrite/Platform/Modules/Projects/Http/DevKeys/DeleteDevKey.php index 0fae2c30aa..a81382e280 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/DeleteKey.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/DeleteDevKey.php @@ -1,8 +1,11 @@ desc('Delete dev key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'deleteDevKey') - ->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT) - ->label('sdk.response.model', Response::MODEL_NONE) + ->label('sdk', new Method( + namespace: 'projects', + name: 'deleteDevKey', + description: '', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_CREATED, + model: Response::MODEL_NONE + ) + ], + contentType: ContentType::NONE + )) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('keyId', '', new UID(), 'Key unique ID.') ->inject('response') diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/GetKey.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/GetDevKey.php similarity index 70% rename from src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/GetKey.php rename to src/Appwrite/Platform/Modules/Projects/Http/DevKeys/GetDevKey.php index 4f2a7fa9ca..d67166c324 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/GetKey.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/GetDevKey.php @@ -1,8 +1,11 @@ desc('Get dev key') ->groups(['api', 'projects']) ->label('scope', 'projects.read') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'getDevKey') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_DEV_KEY) + ->label('sdk', new Method( + namespace: 'projects', + name: 'getDevKey', + description: '', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_OK, + model: Response::MODEL_DEV_KEY + ) + ], + contentType: ContentType::JSON + )) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('keyId', '', new UID(), 'Key unique ID.') ->inject('response') diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/ListKeys.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/ListDevKeys.php similarity index 68% rename from src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/ListKeys.php rename to src/Appwrite/Platform/Modules/Projects/Http/DevKeys/ListDevKeys.php index e9df3167ea..9dc281ef07 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/ListKeys.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/ListDevKeys.php @@ -1,8 +1,11 @@ desc('List dev keys') ->groups(['api', 'projects']) ->label('scope', 'projects.read') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'listDevKeys') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_DEV_KEY_LIST) + ->label('sdk', new Method( + namespace: 'projects', + name: 'listDevKeys', + description: '', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_CREATED, + model: Response::MODEL_DEV_KEY_LIST + ) + ], + contentType: ContentType::JSON + )) ->param('projectId', '', new UID(), 'Project unique ID.') ->inject('response') ->inject('dbForPlatform') diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/UpdateKey.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/UpdateDevKey.php similarity index 76% rename from src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/UpdateKey.php rename to src/Appwrite/Platform/Modules/Projects/Http/DevKeys/UpdateDevKey.php index 6d17429084..3f7952c79d 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/UpdateKey.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/UpdateDevKey.php @@ -1,8 +1,11 @@ desc('Update dev key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') - ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) - ->label('sdk.namespace', 'projects') - ->label('sdk.method', 'updateDevKey') - ->label('sdk.response.code', Response::STATUS_CODE_OK) - ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_DEV_KEY) + ->label('sdk', new Method( + namespace: 'projects', + name: 'updateDevKey', + description: '', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: Response::STATUS_CODE_CREATED, + model: Response::MODEL_DEV_KEY + ) + ], + contentType: ContentType::JSON + )) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('keyId', '', new UID(), 'Key unique ID.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') diff --git a/src/Appwrite/Platform/Modules/DevKeys/Module.php b/src/Appwrite/Platform/Modules/Projects/Module.php similarity index 62% rename from src/Appwrite/Platform/Modules/DevKeys/Module.php rename to src/Appwrite/Platform/Modules/Projects/Module.php index 796ec50186..2a550acf54 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Module.php +++ b/src/Appwrite/Platform/Modules/Projects/Module.php @@ -1,8 +1,8 @@ type = Service::TYPE_HTTP; + $this->addAction(CreateDevKey::getName(), new CreateDevKey()); + $this->addAction(UpdateDevKey::getName(), new UpdateDevKey()); + $this->addAction(GetDevKey::getName(), new GetDevKey()); + $this->addAction(ListDevKeys::getName(), new ListDevKeys()); + $this->addAction(DeleteDevKey::getName(), new DeleteDevKey()); + } +}