|
1 | 1 | use std::collections::HashMap; |
2 | 2 | use serde_json::Value; |
3 | 3 | use uuid::Uuid; |
4 | | -use crate::models::UserMetadata; |
| 4 | +use crate::models::{UserInOrg, UserMetadata}; |
5 | 5 |
|
6 | 6 | pub type OrgRole = String; |
7 | 7 |
|
8 | 8 | #[derive(Clone, Debug, PartialEq, Deserialize)] |
9 | 9 | pub struct ValidateApiKeyResponse { |
10 | 10 | pub metadata: Option<serde_json::Value>, |
11 | | - pub user_metadata: Option<UserMetadata>, |
12 | | - pub org_metadata: Option<OrgInternalMetadata>, |
13 | | - pub user_role_in_org: Option<OrgRole>, |
| 11 | + pub user: Option<UserMetadata>, |
| 12 | + pub org: Option<OrgMetadata>, |
| 13 | + pub user_in_org: Option<UserInOrg>, |
14 | 14 | pub user_id: Option<String>, |
15 | 15 | pub org_id: Option<String>, |
16 | 16 | } |
17 | 17 |
|
18 | | -impl ValidateApiKeyResponse { |
19 | | - pub fn new(metadata: Option<serde_json::Value>, user_metadata: Option<UserMetadata>, org_metadata: Option<OrgInternalMetadata>, user_role_in_org: Option<OrgRole>, user_id: Option<String>, org_id: Option<String>) -> Self { |
20 | | - Self { metadata, user_metadata, org_metadata, user_role_in_org, user_id, org_id } |
21 | | - } |
22 | | -} |
23 | | - |
24 | 18 | #[derive(Clone, Debug, PartialEq, Deserialize)] |
25 | 19 | pub struct ValidatePersonalApiKeyResponse { |
26 | 20 | pub metadata: Option<serde_json::Value>, |
27 | | - pub user_metadata: UserMetadata, |
| 21 | + pub user: UserMetadata, |
28 | 22 | } |
29 | 23 |
|
30 | 24 | #[derive(Clone, Debug, PartialEq, Deserialize)] |
31 | 25 | pub struct ValidateOrgApiKeyResponse { |
32 | 26 | pub metadata: Option<serde_json::Value>, |
33 | | - pub user_metadata: Option<UserMetadata>, |
34 | | - pub org_metadata: OrgInternalMetadata, |
35 | | - pub user_role_in_org: Option<OrgRole>, |
| 27 | + pub user: Option<UserMetadata>, |
| 28 | + pub org: OrgMetadata, |
| 29 | + pub user_in_org: Option<UserInOrg>, |
36 | 30 | } |
37 | 31 |
|
38 | 32 | #[derive(Clone, Debug, PartialEq, Deserialize)] |
39 | | -pub struct OrgInternalMetadata { |
| 33 | +pub struct OrgMetadata { |
40 | 34 | pub org_id: Uuid, |
41 | 35 | pub org_name: String, |
42 | | - pub org_definition: OrgDefinition, |
43 | 36 | pub can_setup_saml: bool, |
44 | | - pub autojoin_by_domain: bool, |
45 | | - pub restrict_to_domain: bool, |
46 | | - pub domain: Option<String>, |
47 | | - //pub require_2fa_by: Option<chrono::DateTime<chrono::Utc>>, |
48 | 37 | pub max_users: Option<i32>, |
49 | 38 | pub metadata: MetadataHashOfValue, |
50 | 39 | } |
51 | 40 |
|
52 | | -#[derive(Clone, Debug, PartialEq, Deserialize)] |
53 | | -pub struct OrgDefinition { |
54 | | - pub roles: Vec<OrgRoleDefinition>, |
55 | | - pub default_role: Option<String>, |
56 | | -} |
57 | | - |
58 | | -#[derive(Clone, Debug, PartialEq, Deserialize)] |
59 | | -pub struct OrgRoleDefinition { |
60 | | - pub name: String, |
61 | | - pub description: Option<String>, |
62 | | - pub can_invite: bool, |
63 | | - pub can_change_roles: bool, |
64 | | - pub can_remove_users: bool, |
65 | | - pub can_setup_saml: Option<bool>, |
66 | | - pub external_permissions: Vec<String>, |
67 | | - pub deprecated: bool, |
68 | | - pub is_visible_to_end_user: bool, |
69 | | -} |
70 | | - |
71 | 41 | pub type MetadataHashOfValue = HashMap<String, Value>; |
72 | 42 |
|
0 commit comments