""" Interface to the ows-product microservice. The model is responsible to make a call to a ows-product microservice. It makes a request to ows-product endpoint ('/upc/'', methods=['HEAD']) and returns a result of the request. """ from owsrequest import request from contracts import response PRODUCT_UPC_RESOURCE = '/upc/{upc}' PRODUCT_SERVICE = 'ows-product' def validate_upc(upc): """Check if a product exists with the given UPC. Args: upc (string): upc Returns: response.Response: status """ resource = PRODUCT_UPC_RESOURCE.format(upc=upc) account_response = request.head(PRODUCT_SERVICE, resource) if account_response.status_code == 200: return response.create_status_ok_response() return response.create_not_found_response('provided upc not found')