Credentials
Credentials for user with Database and Data Storage Connectivity can be stored by the system.
To interact with Credentials API, you should use the Credential class.
List credentials
In order to retrieve the list of all credentials accessible for current user you can use
Credential.list
.
import datarobot as dr
credentials = dr.Credential.list()
Each Credential object contains the credential_id
string field which
can be used e.g. in Batch Predictions.
Basic credentials
You can store generic user/password credentials:
>>> import datarobot as dr
>>> cred = dr.Credential.create_basic(
... name='my_db_cred',
... user='<user>',
... password='<password>',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e0f', 'my_db_cred', 'basic'),
# store cred.credential_id
>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'5e429d6ecf8a5f36c5693e0f'
Stored credential can be used e.g. in Batch Bredictions for JDBC intake or output
.
S3 credentials
You can store AWS credentials either using the three parameters:
aws_access_key_id
aws_secret_access_key
aws_session_token
or the ID of the saved shared secure configuration
config_id
>>> import datarobot as dr
>>> cred = dr.Credential.create_s3(
... name='my_s3_cred',
... aws_access_key_id='<aws access key id>',
... aws_secret_access_key='<aws secret access key>',
... aws_session_token='<aws session token>',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_s3_cred', 's3'),
# using config_id
>>> cred = dr.Credential.dr.Credential.create_s3(
... name='my_s3_cred_with_config_id',
... config_id='<id_of_shared_secure_configuration>',
... )
>>> cred
Credential('65ef55ef4cec97f0f733835c', 'my_s3_cred_with_config_id', 's3')
# store cred.credential_id
>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'5e429d6ecf8a5f36c5693e03'
Stored credential can be used e.g. in Batch Bredictions for S3 intake or output.
OAUTH credentials
You can store oauth credentials in the store:
>>> import datarobot as dr
>>> cred = dr.Credential.create_oauth(
... name='my_oauth_cred',
... token='<token>',
... refresh_token='<refresh_token>',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e0f', 'my_oauth_cred', 'oauth'),
# store cred.credential_id
>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'5e429d6ecf8a5f36c5693e0f'
Snowflake Key Pair credentials
You can store Snowflake Key Pair credentials in the store. It accepts parameters either
private_key
passphrase
or the ID of the saved shared secure configuration.
config_id
>>> import datarobot as dr
>>> cred = dr.Credential.create_snowflake_key_pair(
... name='my_snowflake_key_pair_cred',
... user='<user>',
... private_key="""<private_key>""",
... passphrase='<passphrase>',
... )
>>> cred
Credential('65e9b55e4b0d925c678bb847', 'my_snowflake_key_pair_cred', 'snowflake_key_pair_user_account')
>>> cred = dr.Credential.create_snowflake_key_pair(
... name='my_snowflake_key_pair_cred_with_config_id',
... config_id='<id_of_shared_secure_configuration>',
... )
>>> cred
Credential('65e9b9494b0d925c678bb84d', 'my_snowflake_key_pair_cred_with_config_id', 'snowflake_key_pair_user_account')
Databricks Access Token credentials
You can store Databricks Access Token credentials in the store.
>>> import datarobot as dr
>>> cred = dr.Credential.create_databricks_access_token(
... name='my_databricks_access_token_cred',
... databricks_access_token='<databricks_access_token>',
... )
>>> cred
Credential('65e9bace4b0d925c678bb850', 'my_databricks_access_token_cred', 'databricks_access_token_account')
Databricks Service Principal credentials
You can store Databricks Service Principal credentials in the store. It accepts parameters either
client_id
client_secret
or the ID of the saved shared secure configuration.
config_id
>>> import datarobot as dr
>>> cred = dr.Credential.create_databricks_service_principal(
... name='my_databricks_service_principal_cred',
... client_id='<client_id>',
... client_secret='<client_secret>',
... )
>>> cred
Credential('65e9bb864b0d925c678bb853', 'my_databricks_service_principal_cred', 'databricks_service_principal_account')
>>> cred = dr.Credential.create_databricks_service_principal(
... name='my_databricks_service_principal_cred_with_config_id',
... config_id='<id_of_shared_secure_configuration>',
... )
>>> cred
Credential('65e9bcc14b0d925c678bb85e', 'my_databricks_service_principal_cred_with_config_id', 'databricks_service_principal_account')
Azure Service Principal credentials
You can store Azure Service Principal credentials either using the three parameters:
client_id
client_secret
azure_tenant_id
or the ID of the saved shared secure configuration
config_id
>>> import datarobot as dr
>>> cred = dr.Credential.create_azure_service_principal(
... name='my_azure_service_principal_cred',
... client_id='<client id>',
... client_secret='<client secret>',
... azure_tenant_id='<azure tenant id>',
... )
>>> cred
Credential('66c920fc4ef80072a8225e56', 'my_azure_service_principal_cred2', 'azure_service_principal')
# using config_id
>>> cred = dr.Credential.dr.Credential.create_azure_service_principal(
... name='my_azure_service_principal_cred_with_config_id',
... config_id='<id_of_shared_secure_configuration>',
... )
>>> cred
Credential('66c921aa0ff7aea1ce225e2d', 'my_azure_service_principal_cred_with_config_id', 'azure_service_principal')
# store cred.credential_id
>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'66c921aa0ff7aea1ce225e2d'
ADLS OAuth credentials
You can store ADLS OAuth credentials either using the three parameters:
client_id
client_secret
oauth_scopes
or the ID of the saved shared secure configuration
config_id
>>> import datarobot as dr
>>> cred = dr.Credential.create_adls_oauth(
... name='my_adls_oauth_cred',
... client_id='<client id>',
... client_secret='<client secret>',
... oauth_scopes=['<oauth scope>'],
... )
>>> cred
Credential('66c9227e3b268d3278225e41', 'my_adls_oauth_cred', 'adls_gen2_oauth')
# using config_id
>>> cred = dr.Credential.dr.Credential.create_adls_oauth(
... name='my_adls_oauth_cred_with_config_id',
... config_id='<id_of_shared_secure_configuration>',
... )
>>> cred
Credential('66c922b3ae75806f1d126f06', 'my_adls_oauth_cred_with_config_id', 'adls_gen2_oauth')
# store cred.credential_id
>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'66c922b3ae75806f1d126f06'
Credential Data
For methods that accept credential data instead of user/password, or credential ID:
{
"credentialType": "basic",
"user": "user123",
"password": "pass123",
}
{
"credentialType": "s3",
"awsAccessKeyId": "key123",
"awsSecretAccessKey": "secret123",
}
{
"credentialType": "s3",
"configId": "id123",
}
{
"credentialType": "oauth",
"oauthRefreshToken": "token123",
"oauthClientId": "client123",
"oauthClientSecret": "secret123",
}
{
"credentialType": "snowflake_key_pair_user_account",
"user": "user123",
"privateKey": "privatekey123",
"passphrase": "passphrase123",
}
{
"credentialType": "snowflake_key_pair_user_account",
"configId": "id123",
}
{
"credentialType": "databricks_access_token_account",
"databricksAccessToken": "token123",
}
{
"credentialType": "databricks_service_principal_account",
"clientId": "client123",
"clientSecret": "secret123",
}
{
"credentialType": "databricks_service_principal_account",
"configId": "id123",
}
{
"credentialType": "azure_service_principal",
"clientId": "client123",
"clientSecret": "secret123",
"azureTenantId": "tenant123"
}
{
"credentialType": "azure_service_principal",
"configId": "id123",
}
{
"credentialType": "adls_gen2_oauth",
"clientId": "client123",
"clientSecret": "secret123",
"oauthScopes": ["scope123"]
}
{
"credentialType": "adls_gen2_oauth",
"configId": "id123",
}