Credentials¶
class datarobot.models.Credential¶
classmethod list()¶
Returns list of available credentials.
- Returns: credentials – contains a list of available credentials.
- Return type:
list
ofCredential instances
Examples
>>> import datarobot as dr
>>> data_sources = dr.Credential.list()
>>> data_sources
[
Credential('5e429d6ecf8a5f36c5693e03', 'my_s3_cred', 's3'),
Credential('5e42cc4dcf8a5f3256865840', 'my_jdbc_cred', 'jdbc'),
]
classmethod get(credential_id)¶
Gets the Credential.
- Parameters:
credential_id (
str
) – the identifier of the credential. - Returns: credential – the requested credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.get('5a8ac9ab07a57a0001be501f')
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_s3_cred', 's3'),
delete()¶
Deletes the Credential the store.
- Parameters:
credential_id (
str
) – the identifier of the credential. - Returns: credential – the requested credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.get('5a8ac9ab07a57a0001be501f')
>>> cred.delete()
classmethod create_basic(name, user, password, description=None)¶
Creates the credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - user (
str
) – the username to store for this set of credentials. - password (
str
) – the password to store for this set of credentials. - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_basic(
... name='my_basic_cred',
... user='username',
... password='password',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_basic_cred', 'basic'),
classmethod create_oauth(name, token, refresh_token, description=None)¶
Creates the OAUTH credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - token (
str
) – the OAUTH token - refresh_token (
str
) – The OAUTH token - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_oauth(
... name='my_oauth_cred',
... token='XXX',
... refresh_token='YYY',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_oauth_cred', 'oauth'),
classmethod create_s3(name, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, config_id=None, description=None)¶
Creates the S3 credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - aws_access_key_id (
Optional[str]
) – the AWS access key id. - aws_secret_access_key (
Optional[str]
) – the AWS secret access key. - aws_session_token (
Optional[str]
) – the AWS session token. - config_id (
Optional[str]
) – The ID of the saved shared secure configuration. If specified, cannot include awsAccessKeyId, awsSecretAccessKey or awsSessionToken. - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_s3(
... name='my_s3_cred',
... aws_access_key_id='XXX',
... aws_secret_access_key='YYY',
... aws_session_token='ZZZ',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_s3_cred', 's3'),
classmethod create_azure(name, azure_connection_string, description=None)¶
Creates the Azure storage credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - azure_connection_string (
str
) – the Azure connection string. - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_azure(
... name='my_azure_cred',
... azure_connection_string='XXX',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_azure_cred', 'azure'),
classmethod create_snowflake_key_pair(name, user=None, private_key=None, passphrase=None, config_id=None, description=None)¶
Creates the Snowflake Key Pair credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - user (
Optional[str]
) – the Snowflake login name - private_key (
Optional[str]
) – the private key copied exactly from user private key file. Since it contains multiple lines, when assign to a variable, put the key string inside triple-quotes - passphrase (
Optional[str]
) – the string used to encrypt the private key - config_id (
Optional[str]
) – The ID of the saved shared secure configuration. If specified, cannot include user, privateKeyStr or passphrase. - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_snowflake_key_pair(
... name='key_pair_cred',
... user='XXX',
... private_key='YYY',
... passphrase='ZZZ',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'key_pair_cred', 'snowflake_key_pair_user_account'),
classmethod create_databricks_access_token(name, databricks_access_token, description=None)¶
Creates the Databricks access token credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - databricks_access_token (
Optional[str]
) – the Databricks personal access token - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_databricks_access_token(
... name='access_token_cred',
... databricks_access_token='XXX',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'access_token_cred', 'databricks_access_token_account'),
classmethod create_databricks_service_principal(name, client_id=None, client_secret=None, config_id=None, description=None)¶
Creates the Databricks access token credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - client_id (
Optional[str]
) – the client ID for Databricks Service Principal - client_secret (
Optional[str]
) – the client secret for Databricks Service Principal - config_id (
Optional[str]
) – The ID of the saved shared secure configuration. If specified, cannot include clientId and clientSecret. - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_databricks_service_principal(
... name='svc_principal_cred',
... client_id='XXX',
... client_secret='XXX',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'svc_principal_cred', 'databricks_service_principal_account'),
classmethod create_azure_service_principal(name, client_id=None, client_secret=None, azure_tenant_id=None, config_id=None, description=None)¶
Creates the Azure service principal credentials.
- Parameters:
- name (
str
) – The name to use for these credentials. - client_id (
Optional[str]
) – The client ID. - client_secret (
Optional[str]
) – The client secret. - azure_tenant_id (
Optional[str]
) – The Azure tenant ID. - config_id (
Optional[str]
) – The ID of the saved secure configuration. If specified, the ID cannot include clientId, clientSecret, or azureTenantId. - description (
Optional[str]
) – The description to use for these credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_azure_service_principal(
... name='my_azure_service_principal_cred',
... client_id='XXX',
... client_secret='YYY',
... azure_tenant_id='ZZZ',
... )
>>> cred
Credential('66c9172d8b7a361cda126f5c', 'my_azure_service_principal_cred', 'azure_service_principal')
classmethod create_adls_oauth(name, client_id=None, client_secret=None, oauth_scopes=None, config_id=None, description=None)¶
Creates the ADLS OAuth credentials.
- Parameters:
- name (
str
) – The name to use for these credentials. - client_id (
Optional[str]
) – The client ID. - client_secret (
Optional[str]
) – The client secret. - oauth_scopes (
List[str]
, optional) – The OAuth scopes. - config_id (
Optional[str]
) – The ID of the saved shared secure configuration. If specified, cannot include clientId, clientSecret, or oauthScopes. - description (
Optional[str]
) – The description to use for the ADLS OAuth credentials.
- name (
- Returns: credential – The created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_adls_oauth(
... name='my_adls_oauth_cred',
... client_id='XXX',
... client_secret='YYY',
... oauth_scopes=['ZZZ'],
... )
>>> cred
Credential('66c91e0f03010d4790735220', 'my_adls_oauth_cred', 'adls_gen2_oauth')
classmethod create_gcp(name, gcp_key=None, description=None)¶
Creates the GCP credentials.
- Parameters:
- name (
str
) – the name to use for this set of credentials. - gcp_key (
str | dict
) – the GCP key in json format or parsed as dict. - description (
Optional[str]
) – the description to use for this set of credentials.
- name (
- Returns: credential – the created credential.
- Return type:
Credential
Examples
>>> import datarobot as dr
>>> cred = dr.Credential.create_gcp(
... name='my_gcp_cred',
... gcp_key='XXX',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_gcp_cred', 'gcp'),
update(name=None, description=None, **kwargs)¶
Update the credential values of an existing credential. Updates this object in place.
Added in version v3.2.
- Parameters:
- name (
str
) – The name to use for this set of credentials. - description (
Optional[str]
) – The description to use for this set of credentials; if omitted, and name is not omitted, then it clears any previous description for that name. - kwargs (
Keyword arguments specific
tothe given credential_type that should be updated.
)
- name (
- Return type:
None