onehouse-cli 0.1.2__tar.gz → 0.1.4__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.1.2 → onehouse_cli-0.1.4}/PKG-INFO +4 -2
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/README.md +2 -1
- onehouse_cli-0.1.4/onehouse_cli/__init__.py +21 -0
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/onehouse_cli/cli.py +15 -2
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/onehouse_cli/configure.py +12 -104
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/onehouse_cli.egg-info/PKG-INFO +4 -2
- onehouse_cli-0.1.4/onehouse_cli.egg-info/requires.txt +4 -0
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/pyproject.toml +2 -1
- onehouse_cli-0.1.2/onehouse_cli/__init__.py +0 -10
- onehouse_cli-0.1.2/onehouse_cli.egg-info/requires.txt +0 -1
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/onehouse_cli.egg-info/SOURCES.txt +0 -0
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/onehouse_cli.egg-info/dependency_links.txt +0 -0
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/onehouse_cli.egg-info/entry_points.txt +0 -0
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/onehouse_cli.egg-info/top_level.txt +0 -0
- {onehouse_cli-0.1.2 → onehouse_cli-0.1.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onehouse-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: A command-line tool for executing SQL commands against the Onehouse API
|
|
5
5
|
Author-email: Sagar Lakshmipathy <18vidhyasagar@gmail.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
16
16
|
Requires-Python: >=3.7
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
Requires-Dist: requests
|
|
19
|
+
Requires-Dist: importlib-metadata>=1.0; python_version < "3.8"
|
|
19
20
|
|
|
20
21
|
# Onehouse CLI
|
|
21
22
|
|
|
@@ -43,7 +44,8 @@ This will prompt you for:
|
|
|
43
44
|
- Project Region
|
|
44
45
|
- User ID
|
|
45
46
|
- Request ID
|
|
46
|
-
-
|
|
47
|
+
- API Endpoint (defaults to `https://api.onehouse.ai/v1`)
|
|
48
|
+
- Press Enter to use the default endpoint
|
|
47
49
|
|
|
48
50
|
**Credentials are stored in:** `~/.onehouse/credentials`
|
|
49
51
|
|
|
@@ -24,7 +24,8 @@ This will prompt you for:
|
|
|
24
24
|
- Project Region
|
|
25
25
|
- User ID
|
|
26
26
|
- Request ID
|
|
27
|
-
-
|
|
27
|
+
- API Endpoint (defaults to `https://api.onehouse.ai/v1`)
|
|
28
|
+
- Press Enter to use the default endpoint
|
|
28
29
|
|
|
29
30
|
**Credentials are stored in:** `~/.onehouse/credentials`
|
|
30
31
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Onehouse CLI - A command-line tool for executing SQL commands against the Onehouse API.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
# For Python 3.8+
|
|
7
|
+
from importlib.metadata import version
|
|
8
|
+
except ImportError:
|
|
9
|
+
# For Python 3.7
|
|
10
|
+
from importlib_metadata import version
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
__version__ = version("onehouse-cli")
|
|
14
|
+
except Exception:
|
|
15
|
+
# Fallback version if package is not installed
|
|
16
|
+
__version__ = "0.0.0.dev"
|
|
17
|
+
|
|
18
|
+
from .cli import main as cli_main
|
|
19
|
+
from .configure import main as configure_main
|
|
20
|
+
|
|
21
|
+
__all__ = ["cli_main", "configure_main"]
|
|
@@ -44,6 +44,8 @@ def get_profile_credentials(credentials, profile_name):
|
|
|
44
44
|
def check_request_status(profile_creds, request_id):
|
|
45
45
|
"""Check the status of a request using the status endpoint."""
|
|
46
46
|
api_endpoint = profile_creds.get('api_endpoint', 'https://api.onehouse.ai')
|
|
47
|
+
# Normalize endpoint - remove trailing /v1 if present for backward compatibility
|
|
48
|
+
api_endpoint = api_endpoint.rstrip('/').removesuffix('/v1')
|
|
47
49
|
url = f"{api_endpoint}/v1/status/{request_id}"
|
|
48
50
|
|
|
49
51
|
headers = {
|
|
@@ -180,6 +182,8 @@ def wait_for_completion(profile_creds, request_id, timeout_minutes=10):
|
|
|
180
182
|
def execute_command(profile_creds, command, timeout_minutes=10):
|
|
181
183
|
"""Execute a command against the Onehouse API and wait for completion."""
|
|
182
184
|
api_endpoint = profile_creds.get('api_endpoint', 'https://api.onehouse.ai')
|
|
185
|
+
# Normalize endpoint - remove trailing /v1 if present for backward compatibility
|
|
186
|
+
api_endpoint = api_endpoint.rstrip('/').removesuffix('/v1')
|
|
183
187
|
url = f"{api_endpoint}/v1/resource/"
|
|
184
188
|
|
|
185
189
|
headers = {
|
|
@@ -263,19 +267,22 @@ def list_profiles(credentials):
|
|
|
263
267
|
account_uid = profile_data.get('account_uid', 'N/A')
|
|
264
268
|
project_uid = profile_data.get('project_uid', 'N/A')
|
|
265
269
|
region = profile_data.get('project_region', 'N/A')
|
|
266
|
-
|
|
270
|
+
api_endpoint = profile_data.get('api_endpoint', 'N/A')
|
|
267
271
|
|
|
268
272
|
default_indicator = " (default)" if profile_name == default_profile else ""
|
|
269
273
|
print(f" - {profile_name}{default_indicator}")
|
|
270
274
|
print(f" Account: {account_uid}")
|
|
271
275
|
print(f" Project: {project_uid}")
|
|
272
276
|
print(f" Region: {region}")
|
|
273
|
-
print(f"
|
|
277
|
+
print(f" API Endpoint: {api_endpoint}")
|
|
274
278
|
print()
|
|
275
279
|
|
|
276
280
|
|
|
277
281
|
def main():
|
|
278
282
|
"""Main function to run the CLI tool."""
|
|
283
|
+
# Import version here to avoid circular import
|
|
284
|
+
from . import __version__
|
|
285
|
+
|
|
279
286
|
parser = argparse.ArgumentParser(
|
|
280
287
|
description='Execute SQL commands against Onehouse API',
|
|
281
288
|
epilog='Examples:\n'
|
|
@@ -284,6 +291,12 @@ def main():
|
|
|
284
291
|
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
285
292
|
)
|
|
286
293
|
|
|
294
|
+
parser.add_argument(
|
|
295
|
+
'--version', '-v',
|
|
296
|
+
action='version',
|
|
297
|
+
version=f'onehouse-cli {__version__}'
|
|
298
|
+
)
|
|
299
|
+
|
|
287
300
|
parser.add_argument(
|
|
288
301
|
'--command', '-c',
|
|
289
302
|
type=str,
|
|
@@ -71,7 +71,7 @@ def collect_credentials():
|
|
|
71
71
|
print(f" Account: {existing_profile.get('account_uid', 'N/A')}")
|
|
72
72
|
print(f" Project: {existing_profile.get('project_uid', 'N/A')}")
|
|
73
73
|
print(f" Region: {existing_profile.get('project_region', 'N/A')}")
|
|
74
|
-
print(f"
|
|
74
|
+
print(f" API Endpoint: {existing_profile.get('api_endpoint', 'N/A')}")
|
|
75
75
|
|
|
76
76
|
# Show API Key/Secret previews in the summary
|
|
77
77
|
existing_key = existing_profile.get('api_key', '')
|
|
@@ -164,28 +164,17 @@ def collect_credentials():
|
|
|
164
164
|
print("Error: Request ID is required")
|
|
165
165
|
return None
|
|
166
166
|
|
|
167
|
-
#
|
|
168
|
-
|
|
167
|
+
# API Endpoint
|
|
168
|
+
default_endpoint = "https://api.onehouse.ai/v1"
|
|
169
|
+
existing_endpoint = existing_profile.get('api_endpoint', default_endpoint)
|
|
169
170
|
print()
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
environment = existing_env
|
|
178
|
-
api_endpoint = existing_profile.get('api_endpoint',
|
|
179
|
-
'https://staging-api.onehouse.ai' if existing_env == 'staging'
|
|
180
|
-
else 'https://api.onehouse.ai')
|
|
181
|
-
elif env_choice == "2":
|
|
182
|
-
environment = "staging"
|
|
183
|
-
api_endpoint = "https://staging-api.onehouse.ai"
|
|
184
|
-
else:
|
|
185
|
-
environment = "production"
|
|
186
|
-
api_endpoint = "https://api.onehouse.ai"
|
|
187
|
-
|
|
188
|
-
print(f"Selected: {environment} environment")
|
|
171
|
+
prompt = f"API Endpoint ({existing_endpoint}): " if existing_endpoint else f"API Endpoint ({default_endpoint}): "
|
|
172
|
+
api_endpoint = get_user_input(prompt).strip()
|
|
173
|
+
|
|
174
|
+
if not api_endpoint:
|
|
175
|
+
api_endpoint = existing_endpoint if existing_endpoint else default_endpoint
|
|
176
|
+
|
|
177
|
+
print(f"Using API endpoint: {api_endpoint}")
|
|
189
178
|
|
|
190
179
|
credentials[profile_name] = {
|
|
191
180
|
"account_uid": account_uid,
|
|
@@ -195,7 +184,6 @@ def collect_credentials():
|
|
|
195
184
|
"project_region": project_region,
|
|
196
185
|
"user_id": user_id,
|
|
197
186
|
"request_id": request_id,
|
|
198
|
-
"environment": environment,
|
|
199
187
|
"api_endpoint": api_endpoint
|
|
200
188
|
}
|
|
201
189
|
|
|
@@ -208,77 +196,6 @@ def collect_credentials():
|
|
|
208
196
|
return credentials, profile_name
|
|
209
197
|
|
|
210
198
|
|
|
211
|
-
def is_already_in_shell_profile():
|
|
212
|
-
"""Check if onehouse-cli is already added to shell profile."""
|
|
213
|
-
cli_dir = Path(__file__).parent.absolute()
|
|
214
|
-
|
|
215
|
-
# Detect shell and profile file
|
|
216
|
-
shell_profiles = [
|
|
217
|
-
Path.home() / ".zshrc",
|
|
218
|
-
Path.home() / ".bashrc",
|
|
219
|
-
Path.home() / ".bash_profile"
|
|
220
|
-
]
|
|
221
|
-
|
|
222
|
-
for profile_file in shell_profiles:
|
|
223
|
-
if profile_file.exists():
|
|
224
|
-
try:
|
|
225
|
-
with open(profile_file, 'r') as f:
|
|
226
|
-
content = f.read()
|
|
227
|
-
if str(cli_dir) in content and "onehouse-cli" in content:
|
|
228
|
-
return True
|
|
229
|
-
except IOError:
|
|
230
|
-
pass
|
|
231
|
-
|
|
232
|
-
return False
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
def add_to_shell_profile():
|
|
236
|
-
"""Add onehouse-cli tools to the user's shell profile."""
|
|
237
|
-
import subprocess
|
|
238
|
-
|
|
239
|
-
# Get the directory where the CLI tools are located
|
|
240
|
-
cli_dir = Path(__file__).parent.absolute()
|
|
241
|
-
path_export = f'export PATH="{cli_dir}:$PATH"'
|
|
242
|
-
|
|
243
|
-
# Detect shell and profile file
|
|
244
|
-
shell_profiles = [
|
|
245
|
-
Path.home() / ".zshrc",
|
|
246
|
-
Path.home() / ".bashrc",
|
|
247
|
-
Path.home() / ".bash_profile"
|
|
248
|
-
]
|
|
249
|
-
|
|
250
|
-
profile_file = None
|
|
251
|
-
for profile in shell_profiles:
|
|
252
|
-
if profile.exists():
|
|
253
|
-
profile_file = profile
|
|
254
|
-
break
|
|
255
|
-
|
|
256
|
-
if not profile_file:
|
|
257
|
-
print("Could not find shell profile file (.zshrc, .bashrc, .bash_profile)")
|
|
258
|
-
print(f"Manually add this to your shell profile: {path_export}")
|
|
259
|
-
return
|
|
260
|
-
|
|
261
|
-
# Check if already added
|
|
262
|
-
try:
|
|
263
|
-
with open(profile_file, 'r') as f:
|
|
264
|
-
content = f.read()
|
|
265
|
-
if str(cli_dir) in content and "onehouse-cli" in content:
|
|
266
|
-
print(f"✓ Already added to {profile_file}")
|
|
267
|
-
return
|
|
268
|
-
except IOError:
|
|
269
|
-
pass
|
|
270
|
-
|
|
271
|
-
# Add to profile
|
|
272
|
-
try:
|
|
273
|
-
with open(profile_file, 'a') as f:
|
|
274
|
-
f.write(f"\n# Add onehouse-cli tools to PATH\n{path_export}\n")
|
|
275
|
-
print(f"✓ Added to {profile_file}")
|
|
276
|
-
print("Please run 'source ~/.zshrc' (or your shell profile) to apply changes")
|
|
277
|
-
except IOError as e:
|
|
278
|
-
print(f"Failed to write to {profile_file}: {e}")
|
|
279
|
-
print(f"Manually add this to your shell profile: {path_export}")
|
|
280
|
-
|
|
281
|
-
|
|
282
199
|
def main():
|
|
283
200
|
"""Main function to run the configuration tool."""
|
|
284
201
|
try:
|
|
@@ -302,16 +219,7 @@ def main():
|
|
|
302
219
|
print(f"✓ Profile '{profile_name}' configured successfully!")
|
|
303
220
|
print(f"Credentials saved to: {Path.home() / '.onehouse' / 'credentials'}")
|
|
304
221
|
print()
|
|
305
|
-
|
|
306
|
-
# Check if already in shell profile, only ask if not already added
|
|
307
|
-
if is_already_in_shell_profile():
|
|
308
|
-
print("✓ onehouse-cli tools already in shell PATH")
|
|
309
|
-
else:
|
|
310
|
-
add_to_profile = input("Add onehouse-cli tools to your shell PATH? (y/n): ").strip().lower()
|
|
311
|
-
if add_to_profile in ['y', 'yes']:
|
|
312
|
-
add_to_shell_profile()
|
|
313
|
-
|
|
314
|
-
print("You can now use this profile with future Onehouse CLI commands.")
|
|
222
|
+
print("You can now use this profile with Onehouse CLI commands.")
|
|
315
223
|
|
|
316
224
|
return 0
|
|
317
225
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onehouse-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: A command-line tool for executing SQL commands against the Onehouse API
|
|
5
5
|
Author-email: Sagar Lakshmipathy <18vidhyasagar@gmail.com>
|
|
6
6
|
License: Proprietary
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
16
16
|
Requires-Python: >=3.7
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
Requires-Dist: requests
|
|
19
|
+
Requires-Dist: importlib-metadata>=1.0; python_version < "3.8"
|
|
19
20
|
|
|
20
21
|
# Onehouse CLI
|
|
21
22
|
|
|
@@ -43,7 +44,8 @@ This will prompt you for:
|
|
|
43
44
|
- Project Region
|
|
44
45
|
- User ID
|
|
45
46
|
- Request ID
|
|
46
|
-
-
|
|
47
|
+
- API Endpoint (defaults to `https://api.onehouse.ai/v1`)
|
|
48
|
+
- Press Enter to use the default endpoint
|
|
47
49
|
|
|
48
50
|
**Credentials are stored in:** `~/.onehouse/credentials`
|
|
49
51
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "onehouse-cli"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.4"
|
|
8
8
|
description = "A command-line tool for executing SQL commands against the Onehouse API"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.7"
|
|
@@ -25,6 +25,7 @@ classifiers = [
|
|
|
25
25
|
]
|
|
26
26
|
dependencies = [
|
|
27
27
|
"requests",
|
|
28
|
+
"importlib-metadata>=1.0; python_version < '3.8'",
|
|
28
29
|
]
|
|
29
30
|
|
|
30
31
|
[project.scripts]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
requests
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|