code: def has_scan_errors(digest, pid, api_key):
      """
      Waits for image scan to complete and checks the results. Prints errors found.
  
      :param digest: A digest of the docker image to check errors of
      :param pid: Project identified (PID) from Red Hat Connect portal
      :param api_key: API Key associated with the Red Hat account. Considered secret.
      :return: True if errors are found, otherwise false.
      """
      url = "https://connect.redhat.com/api/v2/container/{}/certResults/{}".format(
          pid, digest
      )
      headers = {
          "accept": "*/*",
          "Authorization": "Bearer {}".format(api_key),
      }
  
      # Wait for HTTP 200 Response from the certification results endpoint
      response = None
      while response is None:
          intermediate_response = requests.get(url=url, headers=headers)
          if intermediate_response.status_code == 200:
              response = intermediate_response
          else:
              time.sleep(5)
  
      # Iterate over scan results, print them and search for erroneous states
      scan_err_present = False
      print("Scan of image '{}' complete.".format(digest))
      for requirement, check_result in response.json()["data"][
          "results"
      ].items():
          print("{}: {}".format(requirement, check_result))
          if not check_result:
              scan_err_present = True
  
      if scan_err_present:
          print(
              "Scan errors found. Please address the issues and push the image again."
          )
  
      return scan_err_present
  
imports: import argparse
  import sys
  import time
  import requests
label_desc: Use image node_id 1 for calling a global function with example usage: has_scan_errors(digest, pid, api_key) and returns: scan_err_present