diff --git a/confidant/models/service.py b/confidant/models/service.py index 43cba2c5..2824b801 100644 --- a/confidant/models/service.py +++ b/confidant/models/service.py @@ -19,15 +19,6 @@ class Meta: modified_date = UTCDateTimeAttribute(range_key=True) -class DataTypeRevisionIndex(GlobalSecondaryIndex): - class Meta: - projection = AllProjection() - read_capacity_units = 10 - write_capacity_units = 10 - data_type = UnicodeAttribute(hash_key=True) - revision = NumberAttribute(range_key=True) - - class Service(Model): class Meta: table_name = app.config.get('DYNAMODB_TABLE') @@ -37,7 +28,6 @@ class Meta: id = UnicodeAttribute(hash_key=True) data_type = UnicodeAttribute() data_type_date_index = DataTypeDateIndex() - data_type_revision_index = DataTypeRevisionIndex() revision = NumberAttribute() credentials = UnicodeSetAttribute() modified_date = UTCDateTimeAttribute(default=datetime.now) diff --git a/confidant/public/index.html b/confidant/public/index.html index 162c7646..ab996252 100644 --- a/confidant/public/index.html +++ b/confidant/public/index.html @@ -42,9 +42,9 @@

Confidant

@@ -96,13 +96,6 @@

Confidant

