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