Skip to content

Commit

Permalink
Update api spec (#524)
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 8caef47 commit 8a400b2
Show file tree
Hide file tree
Showing 9 changed files with 453 additions and 20 deletions.
23 changes: 12 additions & 11 deletions Cargo.lock

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

10 changes: 9 additions & 1 deletion 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.17\""
"install": "[dependencies]\nkittycad = \"0.3.18\""
}
},
{
Expand Down Expand Up @@ -311,6 +311,14 @@
"libDocsLink": "https://docs.rs/kittycad/latest/kittycad/oauth2/struct.Oauth2.html#method.oauth_2_provider_consent"
}
},
{
"op": "add",
"path": "/paths/~1oauth2~1token~1revoke/post/x-rust",
"value": {
"example": "/// Revoke an OAuth2 token.\n/// \n/// This endpoint is designed to be accessed from an *unauthenticated* API client.\nuse std::str::FromStr;\nasync fn example_oauth2_oauth_2_token_revoke() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n client\n .oauth2()\n .oauth_2_token_revoke(&kittycad::types::TokenRevokeRequestForm {\n client_id: uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n client_secret: Some(\"some-string\".to_string()),\n token: uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n })\n .await?;\n Ok(())\n}\n",
"libDocsLink": "https://docs.rs/kittycad/latest/kittycad/oauth2/struct.Oauth2.html#method.oauth_2_token_revoke"
}
},
{
"op": "add",
"path": "/paths/~1org/delete/x-rust",
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.17"
version = "0.3.18"
documentation = "https://docs.rs/kittycad"
readme = "README.md"
repository = "https://github.com/KittyCAD/kittycad.rs/tree/main/kittycad"
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 All @@ -37,7 +37,7 @@ serde = { version = "1", features = ["derive"] }
serde_bytes = "0.11"
serde_json = "1"
serde_urlencoded = { version = "^0.7", optional = true }
tabled = { version = "0.16.0", features = ["ansi"], optional = true }
tabled = { version = "0.15.0", features = ["ansi"], optional = true }
thiserror = "1"
tracing = { version = "^0.1", optional = true }
url = { version = "2", features = ["serde"] }
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.17"
kittycad = "0.3.18"
```

## Basic example
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.17"
//! kittycad = "0.3.18"
//! ```
//!
//! ## Basic example
Expand Down
25 changes: 25 additions & 0 deletions kittycad/src/oauth2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,29 @@ impl Oauth2 {
});
}
}

#[doc = "Revoke an OAuth2 token.\n\nThis endpoint is designed to be accessed from an *unauthenticated* API client.\n\n```rust,no_run\nuse std::str::FromStr;\nasync fn example_oauth2_oauth_2_token_revoke() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n client\n .oauth2()\n .oauth_2_token_revoke(&kittycad::types::TokenRevokeRequestForm {\n client_id: uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n client_secret: Some(\"some-string\".to_string()),\n token: uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n })\n .await?;\n Ok(())\n}\n```"]
#[tracing::instrument]
pub async fn oauth_2_token_revoke<'a>(
&'a self,
body: &crate::types::TokenRevokeRequestForm,
) -> Result<(), crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::POST,
&format!("{}/{}", self.client.base_url, "oauth2/token/revoke"),
);
req = req.bearer_auth(&self.client.token);
req = req.form(body);
let resp = req.send().await?;
let status = resp.status();
if status.is_success() {
Ok(())
} else {
let text = resp.text().await.unwrap_or_default();
return Err(crate::types::error::Error::Server {
body: text.to_string(),
status,
});
}
}
}
103 changes: 102 additions & 1 deletion kittycad/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8010,6 +8010,37 @@ impl tabled::Tabled for LinearTransform {
}
}

#[doc = "The response from the `Loft` command."]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
)]
pub struct Loft {
#[doc = "The UUID of the newly created solid loft."]
pub solid_id: uuid::Uuid,
}

impl std::fmt::Display for Loft {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(
f,
"{}",
serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)?
)
}
}

