-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from vrockai/HAWKULAR-13
Create NgResource Services Layer for Hawkular REST API
- Loading branch information
Showing
20 changed files
with
222 additions
and
114 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions
48
services/hawkular-rest-service/src/hawkRest-inventory-provider.spec.rest.js
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,48 @@ | ||
describe('Provider: Hawkular live REST', function() { | ||
|
||
var HawkularInventory; | ||
var res; | ||
var httpReal; | ||
var $http; | ||
|
||
beforeEach(module('hawkular.rest', 'httpReal')); | ||
|
||
beforeEach(inject(function(_HawkularInventory_, _$resource_, _httpReal_, _$http_) { | ||
HawkularInventory = _HawkularInventory_; | ||
res = _$resource_; | ||
httpReal = _httpReal_; | ||
$http = _$http_; | ||
})); | ||
|
||
describe('Resources: ', function() { | ||
|
||
describe('creating a resource', function() { | ||
var result; | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT; | ||
|
||
beforeEach(function(done) { | ||
var resource = { | ||
type: 'URL', | ||
id: 'x1422733176502', | ||
parameters: { | ||
url: 'http://hawkular.org' | ||
} | ||
}; | ||
|
||
result = HawkularInventory.Resource.save(resource); | ||
httpReal.submit(); | ||
|
||
result.$promise.then(function(){ | ||
}, function(error){ | ||
fail(errorFn(error)); | ||
}).finally(function(){ | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should resolve', function() { | ||
expect(result.$resolved).toEqual(true); | ||
}); | ||
}); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
services/hawkular-rest-service/src/hawkRest-inventory-provider.ts
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,47 @@ | ||
/** | ||
* @ngdoc provider | ||
* @name hawkular.rest.HawkularInventory | ||
* @description | ||
* # HawkularInventory | ||
* Provider in the hawkular.rest. | ||
*/ | ||
|
||
module hawkularRest { | ||
|
||
_module.provider('HawkularInventory', function() { | ||
// time (in ms) the notifications are shown | ||
|
||
this.host = 'localhost'; | ||
this.port = 8080; | ||
|
||
this.setHost = function(host){ | ||
this.host = host; | ||
return this; | ||
}; | ||
|
||
this.setPort = function(port){ | ||
this.port = port; | ||
return this; | ||
}; | ||
|
||
this.$get = ['$resource', function($resource) { | ||
|
||
var prefix = 'http://' + this.host + ':' + this.port; | ||
var factory = {}; | ||
|
||
factory['Resource'] = $resource(prefix + '/hawkular/inventory/:tenantId/resources/:resourceId', { | ||
tenantId : '@tenantId', | ||
resourceId : '@resourceId' | ||
}); | ||
|
||
factory['Metric'] = $resource(prefix + '/hawkular/inventory/:tenantId/resources/:resourceId/metric/:metricId', { | ||
tenantId : '@tenantId', | ||
resourceId: '@resourceId', | ||
metricId: '@metricId' | ||
}); | ||
|
||
return factory; | ||
}]; | ||
|
||
}); | ||
} |
File renamed without changes.
Oops, something went wrong.