"""Header utils.""" from flask import request from oto import response from owsrequest import flask_request def verify_grass_ownership(method, *args, **kwargs): """Verify grass ownership of a request. Methods that are being passed to the Grass Ownership method must includes a named param: `account_type` and `account_id`. Args: method (callable): the method to call with the args and kwargs. args (list): list of params to provide to the method that is being called. kwargs (dict): additional set of data to provide to the method to call. Returns: Response: owernship information. """ account_type, account_id = flask_request.get_grass_headers(request) if any([account_type, account_id]): return method( *args, account_type=account_type, account_id=account_id, **kwargs) return response.Response()