mz_frontegg_mock/models/
group.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use chrono::{DateTime, Utc};
11use serde::{Deserialize, Serialize};
12
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct GroupMapping {
15    #[serde(default)]
16    pub id: String,
17    pub group: String,
18    #[serde(default, rename = "roleIds")]
19    pub role_ids: Vec<String>,
20    #[serde(default, rename = "ssoConfigId")]
21    pub sso_config_id: String,
22    #[serde(default)]
23    pub enabled: bool,
24}
25
26#[derive(Serialize)]
27pub struct GroupMappingResponse {
28    pub id: String,
29    pub group: String,
30    #[serde(rename = "roleIds")]
31    pub role_ids: Vec<String>,
32    #[serde(rename = "ssoConfigId")]
33    pub sso_config_id: String,
34    pub enabled: bool,
35}
36
37#[derive(Deserialize)]
38pub struct GroupMappingUpdateRequest {
39    pub group: Option<String>,
40    #[serde(rename = "roleIds")]
41    pub role_ids: Option<Vec<String>>,
42    pub enabled: Option<bool>,
43}
44
45#[derive(Serialize, Deserialize, Clone, Debug)]
46pub struct DefaultRoles {
47    #[serde(rename = "roleIds")]
48    pub role_ids: Vec<String>,
49}
50
51#[derive(Clone, Serialize, Deserialize, Debug)]
52pub struct Group {
53    #[serde(default)]
54    pub id: String,
55    pub name: String,
56    pub description: String,
57    pub metadata: String,
58    pub roles: Vec<Role>,
59    pub users: Vec<User>,
60    #[serde(rename = "managedBy")]
61    pub managed_by: String,
62    pub color: String,
63    #[serde(rename = "createdAt")]
64    pub created_at: DateTime<Utc>,
65    #[serde(rename = "updatedAt")]
66    pub updated_at: DateTime<Utc>,
67}
68
69#[derive(Clone, Serialize, Deserialize, Debug)]
70pub struct Role {
71    pub id: String,
72    pub key: String,
73    pub name: String,
74    pub description: String,
75    pub is_default: bool,
76}
77
78#[derive(Clone, Serialize, Deserialize, Debug)]
79pub struct User {
80    pub id: String,
81    pub name: String,
82    pub email: String,
83}
84
85#[derive(Deserialize)]
86pub struct GroupCreateParams {
87    pub name: String,
88    pub description: Option<String>,
89    pub color: Option<String>,
90    pub metadata: Option<String>,
91}
92
93#[derive(Deserialize)]
94pub struct GroupUpdateParams {
95    pub name: Option<String>,
96    pub description: Option<String>,
97    pub color: Option<String>,
98    pub metadata: Option<String>,
99}
100
101#[derive(Serialize)]
102pub struct GroupsResponse {
103    pub groups: Vec<Group>,
104}
105
106#[derive(Deserialize)]
107pub struct AddUsersToGroupParams {
108    #[serde(rename = "userIds")]
109    pub user_ids: Vec<String>,
110}
111
112#[derive(Deserialize)]
113pub struct RemoveUsersFromGroupParams {
114    #[serde(rename = "userIds")]
115    pub user_ids: Vec<String>,
116}