GUAC-1132: Update session management to use new active connection objects.
This commit is contained in:
1 parent
2e08cd27c4
commit
d4ec7a3ab7
5 files changed
+91
-87
No files matched your search
+25
-24
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Glyptodon LLC
|
||||
* Copyright (C) 2015 Glyptodon LLC
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -21,23 +21,24 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Service for operating on tunnels via the REST API.
|
||||
* Service for operating on active connections via the REST API.
|
||||
*/
|
||||
angular.module('rest').factory('tunnelService', ['$http', 'authenticationService',
|
||||
function tunnelService($http, authenticationService) {
|
||||
angular.module('rest').factory('activeConnectionService', ['$http', 'authenticationService',
|
||||
function activeConnectionService($http, authenticationService) {
|
||||
|
||||
var service = {};
|
||||
|
||||
/**
|
||||
* Makes a request to the REST API to get the list of active tunnels,
|
||||
* returning a promise that provides a map of @link{ActiveTunnel}
|
||||
* returning a promise that provides a map of @link{ActiveConnection}
|
||||
* objects if successful.
|
||||
*
|
||||
* @returns {Promise.<Object.<String, ActiveTunnel>>}
|
||||
* A promise which will resolve with a map of @link{ActiveTunnel}
|
||||
* objects, where each key is the UUID of the corresponding tunnel.
|
||||
* @returns {Promise.<Object.<String, ActiveConnection>>}
|
||||
* A promise which will resolve with a map of @link{ActiveConnection}
|
||||
* objects, where each key is the identifier of the corresponding
|
||||
* active connection.
|
||||
*/
|
||||
service.getActiveTunnels = function getActiveTunnels() {
|
||||
service.getActiveConnections = function getActiveConnections() {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
@@ -47,46 +48,46 @@ angular.module('rest').factory('tunnelService', ['$http', 'authenticationService
|
||||
// Retrieve tunnels
|
||||
return $http({
|
||||
method : 'GET',
|
||||
url : 'api/tunnels',
|
||||
url : 'api/activeConnections',
|
||||
params : httpParameters
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Makes a request to the REST API to delete the tunnels having the given
|
||||
* UUIDs, effectively disconnecting the tunnels, returning a promise that
|
||||
* can be used for processing the results of the call.
|
||||
* Makes a request to the REST API to delete the active connections having
|
||||
* the given identifiers, effectively disconnecting them, returning a
|
||||
* promise that can be used for processing the results of the call.
|
||||
*
|
||||
* @param {String[]} uuids
|
||||
* The UUIDs of the tunnels to delete.
|
||||
* @param {String[]} identifiers
|
||||
* The identifiers of the active connections to delete.
|
||||
*
|
||||
* @returns {Promise}
|
||||
* A promise for the HTTP call which will succeed if and only if the
|
||||
* delete operation is successful.
|
||||
*/
|
||||
service.deleteActiveTunnels = function deleteActiveTunnels(uuids) {
|
||||
service.deleteActiveConnections = function deleteActiveConnections(identifiers) {
|
||||
|
||||
// Build HTTP parameters set
|
||||
var httpParameters = {
|
||||
token : authenticationService.getCurrentToken()
|
||||
};
|
||||
|
||||
// Convert provided array of UUIDs to a patch
|
||||
var tunnelPatch = [];
|
||||
uuids.forEach(function addTunnelPatch(uuid) {
|
||||
tunnelPatch.push({
|
||||
// Convert provided array of identifiers to a patch
|
||||
var activeConnectionPatch = [];
|
||||
identifiers.forEach(function addActiveConnectionPatch(identifier) {
|
||||
activeConnectionPatch.push({
|
||||
op : 'remove',
|
||||
path : '/' + uuid
|
||||
path : '/' + identifier
|
||||
});
|
||||
});
|
||||
|
||||
// Perform tunnel deletion via PATCH
|
||||
// Perform active connection deletion via PATCH
|
||||
return $http({
|
||||
method : 'PATCH',
|
||||
url : 'api/tunnels',
|
||||
url : 'api/activeConnections',
|
||||
params : httpParameters,
|
||||
data : tunnelPatch
|
||||
data : activeConnectionPatch
|
||||
});
|
||||
|
||||
};
|
||||
Reference in new issue
Block a user