Managing Scoped Roles via the Command Line
You can use the datasphere command line interface to create, read, update, and delete scoped roles.
Prerequisites
-
Data Warehouse General (-R------) - To access SAP Datasphere.
-
Role (CRUD----) - To access the (Roles) and (Authorization Overview) areas in the (Security) tool and to create, update, and delete roles.
-
User (-------M) - To add users to roles.
-
Spaces (-------M) - To add spaces to scoped roles.
-
Install the datasphere command line interface (see Install or Update the SAP Datasphere Command Line Interface).
-
Log in to your SAP Datasphere tenant (see Log into the Command Line Interface via an OAuth Client).
datasphere scoped-roles
For general information about working with scoped roles in SAP Datasphere , see Create a Scoped Role to Assign Privileges to Users in Spaces .
List Scoped Roles
You can list the scoped roles in your tenant, and optionally write them to a file.
datasphere scoped-roles list
[--output <file>.json]
|
Parameter |
Description |
|---|---|
|
--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. |
Read Scoped Roles
You can read the CSN/JSON definition of a scoped role and optionally write it to a file.
datasphere scoped-roles read
--role <id>
[--output <file>.json]
datasphere scoped-roles scopes read
--role <ID>
--output <file>.json
datasphere scoped-roles users read
--role <ID>
--output <file>.json
|
Parameter |
Description |
|---|---|
|
--role <id> |
Enter the ID of a scoped role. |
|
--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. |
Create Scoped Roles
You can create scoped roles by providing a definition in a JSON file or an input string.
datasphere scoped-roles create
--file-path <file>.json|--input '<stringified-json>'
|
Parameter |
Description |
|---|---|
|
--file-path <file>.json |
[optional] Enter a path to a file with a .json extension containing your scoped role definition. {
"name": "<Name>",
"description": "<Description>",
"inheritance": "<Role_Template_Name>"
}
|
|
--input '<stringified-json>' |
[optional] Provide your input in stringified json format instead of via the --file-path option. |
datasphere scoped-roles create --file-path sales_modeler.jsonWhere the file sales_modeler.json contains the following:
{
"name": "Sales_Modeler",
"description": "Modeler for Sales spaces",
"inheritance": "Custom_Modeler"
}
Update Scoped Roles
You can update the description or template role of a scoped role by providing a new definition in a JSON file or an input string.
datasphere scoped-roles update
--role <ID>
--file-path <file>.json|--input '<stringified-json>'
|
Parameter |
Description |
|---|---|
|
--role <id> |
Enter the ID of a scoped role. |
|
--file-path <file>.json |
[optional] Enter a path to a file with a .json extension containing your scoped role definition. {
"description": "<Description>",
"inheritance": "<Role_Template_Name>"
}
|
|
--input '<stringified-json>' |
[optional] Provide your input in stringified json format instead of via the --file-path option. |
Add Spaces to Scoped Roles
datasphere scoped-roles scopes add
--role <ID>
--scopes <ID[,ID...]>
|
Parameter |
Description |
|---|---|
|
--role <id> |
Enter the ID of a scoped role. |
|
--scopes <ID[,ID...]> |
Enter a comma-separated list of space IDs. |
datasphere scoped-roles scopes add --role Sales_Modeler --scopes SALES_EU,SALES_US
Add Users to Scoped Roles
datasphere scoped-roles users add
--role <ID>
--file-path <file>.json|--input '<stringified-json>'
|
Parameter |
Description |
|---|---|
|
--role <id> |
Enter the ID of a scoped role. |
|
--file-path <file>.json |
Enter a path to a file with a .json extension containing the list of users to add and the scopes to add them to:
[
{
"id": "<userID>",
"scopes": ["<spaceID>","<spaceID>"]
},
{
"id": "<userID>",
"scopes": ["<spaceID>","<spaceID>"]
}
]
|
|
--input '<stringified-json>' |
[optional] Provide your input in stringified json format instead of via the --file-path option. |
datasphere scoped-roles users add --role Sales_Modeler --file-path add.jsonWhere the file add.json contains the following:
[
{
"id": "BBAXTER",
"scopes": ["SALES_EU", "SALES_US"]
},
{
"id": "JJONES",
"scopes": ["SALES_EU", "SALES_US"]
}
]
Remove Users from Scoped Roles
datasphere scoped-roles users remove
--role <ID>
--file-path <file>.json|--input '<stringified-json>'
|
Parameter |
Description |
|---|---|
|
--role <id> |
Enter the ID of a scoped role. |
|
--file-path <file>.json |
[optional] Enter a path to a file with a .json extension containing the list of users to remove and the spaces to remove them from:
[
{
"id": "<userID>",
"scopes": ["<spaceID>","<spaceID>"]
},
{
"id": "<userID>",
"scopes": ["<spaceID>","<spaceID>"]
}
]
|
|
--input '<stringified-json>' |
[optional] Provide your input in stringified json format instead of via the --file-path option. |
datasphere scoped-roles users remove --role Sales_Modeler --file-path remove.jsonWhere the file remove.json contains the following:
[
{
"id": "BBAXTER",
"scopes": ["SALES_EU"]
},
{
"id": "JJONES",
"scopes": ["SALES_EU"]
}
]
Remove Scopes from Scoped Roles
You can remove scopes from a scoped role.
datasphere scoped-roles scopes remove
--role <ID>
--scopes <ID[,ID...]>
|
Parameter |
Description |
|---|---|
|
--role <id> |
Enter the ID of a scoped role. |
|
--scopes <ID[,ID...]> |
Enter a comma-separated list of space IDs. |
datasphere scoped-roles scopes remove --role Sales_Modeler --scopes SALES_EU
Delete Scoped Roles
You can delete scoped roles.
datasphere scoped-roles delete
--role <ID>
[--force]
|
Parameter |
Description |
|---|---|
|
--role <id> |
Enter the ID of a scoped role. |
|
--force |
[optional] Suppress the Confirm Deletion step and delete the scoped role without confirmation. |
datasphere scoped-roles delete --role Sales_Modeler --force