couchbase_core/options/
management.rs

1/*
2 *
3 *  * Copyright (c) 2025 Couchbase, Inc.
4 *  *
5 *  * Licensed under the Apache License, Version 2.0 (the "License");
6 *  * you may not use this file except in compliance with the License.
7 *  * You may obtain a copy of the License at
8 *  *
9 *  *    http://www.apache.org/licenses/LICENSE-2.0
10 *  *
11 *  * Unless required by applicable law or agreed to in writing, software
12 *  * distributed under the License is distributed on an "AS IS" BASIS,
13 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  * See the License for the specific language governing permissions and
15 *  * limitations under the License.
16 *
17 */
18
19use crate::httpx::request::OnBehalfOfInfo;
20use crate::mgmtx;
21use crate::mgmtx::bucket_settings::BucketSettings;
22use crate::mgmtx::user::{Group, User};
23use crate::retry::{RetryStrategy, DEFAULT_RETRY_STRATEGY};
24use std::sync::Arc;
25
26#[derive(Debug, Clone)]
27#[non_exhaustive]
28pub struct GetCollectionManifestOptions<'a> {
29    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
30    pub bucket_name: &'a str,
31
32    pub retry_strategy: Arc<dyn RetryStrategy>,
33}
34
35impl<'a> GetCollectionManifestOptions<'a> {
36    pub fn new(bucket_name: &'a str) -> Self {
37        Self {
38            on_behalf_of_info: None,
39            bucket_name,
40            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
41        }
42    }
43
44    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
45        self.retry_strategy = retry_strategy;
46        self
47    }
48
49    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
50        self.on_behalf_of_info = Some(on_behalf_of_info);
51        self
52    }
53}
54
55impl<'a> From<&GetCollectionManifestOptions<'a>>
56    for mgmtx::options::GetCollectionManifestOptions<'a>
57{
58    fn from(opts: &GetCollectionManifestOptions<'a>) -> Self {
59        Self {
60            on_behalf_of_info: opts.on_behalf_of_info,
61            bucket_name: opts.bucket_name,
62        }
63    }
64}
65
66#[derive(Debug, Clone)]
67#[non_exhaustive]
68pub struct CreateScopeOptions<'a> {
69    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
70    pub bucket_name: &'a str,
71    pub scope_name: &'a str,
72
73    pub retry_strategy: Arc<dyn RetryStrategy>,
74}
75
76impl<'a> CreateScopeOptions<'a> {
77    pub fn new(bucket_name: &'a str, scope_name: &'a str) -> Self {
78        Self {
79            on_behalf_of_info: None,
80            bucket_name,
81            scope_name,
82            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
83        }
84    }
85
86    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
87        self.retry_strategy = retry_strategy;
88        self
89    }
90
91    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
92        self.on_behalf_of_info = Some(on_behalf_of_info);
93        self
94    }
95}
96
97impl<'a> From<&CreateScopeOptions<'a>> for mgmtx::options::CreateScopeOptions<'a> {
98    fn from(opts: &CreateScopeOptions<'a>) -> Self {
99        Self {
100            on_behalf_of_info: opts.on_behalf_of_info,
101            bucket_name: opts.bucket_name,
102            scope_name: opts.scope_name,
103        }
104    }
105}
106
107#[derive(Debug, Clone)]
108#[non_exhaustive]
109pub struct DeleteScopeOptions<'a> {
110    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
111    pub bucket_name: &'a str,
112    pub scope_name: &'a str,
113
114    pub retry_strategy: Arc<dyn RetryStrategy>,
115}
116
117impl<'a> DeleteScopeOptions<'a> {
118    pub fn new(bucket_name: &'a str, scope_name: &'a str) -> Self {
119        Self {
120            on_behalf_of_info: None,
121            bucket_name,
122            scope_name,
123            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
124        }
125    }
126
127    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
128        self.retry_strategy = retry_strategy;
129        self
130    }
131
132    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
133        self.on_behalf_of_info = Some(on_behalf_of_info);
134        self
135    }
136}
137
138impl<'a> From<&DeleteScopeOptions<'a>> for mgmtx::options::DeleteScopeOptions<'a> {
139    fn from(opts: &DeleteScopeOptions<'a>) -> Self {
140        Self {
141            on_behalf_of_info: opts.on_behalf_of_info,
142            bucket_name: opts.bucket_name,
143            scope_name: opts.scope_name,
144        }
145    }
146}
147
148#[derive(Debug, Clone)]
149#[non_exhaustive]
150pub struct CreateCollectionOptions<'a> {
151    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
152    pub bucket_name: &'a str,
153    pub scope_name: &'a str,
154    pub collection_name: &'a str,
155    pub max_ttl: Option<i32>,
156    pub history_enabled: Option<bool>,
157
158    pub retry_strategy: Arc<dyn RetryStrategy>,
159}
160
161impl<'a> CreateCollectionOptions<'a> {
162    pub fn new(bucket_name: &'a str, scope_name: &'a str, collection_name: &'a str) -> Self {
163        Self {
164            on_behalf_of_info: None,
165            bucket_name,
166            scope_name,
167            collection_name,
168            max_ttl: None,
169            history_enabled: None,
170            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
171        }
172    }
173
174    pub fn max_ttl(mut self, max_ttl: i32) -> Self {
175        self.max_ttl = Some(max_ttl);
176        self
177    }
178
179    pub fn history_enabled(mut self, history_enabled: bool) -> Self {
180        self.history_enabled = Some(history_enabled);
181        self
182    }
183
184    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
185        self.retry_strategy = retry_strategy;
186        self
187    }
188
189    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
190        self.on_behalf_of_info = Some(on_behalf_of_info);
191        self
192    }
193}
194
195impl<'a> From<&CreateCollectionOptions<'a>> for mgmtx::options::CreateCollectionOptions<'a> {
196    fn from(opts: &CreateCollectionOptions<'a>) -> Self {
197        Self {
198            on_behalf_of_info: opts.on_behalf_of_info,
199            bucket_name: opts.bucket_name,
200            scope_name: opts.scope_name,
201            collection_name: opts.collection_name,
202            max_ttl: opts.max_ttl,
203            history_enabled: opts.history_enabled,
204        }
205    }
206}
207
208#[derive(Debug, Clone)]
209#[non_exhaustive]
210pub struct UpdateCollectionOptions<'a> {
211    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
212    pub bucket_name: &'a str,
213    pub scope_name: &'a str,
214    pub collection_name: &'a str,
215    pub max_ttl: Option<i32>,
216    pub history_enabled: Option<bool>,
217
218    pub retry_strategy: Arc<dyn RetryStrategy>,
219}
220
221impl<'a> UpdateCollectionOptions<'a> {
222    pub fn new(bucket_name: &'a str, scope_name: &'a str, collection_name: &'a str) -> Self {
223        Self {
224            on_behalf_of_info: None,
225            bucket_name,
226            scope_name,
227            collection_name,
228            max_ttl: None,
229            history_enabled: None,
230            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
231        }
232    }
233
234    pub fn max_ttl(mut self, max_ttl: i32) -> Self {
235        self.max_ttl = Some(max_ttl);
236        self
237    }
238
239    pub fn history_enabled(mut self, history_enabled: bool) -> Self {
240        self.history_enabled = Some(history_enabled);
241        self
242    }
243
244    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
245        self.retry_strategy = retry_strategy;
246        self
247    }
248
249    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
250        self.on_behalf_of_info = Some(on_behalf_of_info);
251        self
252    }
253}
254
255impl<'a> From<&UpdateCollectionOptions<'a>> for mgmtx::options::UpdateCollectionOptions<'a> {
256    fn from(opts: &UpdateCollectionOptions<'a>) -> Self {
257        Self {
258            on_behalf_of_info: opts.on_behalf_of_info,
259            bucket_name: opts.bucket_name,
260            scope_name: opts.scope_name,
261            collection_name: opts.collection_name,
262            max_ttl: opts.max_ttl,
263            history_enabled: opts.history_enabled,
264        }
265    }
266}
267
268#[derive(Debug, Clone)]
269#[non_exhaustive]
270pub struct DeleteCollectionOptions<'a> {
271    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
272    pub bucket_name: &'a str,
273    pub scope_name: &'a str,
274    pub collection_name: &'a str,
275
276    pub retry_strategy: Arc<dyn RetryStrategy>,
277}
278
279impl<'a> DeleteCollectionOptions<'a> {
280    pub fn new(bucket_name: &'a str, scope_name: &'a str, collection_name: &'a str) -> Self {
281        Self {
282            on_behalf_of_info: None,
283            bucket_name,
284            scope_name,
285            collection_name,
286            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
287        }
288    }
289
290    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
291        self.retry_strategy = retry_strategy;
292        self
293    }
294
295    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
296        self.on_behalf_of_info = Some(on_behalf_of_info);
297        self
298    }
299}
300
301impl<'a> From<&DeleteCollectionOptions<'a>> for mgmtx::options::DeleteCollectionOptions<'a> {
302    fn from(opts: &DeleteCollectionOptions<'a>) -> Self {
303        Self {
304            on_behalf_of_info: opts.on_behalf_of_info,
305            bucket_name: opts.bucket_name,
306            scope_name: opts.scope_name,
307            collection_name: opts.collection_name,
308        }
309    }
310}
311
312#[derive(Debug, Clone)]
313#[non_exhaustive]
314pub struct EnsureManifestOptions<'a> {
315    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
316    pub bucket_name: &'a str,
317    pub manifest_uid: u64,
318}
319
320impl<'a> EnsureManifestOptions<'a> {
321    pub fn new(bucket_name: &'a str, manifest_uid: u64) -> Self {
322        Self {
323            on_behalf_of_info: None,
324            bucket_name,
325            manifest_uid,
326        }
327    }
328
329    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
330        self.on_behalf_of_info = Some(on_behalf_of_info);
331        self
332    }
333}
334
335#[derive(Debug, Clone)]
336#[non_exhaustive]
337pub struct GetAllBucketsOptions<'a> {
338    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
339
340    pub retry_strategy: Arc<dyn RetryStrategy>,
341}
342
343impl<'a> GetAllBucketsOptions<'a> {
344    pub fn new() -> Self {
345        Self {
346            on_behalf_of_info: None,
347            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
348        }
349    }
350
351    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
352        self.retry_strategy = retry_strategy;
353        self
354    }
355
356    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
357        self.on_behalf_of_info = Some(on_behalf_of_info);
358        self
359    }
360}
361
362impl Default for GetAllBucketsOptions<'_> {
363    fn default() -> Self {
364        Self::new()
365    }
366}
367
368impl<'a> From<&GetAllBucketsOptions<'a>> for mgmtx::options::GetAllBucketsOptions<'a> {
369    fn from(opts: &GetAllBucketsOptions<'a>) -> Self {
370        Self {
371            on_behalf_of_info: opts.on_behalf_of_info,
372        }
373    }
374}
375
376#[derive(Debug, Clone)]
377#[non_exhaustive]
378pub struct GetBucketOptions<'a> {
379    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
380    pub bucket_name: &'a str,
381
382    pub retry_strategy: Arc<dyn RetryStrategy>,
383}
384
385impl<'a> GetBucketOptions<'a> {
386    pub fn new(bucket_name: &'a str) -> Self {
387        Self {
388            on_behalf_of_info: None,
389            bucket_name,
390            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
391        }
392    }
393
394    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
395        self.retry_strategy = retry_strategy;
396        self
397    }
398
399    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
400        self.on_behalf_of_info = Some(on_behalf_of_info);
401        self
402    }
403}
404
405impl<'a> From<&GetBucketOptions<'a>> for mgmtx::options::GetBucketOptions<'a> {
406    fn from(opts: &GetBucketOptions<'a>) -> Self {
407        Self {
408            on_behalf_of_info: opts.on_behalf_of_info,
409            bucket_name: opts.bucket_name,
410        }
411    }
412}
413
414#[derive(Debug, Clone)]
415#[non_exhaustive]
416pub struct CreateBucketOptions<'a> {
417    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
418    pub bucket_name: &'a str,
419    pub bucket_settings: &'a BucketSettings,
420
421    pub retry_strategy: Arc<dyn RetryStrategy>,
422}
423
424impl<'a> CreateBucketOptions<'a> {
425    pub fn new(bucket_name: &'a str, bucket_settings: &'a BucketSettings) -> Self {
426        Self {
427            on_behalf_of_info: None,
428            bucket_name,
429            bucket_settings,
430            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
431        }
432    }
433
434    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
435        self.retry_strategy = retry_strategy;
436        self
437    }
438
439    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
440        self.on_behalf_of_info = Some(on_behalf_of_info);
441        self
442    }
443}
444
445impl<'a> From<&CreateBucketOptions<'a>> for mgmtx::options::CreateBucketOptions<'a> {
446    fn from(opts: &CreateBucketOptions<'a>) -> Self {
447        Self {
448            on_behalf_of_info: opts.on_behalf_of_info,
449            bucket_name: opts.bucket_name,
450            bucket_settings: opts.bucket_settings,
451        }
452    }
453}
454
455#[derive(Debug, Clone)]
456#[non_exhaustive]
457pub struct UpdateBucketOptions<'a> {
458    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
459    pub bucket_name: &'a str,
460    pub bucket_settings: &'a BucketSettings,
461
462    pub retry_strategy: Arc<dyn RetryStrategy>,
463}
464
465impl<'a> UpdateBucketOptions<'a> {
466    pub fn new(bucket_name: &'a str, bucket_settings: &'a BucketSettings) -> Self {
467        Self {
468            on_behalf_of_info: None,
469            bucket_name,
470            bucket_settings,
471            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
472        }
473    }
474
475    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
476        self.retry_strategy = retry_strategy;
477        self
478    }
479
480    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
481        self.on_behalf_of_info = Some(on_behalf_of_info);
482        self
483    }
484}
485
486impl<'a> From<&UpdateBucketOptions<'a>> for mgmtx::options::UpdateBucketOptions<'a> {
487    fn from(opts: &UpdateBucketOptions<'a>) -> Self {
488        Self {
489            on_behalf_of_info: opts.on_behalf_of_info,
490            bucket_name: opts.bucket_name,
491            bucket_settings: opts.bucket_settings,
492        }
493    }
494}
495
496#[derive(Debug, Clone)]
497#[non_exhaustive]
498pub struct DeleteBucketOptions<'a> {
499    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
500    pub bucket_name: &'a str,
501
502    pub retry_strategy: Arc<dyn RetryStrategy>,
503}
504
505impl<'a> DeleteBucketOptions<'a> {
506    pub fn new(bucket_name: &'a str) -> Self {
507        Self {
508            on_behalf_of_info: None,
509            bucket_name,
510            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
511        }
512    }
513
514    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
515        self.retry_strategy = retry_strategy;
516        self
517    }
518
519    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
520        self.on_behalf_of_info = Some(on_behalf_of_info);
521        self
522    }
523}
524
525impl<'a> From<&DeleteBucketOptions<'a>> for mgmtx::options::DeleteBucketOptions<'a> {
526    fn from(opts: &DeleteBucketOptions<'a>) -> Self {
527        Self {
528            on_behalf_of_info: opts.on_behalf_of_info,
529            bucket_name: opts.bucket_name,
530        }
531    }
532}
533
534#[derive(Debug, Clone)]
535#[non_exhaustive]
536pub struct FlushBucketOptions<'a> {
537    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
538    pub bucket_name: &'a str,
539
540    pub retry_strategy: Arc<dyn RetryStrategy>,
541}
542
543impl<'a> FlushBucketOptions<'a> {
544    pub fn new(bucket_name: &'a str) -> Self {
545        Self {
546            on_behalf_of_info: None,
547            bucket_name,
548            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
549        }
550    }
551
552    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
553        self.retry_strategy = retry_strategy;
554        self
555    }
556
557    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
558        self.on_behalf_of_info = Some(on_behalf_of_info);
559        self
560    }
561}
562
563impl<'a> From<&FlushBucketOptions<'a>> for mgmtx::options::FlushBucketOptions<'a> {
564    fn from(opts: &FlushBucketOptions<'a>) -> Self {
565        Self {
566            on_behalf_of_info: opts.on_behalf_of_info,
567            bucket_name: opts.bucket_name,
568        }
569    }
570}
571
572#[derive(Debug, Clone)]
573#[non_exhaustive]
574pub struct EnsureBucketOptions<'a> {
575    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
576    pub bucket_name: &'a str,
577    pub bucket_uuid: Option<&'a str>,
578    pub want_missing: bool,
579}
580
581impl<'a> EnsureBucketOptions<'a> {
582    pub fn new(bucket_name: &'a str, want_missing: bool) -> Self {
583        Self {
584            on_behalf_of_info: None,
585            bucket_name,
586            bucket_uuid: None,
587            want_missing,
588        }
589    }
590
591    pub fn bucket_uuid(mut self, bucket_uuid: &'a str) -> Self {
592        self.bucket_uuid = Some(bucket_uuid);
593        self
594    }
595
596    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
597        self.on_behalf_of_info = Some(on_behalf_of_info);
598        self
599    }
600}
601
602#[derive(Debug, Clone)]
603#[non_exhaustive]
604pub struct GetUserOptions<'a> {
605    pub username: &'a str,
606    pub auth_domain: &'a str,
607    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
608    pub retry_strategy: Arc<dyn RetryStrategy>,
609}
610
611impl<'a> GetUserOptions<'a> {
612    pub fn new(username: &'a str, auth_domain: &'a str) -> Self {
613        Self {
614            username,
615            auth_domain,
616            on_behalf_of: None,
617            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
618        }
619    }
620
621    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
622        self.on_behalf_of = Some(on_behalf_of);
623        self
624    }
625
626    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
627        self.retry_strategy = retry_strategy;
628        self
629    }
630}
631
632impl<'a> From<&GetUserOptions<'a>> for mgmtx::options::GetUserOptions<'a> {
633    fn from(opts: &GetUserOptions<'a>) -> Self {
634        Self {
635            username: opts.username,
636            auth_domain: opts.auth_domain,
637            on_behalf_of_info: opts.on_behalf_of,
638        }
639    }
640}
641
642#[derive(Debug, Clone)]
643#[non_exhaustive]
644pub struct GetAllUsersOptions<'a> {
645    pub auth_domain: &'a str,
646    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
647    pub retry_strategy: Arc<dyn RetryStrategy>,
648}
649
650impl<'a> GetAllUsersOptions<'a> {
651    pub fn new(auth_domain: &'a str) -> Self {
652        Self {
653            auth_domain,
654            on_behalf_of: None,
655            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
656        }
657    }
658
659    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
660        self.on_behalf_of = Some(on_behalf_of);
661        self
662    }
663
664    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
665        self.retry_strategy = retry_strategy;
666        self
667    }
668}
669
670impl<'a> From<&GetAllUsersOptions<'a>> for mgmtx::options::GetAllUsersOptions<'a> {
671    fn from(opts: &GetAllUsersOptions<'a>) -> Self {
672        Self {
673            auth_domain: opts.auth_domain,
674            on_behalf_of_info: opts.on_behalf_of,
675        }
676    }
677}
678
679#[derive(Debug, Clone)]
680#[non_exhaustive]
681pub struct UpsertUserOptions<'a> {
682    pub user: &'a User,
683    pub auth_domain: &'a str,
684    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
685    pub retry_strategy: Arc<dyn RetryStrategy>,
686}
687
688impl<'a> UpsertUserOptions<'a> {
689    pub fn new(user: &'a User, auth_domain: &'a str) -> Self {
690        Self {
691            user,
692            auth_domain,
693            on_behalf_of: None,
694            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
695        }
696    }
697
698    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
699        self.on_behalf_of = Some(on_behalf_of);
700        self
701    }
702
703    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
704        self.retry_strategy = retry_strategy;
705        self
706    }
707}
708
709impl<'a> From<&UpsertUserOptions<'a>> for mgmtx::options::UpsertUserOptions<'a> {
710    fn from(opts: &UpsertUserOptions<'a>) -> Self {
711        Self {
712            user: opts.user,
713            auth_domain: opts.auth_domain,
714            on_behalf_of_info: opts.on_behalf_of,
715        }
716    }
717}
718
719#[derive(Debug, Clone)]
720#[non_exhaustive]
721pub struct DeleteUserOptions<'a> {
722    pub username: &'a str,
723    pub auth_domain: &'a str,
724    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
725    pub retry_strategy: Arc<dyn RetryStrategy>,
726}
727
728impl<'a> DeleteUserOptions<'a> {
729    pub fn new(username: &'a str, auth_domain: &'a str) -> Self {
730        Self {
731            username,
732            auth_domain,
733            on_behalf_of: None,
734            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
735        }
736    }
737
738    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
739        self.on_behalf_of = Some(on_behalf_of);
740        self
741    }
742
743    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
744        self.retry_strategy = retry_strategy;
745        self
746    }
747}
748
749impl<'a> From<&DeleteUserOptions<'a>> for mgmtx::options::DeleteUserOptions<'a> {
750    fn from(opts: &DeleteUserOptions<'a>) -> Self {
751        Self {
752            username: opts.username,
753            auth_domain: opts.auth_domain,
754            on_behalf_of_info: opts.on_behalf_of,
755        }
756    }
757}
758
759#[derive(Debug, Clone)]
760#[non_exhaustive]
761pub struct GetRolesOptions<'a> {
762    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
763    pub retry_strategy: Arc<dyn RetryStrategy>,
764}
765
766impl Default for GetRolesOptions<'_> {
767    fn default() -> Self {
768        Self::new()
769    }
770}
771
772impl<'a> GetRolesOptions<'a> {
773    pub fn new() -> Self {
774        Self {
775            on_behalf_of: None,
776            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
777        }
778    }
779
780    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
781        self.on_behalf_of = Some(on_behalf_of);
782        self
783    }
784
785    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
786        self.retry_strategy = retry_strategy;
787        self
788    }
789}
790
791impl<'a> From<&GetRolesOptions<'a>> for mgmtx::options::GetRolesOptions<'a> {
792    fn from(opts: &GetRolesOptions<'a>) -> Self {
793        Self {
794            on_behalf_of_info: opts.on_behalf_of,
795        }
796    }
797}
798
799#[derive(Debug, Clone)]
800#[non_exhaustive]
801pub struct GetGroupOptions<'a> {
802    pub group_name: &'a str,
803    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
804    pub retry_strategy: Arc<dyn RetryStrategy>,
805}
806
807impl<'a> GetGroupOptions<'a> {
808    pub fn new(group_name: &'a str) -> Self {
809        Self {
810            group_name,
811            on_behalf_of: None,
812            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
813        }
814    }
815
816    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
817        self.on_behalf_of = Some(on_behalf_of);
818        self
819    }
820
821    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
822        self.retry_strategy = retry_strategy;
823        self
824    }
825}
826
827impl<'a> From<&GetGroupOptions<'a>> for mgmtx::options::GetGroupOptions<'a> {
828    fn from(opts: &GetGroupOptions<'a>) -> Self {
829        Self {
830            group_name: opts.group_name,
831            on_behalf_of_info: opts.on_behalf_of,
832        }
833    }
834}
835
836#[derive(Debug, Clone)]
837#[non_exhaustive]
838pub struct GetAllGroupsOptions<'a> {
839    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
840    pub retry_strategy: Arc<dyn RetryStrategy>,
841}
842
843impl Default for GetAllGroupsOptions<'_> {
844    fn default() -> Self {
845        Self::new()
846    }
847}
848
849impl<'a> GetAllGroupsOptions<'a> {
850    pub fn new() -> Self {
851        Self {
852            on_behalf_of: None,
853            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
854        }
855    }
856
857    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
858        self.on_behalf_of = Some(on_behalf_of);
859        self
860    }
861
862    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
863        self.retry_strategy = retry_strategy;
864        self
865    }
866}
867
868impl<'a> From<&GetAllGroupsOptions<'a>> for mgmtx::options::GetAllGroupsOptions<'a> {
869    fn from(opts: &GetAllGroupsOptions<'a>) -> Self {
870        Self {
871            on_behalf_of_info: opts.on_behalf_of,
872        }
873    }
874}
875
876#[derive(Debug, Clone)]
877#[non_exhaustive]
878pub struct UpsertGroupOptions<'a> {
879    pub group: &'a Group,
880    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
881    pub retry_strategy: Arc<dyn RetryStrategy>,
882}
883
884impl<'a> UpsertGroupOptions<'a> {
885    pub fn new(group: &'a Group) -> Self {
886        Self {
887            group,
888            on_behalf_of: None,
889            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
890        }
891    }
892
893    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
894        self.on_behalf_of = Some(on_behalf_of);
895        self
896    }
897
898    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
899        self.retry_strategy = retry_strategy;
900        self
901    }
902}
903
904impl<'a> From<&UpsertGroupOptions<'a>> for mgmtx::options::UpsertGroupOptions<'a> {
905    fn from(opts: &UpsertGroupOptions<'a>) -> Self {
906        Self {
907            group: opts.group,
908            on_behalf_of_info: opts.on_behalf_of,
909        }
910    }
911}
912
913#[derive(Debug, Clone)]
914#[non_exhaustive]
915pub struct DeleteGroupOptions<'a> {
916    pub group_name: &'a str,
917    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
918    pub retry_strategy: Arc<dyn RetryStrategy>,
919}
920
921impl<'a> DeleteGroupOptions<'a> {
922    pub fn new(group_name: &'a str) -> Self {
923        Self {
924            group_name,
925            on_behalf_of: None,
926            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
927        }
928    }
929
930    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
931        self.on_behalf_of = Some(on_behalf_of);
932        self
933    }
934
935    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
936        self.retry_strategy = retry_strategy;
937        self
938    }
939}
940
941impl<'a> From<&DeleteGroupOptions<'a>> for mgmtx::options::DeleteGroupOptions<'a> {
942    fn from(opts: &DeleteGroupOptions<'a>) -> Self {
943        Self {
944            group_name: opts.group_name,
945            on_behalf_of_info: opts.on_behalf_of,
946        }
947    }
948}
949
950#[derive(Debug, Clone)]
951#[non_exhaustive]
952pub struct ChangePasswordOptions<'a> {
953    pub new_password: &'a str,
954    pub on_behalf_of: Option<&'a OnBehalfOfInfo>,
955    pub retry_strategy: Arc<dyn RetryStrategy>,
956}
957
958impl<'a> ChangePasswordOptions<'a> {
959    pub fn new(new_password: &'a str) -> Self {
960        Self {
961            new_password,
962            on_behalf_of: None,
963            retry_strategy: DEFAULT_RETRY_STRATEGY.clone(),
964        }
965    }
966
967    pub fn on_behalf_of(mut self, on_behalf_of: &'a OnBehalfOfInfo) -> Self {
968        self.on_behalf_of = Some(on_behalf_of);
969        self
970    }
971
972    pub fn retry_strategy(mut self, retry_strategy: Arc<dyn RetryStrategy>) -> Self {
973        self.retry_strategy = retry_strategy;
974        self
975    }
976}
977
978impl<'a> From<&ChangePasswordOptions<'a>> for mgmtx::options::ChangePasswordOptions<'a> {
979    fn from(opts: &ChangePasswordOptions<'a>) -> Self {
980        Self {
981            new_password: opts.new_password,
982            on_behalf_of_info: opts.on_behalf_of,
983        }
984    }
985}
986
987#[derive(Debug, Clone)]
988#[non_exhaustive]
989pub struct EnsureUserOptions<'a> {
990    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
991    pub username: &'a str,
992    pub auth_domain: &'a str,
993    pub want_missing: bool,
994}
995
996impl<'a> EnsureUserOptions<'a> {
997    pub fn new(username: &'a str, auth_domain: &'a str, want_missing: bool) -> Self {
998        Self {
999            on_behalf_of_info: None,
1000            username,
1001            auth_domain,
1002            want_missing,
1003        }
1004    }
1005
1006    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
1007        self.on_behalf_of_info = Some(on_behalf_of_info);
1008        self
1009    }
1010}
1011
1012#[derive(Debug, Clone)]
1013#[non_exhaustive]
1014pub struct EnsureGroupOptions<'a> {
1015    pub on_behalf_of_info: Option<&'a OnBehalfOfInfo>,
1016    pub group_name: &'a str,
1017    pub want_missing: bool,
1018}
1019
1020impl<'a> EnsureGroupOptions<'a> {
1021    pub fn new(group_name: &'a str, want_missing: bool) -> Self {
1022        Self {
1023            on_behalf_of_info: None,
1024            group_name,
1025            want_missing,
1026        }
1027    }
1028
1029    pub fn on_behalf_of_info(mut self, on_behalf_of_info: &'a OnBehalfOfInfo) -> Self {
1030        self.on_behalf_of_info = Some(on_behalf_of_info);
1031        self
1032    }
1033}