code: def build_default_endpoint_prefixes(records_rest_endpoints):
      
      pid_types = set()
      guessed = set()
      endpoint_prefixes = {}
  
      for key, endpoint in records_rest_endpoints.items():
          pid_type = endpoint['pid_type']
          pid_types.add(pid_type)
          is_guessed = key == pid_type
          is_default = endpoint.get('default_endpoint_prefix', False)
  
          if is_default:
              if pid_type in endpoint_prefixes and pid_type not in guessed:
                  raise ValueError('More than one "{0}" defined.'.format(
                      pid_type
                  ))
              endpoint_prefixes[pid_type] = key
              guessed -= {pid_type}
          elif is_guessed and pid_type not in endpoint_prefixes:
              endpoint_prefixes[pid_type] = key
              guessed |= {pid_type}
  
      not_found = pid_types - set(endpoint_prefixes.keys())
      if not_found:
          raise ValueError('No endpoint-prefix for {0}.'.format(
              ', '.join(not_found)
          ))
  
      return endpoint_prefixes
docs: Build the default_endpoint_prefixes map.