Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: collection getSettings #2588

Open
wants to merge 5 commits into
base: 2-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions doc/2/api/controllers/collection/get-settings/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
code: true
type: page
title: getSettings | API | Core
---

# getSettings

Retrieves the Elasticsearch index settings for the specified Kuzzle collection.

---

## Query Syntax

### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_settings
Method: GET
```

### Other protocols

```js
{
"index": "<index>",
"collection": "<collection>",
"controller": "collection",
"action": "getSettings",
}
```

---

## Arguments

- `collection`: collection name
- `index`: index name

---

## Response

Returns a setting object with the following structure:

```js
{
"status": 200,
"error": null,
"action": "getSettings",
"controller": "collection",
"collection": "<collection>",
"index": "<index>",
"headers": {},
"result": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "1",
"provided_name": "&platform.config",
"creation_date": "1738682329397",
"number_of_replicas": "1",
"uuid": "aY0IBbKJSvuIrwqqYyKkUw",
"version": {
"created": "7160299"
}
},
}
```

---

## Possible errors

- [Common errors](/core/2/api/errors/types#common-errors)
- [NotFoundError](/core/2/api/errors/types#notfounderror)
13 changes: 13 additions & 0 deletions features/CollectionController.feature
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ Feature: Collection Controller
| createdAt | { "type": "date" } |
| updatedAt | { "type": "date" } |


# collection:getSettings =====================================================

Scenario: Get collection settings
Given an index "nyc-open-data"
And I "create" the collection "nyc-open-data":"green-taxi" with:
| mappings | { "dynamic": "strict", "properties": { "name": { "type": "keyword" } } } |
When I successfully execute the action "collection":"getSettings" with args:
| index | "nyc-open-data" |
| collection | "green-taxi" |
Then I should receive a result matching:
| number_of_shards | "1" |

# collection:delete ==========================================================

Scenario: Delete a collection
Expand Down
18 changes: 18 additions & 0 deletions lib/api/controllers/collectionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CollectionController extends NativeController {
"deleteSpecifications",
"exists",
"getMapping",
"getSettings",
"getSpecifications",
"list",
"refresh",
Expand Down Expand Up @@ -97,6 +98,23 @@ class CollectionController extends NativeController {
return this._filterMappingResponse(mapping);
}

/**
* Get the collection settings
*
* @param {Request} request
* @returns {Promise.<Object>}
*/
async getSettings(request) {
const { index, collection } = request.getIndexAndCollection();

return this.ask(
"core:storage:public:collection:settings:get",
index,
collection,
{},
);
}

/**
* Get the collection validation specifications
*
Expand Down
6 changes: 6 additions & 0 deletions lib/api/httpRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ const routes = [
controller: "collection",
action: "getMapping",
},
{
verb: "get",
path: "/:index/:collection/_settings",
controller: "collection",
action: "getSettings",
},
{
verb: "get",
path: "/:index/:collection/_search",
Expand Down
1 change: 0 additions & 1 deletion test/api/controllers/collectionController.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ describe("Test: collection controller", () => {
index,
collection,
);

should(response).be.instanceof(Object);
should(response).match({
acknowledged: true,
Expand Down
Loading