diff --git a/Cargo.lock b/Cargo.lock index 7ff6dc5..9f8a04b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -949,15 +949,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "progress" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b820305721858696053a7fd0215cfeeee16ecaaf96b7a209945428e02f1c44" -dependencies = [ - "terminal_size", -] - [[package]] name = "quote" version = "1.0.36" @@ -1404,7 +1395,7 @@ dependencies = [ [[package]] name = "szurubooru-client" -version = "0.1.1" +version = "0.2.0" dependencies = [ "base64", "bytes", @@ -1430,7 +1421,6 @@ dependencies = [ name = "szurubooru-integration-test" version = "0.1.0" dependencies = [ - "progress", "szurubooru-client", "tokio", "tracing", @@ -1450,16 +1440,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "terminal_size" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "thiserror" version = "1.0.63" diff --git a/szurubooru-client/src/client.rs b/szurubooru-client/src/client.rs index 152dcaa..5f07556 100644 --- a/szurubooru-client/src/client.rs +++ b/szurubooru-client/src/client.rs @@ -1084,7 +1084,7 @@ impl<'a> SzurubooruRequest<'a> { create_update_pool: &CreateUpdatePool, ) -> SzurubooruResult { let path = format!("/pool/{pool_id}"); - self.do_request(Method::POST, &path, None, Some(create_update_pool)) + self.do_request(Method::PUT, &path, None, Some(create_update_pool)) .await } @@ -1097,10 +1097,12 @@ impl<'a> SzurubooruRequest<'a> { /// Deletes existing pool. All posts in the pool will only have their relation to the pool /// removed. - pub async fn delete_pool(&self, pool_id: u32) -> SzurubooruResult<()> { + pub async fn delete_pool(&self, pool_id: u32, version: u32) -> SzurubooruResult<()> { let path = format!("/pool/{pool_id}"); - self.do_request(Method::DELETE, &path, None, None::<&String>) + let version_obj = ResourceVersion { version }; + self.do_request::(Method::DELETE, &path, None, Some(&version_obj)) .await + .map(|_| ()) } /// Removes source pool and merges all of its posts with the target pool. Other pool properties diff --git a/szurubooru-client/src/models.rs b/szurubooru-client/src/models.rs index 326f837..1defae2 100644 --- a/szurubooru-client/src/models.rs +++ b/szurubooru-client/src/models.rs @@ -360,21 +360,27 @@ pub struct CreateUpdatePost { /// created. Tags created automatically have no implications, no suggestions, one name and /// their category is set to the first tag category found #[builder(default)] - pub tags: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub tags: Option>, /// Required field, represents the SFW/NSFW state of a post - pub safety: PostSafety, + #[serde(skip_serializing_if = "Option::is_none")] + pub safety: Option, /// The origin of the post's content #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub source: Option, /// The IDs of related posts #[builder(default)] - pub relations: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub relations: Option>, /// Notes to be displayed on the post #[builder(default)] - pub notes: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub notes: Option>, /// Flags relevant to the post. If omitted they will be auto-detected #[builder(default)] - pub flags: Vec, + #[serde(skip_serializing_if = "Option::is_none")] + pub flags: Option>, #[serde(skip_serializing_if = "Option::is_none")] /// The URL to download the content from #[builder(default)] @@ -515,16 +521,20 @@ pub struct CreateUpdateUser { pub version: Option, /// The username #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, /// The user's password #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub password: Option, /// The user's desired rank, if not given will default to `default_rank` in the server's /// configuration #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub rank: Option, /// The user avatar style, Gravatar or Manual #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub avatar_style: Option, } @@ -570,15 +580,19 @@ pub struct UserAuthTokenResource { pub struct CreateUpdateUserAuthToken { /// Resource version. See [versioning](ResourceVersion) #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] pub version: Option, /// Whether the token is still valid for authentication #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] pub enabled: Option, /// A note that describes the token #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] pub note: Option, /// Time when the token expires #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] pub expiration_time: Option>, } @@ -731,16 +745,25 @@ pub struct PoolResource { pub struct CreateUpdatePool { /// Resource version. See [versioning](ResourceVersion) #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] pub version: Option, /// Names and aliases for this pool. When creating a new pool the first name in this list /// is used as the pool name + #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub names: Option>, /// Pool category that this pool belongs to. Must already exist + #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub category: Option, /// Markdown string describing this pool + #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, /// A list of posts that belong to this pool. The server will throw an error if one of these /// post IDs doesn't exist + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] pub posts: Option>, } @@ -827,12 +850,14 @@ pub struct CommentResource { /// .unwrap(); /// ``` pub struct CreateUpdateComment { + #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] /// Resource version. See [versioning](ResourceVersion) /// Omitted when creating a new comment pub version: Option, /// The text of the comment pub text: String, + #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] /// The post the comment should be attached to. Only used when creating a new comment pub post_id: Option, diff --git a/szurubooru-integration-test/Cargo.toml b/szurubooru-integration-test/Cargo.toml index dbf1457..2c0554f 100644 --- a/szurubooru-integration-test/Cargo.toml +++ b/szurubooru-integration-test/Cargo.toml @@ -4,8 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -progress = "0.2.0" -szurubooru-client = { version = "0.1.0", path = "../szurubooru-client" } +szurubooru-client = { path = "../szurubooru-client" } tokio = { version = "1.39.2", features = ["full", "test-util", "tracing"] } tracing = "0.1.40" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }