This blog post is part of a series of blogs I published about @sap/datasphere-cli. Find all blog posts related to this topic in my overview blog post here.
The Node.js-based Command-Line Interface (CLI) for SAP Datasphere, @sap/datasphere-cli hosted on npmjs.com, allows you to interact with your SAP Datasphere tenant from the terminal or command line. Since version 2023.1 you can use the CLI to reset and retrieve new passwords for the database users in your space.
$ datasphere host set https://myhost.eu10.hcs.cloud.sap/
$ datasphere login --secrets-file /path/to/secrets/file.json
$ datasphere cache init
Code Sample 1 - Updating the CLI
{
"MYEXAMPLESPACE": {
"spaceDefinition": {
"version": "1.0.4",
"label": "My Example Space",
"assignedStorage": 0,
"assignedRam": 0,
"members": [
{
"name": "JKANNGIESSER",
"type": "user"
}
],
"dbusers": {
"MYEXAMPLESPACE#MY_FIRST_DB_USER": {
"ingestion": {
"auditing": {
"dppRead": {
"isAuditPolicyActive": false,
"retentionPeriod": 7
},
"dppChange": {
"isAuditPolicyActive": false,
"retentionPeriod": 7
}
}
},
"consumption": {
"localSchemaAccess": true,
"spaceSchemaAccess": true,
"hdiGrantorForCupsAccess": true
}
},
"MYEXAMPLESPACE#MY_SECOND_DB_USER": {
"ingestion": {
"auditing": {
"dppRead": {
"isAuditPolicyActive": false,
"retentionPeriod": 7
},
"dppChange": {
"isAuditPolicyActive": false,
"retentionPeriod": 7
}
}
},
"consumption": {
"localSchemaAccess": true,
"spaceSchemaAccess": true,
"hdiGrantorForCupsAccess": true
}
}
}
}
}
}
Space Definition Example 1
$ datasphere spaces create --file-path space.json
Code Sample 2 - Creating a new space
$ datasphere
Usage: datasphere [options] [command]
Command-Line Interface for SAP Datasphere.
Options:
-v, --version output the current version
-H, --host <host> specifies the url where the tenant is hosted (optional)
-O, --options-file <file> path to options file (optional)
-h, --help display help for command
Commands:
cache work with the local CLI cache
dbusers [options] manage and orchestrate database users
help [command] display help for command
host configure host properties
login [options] log in to your account using interactive OAuth authentication
logout log out from your account
passcode-url [options] display the passcode url
secrets work with the locally stored secrets
spaces [options] manage and orchestrate spaces
Code Sample 3 - New command dbusers
$ datasphere dbusers
Usage: datasphere dbusers [options] [command]
manage and orchestrate database users
Options:
-H, --host <host> specifies the url where the tenant is hosted (optional)
-h, --help display help for command
Commands:
password [options] maintain password of database user
help [command] display help for command
Code Sample 4 - datasphere dbusers
$ datasphere dbusers password
Usage: datasphere dbusers password [options] [command]
maintain password of database user
Options:
-H, --host <host> specifies the url where the tenant is hosted (optional)
-h, --help display help for command
Commands:
reset [options] reset password of database user
help [command] display help for command
Code Sample 5 - datasphere dbusers password reset
$ datasphere dbusers password reset --help
Usage: datasphere dbusers password reset [options]
reset password of database user
Options:
-P, --pretty pretty-formats JSON responses (optional)
-S, --space <space> space id (optional)
-j, --databaseuser <databaseuser> database user id (optional)
-o, --output <output> specifies the file to store the output of the command (optional)
-h, --help display help for command
Code Sample 6 - Options available for command datasphere dbusers password reset
$ datasphere dbusers password reset --space MYEXAMPLESPACE --databaseuser MYEXAMPLESPACE#MY_FIRST_DB_USER --pretty
{
"password": ")@:Nrga/6eQq,RPg3-05SL9.Z%]dL_WO",
"username": "MYEXAMPLESPACE#MY_FIRST_DB_USER",
"host": "somehost.hana.prod-eu10.hanacloud.ondemand.com",
"port": 443
}
Code Sample 7 - Resetting the password of a database user
$ datasphere dbusers password reset --pretty
✔ Provide a value for option space (space id): … MYEXAMPLESPACE
✔ Provide a value for option databaseuser (database user id): … MYEXAMPLESPACE#MY_FIRST_DB_USER
{
"password": "M5|44kP?=9s[6;*=VlRK:/aS4jkJZ@$P",
"username": "MYEXAMPLESPACE#MY_FIRST_DB_USER",
"host": "myhost.hana.prod-eu10.hanacloud.ondemand.com",
"port": 443
}
Code Sample 8 - Resetting the password in interactive mode
{
"MYEXAMPLESPACE": {
"spaceDefinition": {
"version": "1.0.4",
"label": "My Example Space",
"assignedStorage": 0,
"assignedRam": 0,
"members": [
{
"name": "JKANNGIESSER",
"type": "user"
}
],
"dbusers": {
"MYEXAMPLESPACE#MY_SECOND_DB_USER": {
"ingestion": {
"auditing": {
"dppRead": {
"isAuditPolicyActive": false,
"retentionPeriod": 7
},
"dppChange": {
"isAuditPolicyActive": false,
"retentionPeriod": 7
}
}
},
"consumption": {
"localSchemaAccess": true,
"spaceSchemaAccess": true,
"hdiGrantorForCupsAccess": true
}
}
}
}
}
}
Space Definition Example 2
Picture 3 - Updated database access section
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
15 | |
12 | |
11 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 |