From 988634eb79f6e8a63fcce0db467ddf8b1287b8cb Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 25 Jan 2022 03:09:24 +0400 Subject: [PATCH] feat: reneame list-tags endpoint --- app/controllers/api/functions.php | 38 +++++++++---------- docs/references/functions/list-deployments.md | 1 + docs/references/functions/list-tags.md | 1 - 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 docs/references/functions/list-deployments.md delete mode 100644 docs/references/functions/list-tags.md diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 795be47fd..7024b2398 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -627,22 +627,22 @@ App::post('/v1/functions/:functionId/deployments') $response->dynamic($deployment, Response::MODEL_DEPLOYMENT); }); -App::get('/v1/functions/:functionId/tags') +App::get('/v1/functions/:functionId/deployments') ->groups(['api', 'functions']) - ->desc('List Tags') + ->desc('List Deployments') ->label('scope', 'functions.read') ->label('sdk.auth', [APP_AUTH_TYPE_KEY]) ->label('sdk.namespace', 'functions') - ->label('sdk.method', 'listTags') - ->label('sdk.description', '/docs/references/functions/list-tags.md') + ->label('sdk.method', 'listDeployments') + ->label('sdk.description', '/docs/references/functions/list-deployments.md') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) - ->label('sdk.response.model', Response::MODEL_TAG_LIST) + ->label('sdk.response.model', Response::MODEL_DEPLOYMENT_LIST) ->param('functionId', '', new UID(), 'Function ID.') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) - ->param('limit', 25, new Range(0, 100), 'Maximum number of tags to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) + ->param('limit', 25, new Range(0, 100), 'Maximum number of deployments to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) ->param('offset', 0, new Range(0, APP_LIMIT_COUNT), 'Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)', true) - ->param('cursor', '', new UID(), 'ID of the tag used as the starting point for the query, excluding the tag itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) + ->param('cursor', '', new UID(), 'ID of the deployment used as the starting point for the query, excluding the deployment itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)', true) ->param('cursorDirection', Database::CURSOR_AFTER, new WhiteList([Database::CURSOR_AFTER, Database::CURSOR_BEFORE]), 'Direction of the cursor.', true) ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->inject('response') @@ -658,10 +658,10 @@ App::get('/v1/functions/:functionId/tags') } if (!empty($cursor)) { - $cursorTag = $dbForProject->getDocument('tags', $cursor); + $cursorDeployment = $dbForProject->getDocument('deployments', $cursor); - if ($cursorTag->isEmpty()) { - throw new Exception("Tag '{$cursor}' for the 'cursor' value not found.", 400); + if ($cursorDeployment->isEmpty()) { + throw new Exception("Deployment '{$cursor}' for the 'cursor' value not found.", 400); } } @@ -673,22 +673,22 @@ App::get('/v1/functions/:functionId/tags') $queries[] = new Query('functionId', Query::TYPE_EQUAL, [$function->getId()]); - $results = $dbForProject->find('tags', $queries, $limit, $offset, [], [$orderType], $cursorTag ?? null, $cursorDirection); - $sum = $dbForProject->count('tags', $queries, APP_LIMIT_COUNT); + $results = $dbForProject->find('deployments', $queries, $limit, $offset, [], [$orderType], $cursorDeployment ?? null, $cursorDirection); + $sum = $dbForProject->count('deployments', $queries, APP_LIMIT_COUNT); // Get Current Build Data - foreach ($results as &$tag) { - $build = $dbForProject->getDocument('builds', $tag->getAttribute('buildId', '')); + foreach ($results as &$deployment) { + $build = $dbForProject->getDocument('builds', $deployment->getAttribute('buildId', '')); - $tag['status'] = $build->getAttribute('status', 'processing'); - $tag['buildStdout'] = $build->getAttribute('stdout', ''); - $tag['buildStderr'] = $build->getAttribute('stderr', ''); + $deployment['status'] = $build->getAttribute('status', 'processing'); + $deployment['buildStdout'] = $build->getAttribute('stdout', ''); + $deployment['buildStderr'] = $build->getAttribute('stderr', ''); } $response->dynamic(new Document([ - 'tags' => $results, + 'deployments' => $results, 'sum' => $sum, - ]), Response::MODEL_TAG_LIST); + ]), Response::MODEL_DEPLOYMENT_LIST); }); App::get('/v1/functions/:functionId/tags/:tagId') diff --git a/docs/references/functions/list-deployments.md b/docs/references/functions/list-deployments.md new file mode 100644 index 000000000..8b24f911f --- /dev/null +++ b/docs/references/functions/list-deployments.md @@ -0,0 +1 @@ +Get a list of all the project's code deployments. You can use the query params to filter your results. \ No newline at end of file diff --git a/docs/references/functions/list-tags.md b/docs/references/functions/list-tags.md deleted file mode 100644 index d872894a6..000000000 --- a/docs/references/functions/list-tags.md +++ /dev/null @@ -1 +0,0 @@ -Get a list of all the project's code tags. You can use the query params to filter your results. \ No newline at end of file