2019-03-21 05:46:49 +00:00
|
|
|
import { ContainerInstanceProviderViewModel } from '../models/provider';
|
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
angular.module('portainer.azure').factory('ProviderService', [
|
|
|
|
'$q',
|
|
|
|
'Provider',
|
|
|
|
function ProviderServiceFactory($q, Provider) {
|
|
|
|
'use strict';
|
|
|
|
var service = {};
|
2018-05-28 14:40:33 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
service.containerInstanceProvider = function (subscriptionId) {
|
|
|
|
var deferred = $q.defer();
|
2018-05-28 14:40:33 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
Provider.get({ subscriptionId: subscriptionId, providerNamespace: 'Microsoft.ContainerInstance' })
|
|
|
|
.$promise.then(function success(data) {
|
|
|
|
var provider = new ContainerInstanceProviderViewModel(data);
|
|
|
|
deferred.resolve(provider);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to retrieve provider', err: err });
|
|
|
|
});
|
2018-05-28 14:40:33 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
return deferred.promise;
|
|
|
|
};
|
2018-05-28 14:40:33 +00:00
|
|
|
|
2020-04-10 21:54:53 +00:00
|
|
|
return service;
|
|
|
|
},
|
|
|
|
]);
|