mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-29 04:09:07 -04:00
Put API keys on service model
Similar to how we put templates on the service model, it means less logic needs to happen in the view code.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from notifications_utils.field import Field
|
||||
from werkzeug.utils import cached_property
|
||||
|
||||
from app.notify_client.api_key_api_client import api_key_api_client
|
||||
from app.notify_client.billing_api_client import billing_api_client
|
||||
from app.notify_client.email_branding_client import email_branding_client
|
||||
from app.notify_client.inbound_number_client import inbound_number_client
|
||||
@@ -335,3 +336,11 @@ class Service():
|
||||
template_ids=ids_to_move & self.all_template_ids,
|
||||
folder_ids=ids_to_move & self.all_template_folder_ids,
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def api_keys(self):
|
||||
return api_key_api_client.get_api_keys(self.id)['apiKeys']
|
||||
|
||||
@property
|
||||
def api_key_names(self):
|
||||
return [key['name'] for key in self.api_keys]
|
||||
|
||||
Reference in New Issue
Block a user