Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK and CLI for CrateDB Cloud Cluster APIs #81

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mongodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
pip install "setuptools>=64" --upgrade

# Install package in editable mode.
pip install --use-pep517 --prefer-binary --editable=.[mongodb,test-mongodb,develop]
pip install --use-pep517 --prefer-binary --upgrade --editable=.[mongodb,test-mongodb,develop]

- name: Downgrade pymongo on MongoDB 2
if: matrix.mongodb-version == '2'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__
dist
build
.coverage*
.env
coverage.xml
node_modules
/cfr
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Fixed connectivity for `jobstats collect`
- Refactored code and improved CLI interface of `ctk info` vs. `ctk cfr`
- Dependencies: Updated to `crate-2.0.0`, which uses `orjson` for JSON marshalling
- Cloud API: SDK and CLI for CrateDB Cloud Cluster and Import APIs

## 2025/01/13 v0.0.30
- Dependencies: Minimize dependencies of core installation,
Expand Down
8 changes: 8 additions & 0 deletions cratedb_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
__version__ = version(__appname__)
except PackageNotFoundError: # pragma: no cover
__version__ = "unknown"

from .config import preconfigure

preconfigure()

from .api import ManagedCluster # noqa: E402, F401
from .config import configure # noqa: E402, F401
from .model import InputOutputResource, TableAddress # noqa: E402, F401
1 change: 1 addition & 0 deletions cratedb_toolkit/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .main import ManagedCluster # noqa: F401
17 changes: 13 additions & 4 deletions cratedb_toolkit/api/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
from click import ClickException
from click_aliases import ClickAliasedGroup

from cratedb_toolkit.options import cratedb_http_option, cratedb_sqlalchemy_option
from cratedb_toolkit.options import option_cluster_id, option_cluster_name, option_http_url, option_sqlalchemy_url
from cratedb_toolkit.util.cli import boot_click


def make_cli():
@click.group(cls=ClickAliasedGroup) # type: ignore[arg-type]
@cratedb_sqlalchemy_option
@cratedb_http_option
@option_cluster_id
@option_cluster_name
@option_sqlalchemy_url
@option_http_url
@click.option("--verbose", is_flag=True, required=False, help="Turn on logging")
@click.option("--debug", is_flag=True, required=False, help="Turn on logging with debug level")
@click.option("--scrub", envvar="SCRUB", is_flag=True, required=False, help="Blank out identifiable information")
@click.version_option()
@click.pass_context
def cli(
ctx: click.Context, cratedb_sqlalchemy_url: str, cratedb_http_url: str, verbose: bool, debug: bool, scrub: bool
ctx: click.Context,
cluster_id: str,
cluster_name: str,
cratedb_sqlalchemy_url: str,
cratedb_http_url: str,
verbose: bool,
debug: bool,
scrub: bool,
):
"""
Diagnostics and informational utilities.
Expand Down
7 changes: 5 additions & 2 deletions cratedb_toolkit/api/guide.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from cratedb_toolkit.util.croud import table_fqn


class GuidingTexts:
"""
TODO: Add more richness / guidance to the text output.
"""

def __init__(self, admin_url: str = None, table_name: str = None):
def __init__(self, admin_url: str, table_name: str):
self.admin_url = admin_url
self.table_name = table_name
self.table_name = table_fqn(table_name)

def success(self):
return f"""
Expand Down
Loading
Loading