docstr: This class encapsulates the logic to collect the openapi.json file from the app to use the CLI Commands.
  
  Arguments:
      app_id_or_name_or_url: An identified for the app.
      use_cache: Whether to load the openapi spec from the cache.
docstr_tok: ["This","class","encapsulates","the","logic","to","collect","the","openapi.json","file","from","the","app","to","use","the","CLI","Commands",".","Arguments",":","app_id_or_name_or_url",":","An","identified","for","the","app",".","use_cache",":","Whether","to","load","the","openapi","spec","from","the","cache","."]
code: def __init__(
      self,
      app_id_or_name_or_url: Optional[str],
      use_cache: bool = False,
  ):
      """This class encapsulates the logic to collect the openapi.json file from the app to use the CLI Commands.
  
      Arguments:
          app_id_or_name_or_url: An identified for the app.
          use_cache: Whether to load the openapi spec from the cache.
  
      """
      self.app_id_or_name_or_url = app_id_or_name_or_url
      self.url = None
      self.openapi = None
      self.api_commands = None
      self.app_id = None
      self.app_name = None
      home = os.path.expanduser("~")
      if use_cache:
          cache_openapi = os.path.join(
              home,
              ".lightning",
              "lightning_connection",
              "commands",
              "openapi.json",
          )
          if os.path.exists(cache_openapi):
              with open(cache_openapi) as f:
                  self.openapi = json.load(f)
              self.api_commands = _extract_command_from_openapi(
                  self.openapi
              )
  
      if not self.api_commands:
          self._collect_open_api_json()
          if self.openapi:
              self.api_commands = _extract_command_from_openapi(
                  self.openapi
              )
  
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 1 to create a new _LightningAppOpenAPIRetriever object  with example: obj = _LightningAppOpenAPIRetriever(app_id_or_name_or_url, use_cache)