Skip to content

Commit 836d484

Browse files
authored
Merge pull request #102 from dpguthrie/feat/create-command-groups
CLI Command Groups
2 parents f555d2c + 9b9c983 commit 836d484

File tree

9 files changed

+4261
-1387
lines changed

9 files changed

+4261
-1387
lines changed

dbtc/cli.py

Lines changed: 1942 additions & 644 deletions
Large diffs are not rendered by default.

dbtc/client/admin.py

Lines changed: 1174 additions & 580 deletions
Large diffs are not rendered by default.

dbtc/client/metadata.py

Lines changed: 454 additions & 1 deletion
Large diffs are not rendered by default.

docs/guide/cloud.md

Lines changed: 131 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
The `cloud` property on the `dbtCloudClient` class contains methods that allow a user to perform CRUD operations against dbt Cloud resources.
44

5-
6-
## Account
5+
## Accounts
76

87
### get_account
98
::: dbtc.client.admin._AdminClient.get_account
@@ -20,7 +19,7 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
2019

2120
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
2221
```bash
23-
dbtc get-account
22+
dbtc accounts get --account-id 1
2423
```
2524

2625
### get_account_by_name
@@ -37,7 +36,7 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
3736
=== "CLI"
3837

3938
```bash
40-
dbtc get-account-by-name --account-name=name
39+
dbtc accounts get-by-name --account-name "Doug Sandbox"
4140
```
4241

4342
### get_account_licenses
@@ -55,7 +54,7 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
5554

5655
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
5756
```bash
58-
dbtc get-account-licenses
57+
dbtc accounts get-licenses
5958
```
6059

6160
### list_accounts
@@ -72,133 +71,216 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
7271
=== "CLI"
7372

7473
```bash
75-
dbtc list-accounts
74+
dbtc accounts list
7675
```
7776

78-
## Artifact
79-
80-
### get_most_recent_run_artifact
81-
::: dbtc.client.admin._AdminClient.get_most_recent_run_artifact
77+
### list_audit_logs
78+
::: dbtc.client.admin._AdminClient.list_audit_logs
8279

8380
**Examples:**
8481
=== "Python"
8582

8683
Assuming that `client` is an instance of `dbtCloudClient`
8784
```py
88-
client.cloud.get_most_recent_run_artifact(account_id, path)
85+
client.cloud.list_audit_logs(account_id)
8986
```
9087

9188
=== "CLI"
9289

9390
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
9491
```bash
95-
dbtc get-most-recent-run-artifact --path manifest.json
92+
dbtc accounts list-audit-logs
9693
```
9794

98-
### get_run_artifact
99-
::: dbtc.client.admin._AdminClient.get_run_artifact
95+
### list_feature_flags
96+
::: dbtc.client.admin._AdminClient.list_feature_flags
10097

10198
**Examples:**
10299
=== "Python"
103100

104101
Assuming that `client` is an instance of `dbtCloudClient`
105102
```py
106-
client.cloud.get_run_artifact(account_id, run_id, path)
103+
client.cloud.list_feature_flags(account_id)
107104
```
108105

109106
=== "CLI"
110107

111108
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
112109
```bash
113-
dbtc get-run-artifact --run-id=1 --path=manifest.json
110+
dbtc list-feature-flags
114111
```
115112

116-
### list_run_artifacts
117-
::: dbtc.client.admin._AdminClient.list_run_artifacts
113+
## Adapters
114+
115+
### create_adapter
116+
::: dbtc.client.admin._AdminClient.create_adapter
118117

119118
**Examples:**
120119
=== "Python"
121120

122121
Assuming that `client` is an instance of `dbtCloudClient`
123122
```py
124-
client.cloud.list_run_artifacts(account_id, run_id)
123+
payload = {
124+
"id": None,
125+
"account_id": 1,
126+
"created_by_id": 1,
127+
"project_id": 1,
128+
"state": 1,
129+
"adapter_version": "databricks_spark_v0"
130+
}
131+
client.cloud.create_adapter(1, 1, payload)
125132
```
126133

127134
=== "CLI"
128135

129-
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
136+
Assuming that `DBT_CLOUD_ACCOUNT_ID` and `DBT_CLOUD_PROJECT_ID`
137+
environment variables have been set.
130138
```bash
131-
dbtc list-environments --run-id=1
139+
dbtc adapters create --payload='{"id": null, "account_id": 1, "created_by_id": 1, "project_id": 1, "state": 1, "adapter_version": "databricks_spark_v0"}'
132140
```
133141

