示例#1
0
def list_secrets(api_client, scope, output):
    """
    Lists the secret keys that are stored at this scope. Also lists the last updated timestamp
    (UNIX time in milliseconds) if available.
    """
    secrets_json = SecretApi(api_client).list_secrets(scope)
    if OutputClickType.is_json(output):
        click.echo(pretty_format(secrets_json))
    else:
        click.echo(
            tabulate(_secrets_to_table(secrets_json), headers=SECRET_HEADER))
示例#2
0
def list_cli(api_client, output):
    """
    Lists active instance pools with the stats of the pools.
    """
    instance_pools_json = InstancePoolsApi(api_client).list_instance_pools()
    if OutputClickType.is_json(output):
        click.echo(pretty_format(instance_pools_json))
    else:
        headers = ['ID', 'NAME', 'IDLE INSTANCES', 'USED INSTANCES', 'PENDING IDLE INSTANCES',
                   'PENDING USED INSTANCES']
        click.echo(tabulate(_instance_pools_to_table(instance_pools_json), headers=headers,
                            tablefmt='plain', numalign='left'))
示例#3
0
def cluster_events_cli(api_client, cluster_id, start_time, end_time, order, event_type, offset,
                       limit, output):
    """
    Gets events for a Spark cluster.
    """
    events_json = ClusterApi(api_client).get_events(
        cluster_id=cluster_id, start_time=start_time, end_time=end_time, order=order,
        event_types=event_type, offset=offset, limit=limit)
    if OutputClickType.is_json(output):
        click.echo(pretty_format(events_json))
    else:
        click.echo(tabulate(_cluster_events_to_table(events_json), tablefmt='plain'))
示例#4
0
def list_cli(api_client, output):
    """
    Lists active and recently terminated clusters.

    Returns information about all currently active clusters, and up
    to 100 most recently terminated clusters in the past 7 days.

    By default the output format will be a human readable table with the following fields

      - Cluster ID

      - Cluster name

      - Cluster state
    """
    clusters_json = ClusterApi(api_client).list_clusters()
    if OutputClickType.is_json(output):
        click.echo(pretty_format(clusters_json))
    else:
        click.echo(tabulate(_clusters_to_table(clusters_json), tablefmt='plain'))
示例#5
0
文件: cli.py 项目: Men0x/aobd_project
def list_cli(api_client, output):
    """
    Lists the jobs in the Databricks Job Service.

    By default the output format will be a human readable table with the following fields

      - Job ID

      - Job name

    A JSON formatted output can also be requested by setting the --output parameter to "JSON"

    In table mode, the jobs are sorted by their name.
    """
    jobs_api = JobsApi(api_client)
    jobs_json = jobs_api.list_jobs()
    if OutputClickType.is_json(output):
        click.echo(pretty_format(jobs_json))
    else:
        click.echo(tabulate(_jobs_to_table(jobs_json), tablefmt='plain', disable_numparse=True))
示例#6
0
def list_cli(api_client, output, job_type, version, expand_tasks, offset, limit, _all):
    """
    Lists the jobs in the Databricks Job Service.

    By default the output format will be a human readable table with the following fields

      - Job ID

      - Job name

    A JSON formatted output can also be requested by setting the --output parameter to "JSON"

    In table mode, the jobs are sorted by their name.
    """
    check_version(api_client, version)
    api_version = version or api_client.jobs_api_version
    if api_version != '2.1' and (expand_tasks or offset or limit or _all):
        click.echo(click.style('ERROR', fg='red') + ': the options --expand-tasks, ' +
                   '--offset, --limit, and --all are only available in API 2.1', err=True)
        return
    jobs_api = JobsApi(api_client)
    has_more = True
    jobs = []
    if _all:
        offset = 0
        limit = 20
    while has_more:
        jobs_json = jobs_api.list_jobs(job_type=job_type, expand_tasks=expand_tasks,
                                       offset=offset, limit=limit, version=version)
        jobs += jobs_json['jobs'] if 'jobs' in jobs_json else []
        has_more = jobs_json.get('has_more', False) and _all
        if has_more:
            offset = offset + \
                (len(jobs_json['jobs']) if 'jobs' in jobs_json else 20)

    out = {'jobs': jobs}
    if OutputClickType.is_json(output):
        click.echo(pretty_format(out))
    else:
        click.echo(tabulate(_jobs_to_table(out),
                   tablefmt='plain', disable_numparse=True))
