From 4c86557b1c24961320f8ed2dcbc1511c2097f492 Mon Sep 17 00:00:00 2001 From: Evaline Ju <69598118+evaline-ju@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:29:49 -0700 Subject: [PATCH] :fire: Remove legacy tokenization client Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com> --- tokenization-client/Cargo.toml | 21 ---- tokenization-client/src/apis/configuration.rs | 49 -------- tokenization-client/src/apis/default_api.rs | 109 ------------------ tokenization-client/src/apis/mod.rs | 97 ---------------- tokenization-client/src/lib.rs | 12 -- .../src/models/http_validation_error.rs | 23 ---- .../src/models/location_inner.rs | 20 ---- tokenization-client/src/models/mod.rs | 12 -- tokenization-client/src/models/token.rs | 31 ----- .../src/models/tokenization_results.rs | 38 ------ .../tokenization_task_http_request_1.rs | 25 ---- .../src/models/validation_error.rs | 27 ----- 12 files changed, 464 deletions(-) delete mode 100644 tokenization-client/Cargo.toml delete mode 100644 tokenization-client/src/apis/configuration.rs delete mode 100644 tokenization-client/src/apis/default_api.rs delete mode 100644 tokenization-client/src/apis/mod.rs delete mode 100644 tokenization-client/src/lib.rs delete mode 100644 tokenization-client/src/models/http_validation_error.rs delete mode 100644 tokenization-client/src/models/location_inner.rs delete mode 100644 tokenization-client/src/models/mod.rs delete mode 100644 tokenization-client/src/models/token.rs delete mode 100644 tokenization-client/src/models/tokenization_results.rs delete mode 100644 tokenization-client/src/models/tokenization_task_http_request_1.rs delete mode 100644 tokenization-client/src/models/validation_error.rs diff --git a/tokenization-client/Cargo.toml b/tokenization-client/Cargo.toml deleted file mode 100644 index 2b6d185b..00000000 --- a/tokenization-client/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "tokenization-client" -version = "0.1.0" -authors = ["Evaline Ju", "Gaurav Kumbhat"] -description = "Orchestrator tokenization client" -license = "Apache 2.0" -edition = "2018" - -[lib] -path = "src/lib.rs" - -[dependencies] -serde = "^1.0" -serde_derive = "^1.0" -serde_with = "^2.0" -serde_json = "^1.0" -url = "^2.2" -uuid = { version = "^1.0", features = ["serde", "v4"] } -[dependencies.reqwest] -version = "^0.11" -features = ["json", "multipart"] diff --git a/tokenization-client/src/apis/configuration.rs b/tokenization-client/src/apis/configuration.rs deleted file mode 100644 index 79415377..00000000 --- a/tokenization-client/src/apis/configuration.rs +++ /dev/null @@ -1,49 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -#[derive(Debug, Clone)] -pub struct Configuration { - pub base_path: String, - pub user_agent: Option, - pub client: reqwest::Client, - pub basic_auth: Option, - pub oauth_access_token: Option, - pub bearer_access_token: Option, - pub api_key: Option, - // TODO: take an oauth2 token source, similar to the go one -} - -pub type BasicAuth = (String, Option); - -#[derive(Debug, Clone)] -pub struct ApiKey { - pub prefix: Option, - pub key: String, -} - -impl Configuration { - pub fn new() -> Configuration { - Configuration::default() - } -} - -impl Default for Configuration { - fn default() -> Self { - Configuration { - base_path: "http://localhost".to_owned(), - user_agent: Some("OpenAPI-Generator/0.1.0/rust".to_owned()), - client: reqwest::Client::new(), - basic_auth: None, - oauth_access_token: None, - bearer_access_token: None, - api_key: None, - } - } -} diff --git a/tokenization-client/src/apis/default_api.rs b/tokenization-client/src/apis/default_api.rs deleted file mode 100644 index ccf3eb45..00000000 --- a/tokenization-client/src/apis/default_api.rs +++ /dev/null @@ -1,109 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -use reqwest; - -use super::{configuration, Error}; -use crate::{apis::ResponseContent, models}; - -/// struct for typed errors of method [`handler_api_v1_task_tokenization_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum HandlerApiV1TaskTokenizationPostError { - UnknownValue(serde_json::Value), -} - -/// struct for typed errors of method [`health_check_health_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum HealthCheckHealthGetError { - UnknownValue(serde_json::Value), -} - -pub async fn handler_api_v1_task_tokenization_post( - configuration: &configuration::Configuration, - inputs: &str, - model_id: &str, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/api/v1/task/tokenization", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - let mut local_var_form = reqwest::multipart::Form::new(); - local_var_form = local_var_form.text("inputs", inputs.to_string()); - local_var_form = local_var_form.text("model_id", model_id.to_string()); - local_var_req_builder = local_var_req_builder.multipart(local_var_form); - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - -pub async fn health_check_health_get( - configuration: &configuration::Configuration, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/health", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} diff --git a/tokenization-client/src/apis/mod.rs b/tokenization-client/src/apis/mod.rs deleted file mode 100644 index 3abf5ce9..00000000 --- a/tokenization-client/src/apis/mod.rs +++ /dev/null @@ -1,97 +0,0 @@ -use std::error; -use std::fmt; - -#[derive(Debug, Clone)] -pub struct ResponseContent { - pub status: reqwest::StatusCode, - pub content: String, - pub entity: Option, -} - -#[derive(Debug)] -pub enum Error { - Reqwest(reqwest::Error), - Serde(serde_json::Error), - Io(std::io::Error), - ResponseError(ResponseContent), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let (module, e) = match self { - Error::Reqwest(e) => ("reqwest", e.to_string()), - Error::Serde(e) => ("serde", e.to_string()), - Error::Io(e) => ("IO", e.to_string()), - Error::ResponseError(e) => ("response", format!("status code {}", e.status)), - }; - write!(f, "error in {}: {}", module, e) - } -} - -impl error::Error for Error { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { - Some(match self { - Error::Reqwest(e) => e, - Error::Serde(e) => e, - Error::Io(e) => e, - Error::ResponseError(_) => return None, - }) - } -} - -impl From for Error { - fn from(e: reqwest::Error) -> Self { - Error::Reqwest(e) - } -} - -impl From for Error { - fn from(e: serde_json::Error) -> Self { - Error::Serde(e) - } -} - -impl From for Error { - fn from(e: std::io::Error) -> Self { - Error::Io(e) - } -} - -pub fn urlencode>(s: T) -> String { - ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() -} - -pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { - if let serde_json::Value::Object(object) = value { - let mut params = vec![]; - - for (key, value) in object { - match value { - serde_json::Value::Object(_) => params.append(&mut parse_deep_object( - &format!("{}[{}]", prefix, key), - value, - )), - serde_json::Value::Array(array) => { - for (i, value) in array.iter().enumerate() { - params.append(&mut parse_deep_object( - &format!("{}[{}][{}]", prefix, key, i), - value, - )); - } - } - serde_json::Value::String(s) => { - params.push((format!("{}[{}]", prefix, key), s.clone())) - } - _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), - } - } - - return params; - } - - unimplemented!("Only objects are supported with style=deepObject") -} - -pub mod default_api; - -pub mod configuration; diff --git a/tokenization-client/src/lib.rs b/tokenization-client/src/lib.rs deleted file mode 100644 index 92760eb5..00000000 --- a/tokenization-client/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![allow(unused_imports)] - -#[macro_use] -extern crate serde_derive; - -extern crate reqwest; -extern crate serde; -extern crate serde_json; -extern crate url; - -pub mod apis; -pub mod models; diff --git a/tokenization-client/src/models/http_validation_error.rs b/tokenization-client/src/models/http_validation_error.rs deleted file mode 100644 index a48e4c23..00000000 --- a/tokenization-client/src/models/http_validation_error.rs +++ /dev/null @@ -1,23 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct HttpValidationError { - #[serde(rename = "detail", skip_serializing_if = "Option::is_none")] - pub detail: Option>, -} - -impl HttpValidationError { - pub fn new() -> HttpValidationError { - HttpValidationError { detail: None } - } -} diff --git a/tokenization-client/src/models/location_inner.rs b/tokenization-client/src/models/location_inner.rs deleted file mode 100644 index f203468e..00000000 --- a/tokenization-client/src/models/location_inner.rs +++ /dev/null @@ -1,20 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct LocationInner {} - -impl LocationInner { - pub fn new() -> LocationInner { - LocationInner {} - } -} diff --git a/tokenization-client/src/models/mod.rs b/tokenization-client/src/models/mod.rs deleted file mode 100644 index e8adfe7a..00000000 --- a/tokenization-client/src/models/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub mod http_validation_error; -pub use self::http_validation_error::HttpValidationError; -pub mod location_inner; -pub use self::location_inner::LocationInner; -pub mod token; -pub use self::token::Token; -pub mod tokenization_results; -pub use self::tokenization_results::TokenizationResults; -pub mod tokenization_task_http_request_1; -pub use self::tokenization_task_http_request_1::TokenizationTaskHttpRequest1; -pub mod validation_error; -pub use self::validation_error::ValidationError; diff --git a/tokenization-client/src/models/token.rs b/tokenization-client/src/models/token.rs deleted file mode 100644 index adf5fc46..00000000 --- a/tokenization-client/src/models/token.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct Token { - #[serde(rename = "start", skip_serializing_if = "Option::is_none")] - pub start: Option, - #[serde(rename = "end", skip_serializing_if = "Option::is_none")] - pub end: Option, - #[serde(rename = "text", skip_serializing_if = "Option::is_none")] - pub text: Option, -} - -impl Token { - pub fn new() -> Token { - Token { - start: None, - end: None, - text: None, - } - } -} diff --git a/tokenization-client/src/models/tokenization_results.rs b/tokenization-client/src/models/tokenization_results.rs deleted file mode 100644 index 8c4ace9b..00000000 --- a/tokenization-client/src/models/tokenization_results.rs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct TokenizationResults { - #[serde( - rename = "results", - default, - with = "::serde_with::rust::double_option", - skip_serializing_if = "Option::is_none" - )] - pub results: Option>>, - #[serde( - rename = "token_count", - default, - with = "::serde_with::rust::double_option", - skip_serializing_if = "Option::is_none" - )] - pub token_count: Option>, -} - -impl TokenizationResults { - pub fn new() -> TokenizationResults { - TokenizationResults { - results: None, - token_count: None, - } - } -} diff --git a/tokenization-client/src/models/tokenization_task_http_request_1.rs b/tokenization-client/src/models/tokenization_task_http_request_1.rs deleted file mode 100644 index a8c673dd..00000000 --- a/tokenization-client/src/models/tokenization_task_http_request_1.rs +++ /dev/null @@ -1,25 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct TokenizationTaskHttpRequest1 { - #[serde(rename = "inputs")] - pub inputs: String, - #[serde(rename = "model_id")] - pub model_id: String, -} - -impl TokenizationTaskHttpRequest1 { - pub fn new(inputs: String, model_id: String) -> TokenizationTaskHttpRequest1 { - TokenizationTaskHttpRequest1 { inputs, model_id } - } -} diff --git a/tokenization-client/src/models/validation_error.rs b/tokenization-client/src/models/validation_error.rs deleted file mode 100644 index 366107be..00000000 --- a/tokenization-client/src/models/validation_error.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* - * FastAPI - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: 0.1.0 - * - * Generated by: https://openapi-generator.tech - */ - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ValidationError { - #[serde(rename = "loc")] - pub loc: Vec, - #[serde(rename = "msg")] - pub msg: String, - #[serde(rename = "type")] - pub r#type: String, -} - -impl ValidationError { - pub fn new(loc: Vec, msg: String, r#type: String) -> ValidationError { - ValidationError { loc, msg, r#type } - } -}