Datasource Type#


A datasource type is an object that represents a source of the data. This can be a database (MongoDB, MySQL), file storage (Dropbox, Google Cloud Storage), generic protocol or API (FTP, HTTP).

Note

For the full list, get all DatasourceTypes objects (Retrieving a DatasourceType) or refer to the IBM documentation.

Datasource objects are used as arguments when creating Connection objects.

Note

To read more about connections see Connections.

The SDK provides functionality to interact with datasource types.

This includes operations such as:
  • Retrieving DatasourceType(s)

Retrieving a DatasourceType#

In the UI, the list of all DatasourceType objects is displayed during creation of Connection (See: Creating a Connection).

Screenshot of the DataSource selection in the UI

In the SDK, a Connection can be retrieved using Project.connections property. You can also further filter and refine the connections returned based on attributes including name, context, properties and datasource_type.

A DatasourceType can be retrieved using Platform.datasources property. You can also further filter and refine the connections returned based on attributes including environment, perspective and product.

This property returns a DatasourceTypes object.

>>> # Return first datasource type matching given `perspective`
>>> datasource = platform.datasources.get(perspective="wx")
DatasourceType(name='informix')

>>> # Return a list of all datasource types that match `perspective`
>>> datasources = platform.datasources.get_all(perspective="wx")
[
    DatasourceType(name='informix'),
    DatasourceType(name='postgresql-ibmcloud'),
    (...)
]

>>> # Return a list of all datasource types
>>> datasources = platform.datasources
[
    DatasourceType(name='informix'),
    DatasourceType(name='postgresql-ibmcloud'),
    (...)
]

Tip

For detailed information about parameters and values refer to https://cloud.ibm.com/apidocs/data-ai-common-core#listdatasourcetypes.

Retrieving a DatasourceType connection properties#

In the UI, available connection fields depend on previously selected DatasourceType (See: Retrieving a DatasourceType).

For example, JDBC connection by default requires 3 parameters - JDBC Connection String, Username, Password.

Screenshot of the JDBC DataSource arguments.

HTTP connection on the other hand by default requires only one parameters - File URL.

Screenshot of the HTTP DataSource arguments.

In the SDK to get all properties available for a DatasourceType object use DatasourceType.properties property (which will return DatasourceTypeProperties object). Then you can call DatasourceTypeProperties.connection to retrieve all available connection properties.

>>> # Get datasource object
>>> datasource = platform.datasources[0]
DatasourceType(name='informix')
>>> properties = datasource.properties.connection
[
    DatasourceTypeProperty(name='cluster_access_token'),
    DatasourceTypeProperty(name='cluster_user_name'),
    (...)
]

>>> # You can get list of all required properties
>>> required_properties = datasource.required_connection_properties
[
    DatasourceTypeProperty(name='host'),
    DatasourceTypeProperty(name='password'),
    (...)
]

>>> # Or get details about the property
>>> required_property_1 = required_properties[0]
DatasourceTypeProperty(name='host')
>>> required_property_1.type
'string'
>>> required_property_1.label
'Hostname or IP address'