Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release organization metrics API #18

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stytch"
version = "2.1.0"
version = "2.2.0"
edition = "2021"
license = "MIT"
description = "Stytch Rust client"
Expand Down
3 changes: 3 additions & 0 deletions src/b2b/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::b2b::sessions::Sessions;
use crate::b2b::sso::SSO;
use crate::b2b::totps::TOTPs;
use crate::consumer::m2m::M2M;
use crate::consumer::project::Project;

pub struct Client {
pub discovery: Discovery,
Expand All @@ -26,6 +27,7 @@ pub struct Client {
pub otps: OTPs,
pub organizations: Organizations,
pub passwords: Passwords,
pub project: Project,
pub rbac: RBAC,
pub recovery_codes: RecoveryCodes,
pub scim: SCIM,
Expand All @@ -50,6 +52,7 @@ impl Client {
otps: OTPs::new(http_client.clone()),
organizations: Organizations::new(http_client.clone()),
passwords: Passwords::new(http_client.clone()),
project: Project::new(http_client.clone()),
rbac: RBAC::new(http_client.clone()),
recovery_codes: RecoveryCodes::new(http_client.clone()),
scim: SCIM::new(http_client.clone()),
Expand Down
24 changes: 24 additions & 0 deletions src/b2b/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,19 @@ pub struct GetResponse {
pub status_code: http::StatusCode,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct MetricsRequest {
pub organization_id: String,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetricsResponse {
pub request_id: String,
pub member_count: u32,
#[serde(with = "http_serde::status_code")]
pub status_code: http::StatusCode,
}

/// SearchRequest: Request type for `Organizations.search`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct SearchRequest {
Expand Down Expand Up @@ -815,4 +828,15 @@ impl Organizations {
})
.await
}
pub async fn metrics(&self, body: MetricsRequest) -> crate::Result<MetricsResponse> {
let organization_id = &body.organization_id;
let path = format!("/v1/b2b/organizations/{organization_id}/metrics");
self.http_client
.send(crate::Request {
method: http::Method::GET,
path,
body,
})
.await
}
}
10 changes: 10 additions & 0 deletions src/b2b/scim_connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ pub enum CreateRequestIdp {
Okta,
#[serde(rename = "microsoftentra")]
Microsoftentra,
#[serde(rename = "cyberark")]
Cyberark,
#[serde(rename = "jumpcloud")]
Jumpcloud,
#[serde(rename = "onelogin")]
Onelogin,
#[serde(rename = "pingfederate")]
Pingfederate,
#[serde(rename = "rippling")]
Rippling,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
Expand Down
3 changes: 3 additions & 0 deletions src/consumer/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::consumer::magic_links::MagicLinks;
use crate::consumer::oauth::OAuth;
use crate::consumer::otp::OTPs;
use crate::consumer::passwords::Passwords;
use crate::consumer::project::Project;
use crate::consumer::sessions::Sessions;
use crate::consumer::totps::TOTPs;
use crate::consumer::users::Users;
Expand All @@ -22,6 +23,7 @@ pub struct Client {
pub oauth: OAuth,
pub otps: OTPs,
pub passwords: Passwords,
pub project: Project,
pub sessions: Sessions,
pub totps: TOTPs,
pub users: Users,
Expand All @@ -43,6 +45,7 @@ impl Client {
oauth: OAuth::new(http_client.clone()),
otps: OTPs::new(http_client.clone()),
passwords: Passwords::new(http_client.clone()),
project: Project::new(http_client.clone()),
sessions: Sessions::new(http_client.clone()),
totps: TOTPs::new(http_client.clone()),
users: Users::new(http_client.clone()),
Expand Down
1 change: 1 addition & 0 deletions src/consumer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod passwords;
pub mod passwords_email;
pub mod passwords_existing_password;
pub mod passwords_session;
pub mod project;
pub mod sessions;
pub mod totps;
pub mod users;
Expand Down
63 changes: 63 additions & 0 deletions src/consumer/project.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ProjectMetric {
pub count: u32,
pub metric_type: std::option::Option<ProjectMetricMetricType>,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct MetricsRequest {}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetricsResponse {
pub request_id: String,
pub project_id: String,
pub metrics: std::vec::Vec<ProjectMetric>,
#[serde(with = "http_serde::status_code")]
pub status_code: http::StatusCode,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum ProjectMetricMetricType {
#[serde(rename = "unknown")]
#[default]
UNKNOWN,
#[serde(rename = "user_count")]
USERCOUNT,
#[serde(rename = "organization_count")]
ORGANIZATIONCOUNT,
#[serde(rename = "member_count")]
MEMBERCOUNT,
#[serde(rename = "m2m_client_count")]
M2MCLIENTCOUNT,
}

pub struct Project {
http_client: crate::client::Client,
}

impl Project {
pub fn new(http_client: crate::client::Client) -> Self {
Self {
http_client: http_client.clone(),
}
}

pub async fn metrics(&self, body: MetricsRequest) -> crate::Result<MetricsResponse> {
let path = String::from("/v1/projects/metrics");
self.http_client
.send(crate::Request {
method: http::Method::GET,
path,
body,
})
.await
}
}
Loading