Connections#

For usage information and examples, see Connections

class dataikuapi.dss.admin.DSSConnection(client, name)#

A connection on the DSS instance.

Important

Do not instantiate directly, use dataikuapi.DSSClient.get_connection() instead.

get_location_info()#

Get information about this connection.

Caution

Deprecated, use get_info()

get_info(contextual_project_key=None)#

Get information about this connection.

Note

This call requires permissions to read connection details

Parameters:

contextual_project_key (string) – (optional) project key to use to resolve variables

Returns:

an object containing connection information

Return type:

DSSConnectionInfo

delete()#

Delete the connection

get_settings()#

Get the settings of the connection.

You must use save() on the returned object to make your changes effective on the connection.

Usage example

# make details of a connection accessible to some groups
connection = client.get_connection("my_connection_name")
settings = connection.get_settings()
readability = settings.details_readability
readability.set_readability(False, "group1", "group2")
settings.save()
Returns:

the settings of the connection

Return type:

DSSConnectionSettings

get_definition()#

Get the connection’s raw definition.

Caution

Deprecated, use get_settings() instead.

The exact structure of the returned dict is not documented and depends on the connection type. Create connections using the DSS UI and call get_definition() to see the fields that are in it.

Note

This method returns a dict with passwords and secrets in their encrypted form. If you need credentials, consider using get_info() and dataikuapi.dss.admin.DSSConnectionInfo.get_basic_credential().

Returns:

a connection definition, as a dict. See DSSConnectionSettings.get_raw()

Return type:

dict

set_definition(definition)#

Set the connection’s definition.

Caution

Deprecated, use get_settings() then DSSConnectionSettings.save() instead.

Important

You should only set_definition() using an object that you obtained through get_definition(), not create a new dict.

Usage example

# make details of a connection accessible to some groups
connection = client.get_connection("my_connection_name")
definition = connection.get_definition()
definition['detailsReadability']['readableBy'] = 'ALLOWED'
definition['detailsReadability']['allowedGroups'] = ['group1', 'group2']
connection.set_definition(definition)
Parameters:

definition (dict) – the definition for the connection, as a dict.

sync_root_acls()#

Resync root permissions on this connection path.

This is only useful for HDFS connections when DSS has User Isolation activated with “DSS-managed HDFS ACL”

Returns:

a handle to the task of resynchronizing the permissions

Return type:

DSSFuture

sync_datasets_acls()#

Resync permissions on datasets in this connection path.

This is only useful for HDFS connections when DSS has User Isolation activated with “DSS-managed HDFS ACL”

Returns:

a handle to the task of resynchronizing the permissions

Return type:

DSSFuture

class dataikuapi.dss.admin.DSSConnectionInfo(data)#

A class holding read-only information about a connection.

Important

Do not instantiate directly, use DSSConnection.get_info() instead.

The main use case of this class is to retrieve the decrypted credentials for a connection, if allowed by the connection permissions.

Depending on the connection kind, the credential may be available using get_basic_credential() or get_aws_credential().

get_type()#

Get the type of the connection

Returns:

a connection type, for example Azure, Snowflake, GCS, …

Return type:

string

get_credential_mode()#

Get the credential mode of the connection

Returns:

a connection mode

Return type:

string

get_params()#

Get the parameters of the connection, as a dict

Returns:

the parameters, as a dict. Each connection type has different sets of fields.

Return type:

dict

get_resolved_params()#

Get the resolved parameters of the connection, as a dict. May be null depending on the connection type.

Returns:

the resolved parameters, as a dict. Each connection type has different sets of fields.

Return type:

dict

get_basic_credential()#

Get the basic credential (user/password pair) for this connection, if available

Returns:

the credential, as a dict containing “user” and “password”

Return type:

dict

get_aws_credential()#

Get the AWS credential for this connection, if available.

The AWS credential can either be a keypair or a STS token triplet.

Returns:

the credential, as a dict containing “accessKey”, “secretKey”, and “sessionToken” (only in the case of STS token)

Return type:

dict

get_oauth2_credential()#

Get the OAUTH2 credential for this connection, if available.

Returns:

the credential, as a dict containing “accessToken”

Return type:

dict

class dataikuapi.dss.admin.DSSConnectionListItem(client, data)#

An item in a list of connections.

Important

Do not instantiate directly, use dataikuapi.DSSClient.list_connections() instead.

to_connection()#

Gets a handle corresponding to this item

Return type:

DSSConnection

property name#

Get the identifier of the connection.

Return type:

string

property type#

Get the type of the connection.

Returns:

a DSS connection type, like PostgreSQL, EC2, Azure, …

Return type:

string

class dataikuapi.dss.admin.DSSConnectionSettings(connection, settings)#

Settings of a DSS connection.

Important

Do not instantiate directly, use DSSConnection.get_settings() instead.

Use save() to save your changes

get_raw()#

Get the raw settings of the connection.

Returns:

a connection definition, as a dict. Notable fields are:

  • type : type of the connection (for example PostgreSQL, Azure, …)

  • params : dict of the parameters specific to the connection type

Return type:

dict

property type#

Get the type of the connection.

Returns:

a DSS connection type, like PostgreSQL, EC2, Azure, …

Return type:

string

property allow_managed_datasets#

Whether managed datasets can use the connection.

Return type:

boolean

property allow_managed_folders#

Whether managed datasets can use the connection.

Return type:

boolean

property allow_write#

Whether data can be written to this connection.

If not, the connection is read-only from DSS point of view.

Return type:

boolean

property details_readability#

Get the access control to connection details.

Returns:

an handle on the access control definition.

Return type:

DSSConnectionDetailsReadability

property usable_by#

Get the mode of access control.

This controls usage of the connection, that is, reading and/or writing data from/to the connection.

Returns:

one ALL (anybody) or ALLOWED (ie. only users from groups in usable_by_allowed_groups())

Return type:

string

property usable_by_allowed_groups#

Get the groups allowed to use the connection

Only applies if usable_by() is ALLOWED.

Returns:

a list of group names

Return type:

list[string]

set_usability(all, *groups)#

Set who can use the connection.

Parameters:
  • all (boolean) – if True, anybody can use the connection

  • groups (*string) – a list of groups that can use the connection

save()#

Save the changes to the connection’s settings

class dataikuapi.dss.admin.DSSConnectionDetailsReadability(data)#

Handle on settings for access to connection details.

Connection details mostly cover credentials, and giving access to the credentials is necessary to some workloads. Typically, having Spark processes access data directly implies giving credentials to these Spark processes, which in turn implies that the user can access the connection’s details.

property readable_by#

Get the mode of access control.

Returns:

one of NONE (nobody), ALL (anybody) or ALLOWED (ie. only users from groups in allowed_groups())

Return type:

string

property allowed_groups#

Get the groups allowed to access connection details.

Only applies if readable_by() is ALLOWED.

Returns:

a list of group names

Return type:

list[string]

set_readability(all, *groups)#

Set who can get details from the connection.

To make the details readable by nobody, pass all=False and no group.

Parameters:
  • all (boolean) – if True, anybody can use the connection

  • groups (*string) – a list of groups that can use the connection