组 CLI(旧版)

重要

本文档已过时,将来可能不会更新。

此信息适用于旧版 Databricks CLI 0.18 及更低版本。 Databricks 建议改用较新的 Databricks CLI 0.205 或更高版本。 请参阅什么是 Databricks CLI?。 若要查找你的 Databricks CLI 的版本,请运行 databricks -v

要从 Databricks CLI 版本 0.18 或更低版本迁移到 Databricks CLI 版本 0.205 或更高版本,请参阅 Databricks CLI 迁移

注意

  • 组 CLI 需要 Databricks CLI 0.8.0 或更高版本。
  • 必须是 Databricks 管理员才能调用此 API。

可以通过将 Databricks 组 CLI 子命令追加到 databricks groups 后面来运行这些命令。 这些子命令调用组 API

databricks groups --help
Usage: databricks groups [OPTIONS] COMMAND [ARGS]...

  Provide utility to interact with Databricks groups.

Options:
  -v, --version   0.8.0
  --debug         Debug Mode. Shows full stack trace on error.
  --profile TEXT  CLI connection profile to use. The default profile is "DEFAULT".
  -h, --help      Show this message and exit.

Commands:
  add-member     Add an existing principal to another existing group.
    Options:
      --parent-name TEXT  Name of the parent group to which the new member will be
                          added. This field is required.  [required]
      --user-name TEXT    The user name which will be added to the parent group.
      --group-name TEXT   If group name which will be added to the parent group.
  create         Create a new group with the given name.
    Options:
      --group-name TEXT  [required]
  delete         Remove a group from this organization.
    Options:
      --group-name TEXT  [required]
  list           Return all of the groups in a workspace.
  list-members   Return all of the members of a particular group.
    Options:
      --group-name TEXT  [required]
  list-parents   Retrieve all groups in which a given user or group is a member.
    Options:
      --user-name TEXT
      --group-name TEXT
  remove-member  Removes a user or group from a group.
    Options:
      --parent-name TEXT  Name of the parent group to which the new member will be
                          removed. This field is required.  [required]
      --user-name TEXT    The user name which will be removed from the parent
                          group.
      --group-name TEXT   If group name which will be removed from the parent
                          group.

将成员添加到组

若要显示使用情况文档,请运行 databricks groups add-member --help

databricks groups add-member \
--parent-name sql-users \
--user-name someone@example.com
databricks groups add-member \
--parent-name sql-power-users \
--group-name sql-users

如果成功,则不显示任何输出。

创建组

若要显示使用情况文档,请运行 databricks groups create --help

databricks groups create --group-name sql-users
{
  "group_name": "sql-users"
}

删除组

若要显示使用情况文档,请运行 databricks groups delete --help

databricks groups delete --group-name sql-users
{}

列出可用组

若要显示使用情况文档,请运行 databricks groups list --help

databricks groups list
{
  "group_names": [
    "sql-users",
    "sql-power-users",
    "sql-admins"
  ]
}

列出组的成员

若要显示使用情况文档,请运行 databricks groups list-members --help

databricks groups list-members --group-name sql-users
{
  "members": [
    {
      "user_name": "someone@example.com"
    }
  ]
}
databricks groups list-members --group-name sql-power-users
{
  "members": [
    {
      "group_name": "sql-users"
    }
  ]
}

列出用户或组所属的组

若要显示使用情况文档,请运行 databricks groups list-parents --help

databricks groups list-parents --user-name someone@example.com
{
  "group_names": [
    "sql-users"
  ]
}
databricks groups list-parents --group-name sql-users
{
  "group_names": [
    "sql-power-users"
  ]
}

从组中删除成员

若要显示使用情况文档,请运行 databricks groups remove-member --help

databricks groups remove-member \
--parent-name sql-power-users \
--group-name sql-users
databricks groups remove-member \
--parent-name sql-users \
--user-name someone@example.com

如果成功,则不显示任何输出。