fix(client): fixing pool CRUD operations
This commit is contained in:
parent
e14c1b48fa
commit
6b20a89c1e
4 changed files with 37 additions and 31 deletions
22
Cargo.lock
generated
22
Cargo.lock
generated
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -1084,7 +1084,7 @@ impl<'a> SzurubooruRequest<'a> {
|
|||
create_update_pool: &CreateUpdatePool,
|
||||
) -> SzurubooruResult<PoolResource> {
|
||||
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::<Value, _, _>(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
|
||||
|
|
|
|||
|
|
@ -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<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub tags: Option<Vec<String>>,
|
||||
/// Required field, represents the SFW/NSFW state of a post
|
||||
pub safety: PostSafety,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub safety: Option<PostSafety>,
|
||||
/// The origin of the post's content
|
||||
#[builder(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub source: Option<String>,
|
||||
/// The IDs of related posts
|
||||
#[builder(default)]
|
||||
pub relations: Vec<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub relations: Option<Vec<u32>>,
|
||||
/// Notes to be displayed on the post
|
||||
#[builder(default)]
|
||||
pub notes: Vec<NoteResource>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub notes: Option<Vec<NoteResource>>,
|
||||
/// Flags relevant to the post. If omitted they will be auto-detected
|
||||
#[builder(default)]
|
||||
pub flags: Vec<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub flags: Option<Vec<String>>,
|
||||
#[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<u32>,
|
||||
/// The username
|
||||
#[builder(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub name: Option<String>,
|
||||
/// The user's password
|
||||
#[builder(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub password: Option<String>,
|
||||
/// 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<UserRank>,
|
||||
/// The user avatar style, Gravatar or Manual
|
||||
#[builder(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub avatar_style: Option<UserAvatarStyle>,
|
||||
}
|
||||
|
||||
|
|
@ -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<u32>,
|
||||
/// Whether the token is still valid for authentication
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[builder(default)]
|
||||
pub enabled: Option<bool>,
|
||||
/// A note that describes the token
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[builder(default)]
|
||||
pub note: Option<String>,
|
||||
/// Time when the token expires
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[builder(default)]
|
||||
pub expiration_time: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
|
|
@ -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<u32>,
|
||||
/// 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<Vec<String>>,
|
||||
/// Pool category that this pool belongs to. Must already exist
|
||||
#[builder(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub category: Option<String>,
|
||||
/// Markdown string describing this pool
|
||||
#[builder(default)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub description: Option<String>,
|
||||
/// 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<Vec<u32>>,
|
||||
}
|
||||
|
||||
|
|
@ -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<u32>,
|
||||
/// 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<u32>,
|
||||
|
|
|
|||
|
|
@ -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"] }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue