This repository has been archived by the owner on Feb 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Add documentation for specification routes in SDK #297
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
505bffe
Add documentation for specification routes in SDK
samniisan c26e1b9
PR feedback
samniisan f616e23
Update to deleteSpecifications doc
samniisan 90fcbdb
Changed deleteSpecifications API return type in doc
samniisan 335be5f
Typo fix
samniisan 3d39a27
Changed deleteSpecifications return type
samniisan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
layout: side-code.html | ||
language-tab: | ||
js: Javascript | ||
java: Android | ||
php: PHP | ||
algolia: true | ||
title: deleteSpecifications | ||
--- | ||
|
||
# deleteSpecifications | ||
|
||
```js | ||
// Deleting specifications using callbacks (NodeJS or Web Browser) | ||
kuzzle | ||
.collection('collection', 'index') | ||
.deleteSpecifications(function (err, deleted) { | ||
// callback called once the delete action has been completed | ||
}); | ||
|
||
// Deleting specifications using promises (NodeJS) | ||
kuzzle | ||
.collection('collection', 'index') | ||
.deleteSpecificationsPromise() | ||
.then(deleted => { | ||
// promises resolved once the delete action has been completed | ||
}); | ||
``` | ||
|
||
```java | ||
// Deleting one document | ||
kuzzle | ||
.collection("collection", "index") | ||
.deleteSpecifications(new ResponseListener<Boolean>() { | ||
@Override | ||
public void onSuccess(Boolean deleted) { | ||
|
||
} | ||
|
||
@Override | ||
public void onError(JSONObject error) { | ||
// Handle error | ||
} | ||
}); | ||
``` | ||
|
||
```php | ||
<?php | ||
|
||
use \Kuzzle\Kuzzle; | ||
|
||
$kuzzle = new Kuzzle('localhost'); | ||
$dataCollection = $kuzzle->collection('collection', 'index'); | ||
|
||
// Deleting one document | ||
try { | ||
$deleted = $dataCollection->deleteSpecifications(); | ||
} | ||
catch (ErrorException $e) { | ||
|
||
} | ||
``` | ||
|
||
> Callback response: | ||
|
||
```json | ||
true | ||
``` | ||
|
||
Delete specifications linked to the collection object. | ||
|
||
--- | ||
|
||
## deleteSpecifications([options], [callback]) | ||
|
||
| Arguments | Type | Description | | ||
|---------------|---------|----------------------------------------| | ||
| ``options`` | JSON object | Optional parameters | | ||
| ``callback`` | function | Optional callback | | ||
|
||
--- | ||
|
||
## Options | ||
|
||
| Option | Type | Description | Default | | ||
|---------------|---------|----------------------------------------|---------| | ||
| ``queuable`` | boolean | Mark this request as (not) queuable | ``true`` | | ||
| ``refresh`` | string | If set to ``wait_for``, Kuzzle will wait the persistence layer indexation to return (available with Elasticsearch 5.x and above) | ``undefined`` | | ||
|
||
--- | ||
|
||
## Return value | ||
|
||
Returns the `Collection` object to allow chaining. | ||
|
||
--- | ||
|
||
## Callback response | ||
|
||
Resolves to a boolean confirming the success of the delete action. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
layout: side-code.html | ||
language-tab: | ||
js: Javascript | ||
java: Android | ||
php: PHP | ||
algolia: true | ||
title: getSpecifications | ||
--- | ||
|
||
# getSpecifications | ||
|
||
```js | ||
// Using callbacks (NodeJS or Web Browser) | ||
kuzzle | ||
.collection('collection', 'index') | ||
.getSpecifications(function (error, specifications) { | ||
// specifications is a JSON object | ||
}); | ||
|
||
// Using promises (NodeJS) | ||
kuzzle | ||
.collection('collection', 'index') | ||
.getSpecificationsPromise() | ||
.then(specifications => { | ||
// specifications is a JSON object | ||
}); | ||
``` | ||
|
||
```java | ||
kuzzle | ||
.collection("collection", "index") | ||
.getSpecifications(new ResponseListener<JSONObject>() { | ||
@Override | ||
public void onSuccess(JSONObject specifications) { | ||
// specifications is a JSONObject | ||
} | ||
|
||
@Override | ||
public void onError(JSONObject error) { | ||
// Handle error | ||
} | ||
}); | ||
``` | ||
|
||
```php | ||
<?php | ||
|
||
use \Kuzzle\Kuzzle; | ||
|
||
$kuzzle = new Kuzzle('localhost'); | ||
$dataCollection = $kuzzle->collection('collection', 'index'); | ||
|
||
try { | ||
$specifications = $dataCollection->getSpecifications(); | ||
} | ||
catch (ErrorException $e) { | ||
|
||
} | ||
``` | ||
|
||
> Callback response | ||
|
||
```json | ||
{ | ||
"validation": { | ||
"strict": "true", | ||
"fields": { | ||
"foo": { | ||
"mandatory": "true", | ||
"type": "string", | ||
"defaultValue": "bar" | ||
} | ||
} | ||
}, | ||
"index": "index", | ||
"collection": "collection" | ||
} | ||
``` | ||
|
||
Retrieves the specifications linked to the collection object. | ||
|
||
--- | ||
|
||
## getSpecifications([options], callback) | ||
|
||
| Arguments | Type | Description | | ||
|---------------|---------|----------------------------------------| | ||
| ``options`` | JSON Object | Optional parameters | | ||
| ``callback`` | function | Callback handling the response | | ||
|
||
--- | ||
|
||
## Options | ||
|
||
| Option | Type | Description | Default | | ||
|---------------|---------|----------------------------------------|---------| | ||
| ``queuable`` | boolean | Mark this request as (not) queuable | ``true`` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
layout: side-code.html | ||
language-tab: | ||
js: Javascript | ||
java: Android | ||
php: PHP | ||
algolia: true | ||
title: scrollSpecifications | ||
--- | ||
|
||
# scrollSpecifications | ||
|
||
```js | ||
// Using callbacks (NodeJS or Web Browser) | ||
kuzzle | ||
.collection('collection', 'index') | ||
.scrollSpecifications(scrollId, {scroll: '1m'}, function (err, res) { | ||
res.hits.forEach(function (specification) { | ||
console.log(specification); | ||
}); | ||
|
||
res.total // Total specifications count | ||
}); | ||
|
||
// Using promises (NodeJS only) | ||
kuzzle | ||
.collection('collection', 'index') | ||
.scrollSpecificationsPromise(scrollId, {scroll: '1m'}) | ||
.then(res => { | ||
res.hits.forEach(specification => { | ||
console.log(specification); | ||
}); | ||
|
||
res.total // Total specifications count | ||
}); | ||
``` | ||
|
||
```java | ||
Options opts = new Options(); | ||
opts.setScroll("1m"); | ||
|
||
kuzzle | ||
.collection("collection", "index") | ||
.scrollSpecifications(scrollId, opts, new ResponseListener<JSONObject>() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As seen in the corresponding SDK PRs, this method now resolves to a SearchResult/KuzzleSearchResult object |
||
@Override | ||
public void onSuccess(JSONObject res) { | ||
for (int i = 0; i < res.getJSONArray("hits").length(); i++) { | ||
res.getJSONArray("hits").getJSONObject(i) // Specification | ||
} | ||
|
||
res.getString("total"); // Total specifications count | ||
} | ||
|
||
@Override | ||
public void onError(JSONObject error) { | ||
// Handle error | ||
} | ||
}); | ||
``` | ||
|
||
```php | ||
<?php | ||
|
||
use \Kuzzle\Kuzzle; | ||
|
||
$kuzzle = new Kuzzle('localhost'); | ||
$dataCollection = $kuzzle->collection('collection', 'index'); | ||
|
||
try { | ||
$res = $dataCollection->scrollSpecifications($scrollId, ['scroll' => '1m']); | ||
|
||
foreach ($res['hits'] as $specification) { | ||
// Specification | ||
} | ||
|
||
// Total specifications count | ||
$res['total']; | ||
} | ||
catch (ErrorException $e) { | ||
|
||
} | ||
``` | ||
|
||
> Callback response | ||
|
||
```json | ||
{ | ||
"hits": [ | ||
{"first": "specification"}, | ||
{"second": "specification"} | ||
], | ||
"total": 2 | ||
} | ||
``` | ||
|
||
Returns a JSON object containing the next page of the scroll session, and the `scrollId` to be used by the next `scroll` action. | ||
A scroll session is always initiated by a `searchSpecification` action by using the `scroll` argument. | ||
|
||
--- | ||
|
||
## scrollSpecifications(scrollId, [options], callback) | ||
|
||
| Arguments | Type | Description | | ||
|---------------|---------|----------------------------------------| | ||
| ``scrollId`` | string | The "scrollId" provided with the last scrollSpecifications response or from the initial searchSpecifications request | | ||
| ``options`` | JSON object | Optional parameters | | ||
| ``callback`` | function | Callback handling the response | | ||
|
||
--- | ||
|
||
## Options | ||
|
||
| Option | Type | Description | Default | | ||
|---------------|---------|----------------------------------------|---------| | ||
| ``queuable`` | boolean | Mark this request as (not) queuable | ``true`` | | ||
| ``scroll`` | string | Re-initializes the scroll session timeout to its value. If not defined, the scroll timeout is defaulted to a Kuzzle configuration | ``undefined`` | |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-which
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed