Cloud¶
The cloud
property on the dbtCloudClient
class contains methods that allow a user to perform CRUD operations against dbt Cloud resources.
Accounts¶
get_account¶
Get an account by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_account(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc accounts get --account-id 1
get_account_by_name¶
Get an account by its name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_name |
str
|
Name of an account |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_account_by_name(account_name)
dbtc accounts get-by-name --account-name "Doug Sandbox"
get_account_licenses¶
List account licenses for a specified account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_account_licenses(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc accounts get-licenses
list_accounts¶
List of accounts that your API Token is authorized to access.
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_accounts()
dbtc accounts list
list_audit_logs¶
List audit logs for a specific account
Note
This API is only available to enterprise customers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
logged_at_start |
str
|
Date to begin retrieving audit logs Format is yyyy-mm-dd |
None
|
logged_at_end |
str
|
Date to stop retrieving audit logs. Format is yyyy-mm-dd |
None
|
offset |
int
|
The offset to apply when listing runs. Use with limit to paginate results. |
None
|
limit |
int
|
The limit to apply when listing runs. Use with offset to paginate results. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_audit_logs(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc accounts list-audit-logs
list_feature_flags¶
List feature flags for a specific account
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_feature_flags(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-feature-flags
Adapters¶
create_adapter¶
Create an adapter
Note
This is a prerequisite for creating a Databricks connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
payload |
dict
|
Dictionary representing the adapter to create |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
payload = {
"id": None,
"account_id": 1,
"created_by_id": 1,
"project_id": 1,
"state": 1,
"adapter_version": "databricks_spark_v0"
}
client.cloud.create_adapter(1, 1, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc adapters create --payload='{"id": null, "account_id": 1, "created_by_id": 1, "project_id": 1, "state": 1, "adapter_version": "databricks_spark_v0"}'
delete_adapter¶
Delete an adapter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
adapter_id |
int
|
Numeric ID of the adapter to delete |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_adapter(1, 1, 1)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc adapters delete --adapter-id 1
get_adapter¶
Get an adapter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
adapter_id |
int
|
Numeric ID of the adapter |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_adapter(1, 1, 1)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc adapters get --adapter-id 1
update_adapter¶
Update an adapter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
adapter_id |
int
|
Numeric ID of the adapter |
required |
payload |
dict
|
Dictionary representing the adapter to update |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
payload = {
"id": None,
"account_id": 1,
"created_by_id": 1,
"project_id": 1,
"state": 1,
"adapter_version": "databricks_spark_v0"
}
client.cloud.update_adapter(1, 1, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc adapters update --payload='{"id": null, "account_id": 1, "created_by_id": 1, "project_id": 1, "state": 1, "adapter_version": "databricks_spark_v0"}'
Runs¶
get_most_recent_run_artifact¶
Fetch artifacts from the most recent run
Once a run has completed, you can use this endpoint to download the
manifest.json
, run_results.json
or catalog.json
files from dbt Cloud.
These artifacts contain information about the models in your dbt project,
timing information around their execution, and a status message indicating the
result of the model build.
Note
By default, this endpoint returns artifacts from the last step in the run. To list artifacts from other steps in the run, use the step query parameter described below.
Warning
If requesting a non JSON artifact, the result will be a str
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
path |
str
|
Paths are rooted at the target/ directory. Use manifest.json, catalog.json, or run_results.json to download dbt-generated artifacts for the run. |
required |
job_definition_id |
int
|
Applies a filter to only return runs from the specified Job. |
None
|
environment_id |
int
|
Numeric ID of the environment |
None
|
project_id |
int or list
|
The project ID or IDs |
None
|
deferring_run_id |
int
|
Numeric ID of a deferred run |
None
|
step |
str
|
The index of the Step in the Run to query for artifacts. The first step in the run has the index 1. If the step parameter is omitted, then this endpoint will return the artifacts compiled for the last step in the run. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_most_recent_run_artifact(account_id, path)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc runs get-most-recent-artifact --path manifest.json
get_run_artifact¶
Fetch artifacts from a completed run.
Once a run has completed, you can use this endpoint to download the
manifest.json
, run_results.json
or catalog.json
files from dbt Cloud.
These artifacts contain information about the models in your dbt project,
timing information around their execution, and a status message indicating the
result of the model build.
Note
By default, this endpoint returns artifacts from the last step in the run. To list artifacts from other steps in the run, use the step query parameter described below.
Warning
If requesting a non JSON artifact, the result will be a str
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
run_id |
int
|
Numeric ID of the run to retrieve |
required |
path |
str
|
Paths are rooted at the target/ directory. Use manifest.json, catalog.json, or run_results.json to download dbt-generated artifacts for the run. |
required |
step |
str
|
The index of the Step in the Run to query for artifacts. The first step in the run has the index 1. If the step parameter is omitted, then this endpoint will return the artifacts compiled for the last step in the run. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_run_artifact(account_id, run_id, path)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc runs get-artifact --run-id 1 --path "manifest.json"
list_run_artifacts¶
Fetch a list of artifact files generated for a completed run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
run_id |
int
|
Numeric ID of the run to retrieve |
required |
step |
str
|
The index of the Step in the Run to query for artifacts. The first step in the run has the index 1. If the step parameter is omitted, then this endpoint will return the artifacts compiled for the last step in the run. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_run_artifacts(account_id, run_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc runs list-artifacts --run-id 1
Connection¶
create_connection¶
Create a connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
payload |
dict
|
Dictionary representing the connection to create |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_connection(account_id, project_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc connections create --payload='{"id": null, "name": "<connection-name>", "type": "redshift", "details": {"hostname": "<hostname>", "port": 5439, "dbname": "<your-db-name>", "tunnel_enabled": false}, "state": 1, "account_id": 1, "project_id": 1}' # noqa: E501
payload = {
'id': None,
'name': 'Test',
'type': 'snowflake',
'details': {
'account': snowflake_account,
'role': snowflake_role,
'database': snowflake_database,
'warehouse': snowflake_warehouse,
'oauth_client_id': None,
'oauth_client_secret': None,
'client_session_keep_alive': False,
'allow_sso': False,
},
'state': 1,
'account_id': 1,
'project_id': 1,
}
payload = {
'id': None,
'name': '<test-bigquery-connection>',
'type': 'bigquery',
'details': {
'retries': 1,
'maximum_bytes_billed': 0,
'locaiton': None,
'timeout_seconds': 300,
'project_id': google_cloud_project_id,
'private_key_id': service_account_private_key_id,
'private_key': '-----BEGIN PRIVATE KEY----',
'client_email': 'service_account_email@gmail.com',
'client_id': '<service-account-client-id',
'auth_uri': 'https://accounts.google.com/o/oauth2/auth',
'token_uri': 'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url': 'https://www.googleapiscom/robot/v1/metadata/x509/<service-account-email>',
'application_id': None,
'application_secret': None,
},
'state': 1,
'account_id': 1,
'project_id': 1,
}
payload = {
'id': None,
'name': '<connection-name>',
'type': 'redshift',
'details': {
'hostname': '<hostname>',
'port': 5439,
'dbname': '<your-db-name>',
'tunnel_enabled': False,
},
'state': 1,
'account_id': 1,
'project_id': 1,
}
delete_connection¶
Delete a connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
connection_id |
int
|
Numeric ID of the connection to delete |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_connection(1, 1, 1)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc connections delete --connection-id 1
list_connections¶
List connections for a specific account and project
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
project_id |
int
|
Numeric ID of the project to retrieve |
required |
state |
int
|
1 = active, 2 = deleted |
None
|
offset |
int
|
The offset to apply when listing runs. Use with limit to paginate results. |
None
|
limit |
int
|
The limit to apply when listing runs. Use with offset to paginate results. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_connections(1, 1)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc connections list
test_connection¶
Test a connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
payload |
dict
|
Dictionary representing the connection to test |
required |
update_connection¶
Update a connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
connection_id |
int
|
Numeric ID of the connection to update |
required |
payload |
dict
|
Dictionary representing the connection to update |
required |
Credentials¶
create_credentials¶
Create credentials
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
payload |
dict
|
Dictionary representing the credentials to create |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_credentials(account_id, project_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc create-credentials --payload='{"id": null, "account_id": 1, "created_by_id": 1, "project_id": 1, "state": 1, "adapter_version": "databricks_spark_v0"}' # noqa: E501
payload = {
'id': None,
'account_id': 1,
'created_by_id': 1,
'project_id': 1,
'state': 1,
'adapter_version': 'databricks_spark_v0',
}
list_credentials¶
List credentials for a specific account and project
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
project_id |
int
|
Numeric ID of the project to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_credentials(account_id, project_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc list-credentials
update_credentials¶
Update credentials
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
credentials_id |
int
|
Numeric ID of the credentials to update |
required |
payload |
dict
|
Dictionary representing the credentials to update |
required |
Environment¶
create_environment¶
Create an environment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
payload |
dict
|
Dictionary representing the environment to create |
required |
delete_environment¶
Delete job for a specified account
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
environment_id |
int
|
Numeric ID of the environment to delete |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_environment(account_id, project_id, environment_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc delete-environment --environment-id=1
list_environments¶
List environments for a specific account and project
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
project_id |
int or list
|
The project ID or IDs |
required |
dbt_version |
str or list
|
The version of dbt the environment is using |
None
|
deployment_type |
str or list
|
The deployment type of the environment. Valid values are "staging" and "production" |
None
|
credentials_id |
int
|
Numeric ID of the credentials to retrieve |
None
|
name |
str
|
Name of the environment to retrieve |
None
|
type |
str
|
Type of the environment (deployment or development) |
None
|
state |
int
|
1 = active, 2 = deleted |
None
|
offset |
int
|
The offset to apply when listing runs. Use with limit to paginate results. |
None
|
limit |
int
|
The limit to apply when listing runs. Use with offset to paginate results. |
None
|
order_by |
str
|
Field to order the result by. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_environments(account_id, project_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc list-environments
update_environment¶
Update a connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
environment_id |
int
|
Numeric ID of the environment to update |
required |
payload |
dict
|
Dictionary representing the environment to update |
required |
Environment Variables¶
create_environment_variables¶
Create environment variables
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
payload |
dict
|
Dictionary representing the environment variables to create |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_environment_variables(account_id, project_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc create-credentials --payload='{"env_var": {"name": "DBT_ENV_TEST", "ids": [], "new_name": "DBT_ENV_TEST", "project": "foo", "{{development_environment_name}}": "dev_value", "{{deployment_environment_name}}": "deploy_value"}}'
payload = {
'env_var': {
'name': 'DBT_ENV_TEST',
'ids': [],
'new_name': 'DBT_ENV_TEST',
'project': 'foo',
'{{development_environment_name}}': 'dev_value',
'{{deployment_environment_name}}': 'deploy_value'
}
}
delete_environment_variables¶
Delete environment variables
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
env_var_id |
int
|
Numeric ID of the environment variable to delete |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_environment_variables(account_id, project_id, environment_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc delete-environment --payload='{"name": "DBT_MY_AWESOME_VARIABLE"}'
payload = {
'name': 'DBT_MY_AWESOME_VARIABLE'
}
Group¶
assign_group_permissions¶
Assign group permissions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
group_id |
int
|
Numeric ID of the group |
required |
payload |
dict
|
Dictionary representing the group to create |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.assign_service_token_permissions(account_id, group_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc assign-group-permissions --payload='[{"group_id": 1, "account_id": 1, "permission_set": "analyst", "project_id": 1, "all_projects": false}]'
payload = [
{
'group_id': 1,
'account_id': 1,
'permission_set': 'analyst',
'project_id': 1,
'all_projects': False
},
]
assign_user_to_group¶
Assign a user to a group
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
payload |
dict
|
Dictionary representing the user to assign |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.assign_user_to_group(account_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc assign-user-to-group --payload='{"user_id": 1, "desired_group_ids": [1]}'
payload = {
'user_id': 1,
'desired_group_ids': [1],
}
create_user_group¶
Create a user group
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
payload |
dict
|
Dictionary representing the group to create |
required |
Note
The group_name is the name of the dbt Cloud group. The list of sso_mapping_groups are string values that dbt Cloud will attempt to match with incoming information from your identity provider at login time, in order to assign the group with group_name to the user.
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_user_group(account_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc create-user-group --payload='{"account_id": 1, "name": "{{group_name}}", "assign_by_default": false, "sso_mapping_groups": ["mapping_group_1"]}'
payload = {
'account_id':1,
'name':'{{group_name}}',
'assign_by_default':False,
'sso_mapping_groups':['mapping_group_1']
}
delete_user_group¶
Delete group for a specified account
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
group_id |
int
|
Numeric ID of the group to delete |
required |
payload |
dict
|
Dictionary representing the group to delete with the format { "account_id": int, "name": str, "id": int, "state":2, "assign_by_default":false, "sso_mapping_groups": list } |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_group(account_id, group_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc delete-environment --group-id=1
payload = {
'account_id': 1,
'name': '{{ group_name }}',
'id': 1,
'state':2,
'assign_by_default': False,
'sso_mapping_groups': []
}
list_groups¶
List groups for a specific account and project
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_groups(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-groups
Job¶
create_job¶
Create a job
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
payload |
dict
|
Dictionary representing the job to create |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_job(account_id, project_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc create-credentials --payload='{"account_id": 1, "project_id": 1, "id": null, "environment_id": 1, "name": "<your-job-name>", "dbt_version": "1.0.1", "triggers": {"github_webhook": false, "schedule": false, "custom_branch_only": false}, "execute_steps": ["dbt build"], "settings": {"threads": 1, "target_name": "default"}, "state": 1, "generate_docs": false, "schedule": {"date": {"type": "every_day"}, "time": {"type": "every_hour", "interval": 1}}}'
payload = {
'account_id': 1,
'project_id': 1,
'id': None,
'environment_id': 1,
'name': '<your-job-name>',
'dbt_version': '1.0.1',
'triggers': {
'github_webhook': False,
'schedule': False,
'custom_branch_only': False
},
'execute_steps': [
'dbt build'
],
'settings': {
'threads': 1,
'target_name': 'default'
},
'state': 1,
'generate_docs': False,
'schedule': {
'date': {
'type': 'every_day'
},
'time': {
'type': 'every_hour',
'interval': 1
}
}
}
delete_job¶
Delete job for a specified account
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
job_id |
int
|
Numeric ID of the project to delete |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_job(account_id, job_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc delete-environment --job-id=1
get_job¶
Get a job by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
job_id |
int
|
Numeric ID of the job to retrieve |
required |
order_by |
str
|
Field to order the result by. Use - to indicate reverse order. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_job(account_id, job_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc get-job --job-id=1
list_jobs¶
List jobs in an account or specific project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
environment_id |
int
|
Numeric ID of the environment to retrieve |
None
|
project_id |
int or list
|
The project ID or IDs |
None
|
state |
int
|
1 = active, 2 = deleted |
None
|
offset |
int
|
The offset to apply when listing runs. Use with limit to paginate results. |
None
|
limit |
int
|
The limit to apply when listing runs. Use with offset to paginate results. |
None
|
order_by |
str
|
Field to order the result by. Use - to indicate reverse order. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_jobs(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-jobs
trigger_autoscaling_ci_job¶
Trigger an autoscaling CI job
Info
In the event your CI job is already running, this will do the following:
- If a new commit is created for the currently running job, cancel the job and then trigger again
- If this is an entirely new pull request, clone the job and trigger
- This will also check to see if your account has met or exceeded the allotted run slots. In the event you have, a cloned job will not be created and the existing job will be triggered.
More info here
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
job_id |
int
|
Numeric ID of the job to trigger |
required |
payload |
dict
|
Payload required in triggering a job. It's important that the payload consists of the following keys in order to mimic the native behavior of dbt Cloud's Slim CI functionality:
|
required |
should_poll |
bool
|
Poll until completion if |
False
|
poll_interval |
int
|
Number of seconds to wait in between polling |
10
|
delete_cloned_job |
bool
|
Indicate if cloned job should be deleted after being triggered |
True
|
max_run_slots |
int
|
Number of run slots that should be
available to this process. This will limit the ability to run
concurrent PRs up the the allocated run slots for your account. When
set to |
None
|
trigger_job¶
Trigger a job by its ID
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
job_id |
int
|
Numeric ID of the job to trigger |
required |
payload |
dict
|
Payload required for post request |
required |
should_poll |
bool
|
Poll until completion if |
True
|
poll_interval |
int
|
Number of seconds to wait in between polling |
10
|
retries |
int
|
Number of times to retry a failed job |
0
|
trigger_job_from_failure¶
Trigger job from point of failure
Use this method to retry a failed run for a job from the point of failure, if the run failed. Otherwise trigger a new run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
job_id |
int
|
Numeric ID of the job to trigger |
required |
update_job¶
Update a job by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
job_id |
int
|
Numeric ID of the job to retrieve |
required |
payload |
dict
|
Payload required for post request |
required |
Repository¶
create_repository¶
Create a repository
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
payload |
dict
|
Dictionary representing the repository to create |
required |
Note
After creating / updating a dbt Cloud repository's SSH key, you will need to add the generated key text as a deploy key to the target repository. This gives dbt Cloud permissions to read / write in the repository
You can read more in the docs # noqa: E501
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_repository(account_id, project_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc create-repository --payload='{"account_id": 1, "project_id": 1, "remote_url": "{{git_clone_url}}", "git_clone_strategy": "deploy_key", "github_installation_id": null, "token_str": null}'
payload = {
'account_id': 1,
'project_id': 1,
'remote_url':'{{git_clone_url}}',
'git_clone_strategy': 'deploy_key',
'github_installation_id': None,
'token_str': None
}
delete_repository¶
Delete repository for a specified account
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
repository_id |
int
|
Numeric ID of the repository to delete |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_repository(account_id, project_id, repository_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc delete-repository --repository-id=1
list_repositories¶
List repositories for a specific account and project
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
project_id |
int
|
Numeric ID of the project to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_repositories(account_id, project_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc list-repositories
update_repository¶
Update a connection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project |
required |
repository_id |
int
|
Numeric ID of the repository to update |
required |
payload |
dict
|
Dictionary representing the repository to update |
required |
Run¶
cancel_run¶
Cancel a run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
run_id |
int
|
Numeric ID of the run to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.cancel_run(account_id, run_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
```bash
dbtc cancel-run --account-id=1 --run-id=1
get_most_recent_run¶
Get the most recent run
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
include_related |
list
|
List of related
fields to pull with the run. Valid values are |
None
|
job_definition_id |
int
|
Applies a filter to only return runs from the specified Job. |
None
|
environment_id |
int
|
Numeric ID of the environment |
None
|
project_id |
int or list
|
The project ID or IDs |
None
|
deferring_run_id |
int
|
Numeric ID of a deferred run |
None
|
status |
str or list
|
The status to apply when listing runs. Options include queued, starting, running, success, error, and cancelled |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_most_recent_run(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc get-most-recent-run
get_run¶
Get a run by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
run_id |
int
|
Numeric ID of the run to retrieve |
required |
include_related |
list
|
List of related
fields to pull with the run. Valid values are |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_run(account_id, run_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc get-run --run-id=1
get_run_timing_details¶
Retrieves the timing details related to a run
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
run_id |
int
|
Numeric ID of the run to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_run_timing_details(account_id, project_id, run_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc get-run-timing-details --run-id=1
list_runs¶
List runs in an account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
include_related |
list
|
List of related
fields to pull with the run. Valid values are |
None
|
job_definition_id |
int
|
Applies a filter to only return runs from the specified Job. |
None
|
environment_id |
int
|
Numeric ID of the environment |
None
|
project_id |
int or list
|
The project ID or IDs |
None
|
deferring_run_id |
int
|
Numeric ID of a deferred run |
None
|
status |
str or list
|
The status to apply when listing runs. Options include queued, starting, running, success, error, and cancelled |
None
|
order_by |
str
|
Field to order the result by. Use - to indicate reverse order. |
None
|
offset |
int
|
The offset to apply when listing runs. Use with limit to paginate results. |
None
|
limit |
int
|
The limit to apply when listing runs. Use with offset to paginate results. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_runs(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-runs
Project¶
create_project¶
Create a project
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
payload |
dict
|
Dictionary representing the project to create |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_project(account_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc create-project --payload='{"id": null, "name": "{{project_name}}", "dbt_project_subdirectory": null, "account_id": 1, "connection_id": null, "repository_id": null}'
payload = {
'id': None,
'name': '{{project_name}}',
'dbt_project_subdirectory': None,
'account_id': 1,
'connection_id': None,
'repository_id': None
}
delete_project¶
Delete project for a specified account
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project to delete |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.delete_project(account_id, project_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc delete-project
get_project¶
Get a project by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
project_id |
int
|
Numeric ID of the project to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_project(account_id, project_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc get-project
get_project_by_name¶
Get a project by its name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name |
str
|
Name of project to retrieve |
required |
account_id |
int
|
Numeric ID of the account to retrieve |
None
|
account_name |
str
|
Name of account to retrieve |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_project_by_name(account_id, project_name)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc get-project --project-name=name
list_projects¶
List projects for a specified account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
project_id |
int or list
|
The project ID or IDs |
None
|
state |
int
|
1 = active, 2 = deleted |
None
|
offset |
int
|
The offset to apply when listing runs. Use with limit to paginate results. |
None
|
limit |
int
|
The limit to apply when listing runs. Use with offset to paginate results. |
None
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_projects(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-projects
update_project¶
Update project for a specified account
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
project_id |
int
|
Numeric ID of the project to update |
required |
payload |
dict
|
Dictionary representing the project to update |
required |
Service Token¶
assign_service_token_permissions¶
Assign permissions to a service token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
service_token_id |
int
|
Numeric ID of the service token |
required |
payload |
list
|
List of dictionaries representing the permissions to assign |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.assign_service_token_permissions(account_id, service_token_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
and DBT_CLOUD_PROJECT_ID
environment variables have been set.
dbtc assign-service-token-permissions --payload='[{"service_token_id": 1, "account_id": 1, "permission_set": "job_viewer", "project_id": 1, "all_projects": false}]'
payload = [
{
'service_token_id': 1,
'account_id': 1,
'permission_set': 'job_viewer',
'project_id': 1,
'all_projects': False
},
]
create_service_token¶
Create a service token
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
payload |
dict
|
Dictionary representing the service token to create |
required |
Note
This request creates a service token, but does not assign permissions to it. Permissions are assigned via the assign_service_token_permissions
See the user tokens # noqa: E501 and service tokens # noqa: E501 documentation for more information.
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.create_service_token(account_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc create-service-token --payload='{"id": null, "name": "api-test", "state": 1, "account_id": 1, "access": {"admin": {"permissionSet": "admin", "projects": [1]}, "job_admin": {"permissionSet": "job_admin", "projects": [1]}}}'
payload = {
'id': None,
'name': 'api-test',
'state': 1,
'account_id': 1,
'access': {
'admin': {
'permissionSet': 'admin',
'projects': [
1
]
},
'job_admin': {
'permissionSet': 'job_admin',
'projects': [
1
]
}
}
}
get_service_token¶
Retrieves a service token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
service_token_id |
int
|
Numeric ID of the service token to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_service_toke (account_id, service_token_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc get-service-token --service-token-id=1
list_service_tokens¶
List service tokens for a specific account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_service_tokens(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-service-tokens
list_service_token_permissions¶
List service token permissions for a specific account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
service_token_id |
int
|
Numeric ID of the service token to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_service_token_permissions(account_id, service_token_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-service-token-permissions --service-token-id=1
User¶
deactivate_user_license¶
Deactivate user license
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account |
required |
permission_id |
int
|
Numeric ID of the permission that contains user you'd like to deactivate |
required |
Note
Ensure the groups
object contains all of a user's assigned group
permissions. This request will fail if a user has already been deactivated.
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.deactivate_user_license(account_id, permission_id, payload)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc deactivate-user-license --permission_id=1 --payload='{"license_type": "developer", "id": 1, "user_id": 1, "account_id": 1, "state": 2, "groups": [{"account_id": 1, "name": "test-group-with-sso-mappings", "id": 1, "state": 1, "assign_by_default": false, "sso_mapping_groups": ["something"], "group_permissions": [{"account_id": 1, "group_id": 1, "project_id": null, "all_projects": true, "permission_set": "analyst", "permission_level": null, "id": "{{group_permission_id}}", "state": 1}]}], "permission_statements": [{"permission": "invitations_read", "target_resource": null, "all_resources": true}, {"permission": "license_read", "target_resource": null, "all_resources": true}, {"permission": "projects_read", "target_resource": null, "all_resources": true}, {"permission": "environments_read", "target_resource": null, "all_resources": true}, {"permission": "jobs_read", "target_resource": null, "all_resources": true}, {"permission": "runs_read", "target_resource": null, "all_resources": true}, {"permission": "metadata_read", "target_resource": null, "all_resources": true}, {"permission": "custom_environment_variables_read", "target_resource": null, "all_resources": true}, {"permission": "projects_develop", "target_resource": null, "all_resources": true}, {"permission": "credentials_write", "target_resource": null, "all_resources": true}, {"permission": "develop_access", "target_resource": null, "all_resources": true}, {"permission": "custom_environment_variables_write", "target_resource": null, "all_resources": true}]}'
payload = {
'license_type': 'developer',
'id': 1,
'user_id': 1,
'account_id': 1,
'state': 2,
'groups': [
{
'account_id': 1,
'name': 'test-group-with-sso-mappings',
'id': 1,
'state': 1,
'assign_by_default': False,
'sso_mapping_groups': [
'something'
],
'group_permissions': [
{
'account_id': 1,
'group_id': 1,
'project_id': None,
'all_projects': True,
'permission_set': 'analyst',
'permission_level': None,
'id': '{{group_permission_id}}',
'state': 1
}
]
}
],
'permission_statements': [
{
'permission': 'invitations_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'license_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'projects_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'environments_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'jobs_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'runs_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'metadata_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'custom_environment_variables_read',
'target_resource': None,
'all_resources': True
},
{
'permission': 'projects_develop',
'target_resource': None,
'all_resources': True
},
{
'permission': 'credentials_write',
'target_resource': None,
'all_resources': True
},
{
'permission': 'develop_access',
'target_resource': None,
'all_resources': True
},
{
'permission': 'custom_environment_variables_write',
'target_resource': None,
'all_resources': True
}
]
}
get_user¶
List invited users in an account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
user_id |
int
|
Numeric ID of the user to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.get_user(account_id, user_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc get_user --user-id=1
list_invited_users¶
List invited users in an account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_invited_users(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-invited-users
list_users¶
List users in an account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id |
int
|
Numeric ID of the account to retrieve |
required |
state |
int
|
1 = active, 2 = deleted |
None
|
limit |
int
|
The limit to apply when listing runs. Use with offset to paginate results. |
None
|
offset |
int
|
The offset to apply when listing runs. Use with limit to paginate results. |
None
|
order_by |
str
|
Field to order the result by. Use - to indicate reverse order. |
'email'
|
Examples:
Assuming that client
is an instance of dbtCloudClient
client.cloud.list_users(account_id)
Assuming that DBT_CLOUD_ACCOUNT_ID
environment variable has been set.
dbtc list-users