You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@horaedb.apache.org by ji...@apache.org on 2024/05/23 09:27:42 UTC

(incubator-horaedb-client-py) branch feat-auth created (now 8ddc209)

This is an automated email from the ASF dual-hosted git repository.

jiacai2050 pushed a change to branch feat-auth
in repository https://gitbox.apache.org/repos/asf/incubator-horaedb-client-py.git


      at 8ddc209  feat: support basic auth

This branch includes the following new commits:

     new 8ddc209  feat: support basic auth

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@horaedb.apache.org
For additional commands, e-mail: commits-help@horaedb.apache.org


(incubator-horaedb-client-py) 01/01: feat: support basic auth

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jiacai2050 pushed a commit to branch feat-auth
in repository https://gitbox.apache.org/repos/asf/incubator-horaedb-client-py.git

commit 8ddc2097be5af4e91b85289750539d962c75d1a5
Author: jiacai2050 <de...@liujiacai.net>
AuthorDate: Thu May 23 17:27:22 2024 +0800

    feat: support basic auth
---
 Cargo.toml         |  1 +
 ceresdb_client.pyi |  5 +++++
 src/client.rs      | 21 +++++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/Cargo.toml b/Cargo.toml
index 3de266f..8275950 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,6 +6,7 @@ edition = "2021"
 
 [dependencies]
 horaedb-client = "1.0"
+horaedb-client = { git = "https://github.com/apache/incubator-horaedb-client-rs.git", rev = "cc7a2fd07a8dbaad2d405f310f4239b889709afa" }
 pyo3           = { version = "0.16", features = ["extension-module", "abi3-py37"] }
 pyo3-asyncio   = { version = "0.16", features = ["attributes", "tokio-runtime"] }
 tokio          = { version = "1", features = ["sync"] }
diff --git a/ceresdb_client.pyi b/ceresdb_client.pyi
index 8e057cd..20550e6 100644
--- a/ceresdb_client.pyi
+++ b/ceresdb_client.pyi
@@ -129,9 +129,14 @@ class RpcContext:
     timeout_ms: int
     database: str
 
+class Authorization:
+    def __init__(self): ...
+    username: str
+    password: str
 
 class Builder:
     def __init__(self, endpoint: str): ...
     def set_rpc_config(self, conf: RpcConfig): ...
     def set_default_database(self, db: str): ...
+    def set_authorization(self, auth: Authorization): ...
     def build(self) -> Client: ...
diff --git a/src/client.rs b/src/client.rs
index ef8f97f..23c89cb 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -212,6 +212,22 @@ pub enum Mode {
     Proxy,
 }
 
+#[pyclass]
+#[derive(Debug, Clone)]
+pub struct Authorization {
+    username: String,
+    password: String,
+}
+
+impl From<Authorization> for horaedb_client::Authorization {
+    fn from(auth: Authorization) -> Self {
+        Self {
+            username: auth.username,
+            password: auth.password,
+        }
+    }
+}
+
 #[pymethods]
 impl Builder {
     #[new]
@@ -238,6 +254,11 @@ impl Builder {
         self.rust_builder = Some(builder);
     }
 
+    pub fn set_authorization(&mut self, auth: Authorization) {
+        let builder = self.rust_builder.take().unwrap().authorization(auth.into());
+        self.rust_builder = Some(builder);
+    }
+
     pub fn build(&mut self) -> Client {
         let client = self.rust_builder.take().unwrap().build();
         Client {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@horaedb.apache.org
For additional commands, e-mail: commits-help@horaedb.apache.org