1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-20 05:49:40 +02:00
portainer/js/services.js

64 lines
3.1 KiB
JavaScript
Raw Normal View History

2013-06-08 15:12:14 -09:00
'use strict';
2013-06-08 16:20:29 -09:00
angular.module('dockerui.services', ['ngResource'])
2013-06-10 15:10:43 -09:00
.factory('Container', function($resource, Settings) {
2013-06-08 16:20:29 -09:00
// Resource for interacting with the docker containers
// http://docs.docker.io/en/latest/api/docker_remote_api.html#containers
2013-06-10 15:10:43 -09:00
return $resource(Settings.url + '/containers/:id/:action', {}, {
2013-06-08 16:20:29 -09:00
query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true},
get :{method: 'GET', params: { action:'json'}},
2013-06-09 14:56:54 -09:00
start: {method: 'POST', params: {id: '@id', action: 'start'}},
stop: {method: 'POST', params: {id: '@id', t: 5, action: 'stop'}},
restart: {method: 'POST', params: {id: '@id', t: 5, action: 'restart' }},
kill :{method: 'POST', params: {id: '@id', action:'kill'}},
2013-06-08 16:20:29 -09:00
changes :{method: 'GET', params: {action:'changes'}, isArray: true},
create :{method: 'POST', params: {action:'create'}},
2013-06-09 14:56:54 -09:00
remove :{method: 'DELETE', params: {id: '@id', v:0}}
2013-06-08 16:20:29 -09:00
});
})
2013-06-10 15:10:43 -09:00
.factory('Image', function($resource, Settings) {
2013-06-08 16:20:29 -09:00
// Resource for docker images
// http://docs.docker.io/en/latest/api/docker_remote_api.html#images
2013-06-10 15:10:43 -09:00
return $resource(Settings.url + '/images/:id/:action', {}, {
2013-06-08 16:20:29 -09:00
query: {method: 'GET', params:{ all: 0, action: 'json'}, isArray: true},
get :{method: 'GET', params: { action:'json'}},
search :{method: 'GET', params: { action:'search'}},
2013-06-09 14:11:40 -09:00
history :{method: 'GET', params: { action:'history'}, isArray: true},
2013-06-08 16:20:29 -09:00
create :{method: 'POST', params: {action:'create'}},
2013-06-09 14:56:54 -09:00
insert :{method: 'POST', params: {id: '@id', action:'insert'}},
push :{method: 'POST', params: {id: '@id', action:'push'}},
tag :{method: 'POST', params: {id: '@id', action:'tag'}},
delete :{id: '@id', method: 'DELETE'}
2013-06-08 16:20:29 -09:00
});
2013-06-09 14:56:54 -09:00
})
2013-06-10 15:10:43 -09:00
.factory('Docker', function($resource, Settings) {
2013-06-09 16:31:05 -09:00
// Information for docker
// http://docs.docker.io/en/latest/api/docker_remote_api.html#display-system-wide-information
2013-06-10 15:10:43 -09:00
return $resource(Settings.url + '/version', {}, {
2013-06-09 16:31:05 -09:00
get: {method: 'GET'}
});
})
2013-06-10 15:10:43 -09:00
.factory('Auth', function($resource, Settings) {
2013-06-09 16:31:05 -09:00
// Auto Information for docker
// http://docs.docker.io/en/latest/api/docker_remote_api.html#set-auth-configuration
2013-06-10 15:10:43 -09:00
return $resource(Settings.url + '/auth', {}, {
2013-06-09 16:31:05 -09:00
get: {method: 'GET'},
update: {method: 'POST'}
});
})
2013-06-10 15:10:43 -09:00
.factory('System', function($resource, Settings) {
2013-06-09 16:31:05 -09:00
// System for docker
// http://docs.docker.io/en/latest/api/docker_remote_api.html#display-system-wide-information
2013-06-10 15:10:43 -09:00
return $resource(Settings.url + '/info', {}, {
2013-06-09 16:31:05 -09:00
get: {method: 'GET'}
});
})
2013-06-10 15:10:43 -09:00
.factory('Settings', function(DOCKER_ENDPOINT, DOCKER_API_VERSION) {
2013-06-09 14:56:54 -09:00
return {
2013-06-10 03:59:57 -09:00
displayAll: false,
2013-06-10 15:10:43 -09:00
endpoint: DOCKER_ENDPOINT,
version: DOCKER_API_VERSION,
url: DOCKER_ENDPOINT + DOCKER_API_VERSION
2013-06-09 14:56:54 -09:00
};
2013-06-08 15:12:14 -09:00
});