- - - - - - - diff --git a/confidant/public/modules/common/constants.js b/confidant/public/modules/common/constants.js index 8d02e995..e6c29aea 100644 --- a/confidant/public/modules/common/constants.js +++ b/confidant/public/modules/common/constants.js @@ -15,11 +15,9 @@ SERVICE: 'v1/services/:id', SERVICES: 'v1/services', ARCHIVE_SERVICES: 'v1/archive/services', - ARCHIVE_SERVICE_REVISIONS: 'v1/archive/services/:id/:revision', CREDENTIAL: 'v1/credentials/:id', CREDENTIALS: 'v1/credentials', ARCHIVE_CREDENTIALS: 'v1/archive/credentials', - ARCHIVE_CREDENTIAL_REVISIONS: 'v1/archive/credentials/:id/:revision', PROFILES: 'v1/profiles' }) diff --git a/confidant/public/modules/common/controllers/NavCtrl.js b/confidant/public/modules/common/controllers/NavCtrl.js index 725ed76a..7489473a 100644 --- a/confidant/public/modules/common/controllers/NavCtrl.js +++ b/confidant/public/modules/common/controllers/NavCtrl.js @@ -14,12 +14,6 @@ $scope.viewLocation = newViewLocation; } }); - $scope.getHistoryView = NavService.getHistoryView; - $scope.$watch('getHistoryView()', function(newHistoryView, oldHistoryView) { - if(newHistoryView !== oldHistoryView) { - $scope.historyView = newHistoryView; - } - }); }]) ; diff --git a/confidant/public/modules/common/services/NavService.js b/confidant/public/modules/common/services/NavService.js index 9debc1e1..7b9682d3 100644 --- a/confidant/public/modules/common/services/NavService.js +++ b/confidant/public/modules/common/services/NavService.js @@ -8,11 +8,9 @@ function($rootScope) { var _this = this; this.viewLocation = ''; - this.historyView = ''; $rootScope.$on('$stateChangeSuccess', function(evt, state) { if(state.data) { _this.viewLocation = state.data.viewLocation; - _this.historyView = state.data.historyView; } }); @@ -20,10 +18,6 @@ return _this.viewLocation; }; - this.getHistoryView = function() { - return _this.historyView; - }; - }]) ; diff --git a/confidant/public/modules/history/controllers/CredentialHistoryCtrl.js b/confidant/public/modules/history/controllers/CredentialHistoryCtrl.js deleted file mode 100644 index f4d6ddfb..00000000 --- a/confidant/public/modules/history/controllers/CredentialHistoryCtrl.js +++ /dev/null @@ -1,103 +0,0 @@ -(function(angular) { - 'use strict'; - - angular.module('confidant.history.controllers.CredentialHistoryCtrl', [ - 'ui.router', - 'ngResource', - 'xeditable', - 'confidant.resources.services', - 'confidant.history.services' - ]) - - - .controller('history.CredentialHistoryCtrl', [ - '$scope', - '$stateParams', - '$filter', - '$q', - '$log', - '$location', - 'credentials.credential', - 'credentials.archiveCredentialRevisions', - 'history.ResourceArchiveService', - function ($scope, $stateParams, $filter, $q, $log, $location, Credential, CredentialArchiveRevisions, ResourceArchiveService) { - function doQuery(credential, id) { - var d = $q.defer(), - result = credential.get({'id': id}, function() { d.resolve(result); }); - return d.promise; - } - - $scope.$log = $log; - $scope.revisions = []; - - var idArr = $stateParams.credentialId.split('-'); - $scope.credentialId = idArr[0]; - $scope.credentialRevision = parseInt(idArr[1]); - CredentialArchiveRevisions.get({'id': $scope.credentialId}).$promise.then(function(revisions) { - $scope.revisions = $filter('orderBy')(revisions.revisions, 'revision', true); - $scope.currentRevision = $scope.revisions[0].revision; - $scope.isOnlyRevision = false; - $scope.isCurrentRevision = false; - if ($scope.currentRevision === 1) { - $scope.isOnlyRevision = true; - $scope.diffRevision = $scope.currentRevision; - Credential.get({'id': $stateParams.credentialId}).$promise.then(function(credential) { - $scope.currentCredential = credential; - $scope.diffCredential = credential; - }, function() { - $scope.currentCredential = null; - $scope.diffCredential = null; - }); - } else { - if ($scope.credentialRevision === $scope.currentRevision) { - $scope.diffRevision = parseInt($scope.currentRevision) - 1; - } else { - $scope.diffRevision = parseInt($scope.credentialRevision); - } - var currentCredentialPromise = doQuery(Credential, $scope.credentialId + '-' + $scope.currentRevision), - diffCredentialPromise = doQuery(Credential, $scope.credentialId + '-' + $scope.diffRevision); - $q.all([currentCredentialPromise, diffCredentialPromise]).then(function(results) { - $scope.currentCredential = results[0]; - $scope.diffCredential = results[1]; - }, function() { - $scope.currentCredential = null; - $scope.diffCredential = null; - }); - } - if ($scope.currentRevision === $scope.credentialRevision) { - $scope.isCurrentRevision = true; - } - }); - - $scope.revertToDiffRevision = function() { - var deferred = $q.defer(); - if (angular.equals($scope.diffCredential.name, $scope.currentCredential.name) && - angular.equals($scope.diffCredential.credential_pairs, $scope.currentCredential.credential_pairs)) { - $scope.saveError = 'Can not revert to revision ' + $scope.diffCredential.revision + '. No difference between it and current revision.'; - deferred.reject(); - return deferred.promise; - } - Credential.update({'id': $scope.credentialId}, $scope.diffCredential).$promise.then(function(newCredential) { - deferred.resolve(); - ResourceArchiveService.updateResourceArchive(); - $location.path('/history/credential/' + newCredential.id + '-' + newCredential.revision); - }, function(res) { - if (res.status === 500) { - $scope.saveError = 'Unexpected server error.'; - $log.error(res); - } else { - $scope.saveError = res.data.error; - if ('conflicts' in res.data) { - $scope.credentialPairConflicts = res.data.conflicts; - } - } - deferred.reject(); - }); - return deferred.promise; - }; - - }]) - - ; - -})(window.angular); diff --git a/confidant/public/modules/history/controllers/ResourceHistoryCtrl.js b/confidant/public/modules/history/controllers/ResourceHistoryCtrl.js deleted file mode 100644 index 4297ba06..00000000 --- a/confidant/public/modules/history/controllers/ResourceHistoryCtrl.js +++ /dev/null @@ -1,60 +0,0 @@ -(function(angular) { - 'use strict'; - - angular.module('confidant.history.controllers.ResourceHistoryCtrl', [ - 'ui.router', - 'ngResource', - 'xeditable', - 'confidant.resources.services', - 'confidant.history.services' - ]) - - - .controller('history.ResourceHistoryCtrl', [ - '$scope', - '$log', - '$location', - 'credentials.list', - 'history.ResourceArchiveService', - function ($scope, $log, $location, CredentialList, ResourceArchiveService) { - CredentialList.get().$promise.then(function(credentialList) { - $scope.credentialList = credentialList.credentials; - }, function() { - $scope.credentialList = []; - }); - - // Reformat archive credential IDs for display. Archive credential IDs - // are formatted as id-revision. - $scope.reformatId = function(id) { - return id.split('-')[0]; - }; - - $scope.resourceRegexFilter = function(field, regex) { - return function(resource) { - var pattern = new RegExp(regex, 'ig'); - return pattern.test(resource[field]); - } - }; - - $scope.gotoResource = function(resource) { - if (resource.type == 'credential') { - $location.path('/history/credential/' + resource.id); - } else if (resource.type == 'service') { - $location.path('/history/service/' + resource.id); - } - }; - - $scope.$log = $log; - $scope.getResourceArchive = ResourceArchiveService.getResourceArchive; - $scope.$watch('getResourceArchive()', function(newResourceArchive, oldResourceArchive) { - if(newResourceArchive !== oldResourceArchive) { - $scope.resourceArchive = newResourceArchive; - } - }); - ResourceArchiveService.updateResourceArchive(); - - }]) - - ; - -})(window.angular); diff --git a/confidant/public/modules/history/controllers/ServiceHistoryCtrl.js b/confidant/public/modules/history/controllers/ServiceHistoryCtrl.js deleted file mode 100644 index c7045ab1..00000000 --- a/confidant/public/modules/history/controllers/ServiceHistoryCtrl.js +++ /dev/null @@ -1,99 +0,0 @@ -(function(angular) { - 'use strict'; - - angular.module('confidant.history.controllers.ServiceHistoryCtrl', [ - 'ui.router', - 'ngResource', - 'xeditable', - 'confidant.resources.services', - 'confidant.history.services' - ]) - - - .controller('history.ServiceHistoryCtrl', [ - '$scope', - '$stateParams', - '$filter', - '$q', - '$log', - '$location', - 'services.service', - 'services.archiveServiceRevisions', - 'history.ResourceArchiveService', - function ($scope, $stateParams, $filter, $q, $log, $location, Service, ServiceArchiveRevisions, ResourceArchiveService) { - $scope.$log = $log; - $scope.revisions = []; - - var idArr = $stateParams.serviceId.split('-'); - $scope.serviceId = idArr[0]; - $scope.serviceRevision = parseInt(idArr[1]); - ServiceArchiveRevisions.get({'id': $scope.serviceId}).$promise.then(function(revisions) { - $scope.revisions = $filter('orderBy')(revisions.revisions, 'revision', true); - $scope.currentRevision = $scope.revisions[0].revision; - if ($scope.currentRevision === 1) { - $scope.isOnlyRevision = true; - $scope.diffRevision = $scope.currentRevision; - } else { - if ($scope.serviceRevision === $scope.currentRevision) { - $scope.diffRevision = parseInt($scope.currentRevision) - 1; - } else { - $scope.diffRevision = parseInt($scope.serviceRevision); - } - } - if ($scope.currentRevision === $scope.serviceRevision) { - $scope.isCurrentRevision = true; - } - }); - - $scope.getServiceByRevision = function(rev) { - return $filter('filter')($scope.revisions, {revision: rev})[0]; - } - - $scope.getCredentialName = function(credId) { - var name = ''; - if (!$scope.$parent.credentialList) { - return name; - } - for (var i = 0; i < $scope.$parent.credentialList.length; i++) { - var cred = $scope.$parent.credentialList[i]; - if (cred.id.indexOf(credId) === 0) { - name = cred.name; - break; - } - } - return name; - }; - - $scope.revertToDiffRevision = function() { - var diffService = $scope.getServiceByRevision($scope.diffRevision), - currentService = $scope.getServiceByRevision($scope.currentRevision), - deferred = $q.defer(); - if (angular.equals(diffService.credentials, currentService.credentials)) { - $scope.saveError = 'Can not revert to revision ' + diffService.revision + '. No difference between it and current revision.'; - deferred.reject(); - return deferred.promise; - } - Service.update({'id': $scope.serviceId}, diffService).$promise.then(function(newService) { - deferred.resolve(); - ResourceArchiveService.updateResourceArchive(); - $location.path('/history/service/' + newService.id + '-' + newService.revision); - }, function(res) { - if (res.status === 500) { - $scope.saveError = 'Unexpected server error.'; - $log.error(res); - } else { - $scope.saveError = res.data.error; - if ('conflicts' in res.data) { - $scope.credentialPairConflicts = res.data.conflicts; - } - } - deferred.reject(); - }); - return deferred.promise; - }; - - }]) - - ; - -})(window.angular); diff --git a/confidant/public/modules/history/controllers/controllers.js b/confidant/public/modules/history/controllers/controllers.js deleted file mode 100644 index 8149fd10..00000000 --- a/confidant/public/modules/history/controllers/controllers.js +++ /dev/null @@ -1,12 +0,0 @@ -(function(angular) { - 'use strict'; - - - angular.module('confidant.history.controllers', [ - // Keep this list sorted alphabetically! - 'confidant.history.controllers.CredentialHistoryCtrl', - 'confidant.history.controllers.ResourceHistoryCtrl', - 'confidant.history.controllers.ServiceHistoryCtrl' - ]) - ; -}(angular)); diff --git a/confidant/public/modules/history/history.js b/confidant/public/modules/history/history.js deleted file mode 100644 index 18e59541..00000000 --- a/confidant/public/modules/history/history.js +++ /dev/null @@ -1,10 +0,0 @@ -(function(angular) { - 'use strict'; - - angular.module('confidant.history', [ - 'confidant.history.controllers', - 'confidant.history.services' - ]) - - ; -})(window.angular); diff --git a/confidant/public/modules/history/services/archive.js b/confidant/public/modules/history/services/archive.js deleted file mode 100644 index b0544565..00000000 --- a/confidant/public/modules/history/services/archive.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * common $resources for Confidant - */ -(function(angular, _) { - 'use strict'; - - angular.module('confidant.history.services.archive', [ - 'ngResource', - 'confidant.resources.services' - ]) - - .service('history.ResourceArchiveService', [ - '$q', - 'credentials.archiveList', - 'services.archiveList', - function($q, CredentialArchive, ServiceArchive) { - function doQuery(service) { - var d = $q.defer(), - result = service.get(function() { d.resolve(result); }); - return d.promise; - } - var _this = this; - this.resourceArchive = []; - - this.updateResourceArchive = function() { - var credentialArchivePromise = doQuery(CredentialArchive), - serviceArchivePromise = doQuery(ServiceArchive); - $q.all([credentialArchivePromise, serviceArchivePromise]).then(function(results) { - var credentialArchive = results[0].credentials, - serviceArchive = results[1].services; - for (var i = credentialArchive.length; i--;) { - credentialArchive[i].type = 'credential'; - } - for (var i = serviceArchive.length; i--;) { - serviceArchive[i].type = 'service'; - serviceArchive[i].name = serviceArchive[i].id.split('-')[0]; - } - _this.resourceArchive = credentialArchive.concat(serviceArchive); - }, function() { - _this.resourceArchive = []; - }); - }; - - this.getResourceArchive = function() { - return _this.resourceArchive; - }; - - }]) - - ; - -})(window.angular, window._); diff --git a/confidant/public/modules/history/services/services.js b/confidant/public/modules/history/services/services.js deleted file mode 100644 index b7e9a7bf..00000000 --- a/confidant/public/modules/history/services/services.js +++ /dev/null @@ -1,17 +0,0 @@ -(function(angular) { - 'use strict'; - - - /** - * This module requires all common services. - * - * It mainly provides a convenient way to import all common services by only - * requiring a dependency on a single module. - * - */ - angular.module('confidant.history.services', [ - // Keep this list sorted alphabetically! - 'confidant.history.services.archive' - ]) - ; -}(angular)); diff --git a/confidant/public/modules/history/views/credential-history.html b/confidant/public/modules/history/views/credential-history.html deleted file mode 100644 index f60c4dad..00000000 --- a/confidant/public/modules/history/views/credential-history.html +++ /dev/null @@ -1,90 +0,0 @@ -
-

{{ saveError }}

-
-

The following credential pair keys conflict in the listed credentials:

- -

Please ensure credential pair keys are unique, then try again.

-
-
-
-

Difference between revisions of {{ currentCredential.name }}

-
- previous revision - next revision -
-
-
-
-
Revision {{ diffRevision }}
-
Name
-
-

{{ diffCredential.name }}

-
-
Credential Pairs
-
- - - - - - - - - - - - - -
KeyValue
{{ key }}
{{ val }}
-
-
-
-
No other revision.
-
-
-
-
Current revision
-
Name
-
-

{{ currentCredential.name }}

-
-
Credential Pairs
-
- - - - - - - - - - - - - -
KeyValue
{{ key }}
{{ val }}
-
-
-
-
-

This is the only revision of this credential. You'll need to edit the credential to make any changes.

-
-

This is the current revision of this credential. The above diff is between the current revision and the previous revision.

- -
-
-
- -
-
diff --git a/confidant/public/modules/history/views/history.html b/confidant/public/modules/history/views/history.html new file mode 100644 index 00000000..7b204631 --- /dev/null +++ b/confidant/public/modules/history/views/history.html @@ -0,0 +1 @@ +Test history! diff --git a/confidant/public/modules/history/views/resources.html b/confidant/public/modules/history/views/resources.html deleted file mode 100644 index cad331d9..00000000 --- a/confidant/public/modules/history/views/resources.html +++ /dev/null @@ -1,33 +0,0 @@ -
-
-
-
-
- -
-
-
-
-
- - - - - - - - - - - - - - - - -
TypeNameRevisionModified
{{ resource.type }}{{ resource.name }}{{ resource.revision }}{{ resource.modified_date }}
-
-
-
-

No resource selected.

-
diff --git a/confidant/public/modules/history/views/service-history.html b/confidant/public/modules/history/views/service-history.html deleted file mode 100644 index 4784bdf0..00000000 --- a/confidant/public/modules/history/views/service-history.html +++ /dev/null @@ -1,60 +0,0 @@ -
-

{{ saveError }}

-
-

The following credential pair keys conflict in the listed credentials:

- -

Please ensure credential pair keys are unique, then try again.

-
-
-
-

Difference between revisions of {{ serviceId }}

-
- previous revision - next revision -
-
-
-
-
Revision {{ diffRevision }}
-
credentials
-
-
    -
  • {{ getCredentialName(credential) }}
  • -
-
-
-
-
No other revision.
-
-
-
-
Current revision
-
credentials
-
-
    -
  • {{ getCredentialName(credential) }}
  • -
-
-
-
-
-

This is the only revision of this service. You'll need to edit the service to make any changes.

-
-

This is the current revision of this service. The above diff is between the current revision and the previous revision.

- -
-
-
- -
-
diff --git a/confidant/public/modules/resources/services/confidantservices.js b/confidant/public/modules/resources/services/confidantservices.js index 55ebc497..441d10bf 100644 --- a/confidant/public/modules/resources/services/confidantservices.js +++ b/confidant/public/modules/resources/services/confidantservices.js @@ -10,20 +10,12 @@ return $resource(CONFIDANT_URLS.SERVICES); }]) - .factory('services.archiveList', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { - return $resource(CONFIDANT_URLS.ARCHIVE_SERVICES); - }]) - .factory('services.service', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { return $resource(CONFIDANT_URLS.SERVICE, {id: '@id'}, { update: {method: 'PUT', isArray: false} }); }]) - .factory('services.archiveServiceRevisions', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { - return $resource(CONFIDANT_URLS.ARCHIVE_SERVICE_REVISIONS, {id: '@id'}); - }]) - .factory('services.services', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { return $resource(CONFIDANT_URLS.SERVICES, {}, { create: {method: 'POST', isArray: false} diff --git a/confidant/public/modules/resources/services/credentials.js b/confidant/public/modules/resources/services/credentials.js index 964ad104..31007d07 100644 --- a/confidant/public/modules/resources/services/credentials.js +++ b/confidant/public/modules/resources/services/credentials.js @@ -13,20 +13,12 @@ return $resource(CONFIDANT_URLS.CREDENTIALS); }]) - .factory('credentials.archiveList', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { - return $resource(CONFIDANT_URLS.ARCHIVE_CREDENTIALS); - }]) - .factory('credentials.credential', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { return $resource(CONFIDANT_URLS.CREDENTIAL, {id: '@id'}, { update: {method: 'PUT', isArray: false} }); }]) - .factory('credentials.archiveCredentialRevisions', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { - return $resource(CONFIDANT_URLS.ARCHIVE_CREDENTIAL_REVISIONS, {id: '@id'}); - }]) - .factory('credentials.credentials', ['$resource', 'CONFIDANT_URLS', function($resource, CONFIDANT_URLS) { return $resource(CONFIDANT_URLS.CREDENTIALS, {}, { create: {method: 'POST', isArray: false} diff --git a/confidant/public/modules/routes/history.js b/confidant/public/modules/routes/history.js index 5e76eabe..b2ca6aa8 100644 --- a/confidant/public/modules/routes/history.js +++ b/confidant/public/modules/routes/history.js @@ -2,8 +2,7 @@ 'use strict'; angular.module('confidant.routes.history', [ - 'ui.router', - 'confidant.history' + 'ui.router' ]) .config(['$stateProvider', function($stateProvider) { @@ -13,8 +12,7 @@ url: '/history', views: { main: { - controller: 'history.ResourceHistoryCtrl', - templateUrl: '/modules/history/views/resources.html' + templateUrl: '/modules/history/views/history.html' } }, data: { @@ -22,32 +20,6 @@ } }) - .state('history.credential-history', { - url: '/credential/:credentialId', - views: { - 'details': { - controller: 'history.CredentialHistoryCtrl', - templateUrl: '/modules/history/views/credential-history.html' - } - }, - data: { - viewLocation: 'history', - } - }) - - .state('history.service-history', { - url: '/service/:serviceId', - views: { - 'details': { - controller: 'history.ServiceHistoryCtrl', - templateUrl: '/modules/history/views/service-history.html' - } - }, - data: { - viewLocation: 'history', - } - }) - ; }]) diff --git a/confidant/public/styles/main.scss b/confidant/public/styles/main.scss index 88febfd0..020c6d60 100644 --- a/confidant/public/styles/main.scss +++ b/confidant/public/styles/main.scss @@ -45,19 +45,9 @@ body { .row-overflow-resources { position: relative; overflow-y: auto; - // subtract number of pixels between the overflow element and its parent - // container (height of object between them). height: calc(100% - 50px); } -.row-overflow-history-resources { - position: relative; - overflow-y: auto; - // subtract number of pixels between the overflow element and its parent - // container (height of object between them). - height: calc(100% - 80px); -} - .row-overflow { position: relative; overflow-y: auto; diff --git a/confidant/routes/v1.py b/confidant/routes/v1.py index 20c40f20..7e085041 100644 --- a/confidant/routes/v1.py +++ b/confidant/routes/v1.py @@ -197,38 +197,6 @@ def get_service(id): }) -@app.route('/v1/archive/services/', methods=['GET']) -@authnz.require_auth -def get_archive_service_revisions(id): - try: - service = Service.get(id) - except Service.DoesNotExist: - return jsonify({}), 404 - if (service.data_type != 'service' and - service.data_type != 'archive-service'): - return jsonify({}), 404 - revisions = [] - _range = range(1, service.revision + 1) - ids = [] - for i in _range: - ids.append("{0}-{1}".format(id, i)) - for revision in Service.batch_get(ids): - revisions.append({ - 'id': revision.id, - 'revision': revision.revision, - 'credentials': list(revision.credentials), - 'modified_date': revision.modified_date, - 'modified_by': revision.modified_by - }) - return jsonify({ - 'revisions': sorted( - revisions, - key=lambda k: k['revision'], - reverse=True - ) - }) - - @app.route('/v1/archive/services', methods=['GET']) @authnz.require_auth def get_archive_service_list(): @@ -376,38 +344,6 @@ def get_credential(id): }) -@app.route('/v1/archive/credentials/', methods=['GET']) -@authnz.require_auth -def get_archive_credential_revisions(id): - try: - cred = Credential.get(id) - except Credential.DoesNotExist: - return jsonify({}), 404 - if (cred.data_type != 'credential' and - cred.data_type != 'archive-credential'): - return jsonify({}), 404 - revisions = [] - _range = range(1, cred.revision + 1) - ids = [] - for i in _range: - ids.append("{0}-{1}".format(id, i)) - for revision in Credential.batch_get(ids): - revisions.append({ - 'id': revision.id, - 'name': revision.name, - 'revision': revision.revision, - 'modified_date': revision.modified_date, - 'modified_by': revision.modified_by - }) - return jsonify({ - 'revisions': sorted( - revisions, - key=lambda k: k['revision'], - reverse=True - ) - }) - - @app.route('/v1/archive/credentials', methods=['GET']) @authnz.require_auth def get_archive_credential_list():