示例#7
0
文件: cli.py 项目: Men0x/aobd_project
def list_cli(api_client, output):
    """
    Lists cluster olicies.

    Returns information about all currently cluster olicies.

    By default the output format will be a human readable table with the following fields

      - Policy ID

      - Policy Name

      - Policy Definition
    """
    policies_json = ClusterPolicyApi(api_client).list_cluster_policies()

    if OutputClickType.is_json(output):
        click.echo(pretty_format(policies_json))
    else:
        click.echo(
            tabulate(_cluster_policies_to_table(policies_json),
                     tablefmt='plain'))
示例#8
0
def list_cli(api_client, job_id, active_only, completed_only, offset, limit, output): # noqa
    """
    Lists job runs.

    The limit and offset determine which runs will be listed. Runs are always listed
    by descending order of run start time and run ID.

    In the TABLE output mode, the columns are as follows.

      - Run ID

      - Run name

      - Life cycle state

      - Result state (can be n/a)
    """
    runs_json = RunsApi(api_client).list_runs(job_id, active_only, completed_only, offset, limit)
    if OutputClickType.is_json(output):
        click.echo(pretty_format(runs_json))
    else:
        click.echo(tabulate(_runs_to_table(runs_json), tablefmt='plain'))
示例#9
0
    JobsApi(api_client).reset_job(request_body)


def _jobs_to_table(jobs_json):
    ret = []
    for j in jobs_json['jobs']:
        ret.append((j['job_id'], truncate_string(j['settings']['name'])))
    return sorted(ret, key=lambda t: t[1].lower())


@click.command(context_settings=CONTEXT_SETTINGS,
               short_help='Lists the jobs in the Databricks Job Service.')
@click.option('--output',
              default=None,
              help=OutputClickType.help,
              type=OutputClickType())
@debug_option
@profile_option
@eat_exceptions
@provide_api_client
def list_cli(api_client, output):
    """
    Lists the jobs in the Databricks Job Service.

    By default the output format will be a human readable table with the following fields

      - Job ID

      - Job name

    A JSON formatted output can also be requested by setting the --output parameter to "JSON"
示例#10
0

def _scopes_to_table(scopes_json):
    ret = []
    for s in scopes_json.get('scopes', []):
        if "keyvault_metadata" in s:
            url = s["keyvault_metadata"]["dns_name"]
            ret.append((truncate_string(s['name']), s['backend_type'], url))
        else:
            ret.append((truncate_string(s['name']), s['backend_type'], "N/A"))
    return ret


@click.command(context_settings=CONTEXT_SETTINGS,
               short_help='Lists all secret scopes.')
@click.option('--output', help=OutputClickType.help, type=OutputClickType())
@debug_option
@profile_option
@eat_exceptions
@provide_api_client
def list_scopes(api_client, output):
    """
    Lists all secret scopes.
    """
    scopes_json = SecretApi(api_client).list_scopes()
    if OutputClickType.is_json(output):
        click.echo(pretty_format(scopes_json))
    else:
        click.echo(
            tabulate(_scopes_to_table(scopes_json), headers=SCOPE_HEADER))
示例#11
0
    ret = []
    stats_headers = ['idle_count', 'used_count', 'pending_idle_count', 'pending_used_count']
    for c in instance_pools_json.get('instance_pools', []):
        pool_stats = []
        pool_stats.append(c['instance_pool_id'])
        pool_stats.append(truncate_string(c['instance_pool_name']))
        for header in stats_headers:
            pool_stats.append(c['stats'][header])
        # clone the content in the pool_stats. Pool_stats will be re-used in next iteration.
        ret.append(pool_stats[:])
    return ret


@click.command(context_settings=CONTEXT_SETTINGS,
               short_help='Lists active and recently terminated instance pools.')
@click.option('--output', default=None, help=OutputClickType.help, type=OutputClickType())
@debug_option
@profile_option
@eat_exceptions
@provide_api_client
def list_cli(api_client, output):
    """
    Lists active instance pools with the stats of the pools.
    """
    instance_pools_json = InstancePoolsApi(api_client).list_instance_pools()
    if OutputClickType.is_json(output):
        click.echo(pretty_format(instance_pools_json))
    else:
        headers = ['ID', 'NAME', 'IDLE INSTANCES', 'USED INSTANCES', 'PENDING IDLE INSTANCES',
                   'PENDING USED INSTANCES']
        click.echo(tabulate(_instance_pools_to_table(instance_pools_json), headers=headers,