Skip to content

APR-81_1: Check Duplicates #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/common/vips_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def status_get(prohibition_id: str, config, correlation_id='abcd') -> tuple:
return True, data
return False, dict({})

def duplicate_get(prohibition_id: str, config, correlation_id='abcd'):
endpoint = build_endpoint(config.VIPS_API_ROOT_URL, 'application', 'notice', prohibition_id, correlation_id)
is_response_successful, data = get(endpoint, config.VIPS_API_USERNAME, config.VIPS_API_PASSWORD, correlation_id)
if 'resp' in data:
return True, data
return False, dict({})

def disclosure_get(document_id: str, config, correlation_id='abcd'):
endpoint = build_endpoint(config.VIPS_API_ROOT_URL, document_id, 'disclosure', correlation_id)
Expand Down
18 changes: 17 additions & 1 deletion python/ingestor/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import python.common.helper as helper
import python.common.vips_api as vips
from python.ingestor.config import Config
from python.common.rabbitmq import RabbitMQ
from python.common.message import encode_message
Expand Down Expand Up @@ -124,7 +125,6 @@ def evidence():
}
}))


@application.route('/check', methods=['GET'])
def check():
"""
Expand Down Expand Up @@ -159,6 +159,22 @@ def check_templates():
templates=rsi_email.content_data()
)

@application.route('/duplicate', methods=['GET'])
@basic_auth_required
def check_duplicate():

prohibition_number = request.args.get('prohibition_number')

is_api_callout_successful, vips_duplicate_data = vips.duplicate_get(
prohibition_id=prohibition_number,
config=Config)
if is_api_callout_successful:
return vips_duplicate_data
error = 'the VIPS get_duplicate operation returned an invalid response'
args['error_string'] = "The system is down, please try again later."
logging.info(error)
return False, args


if __name__ == "__main__":
application.run(host='0.0.0.0')