"""Utility Functions for Handlers.""" from asset_file_details.constants import header from asset_file_details.models import ows_product def get_grass_headers(request): """Extract grass headers from the request. Args: request (Flask.request): the request. Returns: tuple: contains grass account type and grass account id. """ header_account_type = request.headers.get(header.GRASS_ACCOUNT_TYPE) header_account_id = request.headers.get(header.GRASS_ACCOUNT_ID) return (header_account_type, header_account_id) def check_product_ownership(upc, account_type, account_id, correlation_id): """Check if product is owned by the given account. Args: product_id (int): the id of the product to check account_type (str): type of account (vendor or subaccount) account_id (int): id of the account to check Returns: response.Response: status code 200 if owner, 403 if not owner """ return ows_product.check_ownership( upc, account_type, account_id, correlation_id)