class_docstr: So we could provide handling for URLs with corresponding credentials
  and specific (reusable) downloader.  Internally it contains
  Providers and interfaces them based on a given URL.  Each provider
  in turn takes care about associated with it Downloader.
class_docstr_tok: ["So","we","could","provide","handling","for","URLs","with","corresponding","credentials","and","specific","(","reusable",")","downloader",".","Internally","it","contains","Providers","and","interfaces","them","based","on","a","given","URL",".","Each","provider","in","turn","takes","care","about","associated","with","it","Downloader","."]
docstr: Create new provider and credential config
  
  If interactive, this will ask the user to enter the details (or confirm
  default choices). A dedicated config file is written at
  <user_config_dir>/providers/<name>.cfg
  
  Parameters:
  -----------
  url: str or RI
    URL this config is created for
  auth_types: list
    List of authentication types to choose from. First entry becomes
    default. See datalad.downloaders.providers.AUTHENTICATION_TYPES
  url_re: str
    regular expression; Once created, this config will be used for any
    matching URL; defaults to `url`
  name: str
    name for the provider; needs to be unique per user
  credential_name: str
    name for the credential; defaults to the provider's name
  credential_type: str
    credential type to use (key for datalad.downloaders.CREDENTIAL_TYPES)
code: def enter_new(
      self,
      url=None,
      auth_types=[],
      url_re=None,
      name=None,
      credential_name=None,
      credential_type=None,
  ):
      # TODO: level/location!
      """Create new provider and credential config
  
      If interactive, this will ask the user to enter the details (or confirm
      default choices). A dedicated config file is written at
      <user_config_dir>/providers/<name>.cfg
  
      Parameters:
      -----------
      url: str or RI
        URL this config is created for
      auth_types: list
        List of authentication types to choose from. First entry becomes
        default. See datalad.downloaders.providers.AUTHENTICATION_TYPES
      url_re: str
        regular expression; Once created, this config will be used for any
        matching URL; defaults to `url`
      name: str
        name for the provider; needs to be unique per user
      credential_name: str
        name for the credential; defaults to the provider's name
      credential_type: str
        credential type to use (key for datalad.downloaders.CREDENTIAL_TYPES)
      """
  
      from datalad.ui import ui
  
      if url and not name:
          ri = RI(url)
          for f in ("hostname", "name"):
              try:
                  # might need sanitarization
                  name = str(getattr(ri, f))
              except AttributeError:
                  pass
      known_providers_by_name = {p.name: p for p in self._providers}
      providers_user_dir = self._get_providers_dirs()["user"]
      while True:
          name = ui.question(
              title="New provider name",
              text="Unique name to identify 'provider' for %s" % url,
              default=name,
          )
          filename = pathjoin(providers_user_dir, "%s.cfg" % name)
          if name in known_providers_by_name:
              if ui.yesno(
                  title="Known provider %s" % name,
                  text="Provider with name %s already known. Do you want to "
                  "use it for this session?" % name,
                  default=True,
              ):
                  return known_providers_by_name[name]
          elif path.lexists(filename):
              ui.error(
                  "File %s already exists, choose another name"
                  % filename
              )
          else:
              break
  
      if not credential_name:
          credential_name = name
      if not url_re:
          url_re = re.escape(url) if url else None
      while True:
          url_re = ui.question(
              title="New provider regular expression",
              text="A (Python) regular expression to specify for which URLs "
              "this provider should be used",
              default=url_re,
          )
          if not re.match(url_re, url):
              ui.error(
                  "Provided regular expression doesn't match original "
                  "url.  Please re-enter"
              )
          # TODO: url_re of another provider might match it as well
          #  I am not sure if we have any kind of "priority" setting ATM
          #  to differentiate or to to try multiple types :-/
          else:
              break
  
      authentication_type = None
      if auth_types:
          auth_types = [
              t for t in auth_types if t in AUTHENTICATION_TYPES
          ]
          if auth_types:
              authentication_type = auth_types[0]
  
      # Setup credential
      authentication_type = ui.question(
          title="Authentication type",
          text="What authentication type to use",
          default=authentication_type,
          choices=sorted(AUTHENTICATION_TYPES),
      )
      authenticator_class = AUTHENTICATION_TYPES[authentication_type]
  
      # TODO: need to figure out what fields that authenticator might
      #       need to have setup and ask for them here!
  
      credential_type = ui.question(
          title="Credential",
          text="What type of credential should be used?",
          choices=sorted(CREDENTIAL_TYPES),
          default=credential_type
          or getattr(authenticator_class, "DEFAULT_CREDENTIAL_TYPE"),
      )
  
      cfg = self._CONFIG_TEMPLATE.format(**locals())
      if ui.yesno(
          title="Save provider configuration file",
          text="Following configuration will be written to %s:\n%s"
          % (filename, cfg),
          default="yes",
      ):
          # Just create a configuration file and reload the thing
          return self._store_new(
              url=url,
              authentication_type=authentication_type,
              authenticator_class=authenticator_class,
              url_re=url_re,
              name=name,
              credential_name=credential_name,
              credential_type=credential_type,
              level="user",
          )
      else:
          return None
  
imports: from glob import glob
  from logging import getLogger
  import re
  from os.path import dirname, abspath, join
  from urllib.parse import urlparse
  from .base import NoneAuthenticator, NotImplementedAuthenticator
  from .http import HTMLFormAuthenticator, HTTPAnonBearerTokenAuthenticator, HTTPAuthAuthenticator, HTTPBasicAuthAuthenticator, HTTPDigestAuthAuthenticator, HTTPBearerTokenAuthenticator, HTTPDownloader
  from .s3 import S3Authenticator, S3Downloader
  from .shub import SHubDownloader
  from configparser import ConfigParser
  from datalad.support.external_versions import external_versions
  from datalad.support.network import RI
  from datalad.support import path
  from datalad.utils import auto_repr, ensure_list_from_str, get_dataset_root, Path
  from ..interface.common_cfg import dirs
  from datalad.downloaders import CREDENTIAL_TYPES
label_desc: Use image node_id 15 for calling the Providers obj's underlying member method code with example usage: obj.enter_new(url, auth_types, url_re, name, credential_name, credential_type) and returns: self, None, known_providers_by_name