Managing Spaces via the Command Line

You can use the datasphere command line interface to list, read, create, update, and delete spaces.

The following sections are available in this topic:

Prerequisites

To manage spaces via the command line, you must have either:
A global role that grants you the following privileges:
  • Data Warehouse General (-R------) - To access SAP Datasphere.

  • Spaces (C------M) - To create a space, modify its properties (except for the sections HDI Containers and Time Data), and delete a space.

  • User (-R------) - To allow the creation of spaces.

The DW Administrator role template, for example, grants these privileges.
A scoped role that grants you access to a space with the following privileges:
  • Data Warehouse General (-R------) - To access SAP Datasphere.

  • Spaces (-RU-----) - To modify all space properties (except for the sections Space Storage, Data Lake Access, and Workload Management).

  • Spaces (---D----) - To delete a 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
For general information about working with spaces, see Creating Spaces and Allocating Resources and Managing Your Space.

List Spaces

To list the spaces available to you on the tenant, enter the following command and press Return:

datasphere spaces list 
    [--host "<url>"] 
    [--output <file>.json]
Complete the parameters as follows:

Parameter

Description

--host "<url>"

Enter the URL of your SAP Datasphere tenant. You can copy the URL of any page in your tenant. Alternatively, set a host value (see Set a Host Value to Identify Your SAP Datasphere Tenant).

--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 a Space

To read a space definition to the console or to a file, enter the following command and press Return:

datasphere spaces read 
    --space <id> 
    [--definitions [<obj1>,<obj2>]] 
    [--no-space-definition] 
    [--output <file>.json]
Complete the parameters as follows:

Parameter

Description

--space <id>

Enter the Space ID of the space.

--definitions [<obj1>,<obj2>]

[Optional] Read the object definitions contained in the space. You can use the --definitions parameter by itself to read all the objects, or specify a comma-separated list of object technical names.

Object definitions are read using the standard CSN syntax (see Core Data Services Schema Notation (CSN)Information published on SAP site). The following objects can be read (exported):
  • Local Tables - The definition of a local table without delta capture contains the structure of the table only, and does not have dependencies on any other objects. The definition of a local table with delta capture enabled contains the definition of an additional internal table with the suffix _Delta. When you export a table with delta capture enabled, this table is exported too.

  • Remote Tables - The definition of a remote table contains information about its connection.

  • Views - The definition of a view contains the definitions of all its sources and any used data access controls. When you export a view, these objects are exported too.

  • Data Access Controls - The definition of a data access control contains the definition of its permissions entity. When you export a data access control, the permissions entity is exported too.

--no-space-definition

[Optional] Suppress the display of the spaceDefinition property. When used with the --definitions option, this allows you to read object definitions without seeing the other properties of the space.

--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.

The space definition is written to the console or to the specified file.

Create or Update a Space

To create or update a space, you must first prepare a space definition file (see The Space Definition File Format).
When your file is ready, enter the following command and press Return:
datasphere spaces create 
    --file-path <file>
Complete the parameters as follows:

Parameter

Description

--file-path <file>.json

Enter a path to a file with a .json extension containing your space definition.

--force-definition-deployment

[Optional] Deploy changes to objects even if they will generate validation messages warning of impacts to objects that depend on them. Using this option is equivalent to clicking the Deploy Anyway button in the Validation Messages dialog (see Modifying Objects That Have Dependent Objects).

--enforce-database-user-deletion

[Optional] Allow the deletion of database users and their associated Open SQL schemas, when the dbusers section is present in the space definition file. If any existing database user is not included in the dbusers section and this option is omitted, then they will not be deleted in order to protect against unintended data loss.

--input '<stringified-json>'

[Optional] Provide your space definition in stringified json format instead of via the --file-path option. For example:

--input '{"MY_SPACE":{"spaceDefinition":{"version":"1.0.4"}}}'
The space is created or updated as you have specified.

Delete a Space

To delete a space, enter the following command and press Return:
datasphere spaces delete 
    --space <id> 
    [--force]
Complete the parameters as follows:

Parameter

Description

--space <id>

Enter the Space ID of the space.

--force

Delete the space without confirmation. If you do not include this option you will be prompted to confirm the deletion.

If prompted, confirm that you want to delete the space. The space is deleted and a confirmation message is written to the console.