Skip to content
Closed
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
206 changes: 204 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ CLICKHOUSE_PASSWORD=secret clickhousectl cloud service client --name my-service
# Use a local client version instead of auto-downloading the matching one
clickhousectl cloud service client --name my-service --allow-mismatched-client-version

# Run SQL over HTTP — no local clickhouse-client needed, uses active cloud credentials
clickhousectl cloud service query --name my-service --query "SELECT 1"
clickhousectl cloud service query --id <service-id> --queries-file script.sql --database analytics
echo "SELECT count() FROM system.tables" | clickhousectl cloud service query --name my-service

# Override output format (default: PrettyCompact on tty, TabSeparated when piped)
clickhousectl cloud service query --name my-service -q "SELECT 1" --format JSONEachRow

# Update service metadata and patches
clickhousectl cloud service update <service-id> \
--name my-renamed-service \
Expand Down
17 changes: 17 additions & 0 deletions crates/clickhouse-cloud-api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ impl Client {
}
}

/// Build an authenticated request to an absolute URL using this client's credentials.
///
/// The API base URL is ignored — pass the full target URL. Useful for adjacent
/// ClickHouse Cloud services that share the same auth scheme (e.g. the query-run
/// endpoint at `queries.clickhouse.cloud`).
pub fn authenticated_request(
&self,
method: reqwest::Method,
url: &str,
) -> reqwest::RequestBuilder {
let builder = self.http.request(method, url);
match &self.auth {
Auth::Basic { key_id, key_secret } => builder.basic_auth(key_id, Some(key_secret)),
Auth::Bearer { token } => builder.bearer_auth(token),
}
}

/// Get list of available organizations
pub async fn organization_get_list(
&self,
Expand Down
2 changes: 1 addition & 1 deletion crates/clickhousectl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open = "5.3.3"
url = "2.5.8"
tabled = "0.20.0"
clickhouse-cloud-api = { version = "0.1.0", path = "../clickhouse-cloud-api" }
uuid = "1.23.0"
uuid = { version = "1.23.0", features = ["v4"] }

[dev-dependencies]
tempfile = "3.27.0"
Loading
Loading