onehouse-cli 0.1.4__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- onehouse_cli-0.2.0/PKG-INFO +283 -0
- onehouse_cli-0.2.0/README.md +260 -0
- onehouse_cli-0.2.0/onehouse_cli/cli.py +85 -0
- onehouse_cli-0.2.0/onehouse_cli/client.py +39 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/__init__.py +1 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/_base.py +60 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/api_token.py +48 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/catalog.py +88 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/cluster.py +114 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/database.py +63 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/flow.py +194 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/job.py +242 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/lake.py +89 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/service_principal.py +77 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/source.py +91 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/sql.py +42 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/table.py +268 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/transformation.py +83 -0
- onehouse_cli-0.2.0/onehouse_cli/commands/validation.py +83 -0
- {onehouse_cli-0.1.4 → onehouse_cli-0.2.0}/onehouse_cli/configure.py +12 -3
- onehouse_cli-0.2.0/onehouse_cli/output.py +84 -0
- onehouse_cli-0.2.0/onehouse_cli.egg-info/PKG-INFO +283 -0
- onehouse_cli-0.2.0/onehouse_cli.egg-info/SOURCES.txt +28 -0
- {onehouse_cli-0.1.4 → onehouse_cli-0.2.0}/onehouse_cli.egg-info/entry_points.txt +2 -0
- onehouse_cli-0.2.0/onehouse_cli.egg-info/requires.txt +7 -0
- {onehouse_cli-0.1.4 → onehouse_cli-0.2.0}/pyproject.toml +21 -7
- onehouse_cli-0.1.4/PKG-INFO +0 -92
- onehouse_cli-0.1.4/README.md +0 -72
- onehouse_cli-0.1.4/onehouse_cli/cli.py +0 -403
- onehouse_cli-0.1.4/onehouse_cli.egg-info/PKG-INFO +0 -92
- onehouse_cli-0.1.4/onehouse_cli.egg-info/SOURCES.txt +0 -11
- onehouse_cli-0.1.4/onehouse_cli.egg-info/requires.txt +0 -4
- {onehouse_cli-0.1.4 → onehouse_cli-0.2.0}/onehouse_cli/__init__.py +0 -0
- {onehouse_cli-0.1.4 → onehouse_cli-0.2.0}/onehouse_cli.egg-info/dependency_links.txt +0 -0
- {onehouse_cli-0.1.4 → onehouse_cli-0.2.0}/onehouse_cli.egg-info/top_level.txt +0 -0
- {onehouse_cli-0.1.4 → onehouse_cli-0.2.0}/setup.cfg +0 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: onehouse-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A command-line tool for the full Onehouse API
|
|
5
|
+
Author-email: Sagar Lakshmipathy <18vidhyasagar@gmail.com>
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Keywords: onehouse,cli
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: click>=8.0
|
|
18
|
+
Requires-Dist: requests>=2.28
|
|
19
|
+
Requires-Dist: onehouse-python-sdk[resources]
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pytest-mock>=3.0; extra == "dev"
|
|
23
|
+
|
|
24
|
+
# Onehouse CLI (`oh`)
|
|
25
|
+
|
|
26
|
+
A command-line tool for managing your Onehouse project — clusters, lakes, databases, tables, flows, jobs, catalogs, sources, transformations, validations, service principals, and API tokens.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install onehouse-cli
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The SDK dependency (`onehouse-python-sdk[resources]`) is installed automatically.
|
|
35
|
+
|
|
36
|
+
## Setup
|
|
37
|
+
|
|
38
|
+
**Configure credentials:**
|
|
39
|
+
```bash
|
|
40
|
+
oh-configure
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This prompts for your API credentials and saves them to `~/.onehouse/credentials`. You can create multiple named profiles and set a default.
|
|
44
|
+
|
|
45
|
+
Fields collected:
|
|
46
|
+
- Profile name
|
|
47
|
+
- Account UID
|
|
48
|
+
- Project UID
|
|
49
|
+
- API Key / API Secret
|
|
50
|
+
- Project Region
|
|
51
|
+
- User ID
|
|
52
|
+
- Request ID (link UID)
|
|
53
|
+
- API Endpoint (default: `https://api.onehouse.ai/v1`)
|
|
54
|
+
|
|
55
|
+
**Credentials are stored in:** `~/.onehouse/credentials`
|
|
56
|
+
|
|
57
|
+
Alternatively, set environment variables:
|
|
58
|
+
```bash
|
|
59
|
+
export ONEHOUSE_API_KEY=...
|
|
60
|
+
export ONEHOUSE_API_SECRET=...
|
|
61
|
+
export ONEHOUSE_ACCOUNT_UID=...
|
|
62
|
+
export ONEHOUSE_PROJECT_UID=...
|
|
63
|
+
export ONEHOUSE_REGION=...
|
|
64
|
+
export ONEHOUSE_USER_UID=...
|
|
65
|
+
export ONEHOUSE_LINK_UID=...
|
|
66
|
+
export ONEHOUSE_PROFILE=myprofile # select a profile from the credentials file
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Global Options
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
oh [--profile NAME] [--timeout MINS] [--output table|json] COMMAND
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
| Option | Default | Description |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `--profile` / `-p` | `_default` key in credentials file | Credentials profile to use |
|
|
78
|
+
| `--timeout` / `-t` | `10` | Minutes to wait for async operations |
|
|
79
|
+
| `--output` / `-o` | `table` | Output format: `table` or `json` |
|
|
80
|
+
|
|
81
|
+
Every command also accepts `--show-sql` to print the generated SQL statement without executing it.
|
|
82
|
+
|
|
83
|
+
> `onehouse-cli` and `onehouse-cli-configure` are kept as aliases for backward compatibility.
|
|
84
|
+
|
|
85
|
+
## Commands
|
|
86
|
+
|
|
87
|
+
### Clusters
|
|
88
|
+
```bash
|
|
89
|
+
oh cluster show
|
|
90
|
+
oh cluster describe CLUSTER_NAME
|
|
91
|
+
oh cluster create CLUSTER_NAME --type SQL --max-ocu 10 --min-ocu 2
|
|
92
|
+
oh cluster alter CLUSTER_NAME --state STOP
|
|
93
|
+
oh cluster alter CLUSTER_NAME --max-ocu 20
|
|
94
|
+
oh cluster alter CLUSTER_NAME --new-name NEW_NAME
|
|
95
|
+
oh cluster delete CLUSTER_NAME
|
|
96
|
+
```
|
|
97
|
+
Cluster types: `Managed`, `SQL`, `Spark`, `Open_Engines`, `Notebook`, `LakeBase`
|
|
98
|
+
|
|
99
|
+
### Lakes
|
|
100
|
+
```bash
|
|
101
|
+
oh lake show
|
|
102
|
+
oh lake create LAKE_NAME --type MANAGED --bucket-path s3://my-bucket/ --default-services-cluster mycluster
|
|
103
|
+
oh lake alter LAKE_NAME --default-services-cluster newcluster
|
|
104
|
+
oh lake delete LAKE_NAME [--cascade]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Databases
|
|
108
|
+
```bash
|
|
109
|
+
oh database show --lake LAKE_NAME
|
|
110
|
+
oh database create DB_NAME --lake LAKE_NAME
|
|
111
|
+
oh database delete DB_NAME --lake LAKE_NAME [--cascade]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Tables
|
|
115
|
+
```bash
|
|
116
|
+
oh table show --lake LAKE_NAME --database DB_NAME
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Table Services
|
|
120
|
+
```bash
|
|
121
|
+
oh table service create --lake L --database D --table T --service COMPACT --trigger-mode ON_DEMAND
|
|
122
|
+
oh table service alter --lake L --database D --table T --service COMPACT --trigger-mode AUTOMATIC
|
|
123
|
+
oh table service describe --lake L --database D --table T --service COMPACT
|
|
124
|
+
oh table service show --lake L --database D --table T
|
|
125
|
+
oh table service show-runs --lake L --database D --table T --service COMPACT
|
|
126
|
+
oh table service run --lake L --database D --table T --service COMPACT
|
|
127
|
+
oh table service pause --lake L --database D --table T --service COMPACT
|
|
128
|
+
oh table service resume --lake L --database D --table T --service COMPACT
|
|
129
|
+
oh table service cancel --lake L --database D --table T --service COMPACT
|
|
130
|
+
oh table service alter-cluster --lake L --database D --table T --services-cluster newcluster
|
|
131
|
+
```
|
|
132
|
+
Services: `CLUSTER`, `COMPACT`, `CLEAN`, `METASYNC`
|
|
133
|
+
Run-only services (for `run`): `CLUSTER`, `COMPACT`, `CLEAN`, `METASYNC`, `AUTOSAVEPOINT`, `RESTORE`
|
|
134
|
+
|
|
135
|
+
### Catalogs
|
|
136
|
+
```bash
|
|
137
|
+
oh catalog show
|
|
138
|
+
oh catalog describe CATALOG_NAME
|
|
139
|
+
oh catalog create CATALOG_NAME --type GLUE --credential-type CREDENTIAL_TYPE_ONEHOUSE
|
|
140
|
+
oh catalog delete CATALOG_NAME
|
|
141
|
+
```
|
|
142
|
+
Types: `GLUE`, `HIVE`, `BIGQUERY`, `DATAHUB`, `ONETABLE`, `DATAPROC`, `UNITY`, `SNOWFLAKE`, `ONELAKE`
|
|
143
|
+
|
|
144
|
+
### Sources
|
|
145
|
+
```bash
|
|
146
|
+
oh source show
|
|
147
|
+
oh source describe SOURCE_NAME
|
|
148
|
+
oh source create SOURCE_NAME --type S3 --credential-type CREDENTIAL_TYPE_ONEHOUSE [--if-not-exists]
|
|
149
|
+
oh source delete SOURCE_NAME
|
|
150
|
+
```
|
|
151
|
+
Types: `APACHE_KAFKA`, `MSK_KAFKA`, `CONFLUENT_KAFKA`, `S3`, `GCS`, `ONEHOUSE_TABLE`, `POSTGRES`, `MY_SQL`
|
|
152
|
+
|
|
153
|
+
### Flows
|
|
154
|
+
```bash
|
|
155
|
+
oh flow show
|
|
156
|
+
oh flow describe FLOW_NAME
|
|
157
|
+
oh flow create FLOW_NAME \
|
|
158
|
+
--source mysource --lake mylake --database mydb --table-name mytable \
|
|
159
|
+
--write-mode IMMUTABLE --cluster mycluster \
|
|
160
|
+
[--performance-profile BALANCED] \
|
|
161
|
+
[--record-key-fields id] \
|
|
162
|
+
[--partition-key-fields date:DATE_STRING] \
|
|
163
|
+
[--precombine-key-field ts] \
|
|
164
|
+
[--min-sync-frequency-mins 5] \
|
|
165
|
+
[--quarantine-enabled] \
|
|
166
|
+
[--catalogs cat1] [--transformations tx1] [--validations val1]
|
|
167
|
+
oh flow alter FLOW_NAME --state PAUSE # or RESUME, CLEAN_AND_RESTART
|
|
168
|
+
oh flow alter FLOW_NAME --cluster newcluster # exactly one option at a time
|
|
169
|
+
oh flow delete FLOW_NAME
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Partition key field format: `FIELD:TYPE:INPUT_FORMAT:OUTPUT_FORMAT`
|
|
173
|
+
Write modes: `IMMUTABLE`, `MUTABLE`
|
|
174
|
+
Performance profiles: `BALANCED`, `FASTEST_READ`, `FASTEST_WRITE`
|
|
175
|
+
|
|
176
|
+
### Transformations
|
|
177
|
+
```bash
|
|
178
|
+
oh transformation show
|
|
179
|
+
oh transformation describe TX_NAME
|
|
180
|
+
oh transformation create TX_NAME --type ROW_FILTERING [--options FILTER_SQL="col > 0"]
|
|
181
|
+
oh transformation delete TX_NAME
|
|
182
|
+
```
|
|
183
|
+
Types: `CONVERT_CDC`, `ROW_FILTERING`, `DERIVED_DATE`, `ADD_CURRENT_TIMESTAMP`, `USER_PROVIDED`, `DATA_MASKING`, `L_PARSE_JSON`, `FLATTEN_STRUCT`, `EXPLODE_ARRAY`, `VECTOR_EMBEDDING`
|
|
184
|
+
|
|
185
|
+
### Validations
|
|
186
|
+
```bash
|
|
187
|
+
oh validation show
|
|
188
|
+
oh validation describe VAL_NAME
|
|
189
|
+
oh validation create VAL_NAME --type SCHEMA
|
|
190
|
+
oh validation delete VAL_NAME
|
|
191
|
+
```
|
|
192
|
+
Types: `SCHEMA`, `TIMESTAMP`
|
|
193
|
+
|
|
194
|
+
### Jobs
|
|
195
|
+
```bash
|
|
196
|
+
oh job show
|
|
197
|
+
oh job describe JOB_NAME
|
|
198
|
+
oh job create JOB_NAME --type JAR --cluster mycluster --parameters arg1 --parameters arg2
|
|
199
|
+
oh job create-and-run JOB_NAME --type PYTHON --cluster mycluster --parameters script.py
|
|
200
|
+
oh job alter JOB_NAME --cluster newcluster # or --parameters (not both)
|
|
201
|
+
oh job run JOB_NAME
|
|
202
|
+
oh job cancel-run JOB_RUN_UUID --job-name JOB_NAME
|
|
203
|
+
oh job describe-run JOB_RUN_UUID --job-name JOB_NAME
|
|
204
|
+
oh job show-runs JOB_NAME
|
|
205
|
+
oh job upload-jar JAR_NAME --options FILE_PATH=/path/to/file.jar
|
|
206
|
+
oh job replace-jar JAR_NAME --options FILE_PATH=/path/to/file.jar
|
|
207
|
+
```
|
|
208
|
+
Job types: `JAR`, `PYTHON`
|
|
209
|
+
|
|
210
|
+
### Service Principals
|
|
211
|
+
```bash
|
|
212
|
+
oh service-principal show
|
|
213
|
+
oh service-principal create SP_NAME
|
|
214
|
+
oh service-principal alter SP_NAME --new-name NEW_NAME
|
|
215
|
+
oh service-principal delete SP_NAME
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### API Tokens
|
|
219
|
+
```bash
|
|
220
|
+
oh api-token create TOKEN_NAME --service-principal SP_NAME
|
|
221
|
+
oh api-token delete TOKEN_NAME --service-principal SP_NAME
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Raw SQL
|
|
225
|
+
```bash
|
|
226
|
+
# Execute any SQL statement
|
|
227
|
+
oh sql exec --command "SHOW CLUSTERS"
|
|
228
|
+
|
|
229
|
+
# Fire-and-forget (returns request ID immediately, no polling)
|
|
230
|
+
oh sql exec --command "SHOW CLUSTERS" --async-mode
|
|
231
|
+
|
|
232
|
+
# Check status of a previous request
|
|
233
|
+
oh sql status REQUEST_ID
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## WITH options
|
|
237
|
+
|
|
238
|
+
Commands that accept extra configuration take `--options KEY=VALUE` (repeatable):
|
|
239
|
+
```bash
|
|
240
|
+
oh catalog create mycat --type HIVE \
|
|
241
|
+
--credential-type CREDENTIAL_TYPE_ONEHOUSE \
|
|
242
|
+
--options METASTORE_URI=thrift://host:9083 \
|
|
243
|
+
--options DATABASE=default
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Show SQL
|
|
247
|
+
|
|
248
|
+
Any command can print its generated SQL without making a network call:
|
|
249
|
+
```bash
|
|
250
|
+
oh cluster create mycluster --type SQL --show-sql
|
|
251
|
+
# CREATE CLUSTER `mycluster`
|
|
252
|
+
# TYPE = 'SQL'
|
|
253
|
+
|
|
254
|
+
oh flow create myflow --source src --lake l --database d \
|
|
255
|
+
--table-name t --write-mode IMMUTABLE --cluster c --show-sql
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Examples
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Create a managed lake and database
|
|
262
|
+
oh lake create prod-lake --type MANAGED \
|
|
263
|
+
--bucket-path s3://my-data-lake/ \
|
|
264
|
+
--default-services-cluster services-cluster
|
|
265
|
+
oh database create analytics --lake prod-lake
|
|
266
|
+
|
|
267
|
+
# Create a Kafka flow
|
|
268
|
+
oh source create kafka-src --type APACHE_KAFKA \
|
|
269
|
+
--credential-type CREDENTIAL_TYPE_ONEHOUSE \
|
|
270
|
+
--options BOOTSTRAP_SERVERS=kafka:9092
|
|
271
|
+
oh flow create orders-flow \
|
|
272
|
+
--source kafka-src --lake prod-lake \
|
|
273
|
+
--database analytics --table-name orders \
|
|
274
|
+
--write-mode MUTABLE --cluster ingest-cluster \
|
|
275
|
+
--record-key-fields order_id
|
|
276
|
+
|
|
277
|
+
# Monitor a table's compaction service
|
|
278
|
+
oh table service show --lake prod-lake --database analytics --table orders
|
|
279
|
+
oh table service run --lake prod-lake --database analytics --table orders --service COMPACT
|
|
280
|
+
|
|
281
|
+
# JSON output for scripting
|
|
282
|
+
oh --output json cluster show | jq '.'
|
|
283
|
+
```
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Onehouse CLI (`oh`)
|
|
2
|
+
|
|
3
|
+
A command-line tool for managing your Onehouse project — clusters, lakes, databases, tables, flows, jobs, catalogs, sources, transformations, validations, service principals, and API tokens.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install onehouse-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The SDK dependency (`onehouse-python-sdk[resources]`) is installed automatically.
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
**Configure credentials:**
|
|
16
|
+
```bash
|
|
17
|
+
oh-configure
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This prompts for your API credentials and saves them to `~/.onehouse/credentials`. You can create multiple named profiles and set a default.
|
|
21
|
+
|
|
22
|
+
Fields collected:
|
|
23
|
+
- Profile name
|
|
24
|
+
- Account UID
|
|
25
|
+
- Project UID
|
|
26
|
+
- API Key / API Secret
|
|
27
|
+
- Project Region
|
|
28
|
+
- User ID
|
|
29
|
+
- Request ID (link UID)
|
|
30
|
+
- API Endpoint (default: `https://api.onehouse.ai/v1`)
|
|
31
|
+
|
|
32
|
+
**Credentials are stored in:** `~/.onehouse/credentials`
|
|
33
|
+
|
|
34
|
+
Alternatively, set environment variables:
|
|
35
|
+
```bash
|
|
36
|
+
export ONEHOUSE_API_KEY=...
|
|
37
|
+
export ONEHOUSE_API_SECRET=...
|
|
38
|
+
export ONEHOUSE_ACCOUNT_UID=...
|
|
39
|
+
export ONEHOUSE_PROJECT_UID=...
|
|
40
|
+
export ONEHOUSE_REGION=...
|
|
41
|
+
export ONEHOUSE_USER_UID=...
|
|
42
|
+
export ONEHOUSE_LINK_UID=...
|
|
43
|
+
export ONEHOUSE_PROFILE=myprofile # select a profile from the credentials file
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Global Options
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
oh [--profile NAME] [--timeout MINS] [--output table|json] COMMAND
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| Option | Default | Description |
|
|
53
|
+
|---|---|---|
|
|
54
|
+
| `--profile` / `-p` | `_default` key in credentials file | Credentials profile to use |
|
|
55
|
+
| `--timeout` / `-t` | `10` | Minutes to wait for async operations |
|
|
56
|
+
| `--output` / `-o` | `table` | Output format: `table` or `json` |
|
|
57
|
+
|
|
58
|
+
Every command also accepts `--show-sql` to print the generated SQL statement without executing it.
|
|
59
|
+
|
|
60
|
+
> `onehouse-cli` and `onehouse-cli-configure` are kept as aliases for backward compatibility.
|
|
61
|
+
|
|
62
|
+
## Commands
|
|
63
|
+
|
|
64
|
+
### Clusters
|
|
65
|
+
```bash
|
|
66
|
+
oh cluster show
|
|
67
|
+
oh cluster describe CLUSTER_NAME
|
|
68
|
+
oh cluster create CLUSTER_NAME --type SQL --max-ocu 10 --min-ocu 2
|
|
69
|
+
oh cluster alter CLUSTER_NAME --state STOP
|
|
70
|
+
oh cluster alter CLUSTER_NAME --max-ocu 20
|
|
71
|
+
oh cluster alter CLUSTER_NAME --new-name NEW_NAME
|
|
72
|
+
oh cluster delete CLUSTER_NAME
|
|
73
|
+
```
|
|
74
|
+
Cluster types: `Managed`, `SQL`, `Spark`, `Open_Engines`, `Notebook`, `LakeBase`
|
|
75
|
+
|
|
76
|
+
### Lakes
|
|
77
|
+
```bash
|
|
78
|
+
oh lake show
|
|
79
|
+
oh lake create LAKE_NAME --type MANAGED --bucket-path s3://my-bucket/ --default-services-cluster mycluster
|
|
80
|
+
oh lake alter LAKE_NAME --default-services-cluster newcluster
|
|
81
|
+
oh lake delete LAKE_NAME [--cascade]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Databases
|
|
85
|
+
```bash
|
|
86
|
+
oh database show --lake LAKE_NAME
|
|
87
|
+
oh database create DB_NAME --lake LAKE_NAME
|
|
88
|
+
oh database delete DB_NAME --lake LAKE_NAME [--cascade]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Tables
|
|
92
|
+
```bash
|
|
93
|
+
oh table show --lake LAKE_NAME --database DB_NAME
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Table Services
|
|
97
|
+
```bash
|
|
98
|
+
oh table service create --lake L --database D --table T --service COMPACT --trigger-mode ON_DEMAND
|
|
99
|
+
oh table service alter --lake L --database D --table T --service COMPACT --trigger-mode AUTOMATIC
|
|
100
|
+
oh table service describe --lake L --database D --table T --service COMPACT
|
|
101
|
+
oh table service show --lake L --database D --table T
|
|
102
|
+
oh table service show-runs --lake L --database D --table T --service COMPACT
|
|
103
|
+
oh table service run --lake L --database D --table T --service COMPACT
|
|
104
|
+
oh table service pause --lake L --database D --table T --service COMPACT
|
|
105
|
+
oh table service resume --lake L --database D --table T --service COMPACT
|
|
106
|
+
oh table service cancel --lake L --database D --table T --service COMPACT
|
|
107
|
+
oh table service alter-cluster --lake L --database D --table T --services-cluster newcluster
|
|
108
|
+
```
|
|
109
|
+
Services: `CLUSTER`, `COMPACT`, `CLEAN`, `METASYNC`
|
|
110
|
+
Run-only services (for `run`): `CLUSTER`, `COMPACT`, `CLEAN`, `METASYNC`, `AUTOSAVEPOINT`, `RESTORE`
|
|
111
|
+
|
|
112
|
+
### Catalogs
|
|
113
|
+
```bash
|
|
114
|
+
oh catalog show
|
|
115
|
+
oh catalog describe CATALOG_NAME
|
|
116
|
+
oh catalog create CATALOG_NAME --type GLUE --credential-type CREDENTIAL_TYPE_ONEHOUSE
|
|
117
|
+
oh catalog delete CATALOG_NAME
|
|
118
|
+
```
|
|
119
|
+
Types: `GLUE`, `HIVE`, `BIGQUERY`, `DATAHUB`, `ONETABLE`, `DATAPROC`, `UNITY`, `SNOWFLAKE`, `ONELAKE`
|
|
120
|
+
|
|
121
|
+
### Sources
|
|
122
|
+
```bash
|
|
123
|
+
oh source show
|
|
124
|
+
oh source describe SOURCE_NAME
|
|
125
|
+
oh source create SOURCE_NAME --type S3 --credential-type CREDENTIAL_TYPE_ONEHOUSE [--if-not-exists]
|
|
126
|
+
oh source delete SOURCE_NAME
|
|
127
|
+
```
|
|
128
|
+
Types: `APACHE_KAFKA`, `MSK_KAFKA`, `CONFLUENT_KAFKA`, `S3`, `GCS`, `ONEHOUSE_TABLE`, `POSTGRES`, `MY_SQL`
|
|
129
|
+
|
|
130
|
+
### Flows
|
|
131
|
+
```bash
|
|
132
|
+
oh flow show
|
|
133
|
+
oh flow describe FLOW_NAME
|
|
134
|
+
oh flow create FLOW_NAME \
|
|
135
|
+
--source mysource --lake mylake --database mydb --table-name mytable \
|
|
136
|
+
--write-mode IMMUTABLE --cluster mycluster \
|
|
137
|
+
[--performance-profile BALANCED] \
|
|
138
|
+
[--record-key-fields id] \
|
|
139
|
+
[--partition-key-fields date:DATE_STRING] \
|
|
140
|
+
[--precombine-key-field ts] \
|
|
141
|
+
[--min-sync-frequency-mins 5] \
|
|
142
|
+
[--quarantine-enabled] \
|
|
143
|
+
[--catalogs cat1] [--transformations tx1] [--validations val1]
|
|
144
|
+
oh flow alter FLOW_NAME --state PAUSE # or RESUME, CLEAN_AND_RESTART
|
|
145
|
+
oh flow alter FLOW_NAME --cluster newcluster # exactly one option at a time
|
|
146
|
+
oh flow delete FLOW_NAME
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Partition key field format: `FIELD:TYPE:INPUT_FORMAT:OUTPUT_FORMAT`
|
|
150
|
+
Write modes: `IMMUTABLE`, `MUTABLE`
|
|
151
|
+
Performance profiles: `BALANCED`, `FASTEST_READ`, `FASTEST_WRITE`
|
|
152
|
+
|
|
153
|
+
### Transformations
|
|
154
|
+
```bash
|
|
155
|
+
oh transformation show
|
|
156
|
+
oh transformation describe TX_NAME
|
|
157
|
+
oh transformation create TX_NAME --type ROW_FILTERING [--options FILTER_SQL="col > 0"]
|
|
158
|
+
oh transformation delete TX_NAME
|
|
159
|
+
```
|
|
160
|
+
Types: `CONVERT_CDC`, `ROW_FILTERING`, `DERIVED_DATE`, `ADD_CURRENT_TIMESTAMP`, `USER_PROVIDED`, `DATA_MASKING`, `L_PARSE_JSON`, `FLATTEN_STRUCT`, `EXPLODE_ARRAY`, `VECTOR_EMBEDDING`
|
|
161
|
+
|
|
162
|
+
### Validations
|
|
163
|
+
```bash
|
|
164
|
+
oh validation show
|
|
165
|
+
oh validation describe VAL_NAME
|
|
166
|
+
oh validation create VAL_NAME --type SCHEMA
|
|
167
|
+
oh validation delete VAL_NAME
|
|
168
|
+
```
|
|
169
|
+
Types: `SCHEMA`, `TIMESTAMP`
|
|
170
|
+
|
|
171
|
+
### Jobs
|
|
172
|
+
```bash
|
|
173
|
+
oh job show
|
|
174
|
+
oh job describe JOB_NAME
|
|
175
|
+
oh job create JOB_NAME --type JAR --cluster mycluster --parameters arg1 --parameters arg2
|
|
176
|
+
oh job create-and-run JOB_NAME --type PYTHON --cluster mycluster --parameters script.py
|
|
177
|
+
oh job alter JOB_NAME --cluster newcluster # or --parameters (not both)
|
|
178
|
+
oh job run JOB_NAME
|
|
179
|
+
oh job cancel-run JOB_RUN_UUID --job-name JOB_NAME
|
|
180
|
+
oh job describe-run JOB_RUN_UUID --job-name JOB_NAME
|
|
181
|
+
oh job show-runs JOB_NAME
|
|
182
|
+
oh job upload-jar JAR_NAME --options FILE_PATH=/path/to/file.jar
|
|
183
|
+
oh job replace-jar JAR_NAME --options FILE_PATH=/path/to/file.jar
|
|
184
|
+
```
|
|
185
|
+
Job types: `JAR`, `PYTHON`
|
|
186
|
+
|
|
187
|
+
### Service Principals
|
|
188
|
+
```bash
|
|
189
|
+
oh service-principal show
|
|
190
|
+
oh service-principal create SP_NAME
|
|
191
|
+
oh service-principal alter SP_NAME --new-name NEW_NAME
|
|
192
|
+
oh service-principal delete SP_NAME
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### API Tokens
|
|
196
|
+
```bash
|
|
197
|
+
oh api-token create TOKEN_NAME --service-principal SP_NAME
|
|
198
|
+
oh api-token delete TOKEN_NAME --service-principal SP_NAME
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Raw SQL
|
|
202
|
+
```bash
|
|
203
|
+
# Execute any SQL statement
|
|
204
|
+
oh sql exec --command "SHOW CLUSTERS"
|
|
205
|
+
|
|
206
|
+
# Fire-and-forget (returns request ID immediately, no polling)
|
|
207
|
+
oh sql exec --command "SHOW CLUSTERS" --async-mode
|
|
208
|
+
|
|
209
|
+
# Check status of a previous request
|
|
210
|
+
oh sql status REQUEST_ID
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## WITH options
|
|
214
|
+
|
|
215
|
+
Commands that accept extra configuration take `--options KEY=VALUE` (repeatable):
|
|
216
|
+
```bash
|
|
217
|
+
oh catalog create mycat --type HIVE \
|
|
218
|
+
--credential-type CREDENTIAL_TYPE_ONEHOUSE \
|
|
219
|
+
--options METASTORE_URI=thrift://host:9083 \
|
|
220
|
+
--options DATABASE=default
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Show SQL
|
|
224
|
+
|
|
225
|
+
Any command can print its generated SQL without making a network call:
|
|
226
|
+
```bash
|
|
227
|
+
oh cluster create mycluster --type SQL --show-sql
|
|
228
|
+
# CREATE CLUSTER `mycluster`
|
|
229
|
+
# TYPE = 'SQL'
|
|
230
|
+
|
|
231
|
+
oh flow create myflow --source src --lake l --database d \
|
|
232
|
+
--table-name t --write-mode IMMUTABLE --cluster c --show-sql
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Examples
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# Create a managed lake and database
|
|
239
|
+
oh lake create prod-lake --type MANAGED \
|
|
240
|
+
--bucket-path s3://my-data-lake/ \
|
|
241
|
+
--default-services-cluster services-cluster
|
|
242
|
+
oh database create analytics --lake prod-lake
|
|
243
|
+
|
|
244
|
+
# Create a Kafka flow
|
|
245
|
+
oh source create kafka-src --type APACHE_KAFKA \
|
|
246
|
+
--credential-type CREDENTIAL_TYPE_ONEHOUSE \
|
|
247
|
+
--options BOOTSTRAP_SERVERS=kafka:9092
|
|
248
|
+
oh flow create orders-flow \
|
|
249
|
+
--source kafka-src --lake prod-lake \
|
|
250
|
+
--database analytics --table-name orders \
|
|
251
|
+
--write-mode MUTABLE --cluster ingest-cluster \
|
|
252
|
+
--record-key-fields order_id
|
|
253
|
+
|
|
254
|
+
# Monitor a table's compaction service
|
|
255
|
+
oh table service show --lake prod-lake --database analytics --table orders
|
|
256
|
+
oh table service run --lake prod-lake --database analytics --table orders --service COMPACT
|
|
257
|
+
|
|
258
|
+
# JSON output for scripting
|
|
259
|
+
oh --output json cluster show | jq '.'
|
|
260
|
+
```
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Onehouse CLI — top-level Click entry point.
|
|
3
|
+
|
|
4
|
+
Global options (--profile, --timeout, --output) are propagated to every
|
|
5
|
+
subcommand via the Click context object (ctx.obj).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
import click
|
|
10
|
+
|
|
11
|
+
from . import __version__
|
|
12
|
+
from .commands import (
|
|
13
|
+
cluster,
|
|
14
|
+
lake,
|
|
15
|
+
database,
|
|
16
|
+
table,
|
|
17
|
+
catalog,
|
|
18
|
+
source,
|
|
19
|
+
flow,
|
|
20
|
+
transformation,
|
|
21
|
+
validation,
|
|
22
|
+
job,
|
|
23
|
+
service_principal,
|
|
24
|
+
api_token,
|
|
25
|
+
sql as sql_cmd,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class CliContext:
|
|
30
|
+
def __init__(self, profile: str | None, timeout: int, output: str):
|
|
31
|
+
self.profile = profile
|
|
32
|
+
self.timeout = timeout
|
|
33
|
+
self.output = output
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
|
|
37
|
+
@click.version_option(__version__, "-v", "--version")
|
|
38
|
+
@click.option(
|
|
39
|
+
"--profile", "-p",
|
|
40
|
+
default=None,
|
|
41
|
+
envvar="ONEHOUSE_PROFILE",
|
|
42
|
+
help="Credentials profile to use (default: profile named in _default key).",
|
|
43
|
+
)
|
|
44
|
+
@click.option(
|
|
45
|
+
"--timeout", "-t",
|
|
46
|
+
default=10,
|
|
47
|
+
show_default=True,
|
|
48
|
+
type=int,
|
|
49
|
+
help="Timeout in minutes for async operations.",
|
|
50
|
+
)
|
|
51
|
+
@click.option(
|
|
52
|
+
"--output", "-o",
|
|
53
|
+
default="table",
|
|
54
|
+
show_default=True,
|
|
55
|
+
type=click.Choice(["table", "json"], case_sensitive=False),
|
|
56
|
+
help="Output format for results.",
|
|
57
|
+
)
|
|
58
|
+
@click.pass_context
|
|
59
|
+
def cli(ctx: click.Context, profile: str | None, timeout: int, output: str) -> None:
|
|
60
|
+
"""Onehouse CLI — manage your Onehouse project from the command line."""
|
|
61
|
+
ctx.ensure_object(dict)
|
|
62
|
+
ctx.obj = CliContext(profile=profile, timeout=timeout, output=output)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
cli.add_command(cluster.cluster)
|
|
66
|
+
cli.add_command(lake.lake)
|
|
67
|
+
cli.add_command(database.database)
|
|
68
|
+
cli.add_command(table.table)
|
|
69
|
+
cli.add_command(catalog.catalog)
|
|
70
|
+
cli.add_command(source.source)
|
|
71
|
+
cli.add_command(flow.flow)
|
|
72
|
+
cli.add_command(transformation.transformation)
|
|
73
|
+
cli.add_command(validation.validation)
|
|
74
|
+
cli.add_command(job.job)
|
|
75
|
+
cli.add_command(service_principal.service_principal, name="service-principal")
|
|
76
|
+
cli.add_command(api_token.api_token, name="api-token")
|
|
77
|
+
cli.add_command(sql_cmd.sql)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def main() -> None:
|
|
81
|
+
sys.exit(cli(standalone_mode=False) or 0)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
main()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Thin factory that builds an OnehouseResources client from CLI profile/env credentials."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import click
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
from onehouse_python_sdk.resources.client import OnehouseResources
|
|
11
|
+
from onehouse_python_sdk.resources.exceptions import AuthError, ResourcesError
|
|
12
|
+
except ImportError as exc:
|
|
13
|
+
click.echo(
|
|
14
|
+
f"Error: onehouse-python-sdk is not installed. "
|
|
15
|
+
f"Install it with: pip install 'onehouse-python-sdk[resources]'\n{exc}",
|
|
16
|
+
err=True,
|
|
17
|
+
)
|
|
18
|
+
sys.exit(1)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def make_client(profile: str | None, timeout: int) -> OnehouseResources:
|
|
22
|
+
"""Return an OnehouseResources configured from profile + env vars."""
|
|
23
|
+
kwargs: dict = {
|
|
24
|
+
"default_execute_timeout": float(timeout * 60),
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
credentials_file = os.environ.get("ONEHOUSE_CREDENTIALS_FILE")
|
|
28
|
+
if credentials_file:
|
|
29
|
+
kwargs["credentials_file"] = Path(credentials_file)
|
|
30
|
+
|
|
31
|
+
if profile:
|
|
32
|
+
kwargs["profile"] = profile
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
return OnehouseResources(**kwargs)
|
|
36
|
+
except AuthError as exc:
|
|
37
|
+
raise click.ClickException(f"Authentication error: {exc}") from exc
|
|
38
|
+
except ResourcesError as exc:
|
|
39
|
+
raise click.ClickException(f"Failed to initialise client: {exc}") from exc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Onehouse CLI command modules."""
|