The decorator to convert an XML response to JSON, if the request is
    determined to be from boto3. Pass the API action as a parameter.

def generate_boto3_response(operation):
    """The decorator to convert an XML response to JSON, if the request is
    determined to be from boto3. Pass the API action as a parameter.

    """
    def _boto3_request(method):
        @wraps(method)
        def f(self, *args, **kwargs):
            rendered = method(self, *args, **kwargs)
            if 'json' in self.headers.get('Content-Type', []):
                self.response_headers.update(
                    {'x-amzn-requestid': '2690d7eb-ed86-11dd-9877-6fad448a8419',
                     'date': datetime.now(pytz.utc).strftime('%a, %d %b %Y %H:%M:%S %Z'),
                     'content-type': 'application/x-amz-json-1.1'})
                resp = xml_to_json_response(
                    self.aws_service_spec, operation, rendered)
                return '' if resp is None else json.dumps(resp)
            return rendered
        return f
    return _boto3_request