1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00
portainer/app/kubernetes/endpoint/service.js
Richard Wei 9f179fe3ec
feat(ui):rename endpoint(s) to environment(s) EE-1206 (#5588)
* rename endpoints to environments EE-1206
2021-09-08 20:42:17 +12:00

33 lines
971 B
JavaScript

import _ from 'lodash-es';
import angular from 'angular';
import PortainerError from 'Portainer/error';
import KubernetesEndpointConverter from 'Kubernetes/endpoint/converter';
class KubernetesEndpointService {
/* @ngInject */
constructor($async, KubernetesEndpoints) {
this.$async = $async;
this.KubernetesEndpoints = KubernetesEndpoints;
this.getAllAsync = this.getAllAsync.bind(this);
}
/**
* GET
*/
async getAllAsync(namespace) {
try {
const data = await this.KubernetesEndpoints(namespace).get().$promise;
return _.map(data.items, (item) => KubernetesEndpointConverter.apiToEndpoint(item));
} catch (err) {
throw new PortainerError('Unable to retrieve environments', err);
}
}
get(namespace) {
return this.$async(this.getAllAsync, namespace);
}
}
export default KubernetesEndpointService;
angular.module('portainer.kubernetes').service('KubernetesEndpointService', KubernetesEndpointService);