def start_discovery()

in blueprints/cloud-operations/network-quota-monitoring/src/plugins/core-discover-cai-nodes.py [0:0]


def start_discovery(resources, response=None, data=None):
  'Plugin entry point, triggers discovery and handles requests and responses.'
  LOGGER.info(f'discovery (has response: {response is not None})')
  if response is None:
    # return initial discovery URLs
    if not resources['config:folders'] and not resources['config:projects']:
      LOGGER.info(
          f'No monitored project or folder given, defaulting to discovery root: {resources["config:discovery_root"]}'
      )
      dr_node = resources["config:discovery_root"].split("/")[0]
      dr_value = resources["config:discovery_root"].split("/")[1]
      yield HTTPRequest(CAI_URL.format(f'{dr_node}/{dr_value}'), {}, None)
    for v in resources['config:folders']:
      yield HTTPRequest(CAI_URL.format(f'folders/{v}'), {}, None)
    for v in resources['config:projects']:
      if v not in resources['projects']:
        yield HTTPRequest(CAI_URL.format(f'projects/{v}'), {}, None)