Skip to content

Commit

Permalink
Update api spec (#488)
Browse files Browse the repository at this point in the history
* YOYO NEW API SPEC!

* I have generated the library!

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent ca1de87 commit 112346d
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 24 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions kittycad.rs.patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"path": "/info/x-rust",
"value": {
"client": "// Authenticate via an API token.\nlet client = kittycad::Client::new(\"$TOKEN\");\n\n// - OR -\n\n// Authenticate with your token and host parsed from the environment variables:\n// `KITTYCAD_API_TOKEN`.\nlet client = kittycad::Client::new_from_env();",
"install": "[dependencies]\nkittycad = \"0.3.10\""
"install": "[dependencies]\nkittycad = \"0.3.11\""
}
},
{
Expand Down Expand Up @@ -59,7 +59,7 @@
"op": "add",
"path": "/paths/~1ai~1text-to-cad~1{output_format}/post/x-rust",
"value": {
"example": "/// Generate a CAD model from text.\n/// \n/// Because our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.\n/// This operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.\n/// One thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.\n/// \n/// **Parameters:**\n/// \n/// - `output_format: crate::types::FileExportFormat`: The format the output file should be converted to. (required)\nasync fn example_ai_create_text_to_cad() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::TextToCad = client\n .ai()\n .create_text_to_cad(\n kittycad::types::FileExportFormat::Stl,\n &kittycad::types::TextToCadCreateBody {\n prompt: \"some-string\".to_string(),\n },\n )\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n",
"example": "/// Generate a CAD model from text.\n/// \n/// Because our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.\n/// This operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.\n/// One thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.\n/// \n/// **Parameters:**\n/// \n/// - `kcl: Option<bool>`: If we should output the kcl for the model.\n/// - `output_format: crate::types::FileExportFormat`: The format the output file should be converted to. (required)\nasync fn example_ai_create_text_to_cad() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::TextToCad = client\n .ai()\n .create_text_to_cad(\n Some(false),\n kittycad::types::FileExportFormat::Stl,\n &kittycad::types::TextToCadCreateBody {\n prompt: \"some-string\".to_string(),\n },\n )\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n",
"libDocsLink": "https://docs.rs/kittycad/latest/kittycad/ai/struct.Ai.html#method.create_text_to_cad"
}
},
Expand Down
6 changes: 3 additions & 3 deletions kittycad/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kittycad"
description = "A fully generated & opinionated API client for the KittyCAD API."
version = "0.3.10"
version = "0.3.11"
documentation = "https://docs.rs/kittycad"
readme = "README.md"
repository = "https://github.com/KittyCAD/kittycad.rs/tree/main/kittycad"
Expand All @@ -14,7 +14,7 @@ async-trait = { version = "^0.1.53", optional = true }
base64 = "0.22"
bigdecimal = { version = "0.4", features = ["serde"] }
bytes = { version = "1", features = ["serde"] }
clap = { version = "4.5.14", features = ["cargo", "derive", "env", "unicode"], optional = true }
clap = { version = "4.2.4", features = ["cargo", "derive", "env", "unicode"], optional = true }
chrono = { version = "0.4", default-features = false, features = ["serde", "std"] }
data-encoding = "^2.3.2"
dirs = { version = "^5.0.1", optional = true }
Expand All @@ -24,7 +24,7 @@ http = { version = "^0.2.8", optional = true }
itertools = "0.13.0"
log = { version = "^0.4", features = ["serde"], optional = true }
mime_guess = "2.0.4"
parse-display = "0.10.0"
parse-display = "0.9.1"
phonenumber = "0.3.5"
rand = { version = "0.8", optional = true }
reqwest = { version = "0.11.27", default-features = false, features = ["json", "multipart", "rustls-tls"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion kittycad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To install the library, add the following to your `Cargo.toml` file.

```toml
[dependencies]
kittycad = "0.3.10"
kittycad = "0.3.11"
```

## Basic example
Expand Down
9 changes: 8 additions & 1 deletion kittycad/src/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,11 @@ impl Ai {
}
}

#[doc = "Generate a CAD model from text.\n\nBecause our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.\nThis operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.\nOne thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.\n\n**Parameters:**\n\n- `output_format: crate::types::FileExportFormat`: The format the output file should be converted to. (required)\n\n```rust,no_run\nasync fn example_ai_create_text_to_cad() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::TextToCad = client\n .ai()\n .create_text_to_cad(\n kittycad::types::FileExportFormat::Stl,\n &kittycad::types::TextToCadCreateBody {\n prompt: \"some-string\".to_string(),\n },\n )\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n```"]
#[doc = "Generate a CAD model from text.\n\nBecause our source of truth for the resulting model is a STEP file, you will always have STEP file contents when you list your generated models. Any other formats you request here will also be returned when you list your generated models.\nThis operation is performed asynchronously, the `id` of the operation will be returned. You can use the `id` returned from the request to get status information about the async operation from the `/async/operations/{id}` endpoint.\nOne thing to note, if you hit the cache, this endpoint will return right away. So you only have to wait if the status is not `Completed` or `Failed`.\n\n**Parameters:**\n\n- `kcl: Option<bool>`: If we should output the kcl for the model.\n- `output_format: crate::types::FileExportFormat`: The format the output file should be converted to. (required)\n\n```rust,no_run\nasync fn example_ai_create_text_to_cad() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::TextToCad = client\n .ai()\n .create_text_to_cad(\n Some(false),\n kittycad::types::FileExportFormat::Stl,\n &kittycad::types::TextToCadCreateBody {\n prompt: \"some-string\".to_string(),\n },\n )\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n```"]
#[tracing::instrument]
pub async fn create_text_to_cad<'a>(
&'a self,
kcl: Option<bool>,
output_format: crate::types::FileExportFormat,
body: &crate::types::TextToCadCreateBody,
) -> Result<crate::types::TextToCad, crate::types::error::Error> {
Expand All @@ -218,6 +219,12 @@ impl Ai {
),
);
req = req.bearer_auth(&self.client.token);
let mut query_params = vec![];
if let Some(p) = kcl {
query_params.push(("kcl", format!("{}", p)));
}

