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