docstr: This function is used to retrieve the current url associated with an id.
docstr_tok: ["This","function","is","used","to","retrieve","the","current","url","associated","with","an","id","."]
code: def _collect_open_api_json(self):
      """This function is used to retrieve the current url associated with an id."""
      if _is_url(self.app_id_or_name_or_url):
          self.url = self.app_id_or_name_or_url
          assert self.url
          resp = requests.get(self.url + "/openapi.json")
          if resp.status_code != 200:
              print(
                  f"ERROR: The server didn't process the request properly. Found {resp.json()}"
              )
              sys.exit(0)
          self.openapi = resp.json()
          return
  
      # 2: If no identifier has been provided, evaluate the local application
      if self.app_id_or_name_or_url is None:
          with contextlib.suppress(requests.exceptions.ConnectionError):
              self.url = f"http://localhost:{APP_SERVER_PORT}"
              resp = requests.get(f"{self.url}/openapi.json")
              if resp.status_code != 200:
                  raise Exception(
                      f"The server didn't process the request properly. Found {resp.json()}"
                  )
              self.openapi = resp.json()
  
      # 3: If an identified was provided or the local evaluation has failed, evaluate the cloud.
      else:
          app = self._maybe_find_matching_cloud_app()
          if app:
              if app.status.url == "":
                  raise Exception(
                      "The application is starting. Try in a few moments."
                  )
              resp = requests.get(app.status.url + "/openapi.json")
              if resp.status_code != 200:
                  raise Exception(
                      "The server didn't process the request properly. "
                      "Try once your application is ready."
                  )
              self.url = app.status.url
              self.openapi = resp.json()
              self.app_id = app.id
              self.app_name = _get_app_display_name(app)
  
imports: import contextlib
  import functools
  import json
  import os
  import re
  import subprocess
  import sys
  from typing import Dict, Optional
  import arrow
  import click
  import packaging
  import requests
  import rich
  from lightning_cloud.openapi import Externalv1LightningappInstance
  from lightning.app import __package_name__, __version__
  from lightning.app.core.constants import APP_SERVER_PORT
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.cloud import _get_project
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 5 for calling the _LightningAppOpenAPIRetriever obj's underlying member method code with example usage: obj._collect_open_api_json() without return types