134-
## Audit Log
135-
136-
### list_audit_logs
137-
::: dbtc.client.admin._AdminClient.list_audit_logs
142+
### delete_adapter
143+
::: dbtc.client.admin._AdminClient.delete_adapter
138144

139145
**Examples:**
140146
=== "Python"
141147

142148
Assuming that `client` is an instance of `dbtCloudClient`
143149
```py
144-
client.cloud.list_audit_logs(account_id)
150+
client.cloud.delete_adapter(1, 1, 1)
145151
```
146152

147153
=== "CLI"
148154

149-
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
155+
Assuming that `DBT_CLOUD_ACCOUNT_ID` and `DBT_CLOUD_PROJECT_ID`
156+
environment variables have been set.
150157
```bash
151-
dbtc list-audit-logs
158+
dbtc adapters delete --adapter-id 1
152159
```
153160

154-
## Connection
155-
156-
### create_adapter
157-
::: dbtc.client.admin._AdminClient.create_adapter
161+
### get_adapter
162+
::: dbtc.client.admin._AdminClient.get_adapter
158163

159164
**Examples:**
160165
=== "Python"
161166

162167
Assuming that `client` is an instance of `dbtCloudClient`
163168
```py
164-
client.cloud.create_adapter(account_id, project_id, payload)
169+
client.cloud.get_adapter(1, 1, 1)
165170
```
166171

167172
=== "CLI"
168173

169174
Assuming that `DBT_CLOUD_ACCOUNT_ID` and `DBT_CLOUD_PROJECT_ID`
170175
environment variables have been set.
171176
```bash
172-
dbtc create-adapter --payload='{"id": null, "account_id": 1, "created_by_id": 1, "project_id": 1, "state": 1, "adapter_version": "databricks_spark_v0"}' # noqa: E501
177+
dbtc adapters get --adapter-id 1
173178
```
174179

175-
=== "Payload"
180+
### update_adapter
181+
::: dbtc.client.admin._AdminClient.update_adapter
176182

183+
**Examples:**
184+
=== "Python"
185+
186+
Assuming that `client` is an instance of `dbtCloudClient`
177187
```py
178188
payload = {
179-
'id': None,
180-
'account_id': 1,
181-
'created_by_id': 1,
182-
'project_id': 1,
183-
'state': 1,
184-
'adapter_version': 'databricks_spark_v0',
189+
"id": None,
190+
"account_id": 1,
191+
"created_by_id": 1,
192+
"project_id": 1,
193+
"state": 1,
194+
"adapter_version": "databricks_spark_v0"
185195
}
196+
client.cloud.update_adapter(1, 1, payload)
197+
```
198+
199+
=== "CLI"
200+
201+
Assuming that `DBT_CLOUD_ACCOUNT_ID` and `DBT_CLOUD_PROJECT_ID`
202+
environment variables have been set.
203+
```bash
204+
dbtc adapters update --payload='{"id": null, "account_id": 1, "created_by_id": 1, "project_id": 1, "state": 1, "adapter_version": "databricks_spark_v0"}'
205+
```
206+
207+
## Runs
208+
209+
### get_most_recent_run_artifact
210+
::: dbtc.client.admin._AdminClient.get_most_recent_run_artifact
211+
212+
**Examples:**
213+
=== "Python"
214+
215+
Assuming that `client` is an instance of `dbtCloudClient`
216+
```py
217+
client.cloud.get_most_recent_run_artifact(account_id, path)
218+
```
219+
220+
=== "CLI"
221+
222+
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
223+
```bash
224+
dbtc runs get-most-recent-artifact --path manifest.json
225+
```
226+
227+
### get_run_artifact
228+
::: dbtc.client.admin._AdminClient.get_run_artifact
229+
230+
**Examples:**
231+
=== "Python"
232+
233+
Assuming that `client` is an instance of `dbtCloudClient`
234+
```py
235+
client.cloud.get_run_artifact(account_id, run_id, path)
236+
```
237+
238+
=== "CLI"
239+
240+
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
241+
```bash
242+
dbtc runs get-artifact --run-id 1 --path "manifest.json"
243+
```
244+
245+
### list_run_artifacts
246+
::: dbtc.client.admin._AdminClient.list_run_artifacts
247+
248+
**Examples:**
249+
=== "Python"
250+
251+
Assuming that `client` is an instance of `dbtCloudClient`
252+
```py
253+
client.cloud.list_run_artifacts(account_id, run_id)
186254
```
187255