req = req.query(&query_params);
req = req.json(body);
let resp = req.send().await?;
let status = resp.status();
Expand Down
2 changes: 1 addition & 1 deletion kittycad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//!
//! ```toml
//! [dependencies]
//! kittycad = "0.3.10"
//! kittycad = "0.3.11"
//! ```
//!
//! ## Basic example
Expand Down
54 changes: 50 additions & 4 deletions kittycad/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,16 +880,17 @@ impl tabled::Tabled for AiPromptResultsPage {
)]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "tabled", derive(tabled::Tabled))]
#[derive(Default)]
pub enum AiPromptType {
#[doc = "Text to CAD."]
#[serde(rename = "text_to_cad")]
#[display("text_to_cad")]
#[default]
TextToCad,
#[doc = "Text to KCL."]
#[serde(rename = "text_to_kcl")]
#[display("text_to_kcl")]
TextToKcl,
}


#[doc = "An angle, with a specific unit."]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
Expand Down Expand Up @@ -2096,6 +2097,10 @@ pub enum AsyncApiCallOutput {
#[doc = "Text to CAD."]
#[serde(rename = "text_to_cad")]
TextToCad {
#[doc = "The code for the model. This is optional but will be required in the future once \
we are at v1."]
#[serde(default, skip_serializing_if = "Option::is_none")]
code: Option<String>,
#[doc = "The time and date the API call was completed."]
#[serde(default, skip_serializing_if = "Option::is_none")]
completed_at: Option<chrono::DateTime<chrono::Utc>>,
Expand All @@ -2109,6 +2114,8 @@ pub enum AsyncApiCallOutput {
feedback: Option<AiFeedback>,
#[doc = "The unique identifier of the API call.\n\nThis is the same as the API call ID."]
id: uuid::Uuid,
#[doc = "The model being used."]
model: TextToCadModel,
#[doc = "The version of the model."]
model_version: String,
#[doc = "The output format of the model."]
Expand Down Expand Up @@ -12906,6 +12913,10 @@ impl tabled::Tabled for TakeSnapshot {
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
)]
pub struct TextToCad {
#[doc = "The code for the model. This is optional but will be required in the future once we \
are at v1."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
#[doc = "The time and date the API call was completed."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub completed_at: Option<chrono::DateTime<chrono::Utc>>,
Expand All @@ -12919,6 +12930,8 @@ pub struct TextToCad {
pub feedback: Option<AiFeedback>,
#[doc = "The unique identifier of the API call.\n\nThis is the same as the API call ID."]
pub id: uuid::Uuid,
#[doc = "The model being used."]
pub model: TextToCadModel,
#[doc = "The version of the model."]
pub model_version: String,
#[doc = "The output format of the model."]
Expand Down Expand Up @@ -12952,9 +12965,14 @@ impl std::fmt::Display for TextToCad {

#[cfg(feature = "tabled")]
impl tabled::Tabled for TextToCad {
const LENGTH: usize = 13;
const LENGTH: usize = 15;
fn fields(&self) -> Vec<std::borrow::Cow<'static, str>> {
vec![
if let Some(code) = &self.code {
format!("{:?}", code).into()
} else {
String::new().into()
},
if let Some(completed_at) = &self.completed_at {
format!("{:?}", completed_at).into()
} else {
Expand All @@ -12972,6 +12990,7 @@ impl tabled::Tabled for TextToCad {
String::new().into()
},
format!("{:?}", self.id).into(),
format!("{:?}", self.model).into(),
self.model_version.clone().into(),
format!("{:?}", self.output_format).into(),
if let Some(outputs) = &self.outputs {
Expand All @@ -12993,11 +13012,13 @@ impl tabled::Tabled for TextToCad {

fn headers() -> Vec<std::borrow::Cow<'static, str>> {
vec![
"code".into(),
"completed_at".into(),
"created_at".into(),
"error".into(),
"feedback".into(),
"id".into(),
"model".into(),
"model_version".into(),
"output_format".into(),
"outputs".into(),
Expand Down Expand Up @@ -13041,6 +13062,31 @@ impl tabled::Tabled for TextToCadCreateBody {
}
}

#[doc = "A type of Text-to-CAD model."]
#[derive(
serde :: Serialize,
serde :: Deserialize,
PartialEq,
Hash,
Debug,
Clone,
schemars :: JsonSchema,
parse_display :: FromStr,
parse_display :: Display,
)]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "tabled", derive(tabled::Tabled))]
pub enum TextToCadModel {
#[doc = "CAD."]
#[serde(rename = "cad")]
#[display("cad")]
Cad,
#[doc = "KCL."]
#[serde(rename = "kcl")]
#[display("kcl")]
Kcl,
}

#[doc = "A single page of results"]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
Expand Down
55 changes: 48 additions & 7 deletions openapitor/tests/types/kittycad.rs.gen
Original file line number Diff line number Diff line change
Expand Up @@ -882,12 +882,10 @@ pub enum AiPromptType {
#[serde(rename = "text_to_cad")]
#[display("text_to_cad")]
TextToCad,
}

impl std::default::Default for AiPromptType {
fn default() -> Self {
AiPromptType::TextToCad
}
#[doc = "Text to KCL."]
#[serde(rename = "text_to_kcl")]
#[display("text_to_kcl")]
TextToKcl,
}

#[doc = "An angle, with a specific unit."]
Expand Down Expand Up @@ -2093,6 +2091,9 @@ pub enum AsyncApiCallOutput {
#[doc = "Text to CAD."]
#[serde(rename = "text_to_cad")]
TextToCad {
#[doc = "The code for the model. This is optional but will be required in the future once we are at v1."]
#[serde(default, skip_serializing_if = "Option::is_none")]
code: Option<String>,
#[doc = "The time and date the API call was completed."]
#[serde(default, skip_serializing_if = "Option::is_none")]
completed_at: Option<chrono::DateTime<chrono::Utc>>,
Expand All @@ -2106,6 +2107,8 @@ pub enum AsyncApiCallOutput {
feedback: Option<AiFeedback>,
#[doc = "The unique identifier of the API call.\n\nThis is the same as the API call ID."]
id: uuid::Uuid,
#[doc = "The model being used."]
model: TextToCadModel,
#[doc = "The version of the model."]
model_version: String,
#[doc = "The output format of the model."]
Expand Down Expand Up @@ -12665,6 +12668,9 @@ impl tabled::Tabled for TakeSnapshot {
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
)]
pub struct TextToCad {
#[doc = "The code for the model. This is optional but will be required in the future once we are at v1."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
#[doc = "The time and date the API call was completed."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub completed_at: Option<chrono::DateTime<chrono::Utc>>,
Expand All @@ -12678,6 +12684,8 @@ pub struct TextToCad {
pub feedback: Option<AiFeedback>,
#[doc = "The unique identifier of the API call.\n\nThis is the same as the API call ID."]
pub id: uuid::Uuid,
#[doc = "The model being used."]
pub model: TextToCadModel,
#[doc = "The version of the model."]
pub model_version: String,
#[doc = "The output format of the model."]
Expand Down Expand Up @@ -12710,9 +12718,14 @@ impl std::fmt::Display for TextToCad {

#[cfg(feature = "tabled")]
impl tabled::Tabled for TextToCad {
const LENGTH: usize = 13;
const LENGTH: usize = 15;
fn fields(&self) -> Vec<std::borrow::Cow<'static, str>> {
vec![
if let Some(code) = &self.code {
format!("{:?}", code).into()
} else {
String::new().into()
},
if let Some(completed_at) = &self.completed_at {
format!("{:?}", completed_at).into()
} else {
Expand All @@ -12730,6 +12743,7 @@ impl tabled::Tabled for TextToCad {
String::new().into()
},
format!("{:?}", self.id).into(),
format!("{:?}", self.model).into(),
self.model_version.clone().into(),
format!("{:?}", self.output_format).into(),
if let Some(outputs) = &self.outputs {
Expand All @@ -12751,11 +12765,13 @@ impl tabled::Tabled for TextToCad {

fn headers() -> Vec<std::borrow::Cow<'static, str>> {
vec![
"code".into(),
"completed_at".into(),
"created_at".into(),
"error".into(),
"feedback".into(),
"id".into(),
"model".into(),
"model_version".into(),
"output_format".into(),
"outputs".into(),
Expand Down Expand Up @@ -12799,6 +12815,31 @@ impl tabled::Tabled for TextToCadCreateBody {
}
}

#[doc = "A type of Text-to-CAD model."]
#[derive(
serde :: Serialize,
serde :: Deserialize,
PartialEq,
Hash,
Debug,
Clone,
schemars :: JsonSchema,
parse_display :: FromStr,
parse_display :: Display,
)]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "tabled", derive(tabled::Tabled))]
pub enum TextToCadModel {
#[doc = "CAD."]
#[serde(rename = "cad")]
#[display("cad")]
Cad,
#[doc = "KCL."]
#[serde(rename = "kcl")]
#[display("kcl")]
Kcl,
}

#[doc = "A single page of results"]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
Expand Down
Loading

0 comments on commit 112346d

Please sign in to comment.