mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
This is the first PR in the story to create a suspend service feature.
- Renaming /service/<id>/deactivate to /service/<id>/archive to match language on the UI. - Will need to update admin before deleting the deactive service method - Created dao and endpoint methods to suspend and resume a service. - I confirm the use of suspend and resume with a couple people on the team, seems to be the right choice. The idea is that if you archive a service there is no coming back from that. To suspend a service is marking it as inactive and revoking the api keys. To resume a service is to mark the service as active, the service will need to create new API keys. It makes sense that if a service is under threat that the API keys should be renewed. The next PR will update the code to check that the service is active before sending the request or allowing any actions by the service.
This commit is contained in:
@@ -27,9 +27,10 @@ from app.dao.services_dao import (
|
||||
dao_fetch_todays_stats_for_service,
|
||||
dao_fetch_weekly_historical_stats_for_service,
|
||||
dao_fetch_todays_stats_for_all_services,
|
||||
dao_deactive_service,
|
||||
fetch_stats_by_date_range_for_all_services
|
||||
)
|
||||
dao_archive_service,
|
||||
fetch_stats_by_date_range_for_all_services,
|
||||
dao_suspend_service,
|
||||
dao_resume_service)
|
||||
from app.dao.service_whitelist_dao import (
|
||||
dao_fetch_service_whitelist,
|
||||
dao_add_and_commit_whitelisted_contacts,
|
||||
@@ -335,6 +336,7 @@ def update_whitelist(service_id):
|
||||
return '', 204
|
||||
|
||||
|
||||
# Renaming this endpoint to archive
|
||||
@service_blueprint.route('/<uuid:service_id>/deactivate', methods=['POST'])
|
||||
def deactivate_service(service_id):
|
||||
service = dao_fetch_service_by_id(service_id)
|
||||
@@ -343,7 +345,63 @@ def deactivate_service(service_id):
|
||||
# assume already inactive, don't change service name
|
||||
return '', 204
|
||||
|
||||
dao_deactive_service(service.id)
|
||||
dao_archive_service(service.id)
|
||||
|
||||
return '', 204
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/archive', methods=['POST'])
|
||||
def archive_service(service_id):
|
||||
"""
|
||||
When a service is archived the service is made inactive, templates are archived and api keys are revoked.
|
||||
There is no coming back from this operation.
|
||||
:param service_id:
|
||||
:return:
|
||||
"""
|
||||
service = dao_fetch_service_by_id(service_id)
|
||||
|
||||
if not service.active:
|
||||
# assume already inactive, don't change service name
|
||||
return '', 204
|
||||
|
||||
dao_archive_service(service.id)
|
||||
|
||||
return '', 204
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/suspend', methods=['POST'])
|
||||
def suspend_service(service_id):
|
||||
"""
|
||||
Suspending a service will mark the service as inactive and revoke API keys.
|
||||
:param service_id:
|
||||
:return:
|
||||
"""
|
||||
service = dao_fetch_service_by_id(service_id)
|
||||
|
||||
if not service.active:
|
||||
# assume already inactive, don't change service name
|
||||
return '', 204
|
||||
|
||||
dao_suspend_service(service.id)
|
||||
|
||||
return '', 204
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/resume', methods=['POST'])
|
||||
def resume_service(service_id):
|
||||
"""
|
||||
Resuming a service that has been suspended will mark the service as active.
|
||||
The service will need to re-create API keys
|
||||
:param service_id:
|
||||
:return:
|
||||
"""
|
||||
service = dao_fetch_service_by_id(service_id)
|
||||
|
||||
if service.active:
|
||||
# assume already inactive, don't change service name
|
||||
return '', 204
|
||||
|
||||
dao_resume_service(service.id)
|
||||
|
||||
return '', 204
|
||||
|
||||
|
||||
Reference in New Issue
Block a user