2022-02-01 17:38:45 +00:00
|
|
|
import { ContainerGroupViewModel } from '../models/container_group';
|
2020-06-09 02:43:32 +00:00
|
|
|
|
|
|
|
angular.module('portainer.azure').factory('ContainerGroupService', [
|
|
|
|
'$q',
|
|
|
|
'ContainerGroup',
|
|
|
|
function ContainerGroupServiceFactory($q, ContainerGroup) {
|
|
|
|
'use strict';
|
|
|
|
var service = {};
|
|
|
|
|
|
|
|
service.containerGroups = function (subscriptionId) {
|
|
|
|
var deferred = $q.defer();
|
|
|
|
|
|
|
|
ContainerGroup.query({ subscriptionId: subscriptionId })
|
|
|
|
.$promise.then(function success(data) {
|
|
|
|
var containerGroups = data.value.map(function (item) {
|
|
|
|
return new ContainerGroupViewModel(item);
|
|
|
|
});
|
|
|
|
deferred.resolve(containerGroups);
|
|
|
|
})
|
|
|
|
.catch(function error(err) {
|
|
|
|
deferred.reject({ msg: 'Unable to retrieve container groups', err: err });
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise;
|
|
|
|
};
|
|
|
|
|
2020-07-20 21:08:20 +00:00
|
|
|
service.containerGroup = containerGroup;
|
|
|
|
async function containerGroup(subscriptionId, resourceGroupName, containerGroupName) {
|
|
|
|
const containerGroup = await ContainerGroup.get({ subscriptionId, resourceGroupName, containerGroupName }).$promise;
|
|
|
|
return new ContainerGroupViewModel(containerGroup);
|
|
|
|
}
|
|
|
|
|
2020-06-09 02:43:32 +00:00
|
|
|
return service;
|
|
|
|
},
|
|
|
|
]);
|