Skip to content

Commit 181e953

Browse files
committed
Merge pull request #10 from elasticio/get_steps_data
added new endpoint for retrieving step data
2 parents a81f328 + 223c0b2 commit 181e953

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

lib/resource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ApiResource.method = function method(spec) {
7171

7272
function provideOptions() {
7373
if (!path) {
74-
throw new Error("A resource mus define 'path'");
74+
throw new Error("A resource must define 'path'");
7575
}
7676

7777
if (spec.path) {

lib/resources/tasks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@ module.exports = Resource.extend({
2121
delete: Resource.method({
2222
method: Resource.DELETE,
2323
path: '/{id}'
24+
}),
25+
26+
retrieveStep: Resource.method({
27+
method: Resource.GET,
28+
path: '/{id}/steps/{stepId}'
2429
})
2530
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "elasticio-rest-node",
33
"description": "elastic.io REST API client",
4-
"version": "0.0.10",
4+
"version": "1.0.0",
55
"author": "elastic.io GmbH <[email protected]>",
66
"engine": "node >=4.1.0",
77
"scripts": {

spec/resources/tasks.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,30 @@ describe('/tasks', function () {
166166

167167
});
168168
});
169+
170+
describe('/{id}/steps', function() {
171+
describe('/{stepId}', function() {
172+
it('should send request successfully', function (done) {
173+
var response = {
174+
'id': 'step_1',
175+
'comp_id': 'comp_1'
176+
};
177+
178+
nock('https://api.elastic.io')
179+
.get('/v1/tasks/54f4be3fe7d5224f91000001/steps/step_1')
180+
.basicAuth({
181+
user: 'root',
182+
pass: 'secret'
183+
})
184+
.reply(200, response);
185+
186+
tasks.retrieveStep('54f4be3fe7d5224f91000001', 'step_1')
187+
.then(function (result) {
188+
expect(result).toEqual(response);
189+
})
190+
.then(done)
191+
.catch(done.fail);
192+
});
193+
});
194+
});
169195
});

0 commit comments

Comments
 (0)