256+
=== "CLI"
257+
258+
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
259+
```bash
260+
dbtc runs list-artifacts --run-id 1
261+
```
262+
263+
## Connection
264+
188265
### create_connection
189266
::: dbtc.client.admin._AdminClient.create_connection
190267

191268
**Examples:**
192269
=== "Python"
193270

194271
Assuming that `client` is an instance of `dbtCloudClient`
272+
195273
```py
196274
client.cloud.create_connection(account_id, project_id, payload)
197275
```
198276

199277
=== "CLI"
278+
279+
Assuming that `DBT_CLOUD_ACCOUNT_ID` and `DBT_CLOUD_PROJECT_ID`
280+
environment variables have been set.
281+
200282
```bash
201-
dbtc create-connection --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
283+
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
202284
```
203285

204286
=== "Snowflake"
@@ -280,15 +362,15 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
280362

281363
Assuming that `client` is an instance of `dbtCloudClient`
282364
```py
283-
client.cloud.delete_connection(account_id, project_id, connection_id)
365+
client.cloud.delete_connection(1, 1, 1)
284366
```
285367

286368
=== "CLI"
287369

288370
Assuming that `DBT_CLOUD_ACCOUNT_ID` and `DBT_CLOUD_PROJECT_ID`
289371
environment variables have been set.
290372
```bash
291-
dbtc delete-connection --connection-id=1
373+
dbtc connections delete --connection-id 1
292374
```
293375

294376
### list_connections
@@ -300,15 +382,15 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
300382
Assuming that `client` is an instance of `dbtCloudClient`
301383

302384
```py
303-
client.cloud.list_connections(account_id, project_id)
385+
client.cloud.list_connections(1, 1)
304386
```
305387

306388
=== "CLI"
307389

308390
Assuming that `DBT_CLOUD_ACCOUNT_ID` and `DBT_CLOUD_PROJECT_ID`
309391
environment variables have been set.
310392
```bash
311-
dbtc list-connections
393+
dbtc connections list
312394
```
313395

314396
### test_connection
@@ -420,7 +502,7 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
420502
## Environment Variables
421503

422504
### create_environment_variables
423-
::: dbtc.client.admin._AdminClient.create_environment_variables
505+
::: dbtc.client.admin._AdminClient.create_env_vars
424506

425507
**Examples:**
426508
=== "Python"
@@ -454,7 +536,7 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
454536
```
455537

456538
### delete_environment_variables
457-
::: dbtc.client.admin._AdminClient.delete_environment_variables
539+
::: dbtc.client.admin._AdminClient.delete_env_vars
458540

459541
**Examples:**
460542
=== "Python"
@@ -480,25 +562,6 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
480562
}
481563
```
482564

483-
## Feature Flags
484-
485-
### list_feature_flags
486-
::: dbtc.client.admin._AdminClient.list_feature_flags
487-
488-
**Examples:**
489-
=== "Python"
490-
491-
Assuming that `client` is an instance of `dbtCloudClient`
492-
```py
493-
client.cloud.list_feature_flags(account_id)
494-
```
495-
496-
=== "CLI"
497-
498-
Assuming that `DBT_CLOUD_ACCOUNT_ID` environment variable has been set.
499-
```bash
500-
dbtc list-feature-flags
501-
```
502565

503566
## Group
504567

@@ -619,7 +682,7 @@ The `cloud` property on the `dbtCloudClient` class contains methods that allow a
619682
'account_id': 1,
620683
'name': '{{ group_name }}',
621684
'id': 1,
622-
'state':2,
685+
'state':2,
623686
'assign_by_default': False,
624687
'sso_mapping_groups': []
625688
}

docs/guide/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ client = dbtCloudClient()
3333
```
3434

3535
!!! info
36-
The `host` argument is only necessary for customers on single-tenant instances
36+
The `host` argument is only necessary for customers using dbt Cloud outside of the North America multi-tenant instance (see more info on [dbt Cloud hosting](https://docs.getdbt.com/docs/cloud/about-cloud/regions-ip-addresses))
3737

3838
### Interfaces
3939

0 commit comments

Comments
 (0)