2019-03-21 05:46:49 +00:00
|
|
|
import { jsonObjectsToArrayHandler, deleteImageHandler } from './response/handlers';
|
|
|
|
import { imageGetResponse } from './response/image';
|
|
|
|
|
2018-02-01 12:27:52 +00:00
|
|
|
angular.module('portainer.docker')
|
2018-10-28 09:27:06 +00:00
|
|
|
.factory('Image', ['$resource', 'API_ENDPOINT_ENDPOINTS', 'EndpointProvider', 'HttpRequestHelper', 'ImagesInterceptor',
|
|
|
|
function ImageFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, HttpRequestHelper, ImagesInterceptor) {
|
2017-01-31 23:26:29 +00:00
|
|
|
'use strict';
|
2017-06-20 11:00:32 +00:00
|
|
|
|
2017-07-20 14:22:27 +00:00
|
|
|
return $resource(API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/images/:id/:action', {
|
2017-03-12 16:24:15 +00:00
|
|
|
endpointId: EndpointProvider.endpointID
|
|
|
|
},
|
|
|
|
{
|
2018-10-28 09:27:06 +00:00
|
|
|
query: {method: 'GET', params: {all: 0, action: 'json'}, isArray: true, interceptor: ImagesInterceptor, timeout: 10000},
|
2017-01-31 23:26:29 +00:00
|
|
|
get: {method: 'GET', params: {action: 'json'}},
|
|
|
|
search: {method: 'GET', params: {action: 'search'}},
|
|
|
|
history: {method: 'GET', params: {action: 'history'}, isArray: true},
|
|
|
|
insert: {method: 'POST', params: {id: '@id', action: 'insert'}},
|
2017-11-12 19:27:28 +00:00
|
|
|
tag: {method: 'POST', params: {id: '@id', action: 'tag', force: 0, repo: '@repo', tag: '@tag'}, ignoreLoadingBar: true},
|
2017-01-31 23:26:29 +00:00
|
|
|
inspect: {method: 'GET', params: {id: '@id', action: 'json'}},
|
|
|
|
push: {
|
|
|
|
method: 'POST', params: {action: 'push', id: '@tag'},
|
2017-06-20 11:00:32 +00:00
|
|
|
isArray: true, transformResponse: jsonObjectsToArrayHandler,
|
2017-11-12 19:27:28 +00:00
|
|
|
headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader },
|
|
|
|
ignoreLoadingBar: true
|
2017-01-31 23:26:29 +00:00
|
|
|
},
|
|
|
|
create: {
|
|
|
|
method: 'POST', params: {action: 'create', fromImage: '@fromImage', tag: '@tag'},
|
2017-06-20 11:00:32 +00:00
|
|
|
isArray: true, transformResponse: jsonObjectsToArrayHandler,
|
2017-11-12 19:27:28 +00:00
|
|
|
headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader },
|
|
|
|
ignoreLoadingBar: true
|
2017-01-31 23:26:29 +00:00
|
|
|
},
|
2018-07-26 13:09:48 +00:00
|
|
|
download: {
|
|
|
|
method: 'GET', params: {action:'get', names: '@names'},
|
|
|
|
transformResponse: imageGetResponse,
|
|
|
|
responseType: 'blob',
|
|
|
|
ignoreLoadingBar: true
|
|
|
|
},
|
2017-01-31 23:26:29 +00:00
|
|
|
remove: {
|
2017-02-15 22:14:56 +00:00
|
|
|
method: 'DELETE', params: {id: '@id', force: '@force'},
|
2017-01-31 23:26:29 +00:00
|
|
|
isArray: true, transformResponse: deleteImageHandler
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}]);
|