Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class ResourceConsumption {
- //@ngInject
- constructor($q, $resource, vpcDomainConsumptionAuth) {
- this.$resource = $resource;
- this.vpcDomainConsumptionAuth = vpcDomainConsumptionAuth;
- this.deffer = $q.deffer;
- this.promise = this.deffer.promise;
- this.resource = null;
- this._createResource();
- }
- query(params, data) {
- let $promise = this.promise.then(() => this.resource.query(params, data).$promise);
- return {$promise};
- }
- getResourceInfo(params) {
- let $promise = this.promise.then(() => this.resource.getResourceInfo(params).$promise);
- return {$promise};
- }
- _createResource() {
- return this.vpcDomainConsumptionAuth.getInfo().then(({url}) => {
- const URL = url + '/v1/resource/sel_project/:uuid/metric/:type/measures';
- const PARAMS = {
- uuid: '@uuid',
- type: '@type'
- };
- const ACTIONS = {
- query: {
- method: 'GET',
- isArray: true
- },
- getResourceInfo: {
- method: 'GET',
- url: url + '/v1/resource/sel_project/:uuid'
- }
- };
- this.resource = this.$resource(URL, PARAMS, ACTIONS);
- this.deffer.resolve(this.$resource);
- return this.promise;
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement