"""Interface to the ows-product-workflow microservice.""" from oto import response from owsrequest import request from backend.constants import services def get_last_release_correction(product_id, correlation_id): """Get the last release correction for the given product id. Args: product_id (int): unique identifier for the product correlation_id (str): correlation id for logs Returns: Response containing the properties of the last release correction. """ ows_product_workflow_response = request.get( services.OWS_PRODUCT_WORKFLOW, '/product/{}/correction'.format(product_id), correlation_id=correlation_id ) info_body = ows_product_workflow_response.json() if ows_product_workflow_response.status_code not in (200, 404): return response.create_error_response( status=ows_product_workflow_response.status_code, code=info_body.get('code'), message=info_body.get('message')) return response.Response( message=info_body, status=ows_product_workflow_response.status_code)