mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Don’t do multiple get API calls when revoking
It’s redundant to make two API calls here, one to get all keys and one to get a single key. Since the API calls are sequential we can speed things up by getting the one key from the list of all keys.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from flask import abort
|
||||
from notifications_utils.field import Field
|
||||
from werkzeug.utils import cached_property
|
||||
|
||||
@@ -344,3 +345,9 @@ class Service():
|
||||
@property
|
||||
def api_key_names(self):
|
||||
return [key['name'] for key in self.api_keys]
|
||||
|
||||
def get_api_key(self, id):
|
||||
try:
|
||||
return next(key for key in self.api_keys if key['id'] == id)
|
||||
except StopIteration:
|
||||
abort(404)
|
||||
|
||||
Reference in New Issue
Block a user