diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/CreateKey.php b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/CreateKey.php index 2e1c4db7f2..68ca88a58a 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/CreateKey.php +++ b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/CreateKey.php @@ -28,15 +28,15 @@ class CreateKey extends Action $this ->setHttpMethod(Action::HTTP_REQUEST_METHOD_POST) ->setHttpPath('/v1/projects/:projectId/development-keys') - ->desc('Create key') + ->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', 'createKey') + ->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_KEY) + ->label('sdk.response.model', Response::MODEL_DEV_KEY) ->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) @@ -75,6 +75,6 @@ class CreateKey extends Action $response ->setStatusCode(Response::STATUS_CODE_CREATED) - ->dynamic($key, Response::MODEL_KEY); + ->dynamic($key, Response::MODEL_DEV_KEY); } } diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/DeleteKey.php b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/DeleteKey.php index 1d5b2a324d..fcc6083340 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/DeleteKey.php +++ b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/DeleteKey.php @@ -23,7 +23,7 @@ class DeleteKey extends Action $this ->setHttpMethod(Action::HTTP_REQUEST_METHOD_DELETE) ->setHttpPath('/v1/projects/:projectId/development-keys/:keyId') - ->desc('Delete key') + ->desc('Delete dev key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/GetKey.php b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/GetKey.php index 4dc95bf091..f9c542c6b2 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/GetKey.php +++ b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/GetKey.php @@ -23,7 +23,7 @@ class GetKey extends Action $this ->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET) ->setHttpPath('/v1/projects/:projectId/development-keys/:keyId') - ->desc('Get key') + ->desc('Get dev key') ->groups(['api', 'projects']) ->label('scope', 'projects.read') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) @@ -31,7 +31,7 @@ class GetKey extends Action ->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_KEY) + ->label('sdk.response.model', Response::MODEL_DEV_KEY) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('keyId', '', new UID(), 'Key unique ID.') ->inject('response') @@ -57,6 +57,6 @@ class GetKey extends Action throw new Exception(Exception::KEY_NOT_FOUND); } - $response->dynamic($key, Response::MODEL_KEY); + $response->dynamic($key, Response::MODEL_DEV_KEY); } } diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/ListKeys.php b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/ListKeys.php index a6461014c8..a4b4083080 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/ListKeys.php +++ b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/ListKeys.php @@ -24,15 +24,15 @@ class ListKeys extends Action $this ->setHttpMethod(Action::HTTP_REQUEST_METHOD_GET) ->setHttpPath('/v1/projects/:projectId/development-keys') - ->desc('List keys') + ->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', 'listKeys') + ->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_KEY_LIST) + ->label('sdk.response.model', Response::MODEL_DEV_KEY_LIST) ->param('projectId', '', new UID(), 'Project unique ID.') ->inject('response') ->inject('dbForConsole') @@ -56,6 +56,6 @@ class ListKeys extends Action $response->dynamic(new Document([ 'keys' => $keys, 'total' => count($keys), - ]), Response::MODEL_KEY_LIST); + ]), Response::MODEL_DEV_KEY_LIST); } } diff --git a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/UpdateKey.php b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/UpdateKey.php index 16906e92b3..5c6ded23c0 100644 --- a/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/UpdateKey.php +++ b/src/Appwrite/Platform/Modules/DevKeys/Http/DevKeys/UpdateKey.php @@ -24,7 +24,7 @@ class UpdateKey extends Action { $this->setHttpMethod(Action::HTTP_REQUEST_METHOD_PUT) ->setHttpPath('/v1/projects/:projectId/development-keys/:keyId') - ->desc('Update key') + ->desc('Update dev key') ->groups(['api', 'projects']) ->label('scope', 'projects.write') ->label('sdk.auth', [APP_AUTH_TYPE_ADMIN]) @@ -32,7 +32,7 @@ class UpdateKey extends Action ->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_KEY) + ->label('sdk.response.model', Response::MODEL_DEV_KEY) ->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.') @@ -67,6 +67,6 @@ class UpdateKey extends Action $dbForConsole->purgeCachedDocument('projects', $project->getId()); - $response->dynamic($key, Response::MODEL_KEY); + $response->dynamic($key, Response::MODEL_DEV_KEY); } } diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 6cc2639f51..c196331346 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -39,6 +39,7 @@ use Appwrite\Utopia\Response\Model\Currency; use Appwrite\Utopia\Response\Model\Database; use Appwrite\Utopia\Response\Model\Deployment; use Appwrite\Utopia\Response\Model\Detection; +use Appwrite\Utopia\Response\Model\DevKey; use Appwrite\Utopia\Response\Model\Document as ModelDocument; use Appwrite\Utopia\Response\Model\Error; use Appwrite\Utopia\Response\Model\ErrorDev; @@ -282,6 +283,8 @@ class Response extends SwooleResponse public const MODEL_WEBHOOK_LIST = 'webhookList'; public const MODEL_KEY = 'key'; public const MODEL_KEY_LIST = 'keyList'; + public const MODEL_DEV_KEY = 'devKey'; + public const MODEL_DEV_KEY_LIST = 'devKeyList'; public const MODEL_MOCK_NUMBER = 'mockNumber'; public const MODEL_AUTH_PROVIDER = 'authProvider'; public const MODEL_AUTH_PROVIDER_LIST = 'authProviderList'; @@ -363,6 +366,7 @@ class Response extends SwooleResponse ->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT, true, false)) ->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK, true, false)) ->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY, true, false)) + ->setModel(new BaseList('Dev Keys List', self::MODEL_DEV_KEY_LIST, 'keys', self::MODEL_DEV_KEY, true, false)) ->setModel(new BaseList('Auth Providers List', self::MODEL_AUTH_PROVIDER_LIST, 'platforms', self::MODEL_AUTH_PROVIDER, true, false)) ->setModel(new BaseList('Platforms List', self::MODEL_PLATFORM_LIST, 'platforms', self::MODEL_PLATFORM, true, false)) ->setModel(new BaseList('Countries List', self::MODEL_COUNTRY_LIST, 'countries', self::MODEL_COUNTRY)) @@ -438,6 +442,7 @@ class Response extends SwooleResponse ->setModel(new Project()) ->setModel(new Webhook()) ->setModel(new Key()) + ->setModel(new DevKey()) ->setModel(new MockNumber()) ->setModel(new AuthProvider()) ->setModel(new Platform()) diff --git a/src/Appwrite/Utopia/Response/Model/DevKey.php b/src/Appwrite/Utopia/Response/Model/DevKey.php new file mode 100644 index 0000000000..50ce750b6a --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/DevKey.php @@ -0,0 +1,82 @@ +addRule('$id', [ + 'type' => self::TYPE_STRING, + 'description' => 'Key ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('$createdAt', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Key creation date in ISO 8601 format.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, + ]) + ->addRule('$updatedAt', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Key update date in ISO 8601 format.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, + ]) + ->addRule('name', [ + 'type' => self::TYPE_STRING, + 'description' => 'Key name.', + 'default' => '', + 'example' => 'My API Key', + ]) + ->addRule('expire', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Key expiration date in ISO 8601 format.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, + ]) + ->addRule('secret', [ + 'type' => self::TYPE_STRING, + 'description' => 'Secret key.', + 'default' => '', + 'example' => '919c2d18fb5d4...a2ae413da83346ad2', + ]) + ->addRule('accessedAt', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Most recent access date in ISO 8601 format. This attribute is only updated again after ' . APP_KEY_ACCESS / 60 / 60 . ' hours.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'DevKey'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_DEV_KEY; + } +}