#[cfg(feature = "tabled")]
impl tabled::Tabled for Loft {
const LENGTH: usize = 1;
fn fields(&self) -> Vec<std::borrow::Cow<'static, str>> {
vec![format!("{:?}", self.solid_id).into()]
}

fn headers() -> Vec<std::borrow::Cow<'static, str>> {
vec!["solid_id".into()]
}
}

#[doc = "The mass response."]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
Expand Down Expand Up @@ -8766,7 +8797,7 @@ pub enum ModelingCmd {
joints. Must be positive (i.e. greater than zero)."]
tolerance: f64,
},
#[doc = "Command for revolving a solid 2d."]
#[doc = "Command for shelling a solid3d face"]
#[serde(rename = "solid3d_shell_face")]
Solid3DShellFace {
#[doc = "Which faces to remove, leaving only the shell."]
Expand All @@ -8793,6 +8824,26 @@ pub enum ModelingCmd {
joints. Must be positive (i.e. greater than zero)."]
tolerance: f64,
},
#[doc = "Command for lofting sections to create a solid"]
#[serde(rename = "loft")]
Loft {
#[doc = "This can be set to override the automatically determined topological base curve, \
which is usually the first section encountered."]
#[serde(default, skip_serializing_if = "Option::is_none")]
base_curve_index: Option<u32>,
#[doc = "Attempt to approximate rational curves (such as arcs) using a bezier. This will \
remove banding around interpolations between arcs and non-arcs. It may produce \
errors in other scenarios Over time, this field won't be necessary."]
bez_approximate_rational: bool,
#[doc = "The closed section curves to create a lofted solid from. Currently, these must \
be Solid2Ds"]
section_ids: Vec<uuid::Uuid>,
#[doc = "Tolerance"]
tolerance: f64,
#[doc = "Degree of the interpolation. Must be greater than zero. For example, use 2 for \
quadratic, or 3 for cubic interpolation in the V direction."]
v_degree: u32,
},
#[doc = "Closes a path, converting it to a 2D solid."]
#[serde(rename = "close_path")]
ClosePath {
Expand Down Expand Up @@ -9862,6 +9913,12 @@ pub enum OkModelingCmdResponse {
#[doc = "The response from the `EntityGetSketchPaths` command."]
data: EntityGetSketchPaths,
},
#[doc = "The response to the 'Loft' endpoint"]
#[serde(rename = "loft")]
Loft {
#[doc = "The response from the `Loft` command."]
data: Loft,
},
#[doc = "The response to the 'ClosePath' endpoint"]
#[serde(rename = "close_path")]
ClosePath {
Expand Down Expand Up @@ -13595,6 +13652,50 @@ impl tabled::Tabled for TextToCadResultsPage {
}
}

#[doc = "The request parameters for the OAuth 2.0 token revocation flow."]
#[derive(
serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema,
)]
pub struct TokenRevokeRequestForm {
#[doc = "The client ID."]
pub client_id: uuid::Uuid,
#[doc = "The client secret."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub client_secret: Option<String>,
#[doc = "The token to revoke."]
pub token: uuid::Uuid,
}

impl std::fmt::Display for TokenRevokeRequestForm {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(
f,
"{}",
serde_json::to_string_pretty(self).map_err(|_| std::fmt::Error)?
)
}
}

#[cfg(feature = "tabled")]
impl tabled::Tabled for TokenRevokeRequestForm {
const LENGTH: usize = 3;
fn fields(&self) -> Vec<std::borrow::Cow<'static, str>> {
vec![
format!("{:?}", self.client_id).into(),
if let Some(client_secret) = &self.client_secret {
format!("{:?}", client_secret).into()
} else {
String::new().into()
},
format!("{:?}", self.token).into(),
]
}

fn headers() -> Vec<std::borrow::Cow<'static, str>> {
vec!["client_id".into(), "client_secret".into(), "token".into()]
}
}

#[doc = "The valid types of angle formats."]
#[derive(
serde :: Serialize,
Expand Down
Loading

0 comments on commit 8a400b2

Please sign in to comment.