use crate::client::Client;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
use serde::Serialize;
pub struct UserManagementApi<'a> {
pub(crate) client: &'a Client,
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithPasswordParams {
pub email: String,
pub password: crate::SecretString,
#[serde(skip_serializing_if = "Option::is_none")]
pub invitation_token: Option<crate::SecretString>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithPasswordParams {
pub fn new(email: impl Into<String>, password: impl Into<crate::SecretString>) -> Self {
Self {
email: email.into(),
password: password.into(),
invitation_token: Default::default(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithCodeParams {
pub code: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub code_verifier: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub invitation_token: Option<crate::SecretString>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithCodeParams {
pub fn new(code: impl Into<String>) -> Self {
Self {
code: code.into(),
code_verifier: Default::default(),
invitation_token: Default::default(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithRefreshTokenParams {
pub refresh_token: crate::SecretString,
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithRefreshTokenParams {
pub fn new(refresh_token: impl Into<crate::SecretString>) -> Self {
Self {
refresh_token: refresh_token.into(),
organization_id: Default::default(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithMagicAuthParams {
pub code: String,
pub email: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub invitation_token: Option<crate::SecretString>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithMagicAuthParams {
pub fn new(code: impl Into<String>, email: impl Into<String>) -> Self {
Self {
code: code.into(),
email: email.into(),
invitation_token: Default::default(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithEmailVerificationParams {
pub code: String,
pub pending_authentication_token: crate::SecretString,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithEmailVerificationParams {
pub fn new(
code: impl Into<String>,
pending_authentication_token: impl Into<crate::SecretString>,
) -> Self {
Self {
code: code.into(),
pending_authentication_token: pending_authentication_token.into(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithTotpParams {
pub code: String,
pub pending_authentication_token: crate::SecretString,
pub authentication_challenge_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithTotpParams {
pub fn new(
code: impl Into<String>,
pending_authentication_token: impl Into<crate::SecretString>,
authentication_challenge_id: impl Into<String>,
) -> Self {
Self {
code: code.into(),
pending_authentication_token: pending_authentication_token.into(),
authentication_challenge_id: authentication_challenge_id.into(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithOrganizationSelectionParams {
pub pending_authentication_token: crate::SecretString,
pub organization_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithOrganizationSelectionParams {
pub fn new(
pending_authentication_token: impl Into<crate::SecretString>,
organization_id: impl Into<String>,
) -> Self {
Self {
pending_authentication_token: pending_authentication_token.into(),
organization_id: organization_id.into(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct AuthenticateWithDeviceCodeParams {
pub device_code: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_agent: Option<String>,
}
impl AuthenticateWithDeviceCodeParams {
pub fn new(device_code: impl Into<String>) -> Self {
Self {
device_code: device_code.into(),
ip_address: Default::default(),
device_id: Default::default(),
user_agent: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct GetAuthorizationUrlParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub code_challenge_method: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub code_challenge: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub domain_hint: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub connection_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub provider_query_params: Option<std::collections::HashMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub provider_scopes: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub invitation_token: Option<crate::SecretString>,
#[serde(skip_serializing_if = "Option::is_none")]
pub screen_hint: Option<UserManagementAuthenticationScreenHint>,
#[serde(skip_serializing_if = "Option::is_none")]
pub login_hint: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub provider: Option<UserManagementAuthenticationProvider>,
#[serde(skip_serializing_if = "Option::is_none")]
pub prompt: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
pub redirect_uri: String,
}
impl GetAuthorizationUrlParams {
#[allow(deprecated)]
pub fn new(redirect_uri: impl Into<String>) -> Self {
Self {
code_challenge_method: Default::default(),
code_challenge: Default::default(),
domain_hint: Default::default(),
connection_id: Default::default(),
provider_query_params: Default::default(),
provider_scopes: Default::default(),
invitation_token: Default::default(),
screen_hint: Default::default(),
login_hint: Default::default(),
provider: Default::default(),
prompt: Default::default(),
state: Default::default(),
organization_id: Default::default(),
redirect_uri: redirect_uri.into(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateDeviceParams {
#[serde(skip)]
pub body: SSODeviceAuthorizationRequest,
}
impl CreateDeviceParams {
#[allow(deprecated)]
pub fn new(body: SSODeviceAuthorizationRequest) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct GetLogoutUrlParams {
pub session_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub return_to: Option<String>,
}
impl GetLogoutUrlParams {
#[allow(deprecated)]
pub fn new(session_id: impl Into<String>) -> Self {
Self {
session_id: session_id.into(),
return_to: Default::default(),
}
}
}
#[derive(Debug, Clone, Serialize)]
pub struct RevokeSessionParams {
#[serde(skip)]
pub body: RevokeSession,
}
impl RevokeSessionParams {
#[allow(deprecated)]
pub fn new(body: RevokeSession) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateCorsOriginParams {
#[serde(skip)]
pub body: CreateCorsOrigin,
}
impl CreateCorsOriginParams {
#[allow(deprecated)]
pub fn new(body: CreateCorsOrigin) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ResetPasswordParams {
#[serde(skip)]
pub body: CreatePasswordResetToken,
}
impl ResetPasswordParams {
#[allow(deprecated)]
pub fn new(body: CreatePasswordResetToken) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConfirmPasswordResetParams {
#[serde(skip)]
pub body: CreatePasswordReset,
}
impl ConfirmPasswordResetParams {
#[allow(deprecated)]
pub fn new(body: CreatePasswordReset) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListUsersParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
#[serde(skip_serializing_if = "Option::is_none")]
#[deprecated]
pub organization: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateUserParams {
#[serde(skip)]
pub body: CreateUser,
}
impl CreateUserParams {
#[allow(deprecated)]
pub fn new(body: CreateUser) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateUserParams {
#[serde(skip)]
pub body: UpdateUser,
}
impl UpdateUserParams {
#[allow(deprecated)]
pub fn new(body: UpdateUser) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ConfirmEmailChangeParams {
#[serde(skip)]
pub body: ConfirmEmailChange,
}
impl ConfirmEmailChangeParams {
#[allow(deprecated)]
pub fn new(body: ConfirmEmailChange) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct SendEmailChangeParams {
#[serde(skip)]
pub body: SendEmailChange,
}
impl SendEmailChangeParams {
#[allow(deprecated)]
pub fn new(body: SendEmailChange) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct VerifyEmailParams {
#[serde(skip)]
pub body: VerifyEmailAddress,
}
impl VerifyEmailParams {
#[allow(deprecated)]
pub fn new(body: VerifyEmailAddress) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListSessionsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListInvitationsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct SendInvitationParams {
#[serde(skip)]
pub body: CreateUserInviteOptions,
}
impl SendInvitationParams {
#[allow(deprecated)]
pub fn new(body: CreateUserInviteOptions) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct ResendInvitationParams {
#[serde(skip)]
pub body: ResendUserInviteOptions,
}
impl ResendInvitationParams {
#[allow(deprecated)]
pub fn new(body: ResendUserInviteOptions) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateJWTTemplateParams {
#[serde(skip)]
pub body: UpdateJWTTemplate,
}
impl UpdateJWTTemplateParams {
#[allow(deprecated)]
pub fn new(body: UpdateJWTTemplate) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateMagicAuthParams {
#[serde(skip)]
pub body: CreateMagicCodeAndReturn,
}
impl CreateMagicAuthParams {
#[allow(deprecated)]
pub fn new(body: CreateMagicCodeAndReturn) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListOrganizationMembershipsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub statuses: Option<Vec<UserManagementOrganizationMembershipStatuses>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateOrganizationMembershipParams {
#[serde(skip)]
pub body: CreateUserOrganizationMembership,
}
impl CreateOrganizationMembershipParams {
#[allow(deprecated)]
pub fn new(body: CreateUserOrganizationMembership) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateOrganizationMembershipParams {
#[serde(skip)]
pub body: UpdateUserOrganizationMembership,
}
impl UpdateOrganizationMembershipParams {
#[allow(deprecated)]
pub fn new(body: UpdateUserOrganizationMembership) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateRedirectUriParams {
#[serde(skip)]
pub body: CreateRedirectUri,
}
impl CreateRedirectUriParams {
#[allow(deprecated)]
pub fn new(body: CreateRedirectUri) -> Self {
Self { body }
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListUserAuthorizedApplicationsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListUserApiKeysParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub before: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub after: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<PaginationOrder>,
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_id: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateUserApiKeyParams {
#[serde(skip)]
pub body: CreateUserApiKey,
}
impl CreateUserApiKeyParams {
#[allow(deprecated)]
pub fn new(body: CreateUserApiKey) -> Self {
Self { body }
}
}
impl<'a> UserManagementApi<'a> {
pub async fn get_jwks(&self, client_id: &str) -> Result<JwksResponse, Error> {
self.get_jwks_with_options(client_id, None).await
}
pub async fn get_jwks_with_options(
&self,
client_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<JwksResponse, Error> {
let client_id = crate::client::path_segment(client_id);
let path = format!("/sso/jwks/{client_id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn authenticate_with_password(
&self,
params: AuthenticateWithPasswordParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_password_with_options(params, None)
.await
}
pub async fn authenticate_with_password_with_options(
&self,
params: AuthenticateWithPasswordParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "password",
"client_id": self.client.client_id(),
"client_secret": self.client.api_key(),
"email": params.email,
"password": params.password,
"invitation_token": params.invitation_token,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn authenticate_with_code(
&self,
params: AuthenticateWithCodeParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_code_with_options(params, None).await
}
pub async fn authenticate_with_code_with_options(
&self,
params: AuthenticateWithCodeParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "authorization_code",
"client_id": self.client.client_id(),
"client_secret": self.client.api_key(),
"code": params.code,
"code_verifier": params.code_verifier,
"invitation_token": params.invitation_token,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn authenticate_with_refresh_token(
&self,
params: AuthenticateWithRefreshTokenParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_refresh_token_with_options(params, None)
.await
}
pub async fn authenticate_with_refresh_token_with_options(
&self,
params: AuthenticateWithRefreshTokenParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "refresh_token",
"client_id": self.client.client_id(),
"client_secret": self.client.api_key(),
"refresh_token": params.refresh_token,
"organization_id": params.organization_id,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn authenticate_with_magic_auth(
&self,
params: AuthenticateWithMagicAuthParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_magic_auth_with_options(params, None)
.await
}
pub async fn authenticate_with_magic_auth_with_options(
&self,
params: AuthenticateWithMagicAuthParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "urn:workos:oauth:grant-type:magic-auth:code",
"client_id": self.client.client_id(),
"client_secret": self.client.api_key(),
"code": params.code,
"email": params.email,
"invitation_token": params.invitation_token,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn authenticate_with_email_verification(
&self,
params: AuthenticateWithEmailVerificationParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_email_verification_with_options(params, None)
.await
}
pub async fn authenticate_with_email_verification_with_options(
&self,
params: AuthenticateWithEmailVerificationParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "urn:workos:oauth:grant-type:email-verification:code",
"client_id": self.client.client_id(),
"client_secret": self.client.api_key(),
"code": params.code,
"pending_authentication_token": params.pending_authentication_token,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn authenticate_with_totp(
&self,
params: AuthenticateWithTotpParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_totp_with_options(params, None).await
}
pub async fn authenticate_with_totp_with_options(
&self,
params: AuthenticateWithTotpParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "urn:workos:oauth:grant-type:mfa-totp",
"client_id": self.client.client_id(),
"client_secret": self.client.api_key(),
"code": params.code,
"pending_authentication_token": params.pending_authentication_token,
"authentication_challenge_id": params.authentication_challenge_id,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn authenticate_with_organization_selection(
&self,
params: AuthenticateWithOrganizationSelectionParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_organization_selection_with_options(params, None)
.await
}
pub async fn authenticate_with_organization_selection_with_options(
&self,
params: AuthenticateWithOrganizationSelectionParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "urn:workos:oauth:grant-type:organization-selection",
"client_id": self.client.client_id(),
"client_secret": self.client.api_key(),
"pending_authentication_token": params.pending_authentication_token,
"organization_id": params.organization_id,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn authenticate_with_device_code(
&self,
params: AuthenticateWithDeviceCodeParams,
) -> Result<AuthenticateResponse, Error> {
self.authenticate_with_device_code_with_options(params, None)
.await
}
pub async fn authenticate_with_device_code_with_options(
&self,
params: AuthenticateWithDeviceCodeParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthenticateResponse, Error> {
let path = "/user_management/authenticate".to_string();
let method = http::Method::POST;
let body = serde_json::json!({
"grant_type": "urn:ietf:params:oauth:grant-type:device_code",
"client_id": self.client.client_id(),
"device_code": params.device_code,
"ip_address": params.ip_address,
"device_id": params.device_id,
"user_agent": params.user_agent,
});
#[derive(Serialize)]
struct EmptyQuery {}
self.client
.request_with_body_opts(method, &path, &EmptyQuery {}, Some(&body), options)
.await
}
pub async fn get_authorization_url(
&self,
params: GetAuthorizationUrlParams,
) -> Result<(), Error> {
self.get_authorization_url_with_options(params, None).await
}
pub async fn get_authorization_url_with_options(
&self,
params: GetAuthorizationUrlParams,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let path = "/user_management/authorize".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts_empty(method, &path, ¶ms, options)
.await
}
pub async fn create_device(
&self,
params: CreateDeviceParams,
) -> Result<DeviceAuthorizationResponse, Error> {
self.create_device_with_options(params, None).await
}
pub async fn create_device_with_options(
&self,
params: CreateDeviceParams,
options: Option<&crate::RequestOptions>,
) -> Result<DeviceAuthorizationResponse, Error> {
let path = "/user_management/authorize/device".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_logout_url(&self, params: GetLogoutUrlParams) -> Result<(), Error> {
self.get_logout_url_with_options(params, None).await
}
pub async fn get_logout_url_with_options(
&self,
params: GetLogoutUrlParams,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let path = "/user_management/sessions/logout".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts_empty(method, &path, ¶ms, options)
.await
}
pub async fn revoke_session(&self, params: RevokeSessionParams) -> Result<(), Error> {
self.revoke_session_with_options(params, None).await
}
pub async fn revoke_session_with_options(
&self,
params: RevokeSessionParams,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let path = "/user_management/sessions/revoke".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts_empty(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn create_cors_origin(
&self,
params: CreateCorsOriginParams,
) -> Result<CorsOriginResponse, Error> {
self.create_cors_origin_with_options(params, None).await
}
pub async fn create_cors_origin_with_options(
&self,
params: CreateCorsOriginParams,
options: Option<&crate::RequestOptions>,
) -> Result<CorsOriginResponse, Error> {
let path = "/user_management/cors_origins".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_email_verification(&self, id: &str) -> Result<EmailVerification, Error> {
self.get_email_verification_with_options(id, None).await
}
pub async fn get_email_verification_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<EmailVerification, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/email_verification/{id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn reset_password(
&self,
params: ResetPasswordParams,
) -> Result<PasswordReset, Error> {
self.reset_password_with_options(params, None).await
}
pub async fn reset_password_with_options(
&self,
params: ResetPasswordParams,
options: Option<&crate::RequestOptions>,
) -> Result<PasswordReset, Error> {
let path = "/user_management/password_reset".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn confirm_password_reset(
&self,
params: ConfirmPasswordResetParams,
) -> Result<ResetPasswordResponse, Error> {
self.confirm_password_reset_with_options(params, None).await
}
pub async fn confirm_password_reset_with_options(
&self,
params: ConfirmPasswordResetParams,
options: Option<&crate::RequestOptions>,
) -> Result<ResetPasswordResponse, Error> {
let path = "/user_management/password_reset/confirm".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_password_reset(&self, id: &str) -> Result<PasswordReset, Error> {
self.get_password_reset_with_options(id, None).await
}
pub async fn get_password_reset_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<PasswordReset, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/password_reset/{id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn list_users(&self, params: ListUsersParams) -> Result<UserList, Error> {
self.list_users_with_options(params, None).await
}
pub async fn list_users_with_options(
&self,
params: ListUsersParams,
options: Option<&crate::RequestOptions>,
) -> Result<UserList, Error> {
let path = "/user_management/users".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub fn list_users_auto_paging(
&self,
params: ListUsersParams,
) -> impl futures_util::Stream<Item = Result<User, Error>> + '_ {
crate::pagination::auto_paginate_pages(move |after| {
let mut params = params.clone();
params.after = after;
async move {
let page = self.list_users(params).await?;
Ok((page.data, page.list_metadata.after))
}
})
}
pub async fn create_user(&self, params: CreateUserParams) -> Result<User, Error> {
self.create_user_with_options(params, None).await
}
pub async fn create_user_with_options(
&self,
params: CreateUserParams,
options: Option<&crate::RequestOptions>,
) -> Result<User, Error> {
let path = "/user_management/users".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_user_by_external_id(&self, external_id: &str) -> Result<User, Error> {
self.get_user_by_external_id_with_options(external_id, None)
.await
}
pub async fn get_user_by_external_id_with_options(
&self,
external_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<User, Error> {
let external_id = crate::client::path_segment(external_id);
let path = format!("/user_management/users/external_id/{external_id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn get_user(&self, id: &str) -> Result<User, Error> {
self.get_user_with_options(id, None).await
}
pub async fn get_user_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<User, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn update_user(&self, id: &str, params: UpdateUserParams) -> Result<User, Error> {
self.update_user_with_options(id, params, None).await
}
pub async fn update_user_with_options(
&self,
id: &str,
params: UpdateUserParams,
options: Option<&crate::RequestOptions>,
) -> Result<User, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}");
let method = http::Method::PUT;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn delete_user(&self, id: &str) -> Result<(), Error> {
self.delete_user_with_options(id, None).await
}
pub async fn delete_user_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}");
let method = http::Method::DELETE;
self.client
.request_with_query_opts_empty(method, &path, &(), options)
.await
}
pub async fn confirm_email_change(
&self,
id: &str,
params: ConfirmEmailChangeParams,
) -> Result<EmailChangeConfirmation, Error> {
self.confirm_email_change_with_options(id, params, None)
.await
}
pub async fn confirm_email_change_with_options(
&self,
id: &str,
params: ConfirmEmailChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<EmailChangeConfirmation, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}/email_change/confirm");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn send_email_change(
&self,
id: &str,
params: SendEmailChangeParams,
) -> Result<EmailChange, Error> {
self.send_email_change_with_options(id, params, None).await
}
pub async fn send_email_change_with_options(
&self,
id: &str,
params: SendEmailChangeParams,
options: Option<&crate::RequestOptions>,
) -> Result<EmailChange, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}/email_change/send");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn verify_email(
&self,
id: &str,
params: VerifyEmailParams,
) -> Result<VerifyEmailResponse, Error> {
self.verify_email_with_options(id, params, None).await
}
pub async fn verify_email_with_options(
&self,
id: &str,
params: VerifyEmailParams,
options: Option<&crate::RequestOptions>,
) -> Result<VerifyEmailResponse, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}/email_verification/confirm");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn send_verification_email(
&self,
id: &str,
) -> Result<SendVerificationEmailResponse, Error> {
self.send_verification_email_with_options(id, None).await
}
pub async fn send_verification_email_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<SendVerificationEmailResponse, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}/email_verification/send");
let method = http::Method::POST;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn get_user_identities(&self, id: &str) -> Result<Vec<UserIdentitiesGetItem>, Error> {
self.get_user_identities_with_options(id, None).await
}
pub async fn get_user_identities_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<Vec<UserIdentitiesGetItem>, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}/identities");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn list_sessions(
&self,
id: &str,
params: ListSessionsParams,
) -> Result<Vec<UserSessionsListItem>, Error> {
self.list_sessions_with_options(id, params, None).await
}
pub async fn list_sessions_with_options(
&self,
id: &str,
params: ListSessionsParams,
options: Option<&crate::RequestOptions>,
) -> Result<Vec<UserSessionsListItem>, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/users/{id}/sessions");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub async fn list_invitations(
&self,
params: ListInvitationsParams,
) -> Result<Vec<UserInvite>, Error> {
self.list_invitations_with_options(params, None).await
}
pub async fn list_invitations_with_options(
&self,
params: ListInvitationsParams,
options: Option<&crate::RequestOptions>,
) -> Result<Vec<UserInvite>, Error> {
let path = "/user_management/invitations".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub async fn send_invitation(&self, params: SendInvitationParams) -> Result<UserInvite, Error> {
self.send_invitation_with_options(params, None).await
}
pub async fn send_invitation_with_options(
&self,
params: SendInvitationParams,
options: Option<&crate::RequestOptions>,
) -> Result<UserInvite, Error> {
let path = "/user_management/invitations".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn find_invitation_by_token(&self, token: &str) -> Result<UserInvite, Error> {
self.find_invitation_by_token_with_options(token, None)
.await
}
pub async fn find_invitation_by_token_with_options(
&self,
token: &str,
options: Option<&crate::RequestOptions>,
) -> Result<UserInvite, Error> {
let token = crate::client::path_segment(token);
let path = format!("/user_management/invitations/by_token/{token}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn get_invitation(&self, id: &str) -> Result<UserInvite, Error> {
self.get_invitation_with_options(id, None).await
}
pub async fn get_invitation_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<UserInvite, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/invitations/{id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn accept_invitation(&self, id: &str) -> Result<Invitation, Error> {
self.accept_invitation_with_options(id, None).await
}
pub async fn accept_invitation_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<Invitation, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/invitations/{id}/accept");
let method = http::Method::POST;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn resend_invitation(
&self,
id: &str,
params: ResendInvitationParams,
) -> Result<UserInvite, Error> {
self.resend_invitation_with_options(id, params, None).await
}
pub async fn resend_invitation_with_options(
&self,
id: &str,
params: ResendInvitationParams,
options: Option<&crate::RequestOptions>,
) -> Result<UserInvite, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/invitations/{id}/resend");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn revoke_invitation(&self, id: &str) -> Result<Invitation, Error> {
self.revoke_invitation_with_options(id, None).await
}
pub async fn revoke_invitation_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<Invitation, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/invitations/{id}/revoke");
let method = http::Method::POST;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn list_jwt_template(&self) -> Result<JWTTemplateResponse, Error> {
self.list_jwt_template_with_options(None).await
}
pub async fn list_jwt_template_with_options(
&self,
options: Option<&crate::RequestOptions>,
) -> Result<JWTTemplateResponse, Error> {
let path = "/user_management/jwt_template".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn update_jwt_template(
&self,
params: UpdateJWTTemplateParams,
) -> Result<JWTTemplateResponse, Error> {
self.update_jwt_template_with_options(params, None).await
}
pub async fn update_jwt_template_with_options(
&self,
params: UpdateJWTTemplateParams,
options: Option<&crate::RequestOptions>,
) -> Result<JWTTemplateResponse, Error> {
let path = "/user_management/jwt_template".to_string();
let method = http::Method::PUT;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn create_magic_auth(
&self,
params: CreateMagicAuthParams,
) -> Result<MagicAuth, Error> {
self.create_magic_auth_with_options(params, None).await
}
pub async fn create_magic_auth_with_options(
&self,
params: CreateMagicAuthParams,
options: Option<&crate::RequestOptions>,
) -> Result<MagicAuth, Error> {
let path = "/user_management/magic_auth".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_magic_auth(&self, id: &str) -> Result<MagicAuth, Error> {
self.get_magic_auth_with_options(id, None).await
}
pub async fn get_magic_auth_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<MagicAuth, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/magic_auth/{id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn list_organization_memberships(
&self,
params: ListOrganizationMembershipsParams,
) -> Result<Vec<UserOrganizationMembership>, Error> {
self.list_organization_memberships_with_options(params, None)
.await
}
pub async fn list_organization_memberships_with_options(
&self,
params: ListOrganizationMembershipsParams,
options: Option<&crate::RequestOptions>,
) -> Result<Vec<UserOrganizationMembership>, Error> {
let path = "/user_management/organization_memberships".to_string();
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub async fn create_organization_membership(
&self,
params: CreateOrganizationMembershipParams,
) -> Result<OrganizationMembership, Error> {
self.create_organization_membership_with_options(params, None)
.await
}
pub async fn create_organization_membership_with_options(
&self,
params: CreateOrganizationMembershipParams,
options: Option<&crate::RequestOptions>,
) -> Result<OrganizationMembership, Error> {
let path = "/user_management/organization_memberships".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn get_organization_membership(
&self,
id: &str,
) -> Result<UserOrganizationMembership, Error> {
self.get_organization_membership_with_options(id, None)
.await
}
pub async fn get_organization_membership_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<UserOrganizationMembership, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/organization_memberships/{id}");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn update_organization_membership(
&self,
id: &str,
params: UpdateOrganizationMembershipParams,
) -> Result<UserOrganizationMembership, Error> {
self.update_organization_membership_with_options(id, params, None)
.await
}
pub async fn update_organization_membership_with_options(
&self,
id: &str,
params: UpdateOrganizationMembershipParams,
options: Option<&crate::RequestOptions>,
) -> Result<UserOrganizationMembership, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/organization_memberships/{id}");
let method = http::Method::PUT;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn delete_organization_membership(&self, id: &str) -> Result<(), Error> {
self.delete_organization_membership_with_options(id, None)
.await
}
pub async fn delete_organization_membership_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/organization_memberships/{id}");
let method = http::Method::DELETE;
self.client
.request_with_query_opts_empty(method, &path, &(), options)
.await
}
pub async fn deactivate_organization_membership(
&self,
id: &str,
) -> Result<OrganizationMembership, Error> {
self.deactivate_organization_membership_with_options(id, None)
.await
}
pub async fn deactivate_organization_membership_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<OrganizationMembership, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/organization_memberships/{id}/deactivate");
let method = http::Method::PUT;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn reactivate_organization_membership(
&self,
id: &str,
) -> Result<UserOrganizationMembership, Error> {
self.reactivate_organization_membership_with_options(id, None)
.await
}
pub async fn reactivate_organization_membership_with_options(
&self,
id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<UserOrganizationMembership, Error> {
let id = crate::client::path_segment(id);
let path = format!("/user_management/organization_memberships/{id}/reactivate");
let method = http::Method::PUT;
self.client
.request_with_query_opts(method, &path, &(), options)
.await
}
pub async fn create_redirect_uri(
&self,
params: CreateRedirectUriParams,
) -> Result<RedirectUri, Error> {
self.create_redirect_uri_with_options(params, None).await
}
pub async fn create_redirect_uri_with_options(
&self,
params: CreateRedirectUriParams,
options: Option<&crate::RequestOptions>,
) -> Result<RedirectUri, Error> {
let path = "/user_management/redirect_uris".to_string();
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
pub async fn list_user_authorized_applications(
&self,
user_id: &str,
params: ListUserAuthorizedApplicationsParams,
) -> Result<AuthorizedConnectApplicationList, Error> {
self.list_user_authorized_applications_with_options(user_id, params, None)
.await
}
pub async fn list_user_authorized_applications_with_options(
&self,
user_id: &str,
params: ListUserAuthorizedApplicationsParams,
options: Option<&crate::RequestOptions>,
) -> Result<AuthorizedConnectApplicationList, Error> {
let user_id = crate::client::path_segment(user_id);
let path = format!("/user_management/users/{user_id}/authorized_applications");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub fn list_user_authorized_applications_auto_paging(
&self,
user_id: impl Into<String>,
params: ListUserAuthorizedApplicationsParams,
) -> impl futures_util::Stream<Item = Result<AuthorizedConnectApplicationListData, Error>> + '_
{
let user_id: String = user_id.into();
crate::pagination::auto_paginate_pages(move |after| {
let user_id = user_id.clone();
let mut params = params.clone();
params.after = after;
async move {
let page = self
.list_user_authorized_applications(&user_id, params)
.await?;
Ok((page.data, page.list_metadata.after))
}
})
}
pub async fn delete_user_authorized_application(
&self,
application_id: &str,
user_id: &str,
) -> Result<(), Error> {
self.delete_user_authorized_application_with_options(application_id, user_id, None)
.await
}
pub async fn delete_user_authorized_application_with_options(
&self,
application_id: &str,
user_id: &str,
options: Option<&crate::RequestOptions>,
) -> Result<(), Error> {
let application_id = crate::client::path_segment(application_id);
let user_id = crate::client::path_segment(user_id);
let path =
format!("/user_management/users/{user_id}/authorized_applications/{application_id}");
let method = http::Method::DELETE;
self.client
.request_with_query_opts_empty(method, &path, &(), options)
.await
}
pub async fn list_user_api_keys(
&self,
user_id: &str,
params: ListUserApiKeysParams,
) -> Result<UserApiKeyList, Error> {
self.list_user_api_keys_with_options(user_id, params, None)
.await
}
pub async fn list_user_api_keys_with_options(
&self,
user_id: &str,
params: ListUserApiKeysParams,
options: Option<&crate::RequestOptions>,
) -> Result<UserApiKeyList, Error> {
let user_id = crate::client::path_segment(user_id);
let path = format!("/user_management/users/{user_id}/api_keys");
let method = http::Method::GET;
self.client
.request_with_query_opts(method, &path, ¶ms, options)
.await
}
pub fn list_user_api_keys_auto_paging(
&self,
user_id: impl Into<String>,
params: ListUserApiKeysParams,
) -> impl futures_util::Stream<Item = Result<UserApiKey, Error>> + '_ {
let user_id: String = user_id.into();
crate::pagination::auto_paginate_pages(move |after| {
let user_id = user_id.clone();
let mut params = params.clone();
params.after = after;
async move {
let page = self.list_user_api_keys(&user_id, params).await?;
Ok((page.data, page.list_metadata.after))
}
})
}
pub async fn create_user_api_key(
&self,
user_id: &str,
params: CreateUserApiKeyParams,
) -> Result<UserApiKeyWithValue, Error> {
self.create_user_api_key_with_options(user_id, params, None)
.await
}
pub async fn create_user_api_key_with_options(
&self,
user_id: &str,
params: CreateUserApiKeyParams,
options: Option<&crate::RequestOptions>,
) -> Result<UserApiKeyWithValue, Error> {
let user_id = crate::client::path_segment(user_id);
let path = format!("/user_management/users/{user_id}/api_keys");
let method = http::Method::POST;
self.client
.request_with_body_opts(method, &path, ¶ms, Some(¶ms.body), options)
.await
}
}