Ejemplo n.º 1
0
def configure(version):
    profile = get_profile_from_context()
    config = ProfileConfigProvider(
        profile).get_config() if profile else get_config()
    new_config = config or DatabricksConfig.empty()
    new_config.jobs_api_version = version
    update_and_persist_config(profile, new_config)
Ejemplo n.º 2
0
def configure_cli(token, aad_token, insecure, host, token_file,
                  jobs_api_version, oauth, scope):
    """
    Configures host, authentication, and jobs-api version for the CLI.
    """
    profile = get_profile_from_context()
    insecure_str = str(insecure) if insecure is not None else None

    if token:
        _configure_cli_token(profile=profile,
                             insecure=insecure_str,
                             host=host,
                             jobs_api_version=jobs_api_version)
    elif token_file:
        _configure_cli_token_file(profile=profile,
                                  insecure=insecure_str,
                                  host=host,
                                  token_file=token_file,
                                  jobs_api_version=jobs_api_version)
    elif oauth:
        _configure_cli_oauth(profile=profile,
                             insecure=insecure_str,
                             host=host,
                             scope=scope,
                             jobs_api_version=jobs_api_version)
    elif aad_token:
        _configure_cli_aad_token(profile=profile,
                                 insecure=insecure_str,
                                 host=host,
                                 jobs_api_version=jobs_api_version)
    else:
        _configure_cli_password(profile=profile,
                                insecure=insecure_str,
                                host=host,
                                jobs_api_version=jobs_api_version)
Ejemplo n.º 3
0
def configure_cli(token):
    """
    Configures host and authentication info for the CLI.
    """
    profile = get_profile_from_context()
    if token:
        _configure_cli_token(profile)
    else:
        _configure_cli_password(profile)
Ejemplo n.º 4
0
def configure_cli(token, insecure):
    """
    Configures host and authentication info for the CLI.
    """
    profile = get_profile_from_context()
    insecure_str = str(insecure) if insecure is not None else None
    if token:
        _configure_cli_token(profile, insecure_str)
    else:
        _configure_cli_password(profile, insecure_str)
Ejemplo n.º 5
0
def setup(token, insecure):
    """
    Configures host and authentication info for the Databricks CLI.
    """
    profile = get_profile_from_context()
    insecure_str = str(insecure) if insecure is not None else None
    if token:
        _configure_cli_token(profile, insecure_str)

    return None
Ejemplo n.º 6
0
 def decorator(*args, **kwargs):
     ctx = click.get_current_context()
     command_name = "-".join(ctx.command_path.split(" ")[1:])
     command_name += "-" + str(uuid.uuid1())
     profile = get_profile_from_context()
     if profile:
         # If we request a specific profile, only get credentials from tere.
         config = ProfileConfigProvider(profile).get_config()
     else:
         raise ValueError("Please provide profile field")
     if not config or not config.is_valid:
         raise InvalidConfigurationError.for_profile(profile)
     os.environ["DATABRICKS_HOST"] = config.host
     os.environ["DATABRICKS_TOKEN"] = config.token
     return function(*args, **kwargs)
Ejemplo n.º 7
0
def configure_cli(token, aad_token, insecure, host, token_file):
    """
    Configures host and authentication info for the CLI.
    """
    profile = get_profile_from_context()
    insecure_str = str(insecure) if insecure is not None else None

    if token:
        _configure_cli_token(profile=profile, insecure=insecure_str, host=host)
    elif token_file:
        _configure_cli_token_file(profile=profile, insecure=insecure_str, host=host,
                                  token_file=token_file)
    elif aad_token:
        _configure_cli_aad_token(profile=profile, insecure=insecure_str, host=host)
    else:
        _configure_cli_password(profile=profile, insecure=insecure_str, host=host)