Managing Space Users via the Command Line

You can use the datasphere command line interface to add and remove users from spaces and to update user roles in spaces.

Prerequisites

To manage user access to spaces via the command line, you must have a scoped role that grants you access to your space with the following privileges:
  • Data Warehouse General (-R------) - To access SAP Datasphere.

  • Spaces (-RU-----) - To open and update your space in the Space Management tool.

  • Space Files (-R------) - To view objects in your space.

  • Scoped Role User Assignment (-------M) - To manage the users who can access your space.

The DW Space Administrator role template, for example, grants these privileges. For more information, see Privileges and Permissions and Standard Roles Delivered with SAP Datasphere.
You must, in addition: To browse the available commands, enter the following and press Return:
datasphere spaces users
For general information about working with space users, see Control User Access to Your Space.

List Space Users

You can read a list of users in your space and optionally write it to a file.

Enter the following command and press Return:
datasphere spaces users read
    --space <ID>
    [--accept <format>]
    [--output <file>.json]
Complete the parameters as follows:

Parameter

Description

--space <ID>

Enter the ID of your space.

--accept <format>

[optional] Specify the format to return the list in. You can choose between:

  • application/vnd.sap.datasphere.space.users.list+json - [default] User IDs only.

  • application/vnd.sap.datasphere.space.users.details+json - User IDs and scoped roles.

--output <file>.json

[optional] Enter a path to a .json file to write the output to.

If you do not include this option, the output will be printed to the command line.

Add Users to a Space

To add a user to your space, you must add them to a scoped role that includes your space as a scope and gives the appropriate privileges.

Enter the following command and press Return:
datasphere spaces users add
    --space <ID>
    --file-path <file>.json|--input '<stringified-json>'
Complete the parameters as follows:

Parameter

Description

--space <ID>

Enter the ID of your space.

--file-path <file>.json

Enter a path to a file with a .json extension containing the list of users to add and the scoped roles you want to add them to:

[
  {
    "id": "<UserID>",
    "roles": "<RoleID[,RoleID...]>"
  },
  {
    "id": "<UserID>",
    "roles": "<RoleID[,RoleID...]>"
  }
]

Each user must exist on your tenant and each scoped role that you assign them to must include your space as a scope.

For example, to add the users BBAXTER and JJONES to the space SALES_US via the scoped role Sales_Modeler, enter the following command and press Return:
datasphere spaces users add --space SALES_US --file-path add.json
Where the file add.json contains the following (where <package> and <id> for the tenant are t and W respectively):
[
            {
                "id": "BBAXTER",
                "roles": ["Sales_Admin","Sales_Modeler"]
            },
            {
                "id": "JJONES",
                "roles": ["Sales_Modeler"]
            }
        ]

Update Space User Roles

You can update the roles that are assigned to users for your space. For example you may want to remove a user's modeling privileges and leave here only with viewing privileges

Enter the following command and press Return:
datasphere spaces users update
    --space <ID>
    --file-path <file>.json|--input '<stringified-json>'
Complete the parameters as follows:

Parameter

Description

--space <ID>

Enter the ID of your space.

--file-path <file>.json

Enter a path to a file with a .json extension containing containing the list of users to update and the new scoped roles you want them to belong to

[
  {
    "id": "<UserID>",
    "roles": ["<RoleID>","<RoleID>"]
  },
  {
    "id": "<UserID>",
    "roles": ["<RoleID>","<RoleID>"]
  }
]
For example, to give BBAXTER the roles of both Sales_Modeler and Sales_Integrator, and to remove JJONES from the role Sales_Modeler and to add her to Sales_Space_Admin, enter the following command and press Return:
datasphere spaces users update --space SALES_US --file-path update.json
Where the file update.json contains the following:
[
            {
                "id": "BBAXTER",
                "roles": ["Sales_Modeler","Sales_Integrator"]
            },
            {
                "id": "JJONES",
                "roles": ["Sales_Space_Admin"]
            }
        ]

Remove Users from a Space

You can remove users from your space.

Enter the following command and press Return:
datasphere spaces users remove
    --space <ID>
    --file-path <file>.json|--input '<stringified-json>'
Complete the parameters as follows:

Parameter

Description

--space <ID>

Enter the ID of your space.

--file-path <file>.json

Enter a path to a file with a .json extension containing the list of users to remove and the scoped roles to remove them from:

[
  {
    "id": "<UserID>",
    "role": "<RoleID>"
  },  
  {
    "id": "<UserID>",
    "role": "<RoleID>"
  }
]
For example, to remove BBAXTER from both the Sales_Modeler and Sales_Integrator roles in the SALES_US space, enter the following command and press Return:
datasphere spaces users remove --space SALES_US --file-path remove.json
Where the file remove.json contains the following:
[
            {
                "id": "BBAXTER",
                "role": "Sales_Modeler"
            },
            {
                "id": "BBAXTER",
                "role": "Sales_Integrator"
            }
        ]