Skip to content

Commit 5f9a1f4

Browse files
committed
chore: bump zitadel_rust_client to v0.3.0
1 parent f667b92 commit 5f9a1f4

File tree

4 files changed

+40
-60
lines changed

4 files changed

+40
-60
lines changed

Cargo.lock

Lines changed: 2 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tracing = "0.1.40"
2424
tracing-subscriber = "0.3.18"
2525
url = "2.5.2"
2626
uuid = { version = "1.10.0", features = ["v5"] }
27-
zitadel-rust-client = { git = "https://github.com/famedly/zitadel-rust-client", rev = "9031cd5db17d5d6faf2e5c9bc7b502a16179883e" }
27+
zitadel-rust-client = { git = "https://github.com/famedly/zitadel-rust-client", tag = "v0.3.0" }
2828
wiremock = "0.6.2"
2929
csv = "1.3.0"
3030
tempfile = "3.12.0"

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub async fn perform_sync(config: &Config) -> Result<()> {
111111
/// Delete a list of users given their email addresses
112112
async fn delete_users_by_email(config: &Config, emails: Vec<String>) -> Result<()> {
113113
let mut zitadel = Zitadel::new(config).await?;
114-
let mut stream = zitadel.get_users_by_email(emails)?;
114+
let mut stream = pin!(zitadel.get_users_by_email(emails)?);
115115

116116
while let Some(zitadel_user) = get_next_zitadel_user(&mut stream, &mut zitadel).await? {
117117
zitadel.delete_user(&zitadel_user.1).await?;

src/zitadel.rs

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Helper functions for submitting data to Zitadel
2-
use std::path::PathBuf;
2+
use std::{path::PathBuf, pin::pin};
33

44
use anyhow::{anyhow, bail, Context, Result};
55
use base64::prelude::{Engine, BASE64_STANDARD};
@@ -15,10 +15,10 @@ use zitadel_rust_client::{
1515
},
1616
pagination::PaginationParams,
1717
users::{
18-
AddHumanUserRequest, AndQuery, IdpLink, InUserEmailsQuery, ListUsersRequest,
19-
Organization, OrganizationIdQuery, SearchQuery, SetHumanEmail, SetHumanPhone,
20-
SetHumanProfile, SetMetadataEntry, TypeQuery, UpdateHumanUserRequest,
21-
User as ZitadelUser, UserFieldName, Userv2Type,
18+
AddHumanUserRequest, AndQuery, IdpLink, InUserEmailsQuery, Organization,
19+
OrganizationIdQuery, SearchQuery, SetHumanEmail, SetHumanPhone, SetHumanProfile,
20+
SetMetadataEntry, TypeQuery, UpdateHumanUserRequest, User as ZitadelUser,
21+
UserFieldName, Userv2Type,
2222
},
2323
Zitadel as ZitadelClient,
2424
},
@@ -77,24 +77,23 @@ impl Zitadel {
7777
&mut self,
7878
emails: Vec<String>,
7979
) -> Result<impl Stream<Item = Result<(ZitadelUserBuilder, String)>> + Send> {
80-
self.zitadel_client
80+
Ok(self
81+
.zitadel_client
8182
.list_users(
82-
ListUsersRequest::new(vec![
83+
Some(PaginationParams::DEFAULT.with_asc(true)),
84+
Some(UserFieldName::NickName),
85+
Some(vec![
8386
SearchQuery::new().with_type_query(TypeQuery::new(Userv2Type::Human)),
8487
SearchQuery::new().with_in_user_emails_query(
8588
InUserEmailsQuery::new().with_user_emails(emails),
8689
),
87-
])
88-
.with_asc(true)
89-
.with_sorting_column(UserFieldName::NickName),
90-
)
91-
.map(|stream| {
92-
stream.map(|user| {
93-
let id = user.user_id().ok_or(anyhow!("Missing Zitadel user ID"))?.clone();
94-
let user = search_result_to_user(user)?;
95-
Ok((user, id))
96-
})
97-
})
90+
]),
91+
)?
92+
.and_then(|user| async {
93+
let id = user.user_id().ok_or(anyhow!("Missing Zitadel user ID"))?.clone();
94+
let user = search_result_to_user(user)?;
95+
Ok((user, id))
96+
}))
9897
}
9998

10099
/// Return a stream of Zitadel users
@@ -107,18 +106,16 @@ impl Zitadel {
107106
Ok(self
108107
.zitadel_client
109108
.list_users(
110-
ListUsersRequest::new(vec![SearchQuery::new().with_and_query(
111-
AndQuery::new().with_queries(vec![
112-
SearchQuery::new().with_type_query(TypeQuery::new(Userv2Type::Human)),
113-
SearchQuery::new().with_organization_id_query(OrganizationIdQuery::new(
114-
self.zitadel_config.organization_id.clone(),
115-
)),
116-
]),
117-
)])
118-
.with_asc(true)
119-
.with_sorting_column(UserFieldName::NickName),
109+
Some(PaginationParams::DEFAULT.with_asc(true)),
110+
Some(UserFieldName::NickName),
111+
Some(vec![SearchQuery::new().with_and_query(AndQuery::new().with_queries(vec![
112+
SearchQuery::new().with_type_query(TypeQuery::new(Userv2Type::Human)),
113+
SearchQuery::new().with_organization_id_query(OrganizationIdQuery::new(
114+
self.zitadel_config.organization_id.clone(),
115+
)),
116+
]))]),
120117
)?
121-
.map(|user| {
118+
.and_then(|user| async {
122119
let id = user.user_id().context("Missing Zitadel user ID")?.clone();
123120
let user = search_result_to_user(user)?;
124121
Ok((user, id))
@@ -157,23 +154,18 @@ impl Zitadel {
157154
/// Return a vector of a random sample of Zitadel users
158155
/// We use this to determine the encoding of the external IDs
159156
pub async fn get_users_sample(&mut self) -> Result<Vec<User>> {
160-
let mut stream = self
157+
let mut stream = pin!(self
161158
.zitadel_client
162159
.list_users(
163-
ListUsersRequest::new(vec![
164-
SearchQuery::new().with_type_query(TypeQuery::new(Userv2Type::Human))
165-
])
166-
.with_asc(true)
167-
.with_sorting_column(UserFieldName::NickName)
168-
.with_page_size(USER_SAMPLE_SIZE),
169-
)
170-
.map(|stream| {
171-
stream.map(|user| {
172-
let id = user.user_id().ok_or(anyhow!("Missing Zitadel user ID"))?.clone();
173-
let user = search_result_to_user(user)?;
174-
Ok((user, id))
175-
})
176-
})?;
160+
Some(PaginationParams::DEFAULT.with_asc(true).with_page_size(USER_SAMPLE_SIZE)),
161+
Some(UserFieldName::NickName),
162+
Some(vec![SearchQuery::new().with_type_query(TypeQuery::new(Userv2Type::Human))])
163+
)?
164+
.and_then(|user| async {
165+
let id = user.user_id().ok_or(anyhow!("Missing Zitadel user ID"))?.clone();
166+
let user = search_result_to_user(user)?;
167+
Ok((user, id))
168+
}));
177169

178170
let mut users = Vec::new();
179171

0 commit comments

Comments
 (0)