def get_analysis_protocol(
    analysis_protocol_url, auth_headers, protocol_id, http_requests
):
    """Checks the submission envelope for an analysis_protocol with a protocol_id that matches the pipeline version.

    Args:
        analysis_protocol_url (str): The url for creating the analysis_protocol.
        auth_headers (dict): Dict representing headers to use for auth.
        protocol_id (str): Required field of the analysis_protocol, the version of the given pipeline.
        http_requests (http_requests.HttpRequests): The HttpRequests object to use for talking to Ingest.

    Returns:
        protocol (dict or None): A dict represents the analysis_protocol.

    Raises:
        requests.HTTPError: For 4xx errors or 5xx errors beyond timeout.
    """
    response = http_requests.get(analysis_protocol_url, headers=auth_headers)
    content = response.json().get('_embedded')

    if content:
        for protocol in content.get('protocols'):
            if protocol['content']['protocol_core']['protocol_id'] == protocol_id:
                print(
                    'Found existing analysis_protocol for pipeline version {0} in {1}'.format(
                        protocol_id, analysis_protocol_url
                    )
                )
                return protocol

    print("Cannot find any existing analysis_protocol with id: {0}".format(protocol_id))
    return None