2019-07-26 10:38:07 +12:00
|
|
|
import { genericHandler, logsHandler } from './response/handlers';
|
2019-03-21 07:46:49 +02:00
|
|
|
|
2018-02-01 13:27:52 +01:00
|
|
|
angular.module('portainer.docker').factory('Container', [
|
2018-10-28 10:27:06 +01:00
|
|
|
'$resource',
|
|
|
|
'API_ENDPOINT_ENDPOINTS',
|
|
|
|
'EndpointProvider',
|
2022-11-21 17:25:09 +02:00
|
|
|
function ContainerFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider) {
|
2017-02-01 12:26:29 +13:00
|
|
|
'use strict';
|
2017-07-20 16:22:27 +02:00
|
|
|
return $resource(
|
|
|
|
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/containers/:id/:action',
|
|
|
|
{
|
2017-03-12 17:24:15 +01:00
|
|
|
name: '@name',
|
|
|
|
endpointId: EndpointProvider.endpointID,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
query: {
|
2018-05-06 09:15:57 +02:00
|
|
|
method: 'GET',
|
|
|
|
params: { all: 0, action: 'json', filters: '@filters' },
|
2019-07-26 10:38:07 +12:00
|
|
|
isArray: true,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
get: {
|
2018-05-06 09:15:57 +02:00
|
|
|
method: 'GET',
|
|
|
|
params: { action: 'json' },
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
logs: {
|
2017-09-09 18:49:21 +02:00
|
|
|
method: 'GET',
|
2018-02-28 07:19:28 +01:00
|
|
|
params: { id: '@id', action: 'logs' },
|
|
|
|
ignoreLoadingBar: true,
|
2018-05-04 09:45:05 +02:00
|
|
|
transformResponse: logsHandler,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
stats: {
|
2017-09-09 18:49:21 +02:00
|
|
|
method: 'GET',
|
|
|
|
params: { id: '@id', stream: false, action: 'stats' },
|
2018-02-28 07:19:28 +01:00
|
|
|
ignoreLoadingBar: true,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
top: {
|
2017-10-17 09:56:40 +03:00
|
|
|
method: 'GET',
|
2017-09-09 18:49:21 +02:00
|
|
|
params: { id: '@id', action: 'top' },
|
2018-02-28 07:19:28 +01:00
|
|
|
ignoreLoadingBar: true,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
2017-02-01 12:26:29 +13:00
|
|
|
create: {
|
2018-08-16 10:31:00 +01:00
|
|
|
method: 'POST',
|
2017-02-01 12:26:29 +13:00
|
|
|
params: { action: 'create' },
|
2019-05-09 04:04:40 +02:00
|
|
|
transformResponse: genericHandler,
|
2018-02-28 07:19:28 +01:00
|
|
|
ignoreLoadingBar: true,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
exec: {
|
2019-05-09 04:04:40 +02:00
|
|
|
method: 'POST',
|
2017-02-01 12:26:29 +13:00
|
|
|
params: { id: '@id', action: 'exec' },
|
2019-05-09 04:04:40 +02:00
|
|
|
transformResponse: genericHandler,
|
2018-02-28 07:19:28 +01:00
|
|
|
ignoreLoadingBar: true,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
2017-10-17 09:56:40 +03:00
|
|
|
inspect: {
|
|
|
|
method: 'GET',
|
|
|
|
params: { id: '@id', action: 'json' },
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
2018-08-16 10:31:00 +01:00
|
|
|
update: {
|
2019-05-09 04:04:40 +02:00
|
|
|
method: 'POST',
|
2018-08-16 10:31:00 +01:00
|
|
|
params: { id: '@id', action: 'update' },
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
prune: {
|
2019-05-09 04:04:40 +02:00
|
|
|
method: 'POST',
|
2018-10-28 07:06:50 +01:00
|
|
|
params: { action: 'prune', filters: '@filters' },
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
2019-05-09 04:04:40 +02:00
|
|
|
resize: {
|
|
|
|
method: 'POST',
|
|
|
|
params: { id: '@id', action: 'resize', h: '@height', w: '@width' },
|
|
|
|
transformResponse: genericHandler,
|
2018-02-28 07:19:28 +01:00
|
|
|
ignoreLoadingBar: true,
|
2020-04-11 00:54:53 +03:00
|
|
|
},
|
|
|
|
}
|
|
|
|
);
|
2017-03-12 17:24:15 +01:00
|
|
|
},
|
2020-04-11 00:54:53 +03:00
|
|
|
]);
|