systemprompt_sync/
config.rs1use systemprompt_identifiers::TenantId;
5
6use crate::SyncDirection;
7
8#[derive(Clone, Debug)]
9pub struct SyncConfig {
10 pub direction: SyncDirection,
11 pub dry_run: bool,
12 pub verbose: bool,
13 pub tenant_id: TenantId,
14 pub api_url: String,
15 pub api_token: String,
16 pub services_path: String,
17 pub hostname: Option<String>,
18 pub local_database_url: Option<String>,
19}
20
21#[derive(Debug)]
22pub struct SyncConfigBuilder {
23 direction: SyncDirection,
24 dry_run: bool,
25 verbose: bool,
26 tenant_id: TenantId,
27 api_url: String,
28 api_token: String,
29 services_path: String,
30 hostname: Option<String>,
31 local_database_url: Option<String>,
32}
33
34impl SyncConfigBuilder {
35 pub fn new(
36 tenant_id: impl Into<TenantId>,
37 api_url: impl Into<String>,
38 api_token: impl Into<String>,
39 services_path: impl Into<String>,
40 ) -> Self {
41 Self {
42 direction: SyncDirection::Push,
43 dry_run: false,
44 verbose: false,
45 tenant_id: tenant_id.into(),
46 api_url: api_url.into(),
47 api_token: api_token.into(),
48 services_path: services_path.into(),
49 hostname: None,
50 local_database_url: None,
51 }
52 }
53
54 pub const fn with_direction(mut self, direction: SyncDirection) -> Self {
55 self.direction = direction;
56 self
57 }
58
59 pub const fn with_dry_run(mut self, dry_run: bool) -> Self {
60 self.dry_run = dry_run;
61 self
62 }
63
64 pub const fn with_verbose(mut self, verbose: bool) -> Self {
65 self.verbose = verbose;
66 self
67 }
68
69 pub fn with_hostname(mut self, hostname: Option<String>) -> Self {
70 self.hostname = hostname;
71 self
72 }
73
74 pub fn with_local_database_url(mut self, url: impl Into<String>) -> Self {
75 self.local_database_url = Some(url.into());
76 self
77 }
78
79 pub fn build(self) -> SyncConfig {
80 SyncConfig {
81 direction: self.direction,
82 dry_run: self.dry_run,
83 verbose: self.verbose,
84 tenant_id: self.tenant_id,
85 api_url: self.api_url,
86 api_token: self.api_token,
87 services_path: self.services_path,
88 hostname: self.hostname,
89 local_database_url: self.local_database_url,
90 }
91 }
92}
93
94impl SyncConfig {
95 pub fn builder(
96 tenant_id: impl Into<TenantId>,
97 api_url: impl Into<String>,
98 api_token: impl Into<String>,
99 services_path: impl Into<String>,
100 ) -> SyncConfigBuilder {
101 SyncConfigBuilder::new(tenant_id, api_url, api_token, services_path)
102 }
103}