Skip to main content

wekan_cli/command_result/
admin.rs

1use crate::client::admin::{
2    BatchSize, CpuThreshold, DelayMs, NonNegativeNumber, SettingNumber,
3    attachment_settings as storage, settings as global,
4};
5use serde::Serialize;
6
7#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
8#[serde(rename_all = "snake_case")]
9pub enum GlobalSettingField {
10    DisableRegistration,
11    DisableForgotPassword,
12    ProductName,
13    DisplayAuthenticationMethod,
14    DefaultAuthenticationMethod,
15    SpinnerName,
16    HideLogo,
17    HideCardCounterList,
18    HideBoardMemberList,
19    CustomLoginLogoImageUrl,
20    CustomLoginLogoLinkUrl,
21    CustomHelpLinkUrl,
22    TextBelowCustomLoginLogo,
23    AutomaticLinkedUrlSchemes,
24    CustomTopLeftCornerLogoImageUrl,
25    CustomTopLeftCornerLogoLinkUrl,
26    CustomTopLeftCornerLogoHeight,
27    OidcBtnText,
28    MailDomainName,
29    LegalNotice,
30    CustomHeadEnabled,
31    CustomHeadMetaTags,
32    CustomHeadLinkTags,
33    CustomManifestEnabled,
34    CustomManifestContent,
35    CustomAssetLinksEnabled,
36    CustomAssetLinksContent,
37    AccessibilityPageEnabled,
38    AccessibilityTitle,
39    AccessibilityContent,
40    SupportPopupText,
41    SupportPageEnabled,
42    SupportPagePublic,
43    SupportTitle,
44    SupportPageText,
45}
46
47#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
48#[serde(rename_all = "snake_case")]
49pub enum AttachmentSettingField {
50    DefaultStorage,
51    StorageConfig,
52    UploadSettings,
53    LimitSettings,
54    MigrationSettings,
55}
56#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
57pub struct GlobalSettingsDetail {
58    pub settings_id: Option<String>,
59    pub disable_registration: Option<bool>,
60    pub disable_forgot_password: Option<bool>,
61    pub product_name: Option<String>,
62    pub display_authentication_method: Option<bool>,
63    pub default_authentication_method: Option<String>,
64    pub spinner_name: Option<String>,
65    pub hide_logo: Option<bool>,
66    pub hide_card_counter_list: Option<bool>,
67    pub hide_board_member_list: Option<bool>,
68    pub custom_login_logo_image_url: Option<String>,
69    pub custom_login_logo_link_url: Option<String>,
70    pub custom_help_link_url: Option<String>,
71    pub text_below_custom_login_logo: Option<String>,
72    pub automatic_linked_url_schemes: Option<String>,
73    pub custom_top_left_corner_logo_image_url: Option<String>,
74    pub custom_top_left_corner_logo_link_url: Option<String>,
75    pub custom_top_left_corner_logo_height: Option<String>,
76    pub oidc_btn_text: Option<String>,
77    pub mail_domain_name: Option<String>,
78    pub legal_notice: Option<String>,
79    pub custom_head_enabled: Option<bool>,
80    pub custom_head_meta_tags: Option<String>,
81    pub custom_head_link_tags: Option<String>,
82    pub custom_manifest_enabled: Option<bool>,
83    pub custom_manifest_content: Option<String>,
84    pub custom_asset_links_enabled: Option<bool>,
85    pub custom_asset_links_content: Option<String>,
86    pub accessibility_page_enabled: Option<bool>,
87    pub accessibility_title: Option<String>,
88    pub accessibility_content: Option<String>,
89    pub support_popup_text: Option<String>,
90    pub support_page_enabled: Option<bool>,
91    pub support_page_public: Option<bool>,
92    pub support_title: Option<String>,
93    pub support_page_text: Option<String>,
94}
95impl From<global::GlobalSettingsDocument> for GlobalSettingsDetail {
96    fn from(d: global::GlobalSettingsDocument) -> Self {
97        Self {
98            settings_id: d.settings_id,
99            disable_registration: d.disable_registration,
100            disable_forgot_password: d.disable_forgot_password,
101            product_name: d.product_name,
102            display_authentication_method: d.display_authentication_method,
103            default_authentication_method: d.default_authentication_method,
104            spinner_name: d.spinner_name,
105            hide_logo: d.hide_logo,
106            hide_card_counter_list: d.hide_card_counter_list,
107            hide_board_member_list: d.hide_board_member_list,
108            custom_login_logo_image_url: d.custom_login_logo_image_url,
109            custom_login_logo_link_url: d.custom_login_logo_link_url,
110            custom_help_link_url: d.custom_help_link_url,
111            text_below_custom_login_logo: d.text_below_custom_login_logo,
112            automatic_linked_url_schemes: d.automatic_linked_url_schemes,
113            custom_top_left_corner_logo_image_url: d.custom_top_left_corner_logo_image_url,
114            custom_top_left_corner_logo_link_url: d.custom_top_left_corner_logo_link_url,
115            custom_top_left_corner_logo_height: d.custom_top_left_corner_logo_height,
116            oidc_btn_text: d.oidc_btn_text,
117            mail_domain_name: d.mail_domain_name,
118            legal_notice: d.legal_notice,
119            custom_head_enabled: d.custom_head_enabled,
120            custom_head_meta_tags: d.custom_head_meta_tags,
121            custom_head_link_tags: d.custom_head_link_tags,
122            custom_manifest_enabled: d.custom_manifest_enabled,
123            custom_manifest_content: d.custom_manifest_content,
124            custom_asset_links_enabled: d.custom_asset_links_enabled,
125            custom_asset_links_content: d.custom_asset_links_content,
126            accessibility_page_enabled: d.accessibility_page_enabled,
127            accessibility_title: d.accessibility_title,
128            accessibility_content: d.accessibility_content,
129            support_popup_text: d.support_popup_text,
130            support_page_enabled: d.support_page_enabled,
131            support_page_public: d.support_page_public,
132            support_title: d.support_title,
133            support_page_text: d.support_page_text,
134        }
135    }
136}
137#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
138pub struct FilesystemSettingsDetail {
139    pub enabled: bool,
140    pub read: bool,
141    pub write: bool,
142    pub path: Option<String>,
143}
144impl From<storage::FilesystemDocument> for FilesystemSettingsDetail {
145    fn from(d: storage::FilesystemDocument) -> Self {
146        Self {
147            enabled: d.enabled,
148            read: d.read,
149            write: d.write,
150            path: d.path,
151        }
152    }
153}
154#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
155pub struct GridfsSettingsDetail {
156    pub enabled: bool,
157    pub read: bool,
158    pub write: bool,
159}
160impl From<storage::GridfsDocument> for GridfsSettingsDetail {
161    fn from(d: storage::GridfsDocument) -> Self {
162        Self {
163            enabled: d.enabled,
164            read: d.read,
165            write: d.write,
166        }
167    }
168}
169#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
170pub struct S3SettingsDetail {
171    pub enabled: Option<bool>,
172    pub read: Option<bool>,
173    pub write: Option<bool>,
174    pub endpoint: Option<String>,
175    pub region: Option<String>,
176    pub bucket: Option<String>,
177    pub access_key_id: Option<String>,
178    pub force_path_style: Option<bool>,
179    pub secret_access_key_set: bool,
180}
181impl From<storage::S3Document> for S3SettingsDetail {
182    fn from(d: storage::S3Document) -> Self {
183        Self {
184            enabled: d.enabled,
185            read: d.read,
186            write: d.write,
187            endpoint: d.endpoint,
188            region: d.region,
189            bucket: d.bucket,
190            access_key_id: d.access_key_id,
191            force_path_style: d.force_path_style,
192            secret_access_key_set: d.secret_access_key_set,
193        }
194    }
195}
196#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
197pub struct AzureSettingsDetail {
198    pub enabled: Option<bool>,
199    pub read: Option<bool>,
200    pub write: Option<bool>,
201    pub account_name: Option<String>,
202    pub bucket: Option<String>,
203    pub account_key_set: bool,
204    pub connection_string_set: bool,
205}
206impl From<storage::AzureDocument> for AzureSettingsDetail {
207    fn from(d: storage::AzureDocument) -> Self {
208        Self {
209            enabled: d.enabled,
210            read: d.read,
211            write: d.write,
212            account_name: d.account_name,
213            bucket: d.bucket,
214            account_key_set: d.account_key_set,
215            connection_string_set: d.connection_string_set,
216        }
217    }
218}
219#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
220pub struct GcsSettingsDetail {
221    pub enabled: Option<bool>,
222    pub read: Option<bool>,
223    pub write: Option<bool>,
224    pub project_id: Option<String>,
225    pub key_filename: Option<String>,
226    pub bucket: Option<String>,
227    pub credentials_set: bool,
228}
229impl From<storage::GcsDocument> for GcsSettingsDetail {
230    fn from(d: storage::GcsDocument) -> Self {
231        Self {
232            enabled: d.enabled,
233            read: d.read,
234            write: d.write,
235            project_id: d.project_id,
236            key_filename: d.key_filename,
237            bucket: d.bucket,
238            credentials_set: d.credentials_set,
239        }
240    }
241}
242#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
243pub struct UploadSettingsDetail {
244    pub max_file_size: Option<SettingNumber>,
245    pub allowed_mime_types: Option<Vec<String>>,
246}
247impl From<storage::UploadDocument> for UploadSettingsDetail {
248    fn from(d: storage::UploadDocument) -> Self {
249        Self {
250            max_file_size: d.max_file_size,
251            allowed_mime_types: d.allowed_mime_types,
252        }
253    }
254}
255#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
256pub struct LimitsSettingsDetail {
257    pub attachments_upload_max_bytes: Option<NonNegativeNumber>,
258    pub attachments_upload_blocked: Option<bool>,
259    pub avatars_upload_blocked: Option<bool>,
260    pub attachments_download_max_bytes: Option<NonNegativeNumber>,
261    pub attachments_download_blocked: Option<bool>,
262    pub api_upload_max_bytes: Option<NonNegativeNumber>,
263    pub api_upload_blocked: Option<bool>,
264    pub api_download_max_bytes: Option<NonNegativeNumber>,
265    pub api_download_blocked: Option<bool>,
266}
267impl From<storage::LimitsDocument> for LimitsSettingsDetail {
268    fn from(d: storage::LimitsDocument) -> Self {
269        Self {
270            attachments_upload_max_bytes: d.attachments_upload_max_bytes,
271            attachments_upload_blocked: d.attachments_upload_blocked,
272            avatars_upload_blocked: d.avatars_upload_blocked,
273            attachments_download_max_bytes: d.attachments_download_max_bytes,
274            attachments_download_blocked: d.attachments_download_blocked,
275            api_upload_max_bytes: d.api_upload_max_bytes,
276            api_upload_blocked: d.api_upload_blocked,
277            api_download_max_bytes: d.api_download_max_bytes,
278            api_download_blocked: d.api_download_blocked,
279        }
280    }
281}
282#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
283pub struct MigrationSettingsDetail {
284    pub auto_migrate: bool,
285    pub batch_size: BatchSize,
286    pub delay_ms: DelayMs,
287    pub cpu_threshold: CpuThreshold,
288}
289impl From<storage::MigrationDocument> for MigrationSettingsDetail {
290    fn from(d: storage::MigrationDocument) -> Self {
291        Self {
292            auto_migrate: d.auto_migrate,
293            batch_size: d.batch_size,
294            delay_ms: d.delay_ms,
295            cpu_threshold: d.cpu_threshold,
296        }
297    }
298}
299#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
300pub struct StorageConfigDetail {
301    pub filesystem: Option<FilesystemSettingsDetail>,
302    pub gridfs: Option<GridfsSettingsDetail>,
303    pub s3: Option<S3SettingsDetail>,
304    pub azure: Option<AzureSettingsDetail>,
305    pub gcs: Option<GcsSettingsDetail>,
306}
307impl From<storage::StorageConfigDocument> for StorageConfigDetail {
308    fn from(d: storage::StorageConfigDocument) -> Self {
309        Self {
310            filesystem: d.filesystem.map(Into::into),
311            gridfs: d.gridfs.map(Into::into),
312            s3: d.s3.map(Into::into),
313            azure: d.azure.map(Into::into),
314            gcs: d.gcs.map(Into::into),
315        }
316    }
317}
318#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
319pub struct AttachmentSettingsDetail {
320    pub default_storage: storage::StorageBackend,
321    pub storage_config: Option<StorageConfigDetail>,
322    pub upload_settings: Option<UploadSettingsDetail>,
323    pub limit_settings: Option<LimitsSettingsDetail>,
324    pub migration_settings: Option<MigrationSettingsDetail>,
325    pub created_at: String,
326    pub updated_at: String,
327    pub created_by: Option<String>,
328    pub updated_by: Option<String>,
329    pub settings_id: String,
330}
331impl From<storage::AttachmentSettingsDocument> for AttachmentSettingsDetail {
332    fn from(d: storage::AttachmentSettingsDocument) -> Self {
333        Self {
334            default_storage: d.default_storage,
335            storage_config: d.storage_config.map(Into::into),
336            upload_settings: d.upload_settings.map(Into::into),
337            limit_settings: d.limit_settings.map(Into::into),
338            migration_settings: d.migration_settings.map(Into::into),
339            created_at: d.created_at,
340            updated_at: d.updated_at,
341            created_by: d.created_by,
342            updated_by: d.updated_by,
343            settings_id: d.settings_id,
344        }
345    }
346}
347#[derive(Debug, Eq, PartialEq, Serialize)]
348pub struct GlobalSettingsSuccess {
349    pub settings: GlobalSettingsDetail,
350}
351#[derive(Debug, Eq, PartialEq, Serialize)]
352pub struct GlobalSettingsUpdateSuccess {
353    pub settings: GlobalSettingsDetail,
354    pub submitted_fields: Vec<GlobalSettingField>,
355}
356#[derive(Debug, Eq, PartialEq, Serialize)]
357pub struct AttachmentSettingsSuccess {
358    pub settings: AttachmentSettingsDetail,
359}
360#[derive(Debug, Eq, PartialEq, Serialize)]
361pub struct AttachmentSettingsUpdateSuccess {
362    pub settings: AttachmentSettingsDetail,
363    pub submitted_fields: Vec<AttachmentSettingField>,
364}